query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
determine the present value required to acheive a future value with given interest rate over time periods number of periods (years) that the interest is cumulated rate the annual rate of return future_value the value at the end of the period | def present_value(rate,periods,future_value)
present_value = future_value / (1+rate)**periods
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end",
"def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_compound_fv(rate,periods,present_value)\n end\n future_value = present_value * (1+rate/compound_frequency)** (periods * compound_frequency)\n end",
"def present_given_future(future_value, interest, term)\n (future_value.to_f / (1 +interest.to_f) ** term).round(4)\n end",
"def annuity_given_future(future_value, interest, term)\n (future_value.to_f * (interest.to_f / ((1 + interest) ** term)-1)).round(4)\n end",
"def future_given_annuity(annuity, interest, term)\n (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n# principal amount\n year = 0\n while principal < desired\n year += 1\n income = principal * interest\n principal += income - income * tax\n end\n year\nend",
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"def investment_horizon(rate,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n periods = Math.log(fv/pv) / Math.log(1+rate)\n end",
"def anticipated_fixed_payment(present_value, rate, term)\n\t\t((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n i = 0\n return i if principal == desired\n \n while principal < desired\n principal += (principal * interest) - (principal * interest * tax)\n i += 1\n end\n \n i\nend",
"def annual_ror(initial_value, final_value, years)\n if years <= 0\n 0\n elsif initial_value == 0\n # BigDecimal::INFINITY\n Float::INFINITY\n else\n 100.to_d * if final_value < 0 # fudge if final value is less than zero\n (((initial_value.to_d - final_value.to_d) / initial_value.to_d) ** (1 / years.to_d)) * -1\n else\n ((final_value.to_d / initial_value.to_d) ** (1 / years.to_d)) - 1\n end\n end\n end",
"def annuity_given_present(present_value, interest, term)\n interest = interest.to_f\n (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n total = principal\n years = 0\n loop do\n break if total >= desired\n total_interest = total*interest\n total += total_interest\n total -= total_interest*tax\n years += 1\n end\n years\nend",
"def expression_value\n return @expression_value if defined?(@expression_value)\n\n subexpr_value =\n (1 + periodic_interest_rate) ** total_number_of_payments\n @expression_value =\n (periodic_interest_rate * subexpr_value) / (subexpr_value - 1)\n end",
"def net_present_value\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * (1 + x)**-relative_payment.offset\n end\n end\n end",
"def nominal_due_given_efective(effective_rate, periods)\n\t\t\t((((1 + (effective_rate.to_f/100))**(1/periods.to_f)-1)*periods.to_f)*100).round(4)\n end",
"def calculate_interest principle, days_since\n (principle * APR / 365 * days_since).round(2)\n end",
"def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end",
"def grow_one_year(starting_balance, growth_rate)\n starting_balance * (1.0 + growth_rate)\nend",
"def call(year)\n previous_year = Population.previous_known(year)\n\n return previous_year.population if previous_year.year == year # year entered is known\n\n next_year = Population.next_known(year)\n\n # there is no next year - unable to calculate\n return nil if next_year.nil? \n\n # calculate the percentage that year is between next and previous years\n mod_percentage = (year - previous_year.year).to_f / (next_year.year - previous_year.year).to_f\n delta_population = next_year.population - previous_year.population\n\n (delta_population * mod_percentage).to_i + previous_year.population\n end",
"def installment_value(interest_rate, financing_time_months, loan_value)\n @installment_calculator.calculate(interest_rate, financing_time_months, loan_value)\n end",
"def rates_prediction\r\n final_array = []\r\n today = today_rate\r\n weekly_change = weekly_percentage_change_array\r\n\r\n first = ((weekly_change[0] / 100) * today) + today\r\n final_array << first\r\n\r\n if @time > 1\r\n i = 0\r\n while i < weekly_change[1].length\r\n rate = ((weekly_change[1][i] / 100) * final_array[i]) + final_array[i]\r\n final_array << rate\r\n i += 1\r\n end\r\n end\r\n final_array\r\n end",
"def calculate_loan(rate, n_periods, total_loan_amount)\n fixed_payment = (rate /\n (1 - ((1 + rate)**(n_periods * - 1)))) * total_loan_amount\n\n fixed_payment.to_f\nend",
"def calculate_interest(principal, roi, time)\n rate = roi.to_f / 100\n amount = principal.to_f * (1 + rate * time.to_f)\n\n amount\nend",
"def calculate_interest(current_period, previous_period=0)\n previous_balance = @txns[previous_period][:balance]\n period_of_interest = current_period - previous_period\n @interest += (previous_balance * daily_interest * period_of_interest).round(2)\n end",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annual_percentage_rate = interest_rate_percentage / 100\n principal * (1 + annual_percentage_rate * number_of_years)\nend",
"def daily_interest\n @apr / 100.0 / 365\n end",
"def calculate(loan_value, financing_time_months, interest_rate, loan_date = Date.today)\n balance = loan_value\n installment = installment_value(interest_rate, financing_time_months, loan_value)\n installment_date = loan_date.next_month\n iof = 0\n\n financing_time_months.step(1, -1) do |_|\n amortization = installment - interest_part(balance, interest_rate)\n\n days = past_days(loan_date, installment_date)\n\n iof += amortization*(@iof_day*(minimal_days(days)))\n iof += amortization*@iof_additional\n\n balance -= amortization\n installment_date = installment_date.next_month\n end\n\n loan_iof(iof, loan_value)\n end",
"def nominal_anticipated_given_efective(effective_rate, periods)\n nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1\n toAnticipated = nominalRate / (1+nominalRate)\n (toAnticipated * periods.to_f * 100).round(4)\n end",
"def years_until_retirement\n @retirement_age.to_i - @current_age.to_i\n end",
"def yearly_rate\n yearly? ? rate : rate * 12\n end",
"def interest(rate)\n raise ArgumentError.new \"The rate must be a positive number\" if rate < 0\n interest = @balance * rate/100\n @balance += interest\n return interest\n end",
"def current_age_approximate\n nil\n end",
"def net_present_value_derivative\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * -relative_payment.offset * (1 + x)**(-relative_payment.offset - 1)\n end\n end\n end",
"def yearly_rate\n\t\t yearly? ? rate : rate * 12\n\t\t end",
"def interest\n return (@capital / 100) * @rate\n end",
"def calculate_payment\n x = @periodic_rate * @principal * ((1 + @periodic_rate)**@periods)\n y = ((1 + @periodic_rate)**@periods) - 1\n (x / y).round(2)\n end",
"def pv\n factor = (1.0 + monthly_rate)**duration\n second_factor = (factor - 1) * (1 + monthly_rate * ptype) / monthly_rate\n\n -(future_value + (payment.to_f * second_factor)) / factor\n end",
"def cash_forecast(org_id = nil)\n\n if org_id\n line_items = funding_line_items.where('organization_id = ?', org_id)\n else\n line_items = funding_line_items\n end\n\n first_year = line_items.empty? ? current_fiscal_year_year : line_items.first.fy_year\n\n a = []\n cum_amount = 0\n cum_spent = 0\n cum_committed = 0\n\n (first_year..last_fiscal_year_year).each do |yr|\n year_amount = 0\n year_spent = 0\n year_committed = 0\n\n list = line_items.where('fy_year = ?', yr)\n list.each do |fli|\n year_amount += fli.amount\n year_spent += fli.spent\n year_committed += fli.committed\n end\n\n cum_amount += year_amount\n cum_spent += year_spent\n cum_committed += year_committed\n\n # Add this years summary to the cumulative amounts\n a << [fiscal_year(yr), cum_amount, cum_spent, cum_committed]\n end\n a\n\n end",
"def estimate_embargo_period( issued, embargo_release )\n period = Date.parse( embargo_release ) - Date.parse( issued )\n case period.to_i\n when 0\n return ''\n when 1..186\n return GenericWork::EMBARGO_VALUE_6_MONTH\n when 187..366\n return GenericWork::EMBARGO_VALUE_1_YEAR\n when 367..731\n return GenericWork::EMBARGO_VALUE_2_YEAR\n when 732..1825\n return GenericWork::EMBARGO_VALUE_5_YEAR\n else\n return GenericWork::EMBARGO_VALUE_FOREVER\n end\n end",
"def interest(amount)\n if amount <= 1000\n 0.04 * amount\n elsif amount <= 5000\n 0.045 * amount\n else\n 0.05 * amount\n end\nend",
"def get_quarterly\n # get last year earnings\n l_year = latest_eps.year\n\n # get which quarters are the last 4\n fp = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Fiscal Period\" }\n fp = fp.xpath('./td') if fp\n\n if fp.nil?\n puts \"--------------------------------------Cannot get info for #{ticker}\"\n return false\n end\n # Find last year by counting 'td's up to \"TMM\"\n years_available = 0 # Some stocks may not have 10 years worth of data\n for i in 1..fp.size\n if fp[i].nil? || !fp[i].text.match(\"TTM\").nil?\n break\n end\n years_available = i\n end\n\n puts \"Counted #{years_available} years of available data for #{ticker}\"\n\n update_year = 1 # Some stocks may not be updated for 2012 yet\n update_year = 0 if fp[years_available].text.last == \"2\"\n\n\n\n\n #Acces data page\n url = \"http://www.gurufocus.com/financials/#{ticker}\"\n doc = open_url_or_nil(url)\n if doc.nil?\n puts \"Could not get quarterly finantial data from gurufocus.com\"\n return false\n end\n\n # Get last 4 quarters quarterly data\n # Check first if all 4 quarters are available?\n (1..4).each do |i|\n if fp[i].nil? || !fp[i].text.match(\"TTM\").nil?\n break\n end\n years_available = i\n end\n\n puts \"Counted #{years_available} years of available data for #{ticker}\"\n\n update_year = 1 # Some stocks may not be updated for 2012 yet\n update_year = 0 if fp[years_available].text.last == \"2\"\n\n # A boolean to test if current asset values are available\n using_current_data = true\n\n # Scrape data from doc\n # Current Assets\n ca = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Current Assets\" }\n if ca\n ca = ca.xpath('./td')\n else\n using_current_data = false\n end\n\n ta = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Assets\" }\n ta = ta.xpath('./td') if ta\n\n cl = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Current Liabilities\" }\n if cl\n cl = cl.xpath('./td')\n else\n using_current_data = false\n end\n\n tl = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Liabilities\" }\n tl = tl.xpath('./td') if tl\n\n # Debt, book value, net tangible assets\n ltd = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Long-Term Debt\" }\n ltd = ltd.xpath('./td') if ltd\n\n bv = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Equity\" }\n bv = bv.xpath('./td') if bv\n\n ocs = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Other Current Assets\" }\n ocs = ocs.xpath('./td') if ocs\n\n # Create balance sheet for 10 years\n (1..years_available).each do |i|\n cas = \"\"\n cls = \"\"\n ntas = \"\"\n if using_current_data\n cas = (clean_string(ca[i].text).to_f.round * MILLION).to_s\n cls = (clean_string(cl[i].text).to_f.round * MILLION).to_s\n if ocs\n ntas = (( clean_string(ca[i].text).to_f - clean_string(ocs[i].text).to_f - clean_string(cl[i].text).to_f ).round * MILLION ).to_s\n else\n ntas = cas\n end\n end\n\n # Some trusts don't have liabilities\n tler = \"\"\n tler = (clean_string(tl[i].text).to_f.round * MILLION).to_s if tl\n der = \"\"\n der = (clean_string(ltd[i].text).to_f.round * MILLION).to_s if ltd\n bver = \"\"\n bver = (clean_string(bv[i].text).to_f.round * MILLION).to_s if bv\n bs = BalanceSheet.create(:stock_id => self.id,\n :year => YEAR - (years_available+1 - i) - update_year, #This reveses the year from i\n :current_assets => cas,\n :total_assets => (clean_string(ta[i].text).to_f.round * MILLION).to_s,\n :current_liabilities => cls,\n :total_liabilities => tler,\n :long_term_debt => der,\n :net_tangible_assets => ntas,\n :book_value => bver,\n :quarter => q)\n puts \"Got bs data for #{ticker}, year: #{bs.year}, ta = #{bs.total_assets}\" if !bs.id.nil?\n end\n\n update_attributes( :has_currant_ratio => using_current_data)\n\n end",
"def future(year, month, day)\n years = (10 ** 9) / 60 / 60 / 24 / 365\n days = (10 ** 9) / 60 / 60 / 24 % 365\n\n year = year + years\n \n\nend",
"def what_you_would_get_if_not_full\n if (qualifying_years + years_to_pension) < years_needed\n ((qualifying_years + years_to_pension).to_f / years_needed.to_f) * current_weekly_rate\n else\n current_weekly_rate\n end\n end",
"def calculate_interest(amount, number_of_days)\n (amount * (0.03 / 365) * (number_of_days - 1)).round(10)\n end",
"def calculateInterest\n\t\tinterest = 0\n\t\t@transactions.each do |trans|\n\t\t\tinterest += -1 * ((31 - trans[0]) * trans[-1] * @APR / 365)\n\t\tend\n\t\tinterest < 0 ? 0 : interest.round(2)\n\tend",
"def pmt(interest_rate,payments,principal)\n numerator =interest_rate*principal*(1 + interest_rate)**payments\n denominator= (1+ interest_rate)**payments - 1\n return numerator/denominator.to_f\nend",
"def efective_given_nominal_due(nominal_rate, term)\n ((((1+((nominal_rate.to_f/100)/term))**term)-1).round(6))*100\n end",
"def annualized_return(start_date, end_date)\n difference_in_days = (end_date - start_date).to_i\n average_daily_profit = profit(start_date, end_date) / difference_in_days.to_f\n average_daily_profit * 365.25\n end",
"def interest_part(balance, interest_rate)\n balance*(interest_rate/100)\n end",
"def graph_ideal_value_for_date(date)\n # Firstly, try to use goal's baseline and target\n if self.baseline_date >= date\n return self.baseline\n elsif self.due_date <= date\n return self.accuracy\n end\n\n # Secondly, try to check if there is any progress exact on the given day\n exact_progress = nil\n if self.association(:progresses).loaded?\n # Search in memory\n exact_progress = self.progresses.detect{|p| p.due_date == date}\n else\n # Search in DB\n exact_progress = self.progresses.where(:due_date => date).first\n end\n\n unless exact_progress.blank?\n return exact_progress.accuracy \n end\n\n # Thirdly, we're unlucky, let calculate it!\n\n # The nearest progress that less than the given date\n begin_progress = nil\n # The nearest progress that bigger than the given date\n end_progress = nil\n\n if self.association(:progresses).loaded?\n # Search in memory\n begin_progress = self.progresses.sort_by(&:due_date).reverse.detect{|p| p.due_date <= date}\n end_progress = self.progresses.sort_by(&:due_date).detect{|p| p.due_date >= date}\n else\n # Search in DB\n begin_progress = self.progresses.where(\"due_date <= ?\", date).order(\"due_date DESC\").first\n end_progress = self.progresses.where(\"due_date >= ?\", date).order(\"due_date ASC\").first\n end\n\n # Get the necessary data.\n begin_date = nil\n begin_value = nil\n end_date = 0\n end_value = 0\n\n if begin_progress\n begin_date = begin_progress.due_date\n begin_value = begin_progress.accuracy\n else\n # Use baseline\n begin_date = self.baseline_date\n begin_value = self.baseline\n end\n\n if end_progress\n end_date = end_progress.due_date\n end_value = end_progress.accuracy\n else\n # Use the deadline\n end_date = self.due_date\n end_value = self.accuracy\n end\n\n # Caculate the value\n # Please see the triangle above to understand the meaning of variables.\n ad = (date - begin_date).to_i\n ab = (end_date - begin_date).to_i\n bc = (end_value - begin_value).abs\n\n if ab == 0\n return 0\n else\n return (begin_value + (ad*bc/ab))\n end\n end",
"def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n end",
"def present_value\n # Payoff amount = 0, we’re assuming a fully amortizing loan\n payoff_amount = 0\n end",
"def annualized_30_day_return_volatility(params = {})\n timeseries = params.is_a?(Timeseries) ? params : Timeseries.new(params)\n timeseries.tick = \"1 day\"\n timeseries.from = timeseries.from - 30.days < Timeseries::OLDEST ? Timeseries::OLDEST : timeseries.from - 30.days\n dataset = global_ppi(timeseries).order(:tick)\n .from_self\n .select(:tick, :global_ppi)\n .select_append{ count(global_ppi).over(frame: \"rows 29 preceding\").as(:preceding_rows) }\n .select_append{ ln(global_ppi / lag(global_ppi).over(order: :tick)).as(:daily_return) }\n .from_self\n .select(:tick, :global_ppi, :preceding_rows)\n .select_append{\n round(\n (stddev(daily_return).over(order: :tick, frame: \"rows 29 preceding\") * sqrt(365) * 100).cast(:numeric),\n 2\n ).as(:vol_30d)\n }\n .from_self\n .select(:tick, :global_ppi, :vol_30d)\n .where(preceding_rows: 30)\n .exclude(vol_30d: nil)\n 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 us_treas_10_year_rate\n # In real life call a web service to get it, but I will return a constant here\n 0.02124\n end",
"def compound_interest(rate, count = 1, period = 12)\n Money.new(cents * ((1 + rate / 100.0 / period) ** count - 1))\n end",
"def calculate_irr(min_rate, max_rate, amounts)\n while true\n range = max_rate - min_rate\n\n raise RuntimeError if range <= Float::EPSILON * 2\n\n rate = range.fdiv(2) + min_rate\n present_value = npv(rate, amounts)\n\n if present_value > 0\n min_rate = rate\n elsif present_value < -0.5\n max_rate = rate\n else\n return rate\n end\n end\n end",
"def present_given_annuity(annuity, interest, term)\n (annuity.to_f * (((1 + interest.to_f) ** term) -1) / (interest.to_f * (1 + interest.to_f) ** term )).round(4)\n end",
"def new_sale_price \n noi(num_years_to_hold + 1) / cap_rate(num_years_to_hold + 1)\n end",
"def annualized_portfolio_amount_needed\n savings_portion_needed * 12.0\n end",
"def last_fiscal_year_year\n current_fiscal_year_year + SystemConfig.instance.num_forecasting_years\n end",
"def depositProfit(deposit, rate, threshold)\n count = 0\n profit = deposit\n \n while profit < threshold do\n count += 1\n profit += ((profit*rate)/100).to_f\n end\n \n if rate == 1\n threshold - deposit\n else\n count\n end\nend",
"def yearly_rate(*args)\n if paid?\n if yearly?\n rate(*args) / duration_parts[0] #number of years\n else\n rate(*args) / duration_in_months * 12\n end\n else\n nil\n end\n end",
"def annual_salary\n hourly_rate * 1950\n end",
"def to_extend_now\n length = self.this_year.contract.contract_length \n auction_value = self.current_contract.subcontracts.first.salary_amount\n this_progression = SalaryProgression.find_by_auction_value(auction_value).attributes.to_a\n next_salary = this_progression[(length + 1)][1]\n return next_salary\n end",
"def nb_year(p0, percent, aug, p)\n years = 0\n while p >= p0 do\n p0 += (percent/100.0 * p0) + aug\n years += 1\n end\n p years\nend",
"def fiscal_years\n get_fiscal_years\n end",
"def nb_year(p0, percent, aug, p)\n year_count = 0\n until p0 >= p do\n p0 += (p0 * (percent/100.to_f)) + aug\n year_count += 1\n # binding.pry\n end\n year_count\n # binding.pry\nend",
"def nper\n z = payment * (1.0 + monthly_rate * ptype) / monthly_rate\n\n Math.log(-future_value + z / (amount + z)) / Math.log(1.0 + monthly_rate)\n end",
"def frm(r, n, po)\n\t## \n\t# interest rate is converted to fraction and made a monthly\n\tr = r.to_f/100/12\n\t##\n\t#number of years is converted to number of months\n\tn = n * 12\n\t##\n\t#monthly payment is calculated\n\tc = (r / (1 - (1+r) ** -n) ) * po\n\treturn c\nend",
"def calculate_interest(days_since_transaction)\n\t\t@interest << @balance * @apr / 365 * days_since_transaction\n\tend",
"def effective_annual_rate(rate,compound_frequency)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_effective_annual_rate(rate)\n end\n m= compound_frequency\n e_rate = (1 + rate/m)**m -1\n end",
"def compute_yearwise(incomes_or_deductions)\n income_deduction_per_year = Hash.new(0)\n\n incomes_or_deductions.each do |income_deduction|\n working_days_in_year = Float(52*5)\n daily_income = 0\n\n case income_deduction.frequency\n when \"daily\"\n daily_income = income_deduction.amount_in_cents\n when \"weekly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/52)\n when \"biweekly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/26)\n when \"monthly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/12)\n when \"quarterly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/4)\n when \"half_yearly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/2)\n when \"yearly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year)\n end\n\n income_deduction.start_date = TimeKeeper.date_of_record.beginning_of_year if income_deduction.start_date.to_s.eql? \"01-01-0001\" || income_deduction.start_date.blank?\n income_deduction.end_date = TimeKeeper.date_of_record.end_of_year if income_deduction.end_date.to_s.eql? \"01-01-0001\" || income_deduction.end_date.blank?\n years = (income_deduction.start_date.year..income_deduction.end_date.year)\n\n years.to_a.each do |year|\n actual_days_worked = compute_actual_days_worked(year, income_deduction.start_date, income_deduction.end_date)\n income_deduction_per_year[year] += actual_days_worked * daily_income\n end\n end\n\n income_deduction_per_year.merge(income_deduction_per_year) { |k, v| Integer(v) rescue v }\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def forecast_finish_date(basis_hours)\n if complete_ev(basis_hours) == 100.0\n @ev.keys.max\n elsif today_spi(basis_hours) == 0.0\n @pv.keys.max\n else\n if @issue_max_date < @basis_date\n rest_days = (@pv[@pv.keys.max] - @ev[@ev.keys.max]) / today_spi(basis_hours) / basis_hours\n @basis_date + rest_days\n else\n rest_days = @pv.count { |key, _value| key > @basis_date }\n @pv.keys.max - (rest_days - (rest_days / today_spi(basis_hours)))\n end\n end\n end",
"def simple_interest(rate, count = 1, period = 12)\n Money.new(rate / 100 / period * cents * count)\n end",
"def _reduce_365(val, _values, result); end",
"def ending_balance(rate, amount, number_of_months = nil)\n number_of_months ||= periods\n monthly_payment = get_monthly_payment(rate, amount)\n ending_balance = amount\n\n number_of_months.times do\n ending_balance = ending_balance * (1 + rate) - monthly_payment\n end\n\n ending_balance.round(2)\n end",
"def estimated_consumption_with_cr(cr)\n total = 0\n # if real consumption greater than zero, must compensate estimation balance\n if cr > 0\n total = cr < current_estimation_balance ? cr * (-1) : current_estimation_balance * (-1)\n end # cr > 0\n total || 0\n end",
"def adjusted_target_income\n (self.target_income * (years_to_retirement * self.avg_inflation_rate)) + self.target_income\n end",
"def calculate_life_plan(life_plan = LifePlan.new)\n results = []\n\n years_ahead = life_plan.total_years\n\n years_ahead.times do |year_count|\n year_results = calculate_next_year(\n life_plan.contribution_for(year_count),\n life_plan.withdraw_for(year_count)\n )\n\n @current_balance = year_results.average\n results << year_results\n end\n\n results\n end",
"def daily_rate\n yearly_rate / 365\n end",
"def get_dividend_value\n\t\t @dividend_share_value = @forwardDividendRate / (@overnightDiscountRate - @dividend_growth_rate)\n\n\t\t return @dividend_share_value\n\t\tend",
"def annualy_insurance\n return @capital * @insurance * -1\n end",
"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 debt_rate\n ten_year_treasury + bps(200)\n end",
"def portfolio_value(fake_yahoo_api)\n # Go through our positions and add them up, then add in the cash balance\n @positions.map { |key, value| fake_yahoo_api.get_latest_price(key) * @positions[key] || 0 }\n .reduce(:+) || 0\n + account_balance\n end",
"def rate\n Rate.new(self.interest/100, :apr, duration: self.tenure * 12)\n end",
"def daily_rate\n\t\t yearly_rate / 365\n\t\t end",
"def next_charge\n ( pre_finalised_quote * relative_progress / 100 ) - charged_so_far\n end",
"def cash_flow(org = nil)\n\n if org\n line_items = grants.where('organization_id = ?', org.id)\n else\n line_items = grants\n end\n\n first_year = line_items.empty? ? current_fiscal_year_year : line_items.first.fy_year\n\n a = []\n balance = 0\n\n (first_year..last_fiscal_year_year).each do |yr|\n year_amount = 0\n year_spent = 0\n year_committed = 0\n\n list = line_items.where('fy_year = ?', yr)\n list.each do |fli|\n year_amount += fli.amount\n year_spent += fli.spent\n year_committed += fli.committed\n end\n\n balance += year_amount - (year_spent + year_committed)\n\n # Add this years summary to the array\n a << [fiscal_year(yr), year_amount, year_spent, year_committed, balance]\n end\n a\n\n end",
"def range\n beginning_of_period..(self.next_year).beginning_of_period\n end",
"def calculate_apr\n payment_ratio = pmt / principal_calculation\n duration = @duration\n f = lambda {|k| (k**(duration + 1) - (k**duration * (payment_ratio + 1)) + payment_ratio)}\n f_deriv = lambda { |k| ((duration + 1) * k**duration) - (duration * (payment_ratio + 1) * k**(duration - 1))}\n\n root = newton_raphson(f, f_deriv, monthly_rate + 1)\n 100 * 12 * (root -1).to_f\n end",
"def future_expense_checker (record)\n\t\tdate = record.date_paid\n \ttime = date.to_time\n \ttime.future?\n end",
"def book_royalty(period='enddate', basis=\"Net receipts\")\n royarray = []\n sales = self.book_sales(period, basis, false) # this calls the royalty calculation for net receipts\n sales.each do |sale|\n royarray << sale.royalty_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? || i.nil? }\n end\n book_royalty = royarray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def to_years; Rational === @val ? @val/12 : @val/12.0 end",
"def pmt (interest_rate, nper, pv)\n\t#monthly_payment = 1.00\n\tmonthly_payment = (pv*interest_rate*((1+interest_rate)**nper))/(((1+interest_rate)**nper)-1)\n\treturn monthly_payment\nend",
"def book_value(period='enddate', basis, exclude)\n salearray = []\n sales = self.book_sales(period, basis, exclude)\n sales.each do |sale|\n salearray << sale.value_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? or i.nil? }\n end\n book_value =salearray.inject(0) { |sum, i| sum +i.to_f }\n end"
] | [
"0.74859816",
"0.7460934",
"0.73605585",
"0.70097977",
"0.69373226",
"0.67010456",
"0.65248215",
"0.65005285",
"0.64793396",
"0.6350233",
"0.62822175",
"0.62789625",
"0.62492776",
"0.6179234",
"0.61650795",
"0.6115266",
"0.6107985",
"0.6103223",
"0.60859317",
"0.60255533",
"0.6011521",
"0.59799707",
"0.59727925",
"0.59215283",
"0.59044385",
"0.5855717",
"0.58168334",
"0.5790984",
"0.5721664",
"0.57119286",
"0.5689622",
"0.5673261",
"0.56690276",
"0.5657446",
"0.56545186",
"0.5644099",
"0.55766535",
"0.55756694",
"0.55593055",
"0.5555659",
"0.5530314",
"0.5528049",
"0.55274063",
"0.5521444",
"0.55098945",
"0.5495988",
"0.5487895",
"0.5481755",
"0.5457293",
"0.5449287",
"0.54471105",
"0.54380786",
"0.543303",
"0.5431466",
"0.5422945",
"0.5397391",
"0.539012",
"0.53741455",
"0.5373817",
"0.5338627",
"0.5333773",
"0.5333065",
"0.5309391",
"0.5309222",
"0.5298105",
"0.52971303",
"0.52954966",
"0.5285879",
"0.5278997",
"0.52695006",
"0.5267291",
"0.52586484",
"0.52539045",
"0.52485347",
"0.5241494",
"0.52175367",
"0.5216138",
"0.52069396",
"0.5204222",
"0.51987517",
"0.51965106",
"0.51896244",
"0.5183958",
"0.51805747",
"0.51741445",
"0.5165742",
"0.5161676",
"0.5161525",
"0.5142955",
"0.51427853",
"0.51362306",
"0.5134965",
"0.5114802",
"0.5106226",
"0.51041985",
"0.50987846",
"0.509191",
"0.5088556",
"0.5085797",
"0.50803983"
] | 0.7800808 | 0 |
determine the rate of return over a period periods number of periods (years) that the interest is cumulated present_value the value at the start of the period future_value the value at the end of the period | def compound_return(periods,present_value,future_value)
pv = present_value.to_d
fv = future_value.to_d
n = periods.to_d
rate = ((fv / pv)**(1/n))-1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_compound_fv(rate,periods,present_value)\n end\n future_value = present_value * (1+rate/compound_frequency)** (periods * compound_frequency)\n end",
"def investment_horizon(rate,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n periods = Math.log(fv/pv) / Math.log(1+rate)\n end",
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n# principal amount\n year = 0\n while principal < desired\n year += 1\n income = principal * interest\n principal += income - income * tax\n end\n year\nend",
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"def nominal_due_given_efective(effective_rate, periods)\n\t\t\t((((1 + (effective_rate.to_f/100))**(1/periods.to_f)-1)*periods.to_f)*100).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n i = 0\n return i if principal == desired\n \n while principal < desired\n principal += (principal * interest) - (principal * interest * tax)\n i += 1\n end\n \n i\nend",
"def anticipated_fixed_payment(present_value, rate, term)\n\t\t((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)\n end",
"def annual_ror(initial_value, final_value, years)\n if years <= 0\n 0\n elsif initial_value == 0\n # BigDecimal::INFINITY\n Float::INFINITY\n else\n 100.to_d * if final_value < 0 # fudge if final value is less than zero\n (((initial_value.to_d - final_value.to_d) / initial_value.to_d) ** (1 / years.to_d)) * -1\n else\n ((final_value.to_d / initial_value.to_d) ** (1 / years.to_d)) - 1\n end\n end\n end",
"def calculate_interest principle, days_since\n (principle * APR / 365 * days_since).round(2)\n end",
"def calculate_payment\n x = @periodic_rate * @principal * ((1 + @periodic_rate)**@periods)\n y = ((1 + @periodic_rate)**@periods) - 1\n (x / y).round(2)\n end",
"def present_given_future(future_value, interest, term)\n (future_value.to_f / (1 +interest.to_f) ** term).round(4)\n end",
"def calculate_years(principal, interest, tax, desired)\n total = principal\n years = 0\n loop do\n break if total >= desired\n total_interest = total*interest\n total += total_interest\n total -= total_interest*tax\n years += 1\n end\n years\nend",
"def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annual_percentage_rate = interest_rate_percentage / 100\n principal * (1 + annual_percentage_rate * number_of_years)\nend",
"def calculate_loan(rate, n_periods, total_loan_amount)\n fixed_payment = (rate /\n (1 - ((1 + rate)**(n_periods * - 1)))) * total_loan_amount\n\n fixed_payment.to_f\nend",
"def daily_interest\n @apr / 100.0 / 365\n end",
"def net_present_value\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * (1 + x)**-relative_payment.offset\n end\n end\n end",
"def nominal_anticipated_given_efective(effective_rate, periods)\n nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1\n toAnticipated = nominalRate / (1+nominalRate)\n (toAnticipated * periods.to_f * 100).round(4)\n end",
"def rates_prediction\r\n final_array = []\r\n today = today_rate\r\n weekly_change = weekly_percentage_change_array\r\n\r\n first = ((weekly_change[0] / 100) * today) + today\r\n final_array << first\r\n\r\n if @time > 1\r\n i = 0\r\n while i < weekly_change[1].length\r\n rate = ((weekly_change[1][i] / 100) * final_array[i]) + final_array[i]\r\n final_array << rate\r\n i += 1\r\n end\r\n end\r\n final_array\r\n end",
"def nb_year(p0, percent, aug, p)\n years = 0\n while p >= p0 do\n p0 += (percent/100.0 * p0) + aug\n years += 1\n end\n p years\nend",
"def years_until_retirement\n @retirement_age.to_i - @current_age.to_i\n end",
"def annuity_given_future(future_value, interest, term)\n (future_value.to_f * (interest.to_f / ((1 + interest) ** term)-1)).round(4)\n end",
"def nb_year(p0, percent, aug, p)\n year_count = 0\n until p0 >= p do\n p0 += (p0 * (percent/100.to_f)) + aug\n year_count += 1\n # binding.pry\n end\n year_count\n # binding.pry\nend",
"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 grow_one_year(starting_balance, growth_rate)\n starting_balance * (1.0 + growth_rate)\nend",
"def call(year)\n previous_year = Population.previous_known(year)\n\n return previous_year.population if previous_year.year == year # year entered is known\n\n next_year = Population.next_known(year)\n\n # there is no next year - unable to calculate\n return nil if next_year.nil? \n\n # calculate the percentage that year is between next and previous years\n mod_percentage = (year - previous_year.year).to_f / (next_year.year - previous_year.year).to_f\n delta_population = next_year.population - previous_year.population\n\n (delta_population * mod_percentage).to_i + previous_year.population\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def compound_interest(rate, count = 1, period = 12)\n Money.new(cents * ((1 + rate / 100.0 / period) ** count - 1))\n end",
"def calculate_interest(principal, roi, time)\n rate = roi.to_f / 100\n amount = principal.to_f * (1 + rate * time.to_f)\n\n amount\nend",
"def annuity_given_present(present_value, interest, term)\n interest = interest.to_f\n (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)\n end",
"def expression_value\n return @expression_value if defined?(@expression_value)\n\n subexpr_value =\n (1 + periodic_interest_rate) ** total_number_of_payments\n @expression_value =\n (periodic_interest_rate * subexpr_value) / (subexpr_value - 1)\n end",
"def us_treas_10_year_rate\n # In real life call a web service to get it, but I will return a constant here\n 0.02124\n end",
"def yearly_rate(*args)\n if paid?\n if yearly?\n rate(*args) / duration_parts[0] #number of years\n else\n rate(*args) / duration_in_months * 12\n end\n else\n nil\n end\n end",
"def percent_change periods=1\n must_be_numeric!\n\n prev = nil\n arr = @data.each_with_index.map do |cur, i|\n if i < periods ||\n include_with_nan?(Daru::MISSING_VALUES, cur) ||\n include_with_nan?(Daru::MISSING_VALUES, prev)\n nil\n else\n (cur - prev) / prev.to_f\n end.tap { prev = cur if cur }\n end\n\n Daru::Vector.new(arr, index: @index, name: @name)\n end",
"def sum_income(period)\n if period.is_a?(Range)\n income = items.sum(:value, :conditions=>[\"date >= ? and date <= ? and value > 0\", period.first, period.last])\n else\n income = items.sum(:value, :conditions=>[\"date = ? and value > 0\", period])\n end\n return income || 0\n end",
"def depositProfit(deposit, rate, threshold)\n count = 0\n profit = deposit\n \n while profit < threshold do\n count += 1\n profit += ((profit*rate)/100).to_f\n end\n \n if rate == 1\n threshold - deposit\n else\n count\n end\nend",
"def debt_rate\n ten_year_treasury + bps(200)\n end",
"def daily_rate\n yearly_rate / 365\n end",
"def nb_year(p0, percent, aug, p)\n count = 0\n while p0 < p\n p0 = p0 + (p0 * percent * 0.01).to_i + aug\n count += 1\n end\n \n return count\nend",
"def future_given_annuity(annuity, interest, term)\n (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)\n end",
"def net_present_value_derivative\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * -relative_payment.offset * (1 + x)**(-relative_payment.offset - 1)\n end\n end\n end",
"def pmt(interest_rate,payments,principal)\n numerator =interest_rate*principal*(1 + interest_rate)**payments\n denominator= (1+ interest_rate)**payments - 1\n return numerator/denominator.to_f\nend",
"def annualized_return(start_date, end_date)\n difference_in_days = (end_date - start_date).to_i\n average_daily_profit = profit(start_date, end_date) / difference_in_days.to_f\n average_daily_profit * 365.25\n end",
"def daily_rate\n\t\t yearly_rate / 365\n\t\t end",
"def to_years; Rational === @val ? @val/12 : @val/12.0 end",
"def estimate_embargo_period( issued, embargo_release )\n period = Date.parse( embargo_release ) - Date.parse( issued )\n case period.to_i\n when 0\n return ''\n when 1..186\n return GenericWork::EMBARGO_VALUE_6_MONTH\n when 187..366\n return GenericWork::EMBARGO_VALUE_1_YEAR\n when 367..731\n return GenericWork::EMBARGO_VALUE_2_YEAR\n when 732..1825\n return GenericWork::EMBARGO_VALUE_5_YEAR\n else\n return GenericWork::EMBARGO_VALUE_FOREVER\n end\n end",
"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 calculate_interest(current_period, previous_period=0)\n previous_balance = @txns[previous_period][:balance]\n period_of_interest = current_period - previous_period\n @interest += (previous_balance * daily_interest * period_of_interest).round(2)\n end",
"def years_of_service(period=nil)\n # TODO: need a real general purpose date diff by year\n # function since this is likely needed in multiple places.\n return 0 if contract_start.nil?\n period = Period.current if period.nil?\n\n if (period.finish > contract_start)\n tmp_date = period.finish\n count = 0\n while (tmp_date.prev_year >= contract_start.to_date)\n tmp_date = tmp_date.prev_year\n count += 1\n end\n\n count\n else\n 0\n end\n end",
"def calculate_yearly_rents_years\n convert_lease_transaction_date\n years = @lbtt_return.lease_end_date.year - @lbtt_return.lease_start_date.year\n years += 1 if @lbtt_return.lease_end_date >= @lbtt_return.lease_start_date.next_year(years)\n years\n end",
"def pv\n factor = (1.0 + monthly_rate)**duration\n second_factor = (factor - 1) * (1 + monthly_rate * ptype) / monthly_rate\n\n -(future_value + (payment.to_f * second_factor)) / factor\n end",
"def new_sale_price \n noi(num_years_to_hold + 1) / cap_rate(num_years_to_hold + 1)\n end",
"def calculate_interest(amount, number_of_days)\n (amount * (0.03 / 365) * (number_of_days - 1)).round(10)\n end",
"def annualized_portfolio_amount_needed\n savings_portion_needed * 12.0\n end",
"def current_age_approximate\n nil\n end",
"def rate\n Rate.new(self.interest/100, :apr, duration: self.tenure * 12)\n end",
"def yearly_rate\n yearly? ? rate : rate * 12\n end",
"def yearly_rate\n\t\t yearly? ? rate : rate * 12\n\t\t end",
"def book_royalty(period='enddate', basis=\"Net receipts\")\n royarray = []\n sales = self.book_sales(period, basis, false) # this calls the royalty calculation for net receipts\n sales.each do |sale|\n royarray << sale.royalty_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? || i.nil? }\n end\n book_royalty = royarray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def interest\n return (@capital / 100) * @rate\n end",
"def cash_forecast(org_id = nil)\n\n if org_id\n line_items = funding_line_items.where('organization_id = ?', org_id)\n else\n line_items = funding_line_items\n end\n\n first_year = line_items.empty? ? current_fiscal_year_year : line_items.first.fy_year\n\n a = []\n cum_amount = 0\n cum_spent = 0\n cum_committed = 0\n\n (first_year..last_fiscal_year_year).each do |yr|\n year_amount = 0\n year_spent = 0\n year_committed = 0\n\n list = line_items.where('fy_year = ?', yr)\n list.each do |fli|\n year_amount += fli.amount\n year_spent += fli.spent\n year_committed += fli.committed\n end\n\n cum_amount += year_amount\n cum_spent += year_spent\n cum_committed += year_committed\n\n # Add this years summary to the cumulative amounts\n a << [fiscal_year(yr), cum_amount, cum_spent, cum_committed]\n end\n a\n\n end",
"def what_you_would_get_if_not_full\n if (qualifying_years + years_to_pension) < years_needed\n ((qualifying_years + years_to_pension).to_f / years_needed.to_f) * current_weekly_rate\n else\n current_weekly_rate\n end\n end",
"def compute_yearwise(incomes_or_deductions)\n income_deduction_per_year = Hash.new(0)\n\n incomes_or_deductions.each do |income_deduction|\n working_days_in_year = Float(52*5)\n daily_income = 0\n\n case income_deduction.frequency\n when \"daily\"\n daily_income = income_deduction.amount_in_cents\n when \"weekly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/52)\n when \"biweekly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/26)\n when \"monthly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/12)\n when \"quarterly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/4)\n when \"half_yearly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year/2)\n when \"yearly\"\n daily_income = income_deduction.amount_in_cents / (working_days_in_year)\n end\n\n income_deduction.start_date = TimeKeeper.date_of_record.beginning_of_year if income_deduction.start_date.to_s.eql? \"01-01-0001\" || income_deduction.start_date.blank?\n income_deduction.end_date = TimeKeeper.date_of_record.end_of_year if income_deduction.end_date.to_s.eql? \"01-01-0001\" || income_deduction.end_date.blank?\n years = (income_deduction.start_date.year..income_deduction.end_date.year)\n\n years.to_a.each do |year|\n actual_days_worked = compute_actual_days_worked(year, income_deduction.start_date, income_deduction.end_date)\n income_deduction_per_year[year] += actual_days_worked * daily_income\n end\n end\n\n income_deduction_per_year.merge(income_deduction_per_year) { |k, v| Integer(v) rescue v }\n end",
"def years_count\n ((@end_date - @start_date).to_f / 365).to_f.round(1)\n end",
"def fiscal_years\n get_fiscal_years\n end",
"def graph_ideal_value_for_date(date)\n # Firstly, try to use goal's baseline and target\n if self.baseline_date >= date\n return self.baseline\n elsif self.due_date <= date\n return self.accuracy\n end\n\n # Secondly, try to check if there is any progress exact on the given day\n exact_progress = nil\n if self.association(:progresses).loaded?\n # Search in memory\n exact_progress = self.progresses.detect{|p| p.due_date == date}\n else\n # Search in DB\n exact_progress = self.progresses.where(:due_date => date).first\n end\n\n unless exact_progress.blank?\n return exact_progress.accuracy \n end\n\n # Thirdly, we're unlucky, let calculate it!\n\n # The nearest progress that less than the given date\n begin_progress = nil\n # The nearest progress that bigger than the given date\n end_progress = nil\n\n if self.association(:progresses).loaded?\n # Search in memory\n begin_progress = self.progresses.sort_by(&:due_date).reverse.detect{|p| p.due_date <= date}\n end_progress = self.progresses.sort_by(&:due_date).detect{|p| p.due_date >= date}\n else\n # Search in DB\n begin_progress = self.progresses.where(\"due_date <= ?\", date).order(\"due_date DESC\").first\n end_progress = self.progresses.where(\"due_date >= ?\", date).order(\"due_date ASC\").first\n end\n\n # Get the necessary data.\n begin_date = nil\n begin_value = nil\n end_date = 0\n end_value = 0\n\n if begin_progress\n begin_date = begin_progress.due_date\n begin_value = begin_progress.accuracy\n else\n # Use baseline\n begin_date = self.baseline_date\n begin_value = self.baseline\n end\n\n if end_progress\n end_date = end_progress.due_date\n end_value = end_progress.accuracy\n else\n # Use the deadline\n end_date = self.due_date\n end_value = self.accuracy\n end\n\n # Caculate the value\n # Please see the triangle above to understand the meaning of variables.\n ad = (date - begin_date).to_i\n ab = (end_date - begin_date).to_i\n bc = (end_value - begin_value).abs\n\n if ab == 0\n return 0\n else\n return (begin_value + (ad*bc/ab))\n end\n end",
"def univ_paid_ship_rate\n return 0 unless most_recent_payment_good && university_id\n university.number_per_month(most_recent_payment_good.andand.amount)\n end",
"def discount_of_the_day(day)\n case day\n when (0..(DISCOUNT_PERIOD_1_START_DAY - 1)) then 0\n when (DISCOUNT_PERIOD_1_START_DAY..(DISCOUNT_PERIOD_2_START_DAY - 1)) then DISCOUNT_PERIOD_1_RATE\n when (DISCOUNT_PERIOD_2_START_DAY..(DISCOUNT_PERIOD_3_START_DAY - 1)) then DISCOUNT_PERIOD_2_RATE\n else DISCOUNT_PERIOD_3_RATE\n end\n end",
"def installment_value(interest_rate, financing_time_months, loan_value)\n @installment_calculator.calculate(interest_rate, financing_time_months, loan_value)\n end",
"def calculate_irr(min_rate, max_rate, amounts)\n while true\n range = max_rate - min_rate\n\n raise RuntimeError if range <= Float::EPSILON * 2\n\n rate = range.fdiv(2) + min_rate\n present_value = npv(rate, amounts)\n\n if present_value > 0\n min_rate = rate\n elsif present_value < -0.5\n max_rate = rate\n else\n return rate\n end\n end\n end",
"def calc_years_till\n (calc_months_till / 12.00).round(2)\n end",
"def nper\n z = payment * (1.0 + monthly_rate * ptype) / monthly_rate\n\n Math.log(-future_value + z / (amount + z)) / Math.log(1.0 + monthly_rate)\n end",
"def simple_interest(rate, count = 1, period = 12)\n Money.new(rate / 100 / period * cents * count)\n end",
"def range\n beginning_of_period..(self.next_year).beginning_of_period\n end",
"def year_calculations\n\t\t@prev_beg_range = @beg_range.to_date.beginning_of_year.prev_year\n\t\t@prev_end_range = @beg_range.to_date.beginning_of_year-1.day\n\t\t@next_beg_range = @beg_range.to_date.next_year.beginning_of_year\n\t\t@next_end_range = @beg_range.to_date.next_year.end_of_year\n\tend",
"def frm(r, n, po)\n\t## \n\t# interest rate is converted to fraction and made a monthly\n\tr = r.to_f/100/12\n\t##\n\t#number of years is converted to number of months\n\tn = n * 12\n\t##\n\t#monthly payment is calculated\n\tc = (r / (1 - (1+r) ** -n) ) * po\n\treturn c\nend",
"def present_value\n # Payoff amount = 0, we’re assuming a fully amortizing loan\n payoff_amount = 0\n end",
"def efective_given_nominal_due(nominal_rate, term)\n ((((1+((nominal_rate.to_f/100)/term))**term)-1).round(6))*100\n end",
"def get_dividend_value\n\t\t @dividend_share_value = @forwardDividendRate / (@overnightDiscountRate - @dividend_growth_rate)\n\n\t\t return @dividend_share_value\n\t\tend",
"def final_rate_adjustment rate\n (rate/100.0).ceil - 0.01\n end",
"def annualized_30_day_return_volatility(params = {})\n timeseries = params.is_a?(Timeseries) ? params : Timeseries.new(params)\n timeseries.tick = \"1 day\"\n timeseries.from = timeseries.from - 30.days < Timeseries::OLDEST ? Timeseries::OLDEST : timeseries.from - 30.days\n dataset = global_ppi(timeseries).order(:tick)\n .from_self\n .select(:tick, :global_ppi)\n .select_append{ count(global_ppi).over(frame: \"rows 29 preceding\").as(:preceding_rows) }\n .select_append{ ln(global_ppi / lag(global_ppi).over(order: :tick)).as(:daily_return) }\n .from_self\n .select(:tick, :global_ppi, :preceding_rows)\n .select_append{\n round(\n (stddev(daily_return).over(order: :tick, frame: \"rows 29 preceding\") * sqrt(365) * 100).cast(:numeric),\n 2\n ).as(:vol_30d)\n }\n .from_self\n .select(:tick, :global_ppi, :vol_30d)\n .where(preceding_rows: 30)\n .exclude(vol_30d: nil)\n end",
"def pv_of_1_dollar_payments\n member = 1.0\n factor = 1.0/(1 + debt_rate/PAYMENTS_PER_YEAR)\n res = 0\n\n TOTAL_PAYMENTS.times do\n member *= factor\n res += member\n end\n\n res\n end",
"def calculate_win_broke_fire_rate\n all_cycles_result = []\n win_rate = []\n fire_rate = []\n broke_rate = []\n # todo we can tune this number\n (@number_of_years-100+@fire_age).times do |i|\n all_cycles_result << calculate_one_cycle(i*12)\n end\n number_of_cycles = all_cycles_result.count\n number_of_months = all_cycles_result[0].count\n\n\n (number_of_months/12).times do |year|\n total_win = 0\n total_fire = 0\n total_broke = 0\n number_of_cycles.times do |cycle|\n year_start_month = year*12\n year_end_month = year*12+11\n\n total_win += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == WIN}\n total_fire += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == FIRE}\n total_broke += all_cycles_result[cycle].slice(year_start_month, year_end_month-year_start_month).count{|i| i == BROKE}\n end\n total_count = total_win + total_fire + total_broke\n win_rate << total_win/total_count.to_f\n fire_rate << total_fire/total_count.to_f\n broke_rate << total_broke/total_count.to_f\n end\n return [win_rate, fire_rate, broke_rate]\n end",
"def determine_age_years(age_in_seconds)\n\n age_in_years = age_in_seconds.to_f / SEC_IN_YEAR\n\nend",
"def effective_annual_rate(rate,compound_frequency)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_effective_annual_rate(rate)\n end\n m= compound_frequency\n e_rate = (1 + rate/m)**m -1\n end",
"def profit_day_rate(cal)\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_period_and_client(id, cal.start_date, cal.end_date)\n days_tracked = (hours = mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n invoiced_amount = Invoice.amount_cents_invoiced_for_period_and_client(id, cal.start_date, cal.end_date).round(2)\n total_project_potential = (days_tracked * avg_rate_card_amount_cents.round).round(2)\n\n if invoiced_amount == 0 && days_tracked != 0\n 0\n elsif invoiced_amount != 0 && days_tracked == 0\n invoiced_amount\n elsif invoiced_amount == 0\n day_rate\n else\n ((invoiced_amount / total_project_potential) * day_rate).round(2)\n end\n end",
"def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n end",
"def calculate(loan_value, financing_time_months, interest_rate, loan_date = Date.today)\n balance = loan_value\n installment = installment_value(interest_rate, financing_time_months, loan_value)\n installment_date = loan_date.next_month\n iof = 0\n\n financing_time_months.step(1, -1) do |_|\n amortization = installment - interest_part(balance, interest_rate)\n\n days = past_days(loan_date, installment_date)\n\n iof += amortization*(@iof_day*(minimal_days(days)))\n iof += amortization*@iof_additional\n\n balance -= amortization\n installment_date = installment_date.next_month\n end\n\n loan_iof(iof, loan_value)\n end",
"def expected_invoice_amount_cents_for_period(start_date, end_date, user_id = nil)\n results = { expected_invoice_amount: 0,\n contains_timings_without_rate_card: false }\n result_timings = timings.where(started_at: start_date...end_date)\n result_timings = result_timings.where(user_id: user_id) if user_id.present?\n result_timings.each do |timing|\n if timing.task.quote_activity.present?\n per_minute_amount = timing.task.quote_activity.rate_card.daily_cost / account.account_setting.working_day_duration_minutes\n results[:expected_invoice_amount] += (per_minute_amount * timing.duration_minutes)\n else\n results[:contains_timings_without_rate_card] = true\n end\n end\n results\n end",
"def get_monthly_rate(apr)\n (apr / 100) / 12\nend",
"def paid_principal(amortization=self.amortization, duration=self.holding_period_mth)\n total_payment = -amortization.payments[0...duration].sum\n total_interest = amortization.interest[0...duration].sum\n\n total_payment - total_interest\n end",
"def change_rate\n return nil if @value_1.nil? || @value_2.nil?\n\n if @value_1 == 0\n if @value_2 > 0\n return 1\n elsif @value_2 < 0\n return -1\n else\n return 0\n end\n end\n\n (@value_2 - @value_1) / @value_1.to_f\n end",
"def calculate_average_true_range(yesterday_atr, today_tr, period)\n (yesterday_atr * (period - 1) + today_tr) / period\n end",
"def calculation(duration, loan, apr)\n loan * (apr / (1 - (1 + apr)**(-duration)))\nend",
"def conv_percentage(current_rate, previous_rate)\n # Increase or decrease in value\n diff = ((current_rate - previous_rate) / ((current_rate + previous_rate) / 2)) * 100\n # Weekly change algorithm\n change = ((7 * diff) / 25)\n change\n end",
"def discount_rate\n Rails.cache.fetch('us-treasury-10-year', expires_in: 24.hours) do\n us_treas_10_year_rate\n end\n end",
"def probability_of_success\n experience / 5.0\n end",
"def calculate_apr\n payment_ratio = pmt / principal_calculation\n duration = @duration\n f = lambda {|k| (k**(duration + 1) - (k**duration * (payment_ratio + 1)) + payment_ratio)}\n f_deriv = lambda { |k| ((duration + 1) * k**duration) - (duration * (payment_ratio + 1) * k**(duration - 1))}\n\n root = newton_raphson(f, f_deriv, monthly_rate + 1)\n 100 * 12 * (root -1).to_f\n end"
] | [
"0.78171325",
"0.69233257",
"0.68300253",
"0.6731517",
"0.6698266",
"0.6611931",
"0.6558443",
"0.64138514",
"0.6395259",
"0.635134",
"0.6257746",
"0.62558013",
"0.62553144",
"0.623989",
"0.62014925",
"0.6158807",
"0.6115589",
"0.6073032",
"0.6028322",
"0.6027582",
"0.5992313",
"0.5905765",
"0.5905208",
"0.59027576",
"0.5892498",
"0.5870332",
"0.5868521",
"0.58194965",
"0.5801096",
"0.57637244",
"0.57635546",
"0.57463646",
"0.57398224",
"0.5739663",
"0.5721964",
"0.57097197",
"0.57092816",
"0.5700291",
"0.56924415",
"0.5690143",
"0.5681192",
"0.56809396",
"0.56781214",
"0.5677014",
"0.5673819",
"0.5666677",
"0.5647704",
"0.56424093",
"0.56413454",
"0.563802",
"0.5628664",
"0.56237423",
"0.56177956",
"0.56123036",
"0.5608705",
"0.55926824",
"0.5579173",
"0.55679446",
"0.5547993",
"0.55317193",
"0.55259544",
"0.5518026",
"0.5498032",
"0.54955184",
"0.54802877",
"0.5471603",
"0.5464508",
"0.54637605",
"0.54580915",
"0.5457606",
"0.54568565",
"0.5436992",
"0.5435008",
"0.5434117",
"0.54236424",
"0.5404892",
"0.53936887",
"0.5389438",
"0.5386686",
"0.5384162",
"0.5380481",
"0.5375242",
"0.5368859",
"0.53569704",
"0.53436595",
"0.53355366",
"0.5329809",
"0.53288984",
"0.53222847",
"0.53060085",
"0.53055495",
"0.5295943",
"0.52940494",
"0.52895933",
"0.52776104",
"0.5265144",
"0.52651376",
"0.52651215",
"0.52618784",
"0.5260165"
] | 0.79168487 | 0 |
determine the investment horizon (length of time) required to create a future value given a present value and interest rate present_value the value at the start of the period future_value the value at the end of the period rate the annual rate of return | def investment_horizon(rate,present_value,future_value)
pv = present_value.to_d
fv = future_value.to_d
periods = Math.log(fv/pv) / Math.log(1+rate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def present_given_future(future_value, interest, term)\n (future_value.to_f / (1 +interest.to_f) ** term).round(4)\n end",
"def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end",
"def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_compound_fv(rate,periods,present_value)\n end\n future_value = present_value * (1+rate/compound_frequency)** (periods * compound_frequency)\n end",
"def annuity_given_future(future_value, interest, term)\n (future_value.to_f * (interest.to_f / ((1 + interest) ** term)-1)).round(4)\n end",
"def anticipated_fixed_payment(present_value, rate, term)\n\t\t((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)\n end",
"def annuity_given_present(present_value, interest, term)\n interest = interest.to_f\n (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)\n end",
"def earned_schedule\n ev = project.earned_value(self) #Current Earned Value\n pv_line = planned_value_by_week #Planned value by week to see in what week EV is the same as PV.\n\n week = pv_line.first[0] #PVt week\n next_week = pv_line.first[0] #PVt+1 week\n\n previous_value = 0 #Temp PVt value for loop\n previous_key = pv_line.first[0] #Temp PVt week for loop \n\n pv_line.each do |key, value|\n # puts \"#{previous_value} >= #{ev} < #{value}\"\n if( ev >= previous_value.round && ev < value.round) #Each key is a week, in what week does the EV equal to PV?\n # puts \"#{previous_value} >= #{ev} < #{value}\"\n # puts \"Yes!\"\n week = previous_key\n next_week = key\n elsif( ev == previous_value.round && ev == value.round) #THIS elseif is here when both are equal until the end of the project, e.g. when the project is finished.\n # puts \"Yes! Equal\"\n week = key\n next_week = key\n end\n previous_key = key\n previous_value = value.round\n end\n\n pv_t = pv_line[week] #PVt value\n pv_t_next = pv_line[next_week] #PVt+1 value\n\n num_of_weeks = pv_line.keys[0..pv_line.keys.index(week)].size - 1 #Get num of weeks until \"week\", t is number of weeks.\n \n if (pv_line[next_week] - pv_line[week]) == 0 #Prevent from divide by zero, when values are equal.\n num_of_weeks #This means that the line is flat. So use the previous value because (EV >= PVt and EV < PVt+1).\n else\n num_of_weeks + ((ev - pv_line[week]).to_f / (pv_line[next_week] - pv_line[week]))\n end\n end",
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"def net_present_value\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * (1 + x)**-relative_payment.offset\n end\n end\n end",
"def calculate(loan_value, financing_time_months, interest_rate, loan_date = Date.today)\n balance = loan_value\n installment = installment_value(interest_rate, financing_time_months, loan_value)\n installment_date = loan_date.next_month\n iof = 0\n\n financing_time_months.step(1, -1) do |_|\n amortization = installment - interest_part(balance, interest_rate)\n\n days = past_days(loan_date, installment_date)\n\n iof += amortization*(@iof_day*(minimal_days(days)))\n iof += amortization*@iof_additional\n\n balance -= amortization\n installment_date = installment_date.next_month\n end\n\n loan_iof(iof, loan_value)\n end",
"def nominal_due_given_efective(effective_rate, periods)\n\t\t\t((((1 + (effective_rate.to_f/100))**(1/periods.to_f)-1)*periods.to_f)*100).round(4)\n end",
"def expression_value\n return @expression_value if defined?(@expression_value)\n\n subexpr_value =\n (1 + periodic_interest_rate) ** total_number_of_payments\n @expression_value =\n (periodic_interest_rate * subexpr_value) / (subexpr_value - 1)\n end",
"def future_given_annuity(annuity, interest, term)\n (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)\n end",
"def present_value\n # Payoff amount = 0, we’re assuming a fully amortizing loan\n payoff_amount = 0\n end",
"def installment_value(interest_rate, financing_time_months, loan_value)\n @installment_calculator.calculate(interest_rate, financing_time_months, loan_value)\n end",
"def set_estimate_from_effort\n estimated_effort = self.story_points #custom_value.value\n unless estimated_effort.blank?\n self.estimated_hours = case estimated_effort.to_i\n when 1 then 4\n when 2 then 8\n when 3 then 12\n when 5 then 20\n when 8 then 32\n end\n end\n end",
"def calculate_interest principle, days_since\n (principle * APR / 365 * days_since).round(2)\n end",
"def current_age_approximate\n nil\n end",
"def forecast_finish_date(basis_hours)\n if complete_ev(basis_hours) == 100.0\n @ev.keys.max\n elsif today_spi(basis_hours) == 0.0\n @pv.keys.max\n else\n if @issue_max_date < @basis_date\n rest_days = (@pv[@pv.keys.max] - @ev[@ev.keys.max]) / today_spi(basis_hours) / basis_hours\n @basis_date + rest_days\n else\n rest_days = @pv.count { |key, _value| key > @basis_date }\n @pv.keys.max - (rest_days - (rest_days / today_spi(basis_hours)))\n end\n end\n end",
"def nominal_anticipated_given_efective(effective_rate, periods)\n nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1\n toAnticipated = nominalRate / (1+nominalRate)\n (toAnticipated * periods.to_f * 100).round(4)\n end",
"def calculate_interest(principal, roi, time)\n rate = roi.to_f / 100\n amount = principal.to_f * (1 + rate * time.to_f)\n\n amount\nend",
"def estimate_embargo_period( issued, embargo_release )\n period = Date.parse( embargo_release ) - Date.parse( issued )\n case period.to_i\n when 0\n return ''\n when 1..186\n return GenericWork::EMBARGO_VALUE_6_MONTH\n when 187..366\n return GenericWork::EMBARGO_VALUE_1_YEAR\n when 367..731\n return GenericWork::EMBARGO_VALUE_2_YEAR\n when 732..1825\n return GenericWork::EMBARGO_VALUE_5_YEAR\n else\n return GenericWork::EMBARGO_VALUE_FOREVER\n end\n end",
"def pv\n factor = (1.0 + monthly_rate)**duration\n second_factor = (factor - 1) * (1 + monthly_rate * ptype) / monthly_rate\n\n -(future_value + (payment.to_f * second_factor)) / factor\n end",
"def registro_inicio(vaca,num_horas)\n estim_reg = Time.now.advance(:hours => -num_horas.to_i).localtime\n estimate_time = estim_reg.change(:min => 0)\n return estimate_time \n end",
"def needed_exp\n return next_exp - now_exp\n end",
"def calculate_years(principal, interest, tax, desired)\n i = 0\n return i if principal == desired\n \n while principal < desired\n principal += (principal * interest) - (principal * interest * tax)\n i += 1\n end\n \n i\nend",
"def calculate_interest(current_period, previous_period=0)\n previous_balance = @txns[previous_period][:balance]\n period_of_interest = current_period - previous_period\n @interest += (previous_balance * daily_interest * period_of_interest).round(2)\n end",
"def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end",
"def graph_ideal_value_for_date(date)\n # Firstly, try to use goal's baseline and target\n if self.baseline_date >= date\n return self.baseline\n elsif self.due_date <= date\n return self.accuracy\n end\n\n # Secondly, try to check if there is any progress exact on the given day\n exact_progress = nil\n if self.association(:progresses).loaded?\n # Search in memory\n exact_progress = self.progresses.detect{|p| p.due_date == date}\n else\n # Search in DB\n exact_progress = self.progresses.where(:due_date => date).first\n end\n\n unless exact_progress.blank?\n return exact_progress.accuracy \n end\n\n # Thirdly, we're unlucky, let calculate it!\n\n # The nearest progress that less than the given date\n begin_progress = nil\n # The nearest progress that bigger than the given date\n end_progress = nil\n\n if self.association(:progresses).loaded?\n # Search in memory\n begin_progress = self.progresses.sort_by(&:due_date).reverse.detect{|p| p.due_date <= date}\n end_progress = self.progresses.sort_by(&:due_date).detect{|p| p.due_date >= date}\n else\n # Search in DB\n begin_progress = self.progresses.where(\"due_date <= ?\", date).order(\"due_date DESC\").first\n end_progress = self.progresses.where(\"due_date >= ?\", date).order(\"due_date ASC\").first\n end\n\n # Get the necessary data.\n begin_date = nil\n begin_value = nil\n end_date = 0\n end_value = 0\n\n if begin_progress\n begin_date = begin_progress.due_date\n begin_value = begin_progress.accuracy\n else\n # Use baseline\n begin_date = self.baseline_date\n begin_value = self.baseline\n end\n\n if end_progress\n end_date = end_progress.due_date\n end_value = end_progress.accuracy\n else\n # Use the deadline\n end_date = self.due_date\n end_value = self.accuracy\n end\n\n # Caculate the value\n # Please see the triangle above to understand the meaning of variables.\n ad = (date - begin_date).to_i\n ab = (end_date - begin_date).to_i\n bc = (end_value - begin_value).abs\n\n if ab == 0\n return 0\n else\n return (begin_value + (ad*bc/ab))\n end\n end",
"def calculate_years(principal, interest, tax, desired)\n# principal amount\n year = 0\n while principal < desired\n year += 1\n income = principal * interest\n principal += income - income * tax\n end\n year\nend",
"def net_present_value_derivative\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * -relative_payment.offset * (1 + x)**(-relative_payment.offset - 1)\n end\n end\n end",
"def hours_until_next_allowed\n ((created_at - RECENT_PERIOD.ago) / 3600).to_i\n end",
"def hours_until_next_allowed\n ((created_at - RECENT_PERIOD.ago) / 3600).to_i\n end",
"def SPI\n\n #byebug\n if self.estimated_hours>0 and !self.start_date.nil? and !self.due_date.nil?\n hoxe_dias=(Date.parse(Time.now.to_s) - self.start_date).to_f\n total_dias=(self.due_date-self.start_date).to_f\n earned_value= (completed_percent * estimated_hours)/100 # Podria ser tambien las spent_hours\n planned_value=(hoxe_dias/total_dias)*estimated_hours\n return (earned_value/planned_value)\n else\n return 0\n end\n\n rescue\n return 0\n\n end",
"def future_expense_checker (record)\n\t\tdate = record.date_paid\n \ttime = date.to_time\n \ttime.future?\n end",
"def grow_one_year(starting_balance, growth_rate)\n starting_balance * (1.0 + growth_rate)\nend",
"def rates_prediction\r\n final_array = []\r\n today = today_rate\r\n weekly_change = weekly_percentage_change_array\r\n\r\n first = ((weekly_change[0] / 100) * today) + today\r\n final_array << first\r\n\r\n if @time > 1\r\n i = 0\r\n while i < weekly_change[1].length\r\n rate = ((weekly_change[1][i] / 100) * final_array[i]) + final_array[i]\r\n final_array << rate\r\n i += 1\r\n end\r\n end\r\n final_array\r\n end",
"def calculate_payment\n x = @periodic_rate * @principal * ((1 + @periodic_rate)**@periods)\n y = ((1 + @periodic_rate)**@periods) - 1\n (x / y).round(2)\n end",
"def calculate_loan(rate, n_periods, total_loan_amount)\n fixed_payment = (rate /\n (1 - ((1 + rate)**(n_periods * - 1)))) * total_loan_amount\n\n fixed_payment.to_f\nend",
"def calculation(duration, loan, apr)\n loan * (apr / (1 - (1 + apr)**(-duration)))\nend",
"def compute_actual\n line[1] = @ho_form.line['sqft']\n line[2] = @ho_form.line['total_sqft']\n line[3] = (line[1] * 100.0 / line[2]).round(2)\n\n line['4/gross_inc'] = gross_income\n\n # We make a simplifying assumption that (1) every Home Office Expense\n # applies to every Home Office form, and (2) all expenses are indirect.\n categorize_records('Home Office Expense')\n #\n # We assume that the home office using the actual method is being rented and\n # thus there are no mortgage payments or such on it.\n #\n #fill_for_categories(self, '5b', 'Casualty_Losses')\n #fill_for_categories(self, '6b', 'Mortgage_Interest')\n #fill_for_categories(self, '7b', 'Real_Estate_Taxes')\n\n line['8b'] = sum_lines('5b', '6b', '7b')\n line[9] = (line['8b'] * line[3] / 100.0).round\n line[10] = line[9]\n\n line[11] = other_business_expenses\n\n line[12] = sum_lines(10, 11)\n line['13/ho_max_ded'] = line[4] - line[12]\n\n fill_for_categories(self, '16b', 'Insurance')\n fill_for_categories(self, '17b', 'Rent')\n fill_for_categories(self, '18b', 'Repairs')\n fill_for_categories(self, '19b', 'Utilities')\n fill_other_categories(\n self, '20b', continuation: 'Other Home Office Expenses'\n )\n line['21b'] = sum_lines(*%w(14b 15b 16b 17b 18b 19b 20b))\n line[22] = (line['21b'] * line[3] / 100.0).round\n\n # Assume no carryover for line 23\n line['24/ho_ded'] = sum_lines('21a', 22, 23)\n line[25] = [ line[13], line[24] ].min\n line[26] = line[13] - line[25]\n\n # Assume no casualty losses or depreciation for lines 27-29 and 33\n line[30] = sum_lines(27, 28, 29)\n line[31] = [ line[26], line[30] ].min\n line[32] = sum_lines(10, 25, 31)\n\n line[33] = BlankZero\n line['34/ho_expenses'] = line[32] - line[33]\n\n end",
"def investment_return_from_ownership\n @initial_costs = {}\n @recuring_costs = {}\n @closing_costs = {}\n @home_appreciation = {}\n @costs_compare_sum = {}\n\n @rent_security_deposit = (@home_price/(12*@price_to_rent_ratio))*-1\n @costs_of_buying_house = {}\n @costs_of_buying_house[:rent] = (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @costs_of_buying_house[:buy] = (@home_price*0.02467)*-1\n\n @initial_costs[:rent] = (@home_price/(12*@price_to_rent_ratio))*-1 + (@home_price/(12*@price_to_rent_ratio)*0.25)*-1\n @initial_costs[:buy] = @down_payment*-1 + (@home_price*0.02467)*-1\n\n @recuring_costs[:rent] = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term+@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @recuring_costs[:buy] =\n ((@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1) + (@monthly_exp_breakdown[:property_tax][:total]*-1) + (@monthly_exp_breakdown[:home_insurance][:total]*-1) + (@monthly_exp_breakdown[:pmi_insurance][:total]*-1) + ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @total_monthly_rents = (@home_price/@price_to_rent_ratio*@mortgage_term*(1+0.025)**@mortgage_term)\n @mortgage_payments = (@monthly_exp_breakdown[:mortgage_principal][:total] + @monthly_exp_breakdown[:mortgage_interest][:total])*-1\n @renter_insurance = (@home_price/@price_to_rent_ratio*@mortgage_term*0.0132)*-1\n @returns_for_investment = ((((1+0.054/12)**@number_of_payments-1)*@down_payment)*-1)\n\n @closing_costs[:rent] = 0.0\n @closing_costs[:buy] = (@home_price*0.03)*-1\n\n @home_appreciation[:rent] = @initial_costs[:rent]*-1\n @home_appreciation[:buy] = @home_price*(1.054)**@mortgage_term*0.85\n\n @costs_compare_sum[:rent] =(@initial_costs[:rent] + @recuring_costs[:rent] + @closing_costs[:rent] + @home_appreciation[:rent])\n @costs_compare_sum[:buy] = @initial_costs[:buy] + @recuring_costs[:buy] + @closing_costs[:buy] + @home_appreciation[:buy]\n\n if (@calculate_loan_payment<=750000)\n @mortgage_interest_deduction = (@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term\n else\n @mortgage_interest_deduction = ((@calculate_monthly_payment*@number_of_payments-@calculate_loan_payment)/@mortgage_term)*750000/@calculate_loan_payment\n end\n\n if (@costs_compare_sum[:buy].abs <=0)\n @costs_compare_sum[:benifit] = \"Buying is better than renting even if you could rent for free! In addition, you can save average #{ ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2)) } per year from your federal taxable income. Increase your profit by visiting our <a href='JavaScript:void(0);'>mortgage rates</a> and getting a more favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs > @costs_compare_sum[:buy].abs)\n @costs_compare_sum[:benifit] = \"Buying is cheaper than renting! You’ll earn an extra #{ActionController::Base.helpers.number_to_currency(((@costs_compare_sum[:buy] - @costs_compare_sum[:rent]).round(2)))} after #{@mortgage_term} years of buying a house. In addition, you can save average #{ActionController::Base.helpers.number_to_currency(@mortgage_interest_deduction.round(2))} per year from your federal taxable income. If you lower your mortgage interest rate, you could save more! Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> and find other favorable mortgages.\"\n else\n if (@costs_compare_sum[:buy].abs >0 && @costs_compare_sum[:rent].abs == @costs_compare_sum[:buy].abs )\n @costs_compare_sum[:benifit] = \"The cost of buying a house is about the same as renting a house for #{@mortgage_term} years! However, you could save more through lowering your mortgage interest rate. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n else\n @costs_compare_sum[:benifit] = \"You'd better to rent a house instead pf buying. Or you could lower your mortgage interest rate to save the cost of buying. Come to visit our <a href='JavaScript:void(0);'>mortgage rates</a> to get more favorable mortgages.\"\n end\n end\n end\n end",
"def get_present_value\n self.composite_share_value = (self.get_composite_share_value / ((1 + ValuationEngine::Constants.get_exchange(self.stock_ticker))**self.class.years_horizon)).round(2)\n end",
"def future_expense_checker (record)\n\t\tdate = record.date_incurred\n \ttime = date.to_time\n \ttime.future?\n end",
"def calculate_carrier_demand\n demand_curve.sum * 3600\n end",
"def estimate_at_completion_duration\n return planned_duration - earned_schedule\n end",
"def calculate_earned_value(issues)\n ev = {}\n unless issues.nil?\n issues.each do |issue|\n if issue.closed?\n dt = issue.closed_on.to_time.to_date\n ev[dt] += issue.estimated_hours.to_f unless ev[dt].nil?\n ev[dt] ||= issue.estimated_hours.to_f\n elsif issue.done_ratio > 0\n hours = issue.estimated_hours.to_f * issue.done_ratio / 100.0\n start_date = [issue.start_date, @basis_date].min\n end_date = [issue.due_date, @basis_date].max\n hours_per_day = issue_hours_per_day hours,\n start_date,\n end_date\n (start_date..end_date).each do |date|\n ev[date] += hours_per_day unless ev[date].nil?\n ev[date] ||= hours_per_day\n end\n end\n end\n end\n calculate_earned_value = sort_and_sum_evm_hash ev\n calculate_earned_value.delete_if { |date, _value| date > @basis_date }\n end",
"def to_extend_now\n length = self.this_year.contract.contract_length \n auction_value = self.current_contract.subcontracts.first.salary_amount\n this_progression = SalaryProgression.find_by_auction_value(auction_value).attributes.to_a\n next_salary = this_progression[(length + 1)][1]\n return next_salary\n end",
"def next_charge\n ( pre_finalised_quote * relative_progress / 100 ) - charged_so_far\n end",
"def interest(amount)\n if amount <= 1000\n 0.04 * amount\n elsif amount <= 5000\n 0.045 * amount\n else\n 0.05 * amount\n end\nend",
"def daily_interest\n @apr / 100.0 / 365\n end",
"def trade_value\n 0.4\n\n end",
"def calculate_apr\n payment_ratio = pmt / principal_calculation\n duration = @duration\n f = lambda {|k| (k**(duration + 1) - (k**duration * (payment_ratio + 1)) + payment_ratio)}\n f_deriv = lambda { |k| ((duration + 1) * k**duration) - (duration * (payment_ratio + 1) * k**(duration - 1))}\n\n root = newton_raphson(f, f_deriv, monthly_rate + 1)\n 100 * 12 * (root -1).to_f\n end",
"def retirement_range\n #large simulation\n (1..30)\n end",
"def nper\n z = payment * (1.0 + monthly_rate * ptype) / monthly_rate\n\n Math.log(-future_value + z / (amount + z)) / Math.log(1.0 + monthly_rate)\n end",
"def do_calculate_eta(wls, hours_per_workday,workflow,current_user,currentWorkflowLiveStepConfirm)\n\t pred_max_completion = ''\n\t max_step_completion = ''\n\t if wls.predecessors.present? && !wls.actual_confirmation.present? # && wls.is_active?\n\t comp_attribute_value = wls.object\n\t lang_attribute_value = wls.object.attribute_values.joins(:label_attribute).where(\"label_attributes.short_label='#Lang'\").first\n\t #check successor---------------------\n\t predecessors_steps = wls.predecessors.split(\",\")\n\t predecessors_step_ojbets = WorkflowLiveStep.where(id: predecessors_steps)\n\t predecessors_step_ojbets.each_with_index do |pso, indx|\n\t if indx == 0 and pso.step_completion.present?\n\t pred_max_completion = pso.step_completion\n\t elsif pso.step_completion.present?\n\t \tif pred_max_completion.present?\n\t\t \tif DateTime.parse(pso.step_completion.to_s) > DateTime.parse(pred_max_completion.to_s)\n\t\t \t\tpred_max_completion = pso.step_completion\n\t\t \t\tend\n\t\t \telse\n\t\t \t\tpred_max_completion = pso.step_completion\n\t\t \tend\t\n\t end\n\t end\n\t \n\t predecessors_step_ojbets.each_with_index do |pso, indx|\n\t if indx == 0 and pso.step_completion.present?\n\t station_step = wls.station_step\n\t max_step_completion = station_step.calculate_step_completion(wls, pso.step_completion, comp_attribute_value, lang_attribute_value, hours_per_workday)\n\t elsif pso.step_completion.present?\n\t station_step = wls.station_step\n\t step_completion_other = station_step.calculate_step_completion(wls, pso.step_completion, comp_attribute_value, lang_attribute_value, hours_per_workday)\n\t if step_completion_other.present? and max_step_completion.present?\n\t\t if DateTime.parse(step_completion_other.to_s) > DateTime.parse(max_step_completion.to_s)\n\t\t max_step_completion = step_completion_other \n\t\t end\n\t \telse\n\t \t\tmax_step_completion = step_completion_other \n\t \tend\n\t end\n\t end\n\n\t\t\t current_eta = wls.eta\n\t wls.eta = pred_max_completion\n\t wls.step_completion = max_step_completion\n\t wls.save!\n\t elsif wls.predecessors.present? && wls.actual_confirmation.present?\n\t comp_attribute_value = wls.object\n\t lang_attribute_value = wls.object.attribute_values.joins(:label_attribute).where(\"label_attributes.short_label='#Lang'\").first\n\t\t\t \t\tstation_step = wls.station_step\n\t\t \tstep_completion = station_step.calculate_step_completion(wls, wls.actual_confirmation, comp_attribute_value, lang_attribute_value, hours_per_workday)\n\t\t \twls.step_completion = step_completion\n \t\t wls.save!\n\t end\n\t end",
"def time_global_pheromone_at_time(value_of_objective)\n\t# where q = [time=10, cost= 10_000, quality=0.0005]\n\t((1 - GLOBAL_EVAPORATION_RATE) * pheromone_at_t_minus_1) + time_changed_pheromone(value_of_objective)\nend",
"def store_changes_for_estimated_hours!(result, old_value, new_value)\n \t\tchange = hash_for_ticket_change(old_value, new_value)\n \t\tresult[N_('Estimated hours')] = change if change\n \tend",
"def surrounding_vix_futures_expirations(date=Date.today)\n previous_exp = next_exp = nil\n File.open(vix_futures_expirations_file) do |f|\n while line = f.readline()\n next_exp, symbol = process_line(line)\n if date <= next_exp\n break\n else\n previous_exp = next_exp\n end\n end\n end\n [previous_exp, next_exp]\n end",
"def calculate_interest(amount, number_of_days)\n (amount * (0.03 / 365) * (number_of_days - 1)).round(10)\n end",
"def estimated_consumption_with_cr(cr)\n total = 0\n # if real consumption greater than zero, must compensate estimation balance\n if cr > 0\n total = cr < current_estimation_balance ? cr * (-1) : current_estimation_balance * (-1)\n end # cr > 0\n total || 0\n end",
"def efective_given_nominal_due(nominal_rate, term)\n ((((1+((nominal_rate.to_f/100)/term))**term)-1).round(6))*100\n end",
"def calculateInterest\n\t\tinterest = 0\n\t\t@transactions.each do |trans|\n\t\t\tinterest += -1 * ((31 - trans[0]) * trans[-1] * @APR / 365)\n\t\tend\n\t\tinterest < 0 ? 0 : interest.round(2)\n\tend",
"def calculate_years(principal, interest, tax, desired)\n total = principal\n years = 0\n loop do\n break if total >= desired\n total_interest = total*interest\n total += total_interest\n total -= total_interest*tax\n years += 1\n end\n years\nend",
"def annual_ror(initial_value, final_value, years)\n if years <= 0\n 0\n elsif initial_value == 0\n # BigDecimal::INFINITY\n Float::INFINITY\n else\n 100.to_d * if final_value < 0 # fudge if final value is less than zero\n (((initial_value.to_d - final_value.to_d) / initial_value.to_d) ** (1 / years.to_d)) * -1\n else\n ((final_value.to_d / initial_value.to_d) ** (1 / years.to_d)) - 1\n end\n end\n end",
"def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n 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 quality_global_pheromone_at_time(value_of_objective)\n\t# where q = [time=10, cost= 10_000, quality=0.0005]\n\t((1 - GLOBAL_EVAPORATION_RATE) * pheromone_at_t_minus_1) + quality_changed_pheromone(value_of_objective)\nend",
"def estimated_consumption(cr)\n total = 0\n # If real consumption equals zero, try to estimate\n if cr == 0\n # Only estimates if there is an incidence that requires estimating\n if ReadingIncidence.reading_should_be_estimated(self.id)\n # 1. Consumption invoiced in the same period of last year (reading_2)\n total = consumption_invoiced(reading_2)\n if total == 0\n # 2. Consumption invoiced in the last period (reading_1)\n total = consumption_invoiced(reading_1)\n if total == 0\n # 3. Average consumption of...\n invoice_date = billing_period.try(:prebilling_starting_date) || Date.today\n # 3.1. ...the last 36 months of reading\n from_date = invoice_date - 36.months\n total = consumption_previous_readings(from_date, invoice_date)\n if total == 0\n # 3.2. ...the last 12 months of reading\n from_date = invoice_date - 12.months\n total = consumption_previous_readings(from_date, invoice_date)\n if total == 0\n # 4. Nominal capacity of the meter x 15 hs x quantity of months\n nominal_flow = meter.caliber.nominal_flow rescue 1.5\n nominal_flow = 1.5 if nominal_flow.blank?\n total = (nominal_flow * 15) * billing_frequency.total_months\n end # 3.2\n end # 3.1\n end # 2\n end # 1\n end # ReadingIncidence.reading_should_be_estimated(self.id)\n else # If real consumption not equals zero, try to compensate\n total = estimated_consumption_with_cr(cr)\n end # cr == 0\n total || 0\n end",
"def estimate\n if self.submitted? && (Time.now - self.updated_at) > 5 * 60\n # re-initialize the estimates\n self.estimated_cost = nil\n self.estimated_duration = nil\n # only estimate projects with a budget of $200K! because why bother!\n budget = self.budget_allocated\n if budget > 200_000\n # give them a 50/50\n if rand > 0.5\n # estimate the number of college grads needed during the time frame + 30%\n # to consume the budget * 2\n days = ((self.end_date - self.start_date) * 1.3).ceil\n budget_per_day = budget * 2 / days\n student_per_day = 200 * 8 # $200/hour * 8 hours\n students = (budget_per_day / student_per_day).ceil\n self.estimated_cost = students * student_per_day * days\n self.estimate_breakdown = number_with_delimiter(students) + ' resources needed at $200/hour for ' +\n number_with_delimiter(days) + ' days.'\n self.estimated_duration = (self.start_date + days * 7 / 5).strftime(\"%B %-m %Y\")\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and does not believe the requirements are ' +\n 'feasible within the budget and time frames. Please try submitting another request.'\n end\n else\n self.estimate_breakdown = 'Jay has reviewed your request, and the allocated budget is not sufficient to meet ' +\n 'the requirements. Please try submitting another request.'\n end\n self.status = :complete\n self.save\n end\n end",
"def get_price_intersections history\n close_prices = history[\"historicals\"].map{|h| h[\"close_price\"].to_f}\n period_one = 50\n period_two = 200\n periods = [period_one, period_two].sort!\n shorter_sma = simple_moving_average(close_prices, periods.first)\n longer_sma = simple_moving_average(close_prices, periods.last)\n combined = longer_sma.reverse.map.with_index{|longer,i| {shorter_sma: shorter_sma[(i*-1)-1], longer_sma: longer}}\n combined.each_with_index do |data,i|\n data[:current_price] = history[\"historicals\"][(i*-1)-1][\"close_price\"].to_f\n data[:date] = history[\"historicals\"][(i*-1)-1][\"begins_at\"]\n end\n combined.reverse!\n prev_change = combined.first[:shorter_sma] / combined.first[:longer_sma] - 1\n combined.each_with_index do |data,i|\n next if i == 0\n change = data[:shorter_sma] / data[:longer_sma] - 1\n if prev_change.negative? && change.positive?\n # upward trend\n data[:action] = :buy\n end\n if prev_change.positive? && change.negative?\n # downward trend\n data[:action] = :sell\n end\n prev_change = change\n end\n raise combined.select{|data| data[:action].present?}.to_s\n end",
"def get_price_intersections history\n close_prices = history[\"historicals\"].map{|h| h[\"close_price\"].to_f}\n period_one = 50\n period_two = 200\n periods = [period_one, period_two].sort!\n shorter_sma = simple_moving_average(close_prices, periods.first)\n longer_sma = simple_moving_average(close_prices, periods.last)\n combined = longer_sma.reverse.map.with_index{|longer,i| {shorter_sma: shorter_sma[(i*-1)-1], longer_sma: longer}}\n combined.each_with_index do |data,i|\n data[:current_price] = history[\"historicals\"][(i*-1)-1][\"close_price\"].to_f\n data[:date] = history[\"historicals\"][(i*-1)-1][\"begins_at\"]\n end\n combined.reverse!\n prev_change = combined.first[:shorter_sma] / combined.first[:longer_sma] - 1\n combined.each_with_index do |data,i|\n next if i == 0\n change = data[:shorter_sma] / data[:longer_sma] - 1\n if prev_change.negative? && change.positive?\n # upward trend\n data[:action] = :buy\n end\n if prev_change.positive? && change.negative?\n # downward trend\n data[:action] = :sell\n end\n prev_change = change\n end\n raise combined.select{|data| data[:action].present?}.to_s\n end",
"def assess_status(summary)\n birth = summary[:patient].birth_date\n age = summary[:patient].age_years\n imms = summary.keys\n imms.delete(:patient)\n imms.each do |imm|\n summary[imm][:next] = imm + ': none'\n end\n summary[:age] = age\n\n # HIB\n next_dose = nil\n count = summary['hib'][:count]\n since = summary['hib'][:since]\n last = summary['hib'][:last]\n if since.nil?\n age_at_last = nil\n else\n age_at_last = age - (since/365) # This is age in years at the last Hib dose\n end\n case count\n when 0\n next_dose = Date.today if age.between?(6/52, 5)\n\n when 1\n # Interval = 4 weeks if first dose at < 12 months\n next_dose = last + 28 if ( age < 5 && age_at_last < 1 )\n # Interval = 8 weeks (as final dose) if first dose administered at age 12-14 months\n next_dose = last + 56 if ( age < 5 && age_at_last.between?(1, 1.25))\n\n when 2\n # Interval = 4 weeks if current age < 12 months\n next_dose = last + 28 if ( age < 5 && age_at_last < 1 )\n # Interval = 8 weeks current age > 12 months and second dose administered at age < 15 months\n next_dose = last + 56 if ( age.between?(1, 5) && age_at_last < 1.25)\n\n when 3\n next_dose = birth + 455 # 15 months of age\n next_dose = last + 56 if ( age.between?(1.25, 5) && age_at_last < 1 )\n end\n if next_dose\n next_dose = today.to_date if next_dose < today\n date_s = next_dose.to_s\n date_s = 'today' if next_dose == today\n else\n date_s = 'none'\n end\n summary = update_next_dose(summary, 'hib', next_dose)\n\n # Meningococcus\n next_dose = ''\n since = summary['mening'][:since]\n if since.nil? || since > 730 # if no previous immunization or imm > 2 years ago\n next_dose = today\n next_dose = birth + 0.75*365 if age < 0.75 # if less than nine months old, set next dose to when age is 9 months\n else\n next_dose = last + 730\n end\n summary = update_next_dose(summary, 'mening', next_dose)\n\n # Polio\n next_dose = ''\n count = summary['opv'][:count]\n since = summary['opv'][:since]\n last = summary['opv'][:last]\n if since.nil?\n age_at_last = nil\n else\n age_at_last = age - (since/365) # This is age in years at the last Hib dose\n end\n case count\n when 0\n next_dose = birth + 42 # first dose due at 6 weeks\n when 1..2\n next_dose = last + 28\n when 3\n if age_at_last < 4 # \"fourth dose not needed if third given at older than 4 years of age\"\n next_dose = last + 28\n next_dose = birth + (365*4) if (next_dose < birth + 365*4) # fourth dose given at min 4 years old (check Nigeria policy**\n end\n end\n summary = update_next_dose(summary, 'opv', next_dose)\n\n # DPT\n next_dose = ''\n count = summary['dpt'][:count]\n since = summary['dpt'][:since]\n last = summary['dpt'][:last]\n if since.nil?\n age_at_last = nil\n else\n age_at_last = age - (since/365) # This is age in years at the last dose\n end\n case count\n when 0\n next_dose = birth + 42 # first dose due at 6 weeks\n when 1..2\n next_dose = last + 28\n when 3\n next_dose = last + 183 # Six month interval to fourth dose -- is fourth dose given here? When, at 9 mo?\n when 4\n if age_at_last < 4 # \"fourth dose not needed if third given at older than 4 years of age\"\n next_dose = last + 183\n next_dose = birth + (365*4) if (next_dose < birth + 365*4) # fourth dose given at min 4 years old (check Nigeria policy**\n end\n end\n summary = update_next_dose(summary, 'dpt', next_dose)\n\n # After all the immunizations are assessed and next dose dates calculated\n return summary\n end",
"def calculate_interest(days_since_transaction)\n\t\t@interest << @balance * @apr / 365 * days_since_transaction\n\tend",
"def issue_hours_per_day(estimated_hours, start_date, end_date)\n (estimated_hours || 0.0) / (end_date - start_date + 1)\n end",
"def estimate\n # (native code) \n end",
"def highest_possible_profit(prices)\n best_profit = 0\n # iterate over the dataset\n prices.each_with_index do |price, index|\n # in each hour compare with the future hours to find difference\n\n # check if difference is positive\n # check if difference is greater than current best\n # keep best difference\n # check next hour\n\n end\n # end return the best difference\n\nend",
"def interest\n return (@capital / 100) * @rate\n end",
"def register_estimate(params)\n # half-hour increments\n params.update(:user_estimate => [1, (params[:user_estimate].to_f * 2).round].max)\n\n if params[:user_estimate] > 0 # check to make sure that the user's estimate is meaningful\n a = most_recent_analysis_succeeded\n veritable_estimate = a.predict(stringify_hash_keys(params).update(\n 'true_time' => nil, # this is what we're predicting\n 'user_class' => params[:user_class]\n ))['true_time']\n Task.create(params.update(:veritable_estimate => veritable_estimate))\n end\nend",
"def time_before_next_payment\n delay = payment_frequency[:days]\n withdrawls = sort_operations_desc\n # next_payment_date = operations.last.date + delay.days\n next_payment_date = withdrawls.first.date + delay.days\n distance_of_time_in_words(Date.today, next_payment_date)\n end",
"def linear_path_to_previous_period(start_val, diff, source_frequency, target_frequency)\n date = Date.parse(self) #will raise invalid date if necessary\n \n if (source_frequency == \"year\" or source_frequency == :year) and target_frequency == :quarter\n return {\n (date).to_s => start_val - (diff / 4 * 3),\n (date >> 3).to_s => start_val - (diff / 4 * 2),\n (date >> 6).to_s => start_val - (diff / 4),\n (date >> 9).to_s => start_val\n }\n end\n \n if (source_frequency == \"quarter\" or source_frequency == :quarter) and target_frequency == :month\n return {\n (date).to_s => start_val - (diff / 3 * 2),\n (date >> 1).to_s => start_val - (diff / 3),\n (date >> 2).to_s => start_val\n }\n end\n if (source_frequency == \"month\" or source_frequency == :month) and target_frequency == :day \n num_days = date.days_in_month\n data = {}\n (1..num_days).each do |days_back|\n data[(date + days_back - 1).to_s] = start_val - (diff / num_days * (num_days - days_back))\n end\n return data\n end\n\n return {}\n end",
"def years_until_retirement\n @retirement_age.to_i - @current_age.to_i\n end",
"def pmt(interest_rate,payments,principal)\n numerator =interest_rate*principal*(1 + interest_rate)**payments\n denominator= (1+ interest_rate)**payments - 1\n return numerator/denominator.to_f\nend",
"def target_response_time\n now = Time.now\n if Time.before_business_hours?(now)\n next_business_day = now.midnight\n else\n next_business_day = 1.business_day.after(now).midnight\n end\n due_date = 5.business_hour.after(next_business_day)\n end",
"def current_exp\n self.experience % 100\n end",
"def get_dividend_value\n\t\t @dividend_share_value = @forwardDividendRate / (@overnightDiscountRate - @dividend_growth_rate)\n\n\t\t return @dividend_share_value\n\t\tend",
"def period_start\n period.begin\n end",
"def calculate_irr(min_rate, max_rate, amounts)\n while true\n range = max_rate - min_rate\n\n raise RuntimeError if range <= Float::EPSILON * 2\n\n rate = range.fdiv(2) + min_rate\n present_value = npv(rate, amounts)\n\n if present_value > 0\n min_rate = rate\n elsif present_value < -0.5\n max_rate = rate\n else\n return rate\n end\n end\n end",
"def lead_time\n 4\n end",
"def calculate_and_build_metlife_premium_tables\n (20..65).each do |metlife_age|\n @metlife_age = metlife_age\n key = \"#{@rate[:plan_id]},#{@rate[:effective_date].to_date.year}\"\n rating_area = @rate[:rate_area_id]\n @results[key] << {\n age: metlife_age,\n start_on: @rate[:effective_date],\n end_on: @rate[:expiration_date],\n cost: calculate_metlife_cost,\n rating_area: rating_area\n }\n end\n end",
"def consumo\n estado_actual - estado_anterior\n end",
"def current_interest\n @investment.current_converted_interest / actual_sell_price\n end",
"def frm(r, n, po)\n\t## \n\t# interest rate is converted to fraction and made a monthly\n\tr = r.to_f/100/12\n\t##\n\t#number of years is converted to number of months\n\tn = n * 12\n\t##\n\t#monthly payment is calculated\n\tc = (r / (1 - (1+r) ** -n) ) * po\n\treturn c\nend",
"def approximately\n @approximately ||= 5.minutes\n end",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annual_percentage_rate = interest_rate_percentage / 100\n principal * (1 + annual_percentage_rate * number_of_years)\nend",
"def calculate_life_plan(life_plan = LifePlan.new)\n results = []\n\n years_ahead = life_plan.total_years\n\n years_ahead.times do |year_count|\n year_results = calculate_next_year(\n life_plan.contribution_for(year_count),\n life_plan.withdraw_for(year_count)\n )\n\n @current_balance = year_results.average\n results << year_results\n end\n\n results\n end",
"def interest_part(balance, interest_rate)\n balance*(interest_rate/100)\n end",
"def future(year, month, day)\n years = (10 ** 9) / 60 / 60 / 24 / 365\n days = (10 ** 9) / 60 / 60 / 24 % 365\n\n year = year + years\n \n\nend"
] | [
"0.73584276",
"0.7230214",
"0.6933694",
"0.66302454",
"0.6504473",
"0.61318266",
"0.5859032",
"0.5783148",
"0.5606104",
"0.55674577",
"0.556436",
"0.5499632",
"0.54799885",
"0.54791063",
"0.5467902",
"0.54229295",
"0.5418428",
"0.5403856",
"0.5395165",
"0.5387388",
"0.528683",
"0.52741015",
"0.52691734",
"0.5198442",
"0.51516557",
"0.5121989",
"0.5091097",
"0.5064475",
"0.5061778",
"0.5040751",
"0.5036324",
"0.50053847",
"0.49944684",
"0.49876538",
"0.49876538",
"0.49778423",
"0.4953972",
"0.4953034",
"0.49231312",
"0.49112764",
"0.49066722",
"0.48874214",
"0.4884153",
"0.48835942",
"0.48790634",
"0.48684525",
"0.48551786",
"0.48441717",
"0.48344555",
"0.48291606",
"0.48182806",
"0.48171383",
"0.48075897",
"0.47934607",
"0.4789233",
"0.4767735",
"0.47584534",
"0.47582835",
"0.4745346",
"0.47440073",
"0.47439465",
"0.47422272",
"0.4738069",
"0.47314546",
"0.47139555",
"0.47129878",
"0.4711469",
"0.47026694",
"0.46988395",
"0.46981946",
"0.46906263",
"0.46859425",
"0.468495",
"0.468495",
"0.46559992",
"0.4652151",
"0.46496615",
"0.46429604",
"0.46369344",
"0.46349648",
"0.462593",
"0.46228123",
"0.46227032",
"0.46223614",
"0.46098256",
"0.4608158",
"0.4608043",
"0.46077856",
"0.46071705",
"0.46064422",
"0.46036807",
"0.45999512",
"0.45956287",
"0.45943835",
"0.4589995",
"0.4588143",
"0.45868024",
"0.45780814",
"0.45772833",
"0.45622796"
] | 0.78798425 | 0 |
determine the effective annual rate for a given simple interest rate compounded over a given number of periods rate simple annual rate compound_per_period compound / period | def effective_annual_rate(rate,compound_frequency)
compound_frequency = resolve_compound_frequency!(compound_frequency)
if compound_frequency == :continuous
return continuous_effective_annual_rate(rate)
end
m= compound_frequency
e_rate = (1 + rate/m)**m -1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"def compound_interest(rate, count = 1, period = 12)\n Money.new(cents * ((1 + rate / 100.0 / period) ** count - 1))\n end",
"def calculate_loan(rate, n_periods, total_loan_amount)\n fixed_payment = (rate /\n (1 - ((1 + rate)**(n_periods * - 1)))) * total_loan_amount\n\n fixed_payment.to_f\nend",
"def nominal_anticipated_given_efective(effective_rate, periods)\n nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1\n toAnticipated = nominalRate / (1+nominalRate)\n (toAnticipated * periods.to_f * 100).round(4)\n end",
"def simple_interest(rate, count = 1, period = 12)\n Money.new(rate / 100 / period * cents * count)\n end",
"def total_amount_owed(principal, interest_rate_percentage, number_of_years)\n annual_percentage_rate = interest_rate_percentage / 100\n principal * (1 + annual_percentage_rate * number_of_years)\nend",
"def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end",
"def nominal_due_given_efective(effective_rate, periods)\n\t\t\t((((1 + (effective_rate.to_f/100))**(1/periods.to_f)-1)*periods.to_f)*100).round(4)\n end",
"def pmt(interest_rate,payments,principal)\n numerator =interest_rate*principal*(1 + interest_rate)**payments\n denominator= (1+ interest_rate)**payments - 1\n return numerator/denominator.to_f\nend",
"def apply_rate(amount, interchange_base = 0.0, interchange_percent = 0.0)\n FeeService.apply_raw_rate(amount, @base + interchange_base, @percent + interchange_percent)\n end",
"def calculate_payment\n x = @periodic_rate * @principal * ((1 + @periodic_rate)**@periods)\n y = ((1 + @periodic_rate)**@periods) - 1\n (x / y).round(2)\n end",
"def yearly_rate(*args)\n if paid?\n if yearly?\n rate(*args) / duration_parts[0] #number of years\n else\n rate(*args) / duration_in_months * 12\n end\n else\n nil\n end\n end",
"def interest_part(balance, interest_rate)\n balance*(interest_rate/100)\n end",
"def interest(rate)\n raise ArgumentError.new \"The rate must be a positive number\" if rate < 0\n interest = @balance * rate/100\n @balance += interest\n return interest\n end",
"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 annual_salary\n hourly_rate * 1950\n end",
"def calculate_years(principal, interest, tax, desired)\n# principal amount\n year = 0\n while principal < desired\n year += 1\n income = principal * interest\n principal += income - income * tax\n end\n year\nend",
"def rate\n Rate.new(self.interest/100, :apr, duration: self.tenure * 12)\n end",
"def efective_given_nominal_anticipated(nominal_rate, term)\n (((1/((1-((nominal_rate.to_f/100)/term))**term))-1)*100).round(4)\n end",
"def interest\n return (@capital / 100) * @rate\n end",
"def calculate_interest principle, days_since\n (principle * APR / 365 * days_since).round(2)\n end",
"def debt_rate\n ten_year_treasury + bps(200)\n end",
"def calculate_interest(principal, roi, time)\n rate = roi.to_f / 100\n amount = principal.to_f * (1 + rate * time.to_f)\n\n amount\nend",
"def calculateInterest\n\t\tinterest = 0\n\t\t@transactions.each do |trans|\n\t\t\tinterest += -1 * ((31 - trans[0]) * trans[-1] * @APR / 365)\n\t\tend\n\t\tinterest < 0 ? 0 : interest.round(2)\n\tend",
"def update_rates\n currencies(true).each_pair do |currency, data|\n rate = data[:middle_rate_for_commercial_transactions]\n add_rate(\"EUR\", currency, rate) if known_currencies.include?(currency)\n end\n rates\n end",
"def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_compound_fv(rate,periods,present_value)\n end\n future_value = present_value * (1+rate/compound_frequency)** (periods * compound_frequency)\n end",
"def annual_ror(initial_value, final_value, years)\n if years <= 0\n 0\n elsif initial_value == 0\n # BigDecimal::INFINITY\n Float::INFINITY\n else\n 100.to_d * if final_value < 0 # fudge if final value is less than zero\n (((initial_value.to_d - final_value.to_d) / initial_value.to_d) ** (1 / years.to_d)) * -1\n else\n ((final_value.to_d / initial_value.to_d) ** (1 / years.to_d)) - 1\n end\n end\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def profit_day_rate(cal)\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_period_and_client(id, cal.start_date, cal.end_date)\n days_tracked = (hours = mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n invoiced_amount = Invoice.amount_cents_invoiced_for_period_and_client(id, cal.start_date, cal.end_date).round(2)\n total_project_potential = (days_tracked * avg_rate_card_amount_cents.round).round(2)\n\n if invoiced_amount == 0 && days_tracked != 0\n 0\n elsif invoiced_amount != 0 && days_tracked == 0\n invoiced_amount\n elsif invoiced_amount == 0\n day_rate\n else\n ((invoiced_amount / total_project_potential) * day_rate).round(2)\n end\n end",
"def efective_given_nominal_due(nominal_rate, term)\n ((((1+((nominal_rate.to_f/100)/term))**term)-1).round(6))*100\n end",
"def get_rate(currency_iso_from, currency_iso_to); end",
"def annual_cost_or_base_pay\n case request_model_type\n when 'staff', 'contractor'\n (annual_base_pay_cents / 100.0)\n when 'labor'\n (calculate_annual_cost_in_cents / 100.0)\n else\n logger.error(\"Unknown request model type: #{request_model_type}\")\n 0.00\n end\n end",
"def calculate_years(principal, interest, tax, desired)\n i = 0\n return i if principal == desired\n \n while principal < desired\n principal += (principal * interest) - (principal * interest * tax)\n i += 1\n end\n \n i\nend",
"def annual_cost\n (number_of_positions * hourly_rate * hours_per_week * number_of_weeks)\n end",
"def annual_cost\n (number_of_positions * hourly_rate * hours_per_week * number_of_weeks)\n end",
"def add_rate(currency_iso_from, currency_iso_to, rate); end",
"def grow_one_year(starting_balance, growth_rate)\n starting_balance * (1.0 + growth_rate)\nend",
"def calc_base_rate(version)\n ab = version.student_age_brackets.first\n rate = calc_rate_by_type(ab, \"student\")\n\n # Logic for couple and family rate\n if version.detail_type == \"Couple\" && !version.detail.has_couple_rate\n\n rate_family = calc_rate_by_type(ab, \"family\")\n\n if t1.any? and t2.any?\n rate = rate + rate_family\n end\n elsif self.traveler_type == \"Family\"\n rate = calc_family_rate(rate, version)\n end\n\n unless plan_type == \"Annual\" \n rate = (rate * self.traveled_days)\n end\n\n # check to see if there is a min price and if there is\n # we use the greater of the two\n if version.student_product.min_rate_type == \"Price\"\n minprice = version.min_price\n if rate < minprice\n rate = minprice\n end\n elsif version.student_product.min_rate_type == \"Date\"\n mindate = version.product.min_date\n if mindate > self.traveled_days\n rate = (mindate * version.product_rate).round(2)\n end\n end\n\n return rate.round(2)\n end",
"def interest_discount(int_rate)\n\t int_rate = sanitize_interest(int_rate)\n\t 1.0 / (1.0 + int_rate)\n end",
"def anticipated_fixed_payment(present_value, rate, term)\n\t\t((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)\n end",
"def rates_prediction\r\n final_array = []\r\n today = today_rate\r\n weekly_change = weekly_percentage_change_array\r\n\r\n first = ((weekly_change[0] / 100) * today) + today\r\n final_array << first\r\n\r\n if @time > 1\r\n i = 0\r\n while i < weekly_change[1].length\r\n rate = ((weekly_change[1][i] / 100) * final_array[i]) + final_array[i]\r\n final_array << rate\r\n i += 1\r\n end\r\n end\r\n final_array\r\n end",
"def calculate_monthly_pay(loan_amount, interest_rate, loan_duration)\n loan_amount * (interest_rate * ( 1 + interest_rate) * loan_duration) /\n (interest_rate * ( 1 + interest_rate) * (loan_duration - 1))\nend",
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def yearly_rate\n\t\t yearly? ? rate : rate * 12\n\t\t end",
"def calculate_irr(min_rate, max_rate, amounts)\n while true\n range = max_rate - min_rate\n\n raise RuntimeError if range <= Float::EPSILON * 2\n\n rate = range.fdiv(2) + min_rate\n present_value = npv(rate, amounts)\n\n if present_value > 0\n min_rate = rate\n elsif present_value < -0.5\n max_rate = rate\n else\n return rate\n end\n end\n end",
"def calculate_interest(amount, number_of_days)\n (amount * (0.03 / 365) * (number_of_days - 1)).round(10)\n end",
"def frm(r, n, po)\n\t## \n\t# interest rate is converted to fraction and made a monthly\n\tr = r.to_f/100/12\n\t##\n\t#number of years is converted to number of months\n\tn = n * 12\n\t##\n\t#monthly payment is calculated\n\tc = (r / (1 - (1+r) ** -n) ) * po\n\treturn c\nend",
"def final_rate_adjustment rate\n (rate/100.0).ceil - 0.01\n end",
"def calculate_payment_amount(params, insurance_cost, interest_rate)\n mortgage_principle = params['asking_price'] - params['down_payment'] + insurance_cost\n number_of_payments = SCHEDULE_MAP[params['payment_schedule']] * params['amortization_period']\n nominal_interest_rate = (interest_rate / SCHEDULE_MAP[params['payment_schedule']]) / 100\n\n numerator = (mortgage_principle * nominal_interest_rate * (1 + nominal_interest_rate)**number_of_payments)\n denominator = (1 + nominal_interest_rate)**number_of_payments - 1\n\n (numerator / denominator).round(2)\n end",
"def rate_average_price_earnings_ratio(per)\n sum = per.value_three_years_ago + per.value_two_years_ago + per.value_last_year + per.value_this_year + per.value_next_year\n avg = sum / 5\n case \n when avg < 12\n score = 1\n when avg > 16\n score = -1\n else\n score = 0\n end\n per.average = avg\n per.score = score\n return score\n end",
"def annuity_given_present(present_value, interest, term)\n interest = interest.to_f\n (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)\n end",
"def get_monthly_rate(apr)\n (apr / 100) / 12\nend",
"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 calculate_interest(current_period, previous_period=0)\n previous_balance = @txns[previous_period][:balance]\n period_of_interest = current_period - previous_period\n @interest += (previous_balance * daily_interest * period_of_interest).round(2)\n end",
"def calculate_apr\n payment_ratio = monthly_payment_with_fees / loan_amount\n f = lambda {|k| (k**(self.period + 1) - (k**self.period * (payment_ratio + 1)) + payment_ratio)}\n f_deriv = lambda { |k| ((self.period + 1) * k**self.period) - (self.period * (payment_ratio + 1) * k**(self.period - 1))}\n\n root = newton_raphson(f, f_deriv, monthly_interest_rate + 1)\n 100 * 12 * (root - 1).to_f\n end",
"def avg_rate\n if @total > 0\n if @interval == 0.0 then 0.0 else 1.0 / @interval end\n end\n end",
"def book_royalty(period='enddate', basis=\"Net receipts\")\n royarray = []\n sales = self.book_sales(period, basis, false) # this calls the royalty calculation for net receipts\n sales.each do |sale|\n royarray << sale.royalty_by_band.inject(0) { |sum, i| sum + i.to_f unless i.nan? || i.nil? }\n end\n book_royalty = royarray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def insurance_fee\n (COMMISSION_RATE * INSURANCE_PART_RATE * price).round\n end",
"def calculate_apr\n payment_ratio = pmt / principal_calculation\n duration = @duration\n f = lambda {|k| (k**(duration + 1) - (k**duration * (payment_ratio + 1)) + payment_ratio)}\n f_deriv = lambda { |k| ((duration + 1) * k**duration) - (duration * (payment_ratio + 1) * k**(duration - 1))}\n\n root = newton_raphson(f, f_deriv, monthly_rate + 1)\n 100 * 12 * (root -1).to_f\n end",
"def rate\n if(specific_rate?)\n if(rate_cents < 0)\n task_list.default_rate.to_money\n else\n specific_rate.to_money\n end\n else\n Money.new(0, \"USD\")\n end\n end",
"def calculate_bookingcom_single_rate(rate)\n if self.bookingcom_single_rate_discount.blank? or self.bookingcom_single_rate_discount == 0\n rate\n else\n rate * (1 - (self.bookingcom_single_rate_discount / 100))\n end\n end",
"def calculate_interest(account)\n (account.balance * account.interest_rate).abs\n end",
"def calculate_years(principal, interest, tax, desired)\n total = principal\n years = 0\n loop do\n break if total >= desired\n total_interest = total*interest\n total += total_interest\n total -= total_interest*tax\n years += 1\n end\n years\nend",
"def yearly_rate\n yearly? ? rate : rate * 12\n end",
"def add_interest(rate)\n #add_interest(rate): Calculate the interest on the balance and add the interest to the balance. Return the interest that was calculated and added to the balance (not the updated balance).\n # Input rate is assumed to be a percentage (i.e. 0.25).\n\n interest = (@balance * rate/100).to_i #want to ensure whole cent values.\n @balance = @balance + interest\n\n return interest\n end",
"def interest(amount)\n if amount <= 1000\n 0.04 * amount\n elsif amount <= 5000\n 0.045 * amount\n else\n 0.05 * amount\n end\nend",
"def daily_rate\n\t\t yearly_rate / 365\n\t\t end",
"def pmt rate, nper, pv\n\n\tpay = 0.0\n\tnumerator = 0.0\n\tdenominator = 0.0\n\n\tnumerator = pv * rate * (1 + rate) ** nper\n\n\tdenominator = ((1 + rate) ** nper) - 1\n\n\tpay = numerator / denominator\n\n\treturn pay.round(2)\n\nend",
"def future_given_annuity(annuity, interest, term)\n (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)\n end",
"def bank\n unless @bank\n @bank = Money::Bank::VariableExchange.new\n base_cents = price_currency == 'JPY' ? (price_cents.to_f * 100) : price_cents.to_f\n unless alt1_price_currency.blank?\n alt1_cents = alt1_price_currency == 'JPY' ? (alt1_price_cents.to_f * 100) : alt1_price_cents.to_f\n @bank.add_rate(price_currency, alt1_price_currency, alt1_cents / base_cents)\n @bank.add_rate(alt1_price_currency, price_currency, base_cents / alt1_cents)\n end\n unless alt2_price_currency.blank?\n alt2_cents = alt2_price_currency == 'JPY' ? (alt2_price_cents.to_f * 100) : alt2_price_cents.to_f\n @bank.add_rate(price_currency, alt2_price_currency, alt2_cents / base_cents)\n @bank.add_rate(alt2_price_currency, price_currency, base_cents / alt2_cents)\n end\n if !alt1_price_currency.blank? && !alt2_price_currency.blank?\n @bank.add_rate(alt1_price_currency, alt2_price_currency, alt2_cents / alt1_cents)\n @bank.add_rate(alt2_price_currency, alt1_price_currency, alt1_cents / alt2_cents)\n end\n end\n @bank\n end",
"def daily_interest\n @apr / 100.0 / 365\n end",
"def rate_ratio(rate)\n t1 = (rate+1.0) ** duration\n t2 = (rate+1.0) ** (duration-1.0)\n g = future_value + t1 * amount + payment * (t1 - 1.0) * (rate * ptype + 1.0) / rate\n derivative_g = \\\n (duration * t2 * amount)\n - (payment * (t1 - 1.0) * (rate * ptype + 1.0) / (rate ** 2.0))\n + (duration * payment * t2 * (rate * ptype + 1.0) / rate)\n + (payment * (t1 - 1.0) * ptype/rate)\n \n g / derivative_g\n end",
"def required_annual_savings\n needed_amount_less_savings / years_to_retirement\n end",
"def normal_pay(hourly_rate, hours)\n hourly_rate * hours\nend",
"def adjusted_capital\n return 0.0 if @capital <= 0.0\n return 0.0 if @interest_rate <= 0.0 || @duration <= 0.0\n (@income/ @duration) * ADJ_FACTOR\nend",
"def calculate_annual_cost_in_cents\n (number_of_positions * hourly_rate_cents * hours_per_week.to_f * number_of_weeks)\n end",
"def daily_rate\n yearly_rate / 365\n end",
"def year_to_month_rate_convert(apr_in_decimals, loan_duration)\n ((1 + (apr_in_decimals / loan_duration))**loan_duration) - 1\nend",
"def initialize(principal, *rates, &block)\n @principal = principal.to_d\n @rates = rates\n @block = block\n \n # compute the total duration from all of the rates.\n @periods = (rates.collect { |r| r.duration }).sum\n @period = 0\n\n compute\n end",
"def apr\n payment_ratio = self.monthly_payment_with_fees / self.loan_amount\n f = lambda { |k| (k**(self.period + 1) - (k**self.period * (payment_ratio + 1)) + payment_ratio) }\n f_deriv = lambda { |k| ((self.period + 1) * k**self.period) - (self.period * (payment_ratio + 1) * k**(self.period - 1)) }\n\n root = newton_raphson(f, f_deriv, self.monthly_interest_rate + 1)\n 100 * 12 * (root - 1).to_f\n end",
"def amortize(rate)\n # For the purposes of calculating a payment, the relevant time\n # period is the remaining number of periods in the loan, not\n # necessarily the duration of the rate itself.\n periods = @periods - @period\n amount = Amortization.payment @balance, rate.monthly, periods\n\n pmt = Payment.new(amount, :period => @period)\n if @block then pmt.modify(&@block) end\n \n rate.duration.times do\n # Do this first in case the balance is zero already.\n if @balance.zero? then break end\n\n # Compute and record interest on the outstanding balance.\n int = (@balance * rate.monthly).round(2)\n interest = Interest.new(int, :period => @period)\n @balance += interest.amount\n @transactions << interest.dup\n\n # Record payment. Don't pay more than the outstanding balance.\n if pmt.amount.abs > @balance then pmt.amount = -@balance end\n @transactions << pmt.dup\n @balance += pmt.amount\n \n @period += 1\n end\n end",
"def rate(rates, period_metrics, dataset, classifier)\n classifier.each_pair do |klass, qualified_metrics|\n period_metrics.slice(*dataset.keys).each_pair do |metric, weight|\n range = qualified_metrics[metric.to_s][:range]\n rates[KLASS_2_GRADE[klass]] += weight / max_score if range.cover? dataset[metric].to_f\n end\n end\n end",
"def annualy_insurance\n return @capital * @insurance * -1\n end",
"def rates_from(rate_date_array, rate_effective_date)\n rate_date_array['Cube'].map do |currency_rate_hash|\n create_or_update_currency_rate(currency: currency_rate_hash['currency'],\n value_in_euro: currency_rate_hash['rate'].to_f,\n date_of_rate: rate_effective_date)\n end\n end",
"def present_given_annuity(annuity, interest, term)\n (annuity.to_f * (((1 + interest.to_f) ** term) -1) / (interest.to_f * (1 + interest.to_f) ** term )).round(4)\n end",
"def yearly_discount(int_disc)\n\t 12.0 * (1.0 - (int_disc ** (1.0/12.0)))\n end",
"def calculate_basic_plus_rate_payment\n basic_plus_rate = capped_income - (capped_income * relevant_other_child_multiplier)\n basic_qualifying_child_amount = (BASIC_PLUS_RATE_THRESHOLD * basic_rate_multiplier)\n additional_qualifying_child_amount = ((basic_plus_rate - BASIC_PLUS_RATE_THRESHOLD) * basic_plus_rate_multiplier)\n child_amounts_total = basic_qualifying_child_amount + additional_qualifying_child_amount\n total = (child_amounts_total - (child_amounts_total * shared_care_multiplier))\n if shared_care_multiplier == 0.5\n total = total - (@number_of_children * SHARED_CARE_MAX_RELIEF_EXTRA_AMOUNT)\n end\n total.round(2)\n end",
"def bounce_rate(period)\n stat = self.stats.where(:period => period).first\n return stat.bounce_rate\n end",
"def gm_full_rate(interval)\n @gm_full_rate ||= {}\n return @gm_full_rate[interval] if @gm_full_rate[interval]\n @gm_full_rate[interval] = GmRateFinder.find(:revenue, interval, project: project)\n end",
"def interest_rate\n params['interest_rate'] = params['interest_rate'].to_f\n\n old_rate = @@interest_rate\n @@interest_rate = params['interest_rate']\n json_response(old_rate: old_rate, new_rate: @@interest_rate)\n end",
"def gain_interest\n # Assuming 2% interest rate would be entered as 2,\n # Divide rate by 100, to create 0.02 -- then\n # Add 1, to create 1.02 -- then\n # Multiply @balance by 1.02\n\n interest_div = @interest_rate / 100.0 # changes 2 to 0.02\n\n interest_add = interest_div + 1 # changes 0.02 to 1.02\n\n @balance = @balance * interest_add\n\n puts \"Your money accumulated interest. Now your balance is $#{ @balance }.\"\n end",
"def loan_calc(loan_amount,interest_rate,loan_term,loan_type)\n if loan_type.downcase == \"pi\"\n r = interest_rate/12\n n = loan_term*12\n d = ( ( ( (1+r)**n) - 1) / (r*(1+r)**n))\n result = loan_amount/d\n\n elsif loan_type.downcase == \"io\"\n r = interest_rate/12\n result = loan_amount * r\n end #end if\nend",
"def pv_of_1_dollar_payments\n member = 1.0\n factor = 1.0/(1 + debt_rate/PAYMENTS_PER_YEAR)\n res = 0\n\n TOTAL_PAYMENTS.times do\n member *= factor\n res += member\n end\n\n res\n end",
"def effective_tax_rate income\r\n income = fix_income income\r\n\r\n return marginal_tax_rate income if income == 0 #avoid our later divide by zero\r\n\r\n (tax income) / income \r\n end",
"def add_interest(rate = 0.25)\n interest = @balance * rate/100\n @balance += interest\n return interest\n end",
"def us_treas_10_year_rate\n # In real life call a web service to get it, but I will return a constant here\n 0.02124\n end",
"def annualized_portfolio_amount_needed\n savings_portion_needed * 12.0\n end",
"def pmt(rate,n,amount)\n\n\ttop = 0.0\n\ttop = rate*(1+rate)**n\n\tbot = 0.0\n\tbot = (1+rate)**n-1\n\tresult = 0.0\n\tresult =amount*top/bot\n\treturn result \n\nend",
"def pmt (interest_rate, nper, pv)\n\t#monthly_payment = 1.00\n\tmonthly_payment = (pv*interest_rate*((1+interest_rate)**nper))/(((1+interest_rate)**nper)-1)\n\treturn monthly_payment\nend",
"def estimated_profit_day_rate\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_client(id)\n days_tracked = (mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n task_estimate_mins = Task.total_estimated_minutes_for_client(id)\n task_estimate_days = (task_estimate_mins.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n total_project_potential = (days_tracked * day_rate).round(2)\n\n if task_estimate_days == 0 && days_tracked != 0\n 0\n elsif task_estimate_days != 0 && days_tracked == 0\n (task_estimate_days * day_rate.to_s.to_d).round(2)\n elsif task_estimate_days == 0\n day_rate\n else\n (((task_estimate_days * day_rate.to_s.to_d) / total_project_potential) * day_rate).round(2)\n end\n end"
] | [
"0.6941773",
"0.6785467",
"0.6609534",
"0.65379953",
"0.6418716",
"0.6287261",
"0.627252",
"0.6134057",
"0.6099594",
"0.60314786",
"0.6006965",
"0.59807014",
"0.59512377",
"0.5846905",
"0.58282346",
"0.5824809",
"0.58177525",
"0.5814894",
"0.57970273",
"0.5775244",
"0.5764877",
"0.57511556",
"0.5696544",
"0.568939",
"0.5684052",
"0.56806034",
"0.5675443",
"0.5661221",
"0.5660324",
"0.563824",
"0.56222177",
"0.5617653",
"0.56046766",
"0.560026",
"0.560026",
"0.5594616",
"0.55902576",
"0.5562159",
"0.5558582",
"0.55558884",
"0.55548143",
"0.5552272",
"0.5551075",
"0.5549434",
"0.554814",
"0.5525502",
"0.5508464",
"0.5498637",
"0.54978704",
"0.54947543",
"0.5488701",
"0.54883474",
"0.548476",
"0.547489",
"0.5473182",
"0.54686767",
"0.5457466",
"0.54497814",
"0.5442576",
"0.5435051",
"0.54334474",
"0.54303354",
"0.54289246",
"0.5425081",
"0.538995",
"0.5359136",
"0.53585696",
"0.53568196",
"0.53495604",
"0.5344881",
"0.53423846",
"0.53383505",
"0.53354794",
"0.53321564",
"0.53178746",
"0.5313354",
"0.5307153",
"0.53062266",
"0.53031963",
"0.52971655",
"0.5297058",
"0.5283556",
"0.5252515",
"0.52478635",
"0.523588",
"0.52334607",
"0.51935565",
"0.51710886",
"0.517091",
"0.5164702",
"0.5161318",
"0.51611614",
"0.51484084",
"0.5146667",
"0.5139714",
"0.5138188",
"0.51314",
"0.5127978",
"0.51231515",
"0.51213884"
] | 0.757776 | 0 |
role :servers, 'ec26720233100.compute1.amazonaws.com', 'ec2672026067.compute1.amazonaws.com' | def call_describe_instances
`ec2-describe-instances >> #{EC2_DESCRIBE_INSTANCES_OUTPUT}`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role(role, server)\n @roles[role] ||= []\n @roles[role] << server\n end",
"def serversForCapRoles(roles)\n find_servers(:roles => roles).collect { |x| x.host }\nend",
"def roles(host)\n roles = [ \"network\" ]\n case host\n when /^node/\n roles << \"compute\"\n when /^login/\n roles << \"login\"\n when /^master/\n roles << \"master\"\n when /^nfs/\n roles << \"nfsserver\"\n end\n roles\nend",
"def web_servers; machines_by_role('web'); end",
"def create_policy_role_EC2\n\n AWS.config(\n :access_key_id => ENV[\"S3_ACCESS_KEY\"], \n :secret_access_key => ENV[\"S3_SECRET_KEY\"])\n\n # naming policy \n role_name = 'ec2-start-stop'\n policy_name = 'ec2-start-stop'\n profile_name = 'ec2-start-stop' \n instance_profile_name = 'inst-ec2-start-stop' \n\n # building a custom policy \n policy = AWS::IAM::Policy.new\n policy.allow(\n :actions => [\"ec2:StartInstances\",\"ec2:StopInstances\"],\n :resources => '*')\n\n # EC2 can generate session credentials\n assume_role_policy_document = '{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}'\n \n # creating a role\n $iam.client.create_role(\n :role_name => role_name,\n :assume_role_policy_document => assume_role_policy_document)\n\n # adding policy to role\n $iam.client.put_role_policy(\n :role_name => role_name,\n :policy_name => policy_name,\n :policy_document => policy.to_json)\n\n # creating a profile for the role\n response = $iam.client.create_instance_profile(\n :instance_profile_name => instance_profile_name)\n \n # ARN\n profile_arn = response[:instance_profile][:arn]\n \n $iam.client.add_role_to_instance_profile(\n :instance_profile_name => instance_profile_name,\n :role_name => role_name)\n\n # you can use the profile name or ARN as the :iam_instance_profile option\n $ec2 = AWS::EC2.new\n $ec2.instances.create(:image_id => \"ami-inst-id-1\", :iam_instance_profile => profile_name)\n\n redirect_to iams_path, notice: 'Added Policy and Role for EC2'\n \n end",
"def role(*args)\n cap_role(*args)\n puppet_role(*args)\n end",
"def mounts_ebs_volumes settings\n has_role settings, \"ebs_volumes_mount\"\nend",
"def createEc2Instance\n\t\t name = @server[\"name\"]\n\t\t node = @server['mu_name']\n\t\t\tbegin\n\t\t\t\t@server['iam_role'] = MU::Server.createIAMProfile(\"Server-\"+name, base_profile: @server['iam_role'], extra_policies: @server['iam_policies'])\n\t\t\trescue Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tsleep 10\n\t\t\t\tretry\n\t\t\tend\n\t\t\t@server['iam_role'] = @server['iam_role']\n\n\t\t\tbegin\n\t\t\t\t@deploy.createEc2SSHKey\n\t\t\trescue Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tsleep 10\n\t\t\t\tretry\n\t\t\tend\n\n\t\t instance_descriptor = {\n\t\t :image_id => @server[\"ami_id\"],\n\t\t :key_name => @deploy.keypairname,\n\t\t :instance_type => @server[\"size\"],\n\t\t :disable_api_termination => true,\n\t\t :min_count => 1,\n\t\t :max_count => 1,\n\t\t\t\t:network_interfaces => [\n\t\t\t\t\t{\n\t\t\t\t\t\t:associate_public_ip_address => name[\"associate_public_ip\"]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t }\n\t\t\t\n\t\t\tif !@server['private_ip'].nil?\n\t\t\t\tinstance_descriptor[:private_ip_address] = @server['private_ip']\n\t\t\tend\n\n\t\t\tvpc_id=subnet_id=nat_host_name=nat_ssh_user = nil\n\t\t\tsubnet_retries = 0\n\t\t\tif !@server[\"vpc\"].nil?\n\t\t\t\tbegin\n\t\t\t\t\tvpc_id, subnet_ids, nat_host_name, nat_ssh_user = MU::VPC.parseVPC(@server['vpc'])\n\t\t\t\trescue Aws::EC2::Errors::ServiceError => e\n\t\t\t\t\tMU.log e.message, MU::ERR, details: @server\n\t\t\t\t\tif subnet_retries < 5\n\t\t\t\t\t subnet_retries = subnet_retries + 1\n\t\t\t\t\t sleep 15\n\t\t\t\t\t retry\n\t\t\t\t\tend\n\t\t\t\t\traise e\n\t\t\t\tend\n\t\t\t\tsubnet_id = subnet_ids.first\n\t\t\t\tif subnet_id.nil? or subnet_id.empty?\n\t\t\t\t\tMU.log \"Got null Subnet id out of #{@server['vpc']}\", MU::ERR\n\t\t\t\t\traise \"deploy failure\"\n\t\t\t\tend\n\n\t\t\t\tMU.log \"Deploying #{node} into VPC #{vpc_id} Subnet #{subnet_id}\"\n\n\t\t\t\tif !@server[\"vpc\"][\"nat_host_name\"].nil? or !@server[\"vpc\"][\"nat_host_id\"].nil?\n\t\t\t\t\tadmin_sg = MU::Server.punchAdminNAT(@server, node)\n\t\t\t\telse\n\t\t\t\t\tadmin_sg = MU::FirewallRule.setAdminSG(vpc_id: vpc_id, region: @server['region'])\n\t\t\t\tend\n\n\t\t\t\tinstance_descriptor[:subnet_id] = subnet_id\n\t\t\t\tnode_sg = MU::FirewallRule.createEc2SG(\n\t\t\t\t\t\t@server[\"name\"].upcase,\n\t\t\t\t\t\t@server[\"ingress_rules\"],\n\t\t\t\t\t\tdescription: \"SG holes for #{node}\",\n\t\t\t\t\t\tvpc_id: vpc_id,\n\t\t\t\t\t\tregion: @server['region']\n\t\t\t\t)\n\t\t\telse\n\t\t\t\tadmin_sg = MU::FirewallRule.setAdminSG(region: @server['region'])\n\t\t\t\tnode_sg = MU::FirewallRule.createEc2SG(\n\t\t\t\t\t\t@server[\"name\"].upcase,\n\t\t\t\t\t\t@server[\"ingress_rules\"],\n\t\t\t\t\t\tdescription: \"SG holes for #{node}\",\n\t\t\t\t\t\tregion: @server['region']\n\t\t\t\t)\n\t\t\tend\n\t\t\tsecurity_groups = Array.new\n\t\t\tsecurity_groups << admin_sg\n\t\t\tsecurity_groups << node_sg\n\t\t\tif !@server[\"add_firewall_rules\"].nil?\n\t\t\t\t@server[\"add_firewall_rules\"].each { |acl|\n\t\t\t\t\tsg = MU::FirewallRule.find(sg_id: acl[\"rule_id\"], name: acl[\"rule_name\"], region: @server['region'])\n\t\t\t\t\tif sg.nil?\n\t\t\t\t\t\tMU.log \"Couldn't find dependent security group #{acl} for server #{node}\", MU::ERR\n\t\t\t\t\t\traise \"deploy failure\"\n\t\t\t\t\tend\n\t\t\t\t\tsecurity_groups << sg.group_id\n\t\t\t\t}\n\t\t\tend\n\n\t\t\tinstance_descriptor[:security_group_ids] = security_groups\n\n\t\t if !@userdata.nil? and !@userdata.empty?\n\t\t instance_descriptor[:user_data] = Base64.encode64(@userdata)\n\t\t end\n\n\t\t if !@server[\"iam_role\"].nil?\n\t\t instance_descriptor[:iam_instance_profile] = { name: @server[\"iam_role\"]}\n\t\t end\n\n\t\t\tconfigured_storage = Array.new\n\t\t\tif @server[\"storage\"]\n\t\t\t\t@server[\"storage\"].each { |vol|\n\t\t\t\t\tconfigured_storage << MU::Server.convertBlockDeviceMapping(vol)\n\t\t\t\t}\n\t\t\tend\n\t\t\n\t\t\tMU::Server.waitForAMI(@server[\"ami_id\"], region: @server['region'])\n\n\t\t\tinstance_descriptor[:block_device_mappings] = configured_storage\n\t\t\tinstance_descriptor[:block_device_mappings].concat(@ephemeral_mappings)\n\n\t\t\tinstance_descriptor[:monitoring] = { enabled: @server['monitoring'] }\n\n\t\t\tMU.log \"Creating EC2 instance #{node}\"\n\t\t\tMU.log \"Instance details for #{node}: #{instance_descriptor}\", MU::DEBUG\n#\t\t\t\tif instance_descriptor[:block_device_mappings].empty?\n#\t\t\t\t\tinstance_descriptor.delete(:block_device_mappings)\n#\t\t\t\tend\n#pp instance_descriptor[:block_device_mappings]\n\t\t\tretries = 0\n\t\t\tbegin\n\t\t\t\tresponse = MU.ec2(@server['region']).run_instances(instance_descriptor)\n\t\t\trescue Aws::EC2::Errors::InvalidGroupNotFound, Aws::EC2::Errors::InvalidSubnetIDNotFound, Aws::EC2::Errors::InvalidParameterValue, Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tif retries < 10\n\t\t\t\t\tif retries > 7\n\t\t\t\t\t\tMU.log \"Seeing #{e.inspect} while trying to launch #{node}, retrying a few more times...\", MU::WARN, details: instance_descriptor\n\t\t\t\t\tend\n\t\t\t\t\tsleep 10\n\t\t\t\t\tretries = retries + 1\n\t\t\t\t\tretry\n\t\t\t\telse\n\t\t\t\t\traise e\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tinstance = response.instances.first\n\t\t\tMU.log \"#{node} (#{instance.instance_id}) coming online\"\n\n\n\t\t\treturn instance\n\n\t\tend",
"def get_instances(role: nil, username: nil, bastion: nil)\n puts \"Getting instances for role: #{role}\"\n servers = []\n instances_for_role(role).each do |res|\n res[:instances].each do |inst|\n servers << \"#{username}@#{inst[:private_ip_address]}\"\n end\n end\n\n puts \" - #{servers.join(', ')}\"\n servers\n end",
"def chef_role(names, query=nil, options={}, &block)\n user = options[:user] ||= fetch(:user)\n attribute = options.delete(:attribute) || :ipaddress\n index = options.delete(:index) || :node\n results_proc = block_given? ? block : chef_results_by(attribute)\n terms = [index, query].compact\n addresses = chef_search(*terms).flat_map(&results_proc)\n\n addresses.each do |address|\n server address, options.merge(roles: names)\n end\n end",
"def get_host\n roles(:web).server host\n end",
"def create_aws_instance(config, name, instance_type=\"m3.medium\")\n config.ssh.pty = true\n config.vm.define name do |server|\n server.vm.box = AWS_BOX\n server.vm.provider :aws do |aws, override|\n aws.instance_type = instance_type\n aws.region = AWS_REGION\n aws.ami = AWS_AMI\n aws.keypair_name = AWS_PRIVATE_KEY\n override.ssh.username = AWS_SSH_USERNAME\n override.ssh.private_key_path = AWS_PRIVATE_KEY_PATH\n yield(aws,override,server)\n end\n end\nend",
"def createEc2Instance\n name = @config[\"name\"]\n node = @config['mu_name']\n\n instance_descriptor = {\n :image_id => @config[\"ami_id\"],\n :key_name => @deploy.ssh_key_name,\n :instance_type => @config[\"size\"],\n :disable_api_termination => true,\n :min_count => 1,\n :max_count => 1\n }\n\n arn = nil\n if @config['generate_iam_role']\n role = @deploy.findLitterMate(name: @config['name'], type: \"roles\")\n s3_objs = [\"#{@deploy.deploy_id}-secret\", \"#{role.mu_name}.pfx\", \"#{role.mu_name}.crt\", \"#{role.mu_name}.key\", \"#{role.mu_name}-winrm.crt\", \"#{role.mu_name}-winrm.key\"].map { |file| \n 'arn:'+(MU::Cloud::AWS.isGovCloud?(@config['region']) ? \"aws-us-gov\" : \"aws\")+':s3:::'+MU.adminBucketName+'/'+file\n }\n role.cloudobj.injectPolicyTargets(\"MuSecrets\", s3_objs)\n\n @config['iam_role'] = role.mu_name\n arn = role.cloudobj.createInstanceProfile\n# @cfm_role_name, @cfm_prof_name\n\n elsif @config['iam_role'].nil?\n raise MuError, \"#{@mu_name} has generate_iam_role set to false, but no iam_role assigned.\"\n end\n if !@config[\"iam_role\"].nil?\n if arn\n instance_descriptor[:iam_instance_profile] = {arn: arn}\n else\n instance_descriptor[:iam_instance_profile] = {name: @config[\"iam_role\"]}\n end\n end\n\n security_groups = []\n if @dependencies.has_key?(\"firewall_rule\")\n @dependencies['firewall_rule'].values.each { |sg|\n security_groups << sg.cloud_id\n }\n end\n\n if security_groups.size > 0\n instance_descriptor[:security_group_ids] = security_groups\n else\n raise MuError, \"Didn't get any security groups assigned to be in #{@mu_name}, that shouldn't happen\"\n end\n\n if !@config['private_ip'].nil?\n instance_descriptor[:private_ip_address] = @config['private_ip']\n end\n\n vpc_id = subnet = nil\n if !@vpc.nil? and @config.has_key?(\"vpc\")\n subnet_conf = @config['vpc']\n subnet_conf = @config['vpc']['subnets'].first if @config['vpc'].has_key?(\"subnets\") and !@config['vpc']['subnets'].empty?\n tag_key, tag_value = subnet_conf['tag'].split(/=/, 2) if !subnet_conf['tag'].nil?\n\n subnet = @vpc.getSubnet(\n cloud_id: subnet_conf['subnet_id'],\n name: subnet_conf['subnet_name'],\n tag_key: tag_key,\n tag_value: tag_value\n )\n if subnet.nil?\n raise MuError, \"Got null subnet id out of #{subnet_conf['vpc']}\"\n end\n MU.log \"Deploying #{node} into VPC #{@vpc.cloud_id} Subnet #{subnet.cloud_id}\"\n punchAdminNAT\n instance_descriptor[:subnet_id] = subnet.cloud_id\n end\n\n if !@userdata.nil? and !@userdata.empty?\n instance_descriptor[:user_data] = Base64.encode64(@userdata)\n end\n\n MU::Cloud::AWS::Server.waitForAMI(@config[\"ami_id\"], region: @config['region'], credentials: @config['credentials'])\n\n # Figure out which devices are embedded in the AMI already.\n image = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_images(image_ids: [@config[\"ami_id\"]]).images.first\n ext_disks = {}\n if !image.block_device_mappings.nil?\n image.block_device_mappings.each { |disk|\n if !disk.device_name.nil? and !disk.device_name.empty? and !disk.ebs.nil? and !disk.ebs.empty?\n ext_disks[disk.device_name] = MU.structToHash(disk.ebs)\n end\n }\n end\n\n configured_storage = Array.new\n cfm_volume_map = {}\n if @config[\"storage\"]\n @config[\"storage\"].each { |vol|\n # Drop the \"encrypted\" flag if a snapshot for this device exists\n # in the AMI, even if they both agree about the value of said\n # flag. Apparently that's a thing now.\n if ext_disks.has_key?(vol[\"device\"])\n if ext_disks[vol[\"device\"]].has_key?(:snapshot_id)\n vol.delete(\"encrypted\")\n end\n end\n mapping, cfm_mapping = MU::Cloud::AWS::Server.convertBlockDeviceMapping(vol)\n configured_storage << mapping\n }\n end\n\n instance_descriptor[:block_device_mappings] = configured_storage\n instance_descriptor[:block_device_mappings].concat(@ephemeral_mappings)\n instance_descriptor[:monitoring] = {enabled: @config['monitoring']}\n\n MU.log \"Creating EC2 instance #{node}\"\n MU.log \"Instance details for #{node}: #{instance_descriptor}\", MU::DEBUG\n#\t\t\t\tif instance_descriptor[:block_device_mappings].empty?\n#\t\t\t\t\tinstance_descriptor.delete(:block_device_mappings)\n#\t\t\t\tend\n\n retries = 0\n begin\n response = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).run_instances(instance_descriptor)\n rescue Aws::EC2::Errors::InvalidGroupNotFound, Aws::EC2::Errors::InvalidSubnetIDNotFound, Aws::EC2::Errors::InvalidParameterValue => e\n if retries < 10\n if retries > 7\n MU.log \"Seeing #{e.inspect} while trying to launch #{node}, retrying a few more times...\", MU::WARN, details: instance_descriptor\n end\n sleep 10\n retries = retries + 1\n retry\n else\n raise MuError, e.inspect\n end\n end\n\n instance = response.instances.first\n MU.log \"#{node} (#{instance.instance_id}) coming online\"\n\n return instance\n\n end",
"def roles(host)\n if $PROPERTIES.has_key?(host)\n #get the role assigned for the host\n roles=$PROPERTIES[host][:roles]\n #add the default roles to the host role array\n roles=roles + $PROPERTIES[\"default\"][:roles]\n else \n #assign default role for unassigned hosts\n roles=$PROPERTIES[\"default\"][:roles]\n end\n roles\nend",
"def attaches_ebs_volumes settings\n has_role settings, \"ebs_volumes_attach\"\nend",
"def eks_map(server_config_map)\n YAML.load(server_config_map.dig('data', 'mapRoles'))\n .select { |r| r.fetch('rolearn').include?('NodeInstanceRole') }\n end",
"def server?\n @role == :server\n end",
"def server_params\n params.require(:server).permit(:ip_addr, :role)\n end",
"def app_servers\n return super unless CDO.chef_managed\n require 'aws-sdk'\n servers = Aws::EC2::Client.new.describe_instances(\n filters: [\n {name: 'tag:aws:cloudformation:stack-name', values: [CDO.stack_name]},\n {name: 'tag:aws:cloudformation:logical-id', values: ['Frontends']},\n {name: 'instance-state-name', values: ['running']}\n ]\n ).reservations.map(&:instances).flatten.map {|i| [\"fe-#{i.instance_id}\", i.private_dns_name]}.to_h\n servers.merge(super)\n end",
"def get_ansible_role(boxname)\n case boxname\n when \"centos/7\"\n \"centos7\"\n when \"ubuntu/xenial64\"\n \"xenial64\"\n when \"archlinux/archlinux\"\n \"arch\"\n end\nend",
"def customize_cloud_config(cloud_init_yaml, vm_i)\n case vm_i\n when 1 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=head'\n when 2 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=proxy'\n when 3 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=web'\n when 4 then cloud_init_yaml['coreos']['fleet']['metadata'] = 'role=web'\n end\nend",
"def set_aws_connections\n\n @rs_to_aws_cloud_map = {\n 1 => AWS::EC2.new(region: 'us-east-1'),\n 3 => AWS::EC2.new(region: 'us-west-1'),\n 6 => AWS::EC2.new(region: 'us-west-2'),\n 4 => AWS::EC2.new(region: 'ap-southeast-1'),\n 8 => AWS::EC2.new(region: 'ap-southeast-2'),\n 5 => AWS::EC2.new(region: 'ap-northeast-1'),\n 7 => AWS::EC2.new(region: 'sa-east-1'),\n 2 => AWS::EC2.new(region: 'eu-west-1')\n }\nend",
"def set_aws_connections\n\n @rs_to_aws_cloud_map = {\n 1 => AWS::EC2.new(region: 'us-east-1'),\n 3 => AWS::EC2.new(region: 'us-west-1'),\n 6 => AWS::EC2.new(region: 'us-west-2'),\n 4 => AWS::EC2.new(region: 'ap-southeast-1'),\n 8 => AWS::EC2.new(region: 'ap-southeast-2'),\n 5 => AWS::EC2.new(region: 'ap-northeast-1'),\n 7 => AWS::EC2.new(region: 'sa-east-1'),\n 2 => AWS::EC2.new(region: 'eu-west-1')\n }\nend",
"def trust_ec2_instances(&block)\n trust_service('ec2', 'trust-ec2-instances', &block)\n end",
"def servers_for_role?(roles) #:nodoc:\n roles=Array(roles)\n roles.any? { |r| @roles.keys.include? (r) }\n end",
"def app_servers\n return super unless chef_managed\n require 'aws-sdk-ec2'\n servers = Aws::EC2::Client.new.describe_instances(\n filters: [\n {name: 'tag:aws:cloudformation:stack-name', values: [stack_name]},\n {name: 'tag:aws:cloudformation:logical-id', values: ['Frontends']},\n {name: 'instance-state-name', values: ['running']}\n ]\n ).reservations.map(&:instances).flatten.map {|i| [\"fe-#{i.instance_id}\", i.private_dns_name]}.to_h\n servers.merge(self[:app_servers])\n end",
"def chef_role(name, query = \"*:*\", options = {})\n # TODO: This can only get a node's top-level attributes. Make it get nested\n # ones.\n attr = options.delete(:attribute) || :ipaddress\n nodes = Chef::Search::Query.new.search(:node, query)[0].map {|n| n[attr] }\n role name, *nodes, options\n nodes\n end",
"def role_puppet_master\n $myxp.get_deployed_nodes('capi5k-init').first\nend",
"def is_cassandra_node settings\n has_role settings, \"cassandra_node\"\n security_group 'cassandra_node' do\n authorize :group_name => 'cassandra_node'\n authorize :network => '70.91.172.41/29', :from_port => \"9160\", :to_port => \"9160\"\n authorize :network => '72.32.68.18/32', :from_port => \"9160\", :to_port => \"9160\"\n authorize :network => '72.32.70.9/32', :from_port => \"9160\", :to_port => \"9160\"\n end\nend",
"def configure_instance(aws_node, private_ip_address, node_name, node_config)\n # Spin up EC2 instances\n aws_node.vm.provider :aws do |ec2, override|\n ec2.keypair_name = KEYPAIR_NAME\n ec2.access_key_id = ACCESS_KEY_ID\n ec2.secret_access_key = SECRET_ACCESS_KEY\n ec2.security_groups = SECURITY_GROUPS\n override.ssh.private_key_path = PRIVATE_KEY_PATH\n\n # read region, ami etc from json.\n ec2.region = AWS_CFG['region']\n ec2.subnet_id = AWS_CFG['subnet_id']\n ec2.availability_zone = AWS_CFG['region'] + AWS_CFG['availability_zone']\n ec2.ami = node_config['ami_id']\n ec2.instance_type = node_config['instance_type']\n ec2.private_ip_address = private_ip_address\n ec2.associate_public_ip = true\n\n if node_config.key?('volume_size')\n # Size in GB\n # (untested)\n ec2.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => node_config['volume_size'] }]\n end\n\n override.ssh.username = AWS_CFG['ssh_username']\n\n # Collect tags (can't be longer than 250 chars)\n ec2.tags = ({})\n ec2.tags['Name'] = node_name[0..245]\n ec2.tags['Type'] = 'Hyperledger'\n ec2.tags['Version'] = VERSION\n ec2.tags['Fabric'] = node_config['fabric'].map { |f| f['role'] }.join(',')[0..245]\n end\nend",
"def ecs\n Amazon::Ecs.configure do |options|\n options[:aWS_access_key_id] = @@key_id\n options[:associate_tag] = @@associate_id\n options[:aWS_secret_key] = @@secretkey\n end \n return Amazon::Ecs \nend",
"def resource_name\n\t\t\"role\"\n\tend",
"def iam_instance_profile_with_full_access(role_name, *services)\n resource \"#{role_name}Role\",\n Type: 'AWS::IAM::Role',\n Properties: {\n AssumeRolePolicyDocument: {\n Statement: [\n {\n Effect: 'Allow',\n Principal: {\n Service: ['ec2.amazonaws.com']\n },\n Action: ['sts:AssumeRole']\n }\n ]\n },\n Path: '/',\n Policies: [\n {\n PolicyName: \"#{role_name}Policy\",\n PolicyDocument: {\n Statement: services.map do |s|\n {\n Effect: 'Allow',\n Action: \"#{s}:*\",\n Resource: '*'\n }\n end\n }\n }\n ]\n }\n\n resource \"#{role_name}InstanceProfile\",\n Type: 'AWS::IAM::InstanceProfile',\n Properties: {\n Path: '/',\n Roles: [ref(\"#{role_name}Role\")]\n }\n\n ref(\"#{role_name}InstanceProfile\")\n end",
"def arn\n \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@config[\"region\"]) ? \"aws-us-gov\" : \"aws\")+\":ec2:\"+@config['region']+\":\"+MU::Cloud::AWS.credToAcct(@config['credentials'])+\":instance/\"+@cloud_id\n end",
"def get_role_instances(cloud_id, role_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/roles/#{role_id}/instances\")\n end",
"def create_esb_server (config, hostname, ip1, ip2)\n config.vm.define hostname do |esb|\n esb.vm.provider \"virtualbox\" do |provider|\n provider.customize [\"modifyvm\", :id, \"--memory\", 2048]\n end\n\n esb.vm.network \"private_network\", ip: ip1\n esb.vm.host_name = hostname\n\n esb.vm.network \"private_network\", ip: ip2\n end\nend",
"def role?(role_name)\n Mapr.role? node, role_name\nend",
"def cluster_assign_roles(environment, type, entry=nil)\n types = %w[basic hadoop kafka]\n unless types.include?(type.to_s.downcase)\n raise \"#{type} is not one of #{types.join(',')} !\"\n end\n\n #\n # We use system() instead of Mixlib::ShellOut specifically so that the\n # child process re-uses our STDOUT/STDERR.\n #\n # TODO: replace with IO::popen3\n #\n if entry.nil?\n system('sudo', './cluster-assign-roles.sh',\n environment, type.to_s.downcase.capitalize)\n else\n system('sudo', './cluster-assign-roles.sh',\n environment, type.to_s.downcase.capitalize, entry[:hostname])\n end\n\n # Why doesn't this raise an error?\n puts 'cluster-assign-roles.sh failed!' unless $CHILD_STATUS.success?\nend",
"def update_server(server, ec2_info)\n server[0] = ec2_info[1] # ec2_id\n server[3] = ec2_info[3] # public host\n server[4] = ec2_info[16] # public ip\n server[5] = ec2_info[4] # private host\n server[6] = ec2_info[17] # private ip\nend",
"def role; end",
"def role; end",
"def list_virtual_machines(*cloud_service_names)\n roles = []\n cloud_service_names.flatten!\n if cloud_service_names.empty?\n cloud_service = client.cloud_service_management\n cloud_service_names = cloud_service.list_cloud_services.map(&:name)\n end\n cloud_service_names.each do |cloud_service_name|\n request_path = \"/services/hostedservices/#{cloud_service_name}/deploymentslots/production\"\n request = client.management_request(:get, request_path)\n request.warn = true\n response = request.call\n roles << Serialization.virtual_machines_from_xml(response, cloud_service_name)\n end\n roles.flatten.compact\n end",
"def vm(config, name, *roles)\n roles << name\n config.vm.define name do |m|\n m.vm.host_name = name\n\n #m.vm.provision :shell, :inline => \"apt-get update\"\n #m.vm.provision :shell, :inline => \"apt-get upgrade -y\"\n m.vm.provision :puppet, :module_path => \"modules\" do |puppet|\n puppet.manifests_path = \"manifests\"\n puppet.manifest_file = \"site.pp\"\n\n puppet.facter = {}\n ENV.each do |key, value|\n next unless key =~ /^FACTER_/\n puppet.facter[key.gsub(/^FACTER_/, \"\")] = value\n end\n puppet.facter[\"roles\"] = roles.join(\",\")\n end\n end\nend",
"def create_guild_role(data)\n role_data = data['role']\n server_id = data['guild_id'].to_i\n server = @servers[server_id]\n new_role = Role.new(role_data, self, server)\n server.add_role(new_role)\n end",
"def ansible_galaxy(local)\n venv = File.join local, '..', 'venv'\n roles = File.join local, '..', 'roles'\n file = File.join local, '..', 'galaxy-roles.txt'\n `#{venv}/bin/ansible-galaxy install -r #{file} -p #{roles}`\nend",
"def role\n @manifest_options[:role] || \"\"\n end",
"def arn\n \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":ec2:\"+@region+\":\"+MU::Cloud::AWS.credToAcct(@credentials)+\":instance/\"+@cloud_id\n end",
"def set_stage_roles(config)\n deployment.deploy_to_roles.each do |r|\n \n # create role attributes hash\n role_attr = r.role_attribute_hash\n \n if role_attr.blank?\n config.role r.name, r.hostname_and_port\n else\n config.role r.name, r.hostname_and_port, role_attr\n end\n end\n end",
"def create_guild_role(data)\n role_data = data['role']\n server_id = data['guild_id'].to_i\n server = @servers[server_id]\n new_role = Role.new(role_data, self, server)\n existing_role = server.role(new_role.id)\n if existing_role\n existing_role.update_from(new_role)\n else\n server.add_role(new_role)\n end\n end",
"def role\n @pool.role\n end",
"def define_vm config, role, index, ip, memory = 512\n id = (index + 1).to_s.rjust(3, '0')\n config.vm.define \"#{role}_#{id}\" do |box|\n box.vm.customize [ \"modifyvm\", :id, \"--memory\", memory ]\n box.vm.box = \"centos_6_3\"\n box.vm.box_url = \"https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box\"\n box.vm.network :hostonly, \"192.168.34.#{ip}\", :netmask => \"255.255.255.0\"\n box.vm.host_name = \"#{role.downcase.gsub(/[^a-z0-9]+/, '-')}-#{id}.esi.dev\"\n #box.vm.provision :shell, :path => \"script/bootstrap-vm.sh\"\n box.vm.provision :puppet, :module_path => \"modules\" do |p|\n p.manifests_path = \"manifests\"\n p.manifest_file = \"site.pp\"\n end\n end\nend",
"def create_cluster_role\n @cluster_role_name = \"#{name}-cluster\"\n @cluster_role = new_chef_role(@cluster_role_name, cluster)\n role(@cluster_role_name, :own)\n end",
"def get_server_roles(server_id)\n roles = JSON.parse(Discordrb::API::Server.roles(@bot.token, server_id))\n result = {}\n roles.each do |role|\n result[role[\"name\"]] = role[\"id\"]\n end\n return result\nend",
"def host_and_port\n return roles[:web].servers.first.host, ssh_options[:port] || roles[:web].servers.first.port || 22\n end",
"def role(role)\n @roles = @roles | [@salticid.role(role)]\n end",
"def cluster_servers\n endpoint.config.nodes.map { |h| \"#{h[:host]}:#{h[:port]}\" }\n end",
"def start_new_roles_on_nodes_in_cloud(ips_to_roles)\n Djinn.log_info(\"Starting new roles in cloud with following info: \" +\n \"#{ips_to_roles.inspect}\")\n\n keyname = @creds['keyname']\n num_of_vms = ips_to_roles.keys.length\n roles = ips_to_roles.values\n disks = Array.new(size=num_of_vms, obj=nil) # no persistent disks\n Djinn.log_info(\"Need to spawn up #{num_of_vms} VMs\")\n imc = InfrastructureManagerClient.new(@@secret)\n\n begin\n new_nodes_info = imc.spawn_vms(num_of_vms, @creds, roles, disks)\n rescue AppScaleException => exception\n Djinn.log_error(\"Couldn't spawn #{num_of_vms} VMs with roles #{roles} \" +\n \"because: #{exception.message}\")\n return []\n end\n\n # initialize them and wait for them to start up\n Djinn.log_debug(\"info about new nodes is \" +\n \"[#{new_nodes_info.join(', ')}]\")\n\n add_nodes(new_nodes_info)\n update_hosts_info()\n\n if my_node.is_login?\n regenerate_nginx_config_files()\n end\n\n return new_nodes_info\n end",
"def start_cloud(resource, vm_ips, vm_ip_roles)\n\n puts \"Starting the cloud\"\n \n # SSH keys have already been distributed when machines were monitorized,\n # so we do not have to distribute them again\n \n # Start torque cloud\n return torque_cloud_start(resource, vm_ip_roles)\n\nend",
"def is_hadoop_node settings\n has_role settings, \"hadoop\"\nend",
"def role(name, options = {}, &block)\n final_options = { name: name }.merge(options).merge(scoped_options: scoped_options)\n require_namespace!('role', final_options)\n\n definitions << Matsuri::DSL::Cluster::Role.new(final_options).tap do |role|\n if options[:resources].present? && options[:verbs].present?\n role.resources(options[:resources], names: options[:resource_names], verbs: options[:verbs], api_groups: options[:api_groups])\n end\n\n role.configure(&block)\n end\n end",
"def arn\n \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":elasticache:\"+@region+\":\"+MU::Cloud::AWS.credToAcct(@credentials)+\":cluster/\"+@cloud_id\n end",
"def add_role\n role_name = \"network-#{name}\"\n unless Role.exists?(name: role_name)\n Rails.logger.info(\"Network: Adding role and attribs for #{role_name}\")\n bc = Barclamp.find_key \"network\"\n Role.transaction do\n create_auto_v6_range\n r = Role.find_or_create_by!(name: role_name,\n type: \"BarclampNetwork::Role\", # force\n jig_name: Rails.env.production? ? \"chef\" : \"test\",\n barclamp_id: bc.id,\n description: I18n.t('automatic_by', :name=>name),\n library: false,\n implicit: true,\n milestone: true, # may need more logic later, this is safest for first pass\n bootstrap: false, # don't bootstrap networks anymore.\n discovery: false ) # don't discovery networks anymore.\n RoleRequire.create!(:role_id => r.id, :requires => \"network-server\")\n # The admin net must be bound before any other network can be bound.\n RoleRequireAttrib.create!(role_id: r.id, attrib_name: 'network_interface_maps')\n RoleRequireAttrib.create!(role_id: r.id, attrib_name: 'network-current-config')\n RoleRequireAttrib.create!(role_id: r.id, attrib_name: 'network-wanted-config')\n # attributes for jig configuraiton\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_addresses\",\n :description => \"#{name} network addresses assigned to a node\",\n :map => \"crowbar/network/#{name}/addresses\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_targets\",\n :description => \"#{name} network addresses to be used as ping test targets\",\n :map => \"crowbar/network/#{name}/targets\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_conduit\",\n :description => \"#{name} network conduit map for this node\",\n :map => \"crowbar/network/#{name}/conduit\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_resolved_conduit\",\n :description => \"#{name} network interfaces used on this node\",\n :map => \"crowbar/network/#{name}/resolved_interfaces\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_vlan\",\n :description => \"#{name} network vlan tag\",\n :map => \"crowbar/network/#{name}/vlan\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_team_mode\",\n :description => \"#{name} network bonding mode\",\n :map => \"crowbar/network/#{name}/team_mode\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_use_vlan\",\n :description => \"Whether the #{name} network should use a tagged VLAN interface\",\n :map => \"crowbar/network/#{name}/use_vlan\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_use_team\",\n :description => \"Whether the #{name} network should bond its interfaces\",\n :map => \"crowbar/network/#{name}/use_team\")\n Attrib.create!(:role_id => r.id,\n :barclamp_id => bc.id,\n :name => \"#{role_name}_use_bridge\",\n :description => \"Whether #{name} network should create a bridge for other barclamps to use\",\n :map => \"crowbar/network/#{name}/use_bridge\")\n # attributes for hints\n # These belong to the barclamp, not the role.\n Attrib.create!(:barclamp_id => bc.id,\n :name => \"hint-#{name}-v4addr\",\n :description => \"Hint for #{name} network to assign v4 IP address\",\n :map => \"#{name}-v4addr\",\n :schema => {\n \"type\" => \"str\",\n \"required\" => true,\n \"pattern\" => '/([0-9]{1,3}\\.){3}[0-9]{1,3}/'})\n Attrib.create!(:barclamp_id => bc.id,\n :name => \"hint-#{name}-v6addr\",\n :description => \"Hint for #{name} network to assign v6 IP address\",\n :map => \"#{name}-v6addr\",\n :schema => {\n \"type\" => \"str\",\n \"required\" => true,\n \"pattern\" => '/[0-9a-f:]+/'})\n end\n end\n end",
"def host\n @host ||= 'ec2.amazonaws.com'\n end",
"def credentials\n @credentials ||= GlobalConstant::Aws::Common.get_credentials_for(@role)\n end",
"def credentials\n @credentials ||= GlobalConstant::Aws::Common.get_credentials_for(@role)\n end",
"def right_aws\n cloud_provider.ec2.describe_instances instance_id\n end",
"def set_region(rgn) \n begin\n location = String.new\n \n if rgn =~ /west/\n location = \"us-west-1\"\n @region = \"west\"\n else\n location = \"us-east-1\"\n @region = \"east\"\n end\n \n @fog = Fog::Compute.new(\n :provider => 'AWS',\n :region => location,\n :aws_access_key_id => Chef::Config[:knife][:aws_access_key_id],\n :aws_secret_access_key => Chef::Config[:knife][:aws_secret_access_key]\n )\n\n @right_ec2 = RightAws::Ec2.new(Chef::Config[:knife][:aws_access_key_id], Chef::Config[:knife][:aws_secret_access_key], :region => location)\n\n @right_acw = RightAws::AcwInterface.new(Chef::Config[:knife][:aws_access_key_id], Chef::Config[:knife][:aws_secret_access_key], :region => location)\n return true\n rescue\n return false\n end\n end",
"def server_name_for_role role\n role = role.to_sym\n if servers_by_role[role]\n existing_numbers = servers_by_role[role].collect { |s| s.tags['Name'].split(\"-\").last.to_i }\n next_number = ((1..existing_numbers.count+1).to_a - existing_numbers).first\n else\n next_number = 1\n end\n server_name = \"#{role}-#{next_number}\"\n end",
"def cluster_role(name, options = {}, &block)\n forbid_namespace!('cluster_role', options)\n final_options = { name: name }.merge(options).merge(scoped_options: scoped_options)\n\n definitions << Matsuri::DSL::Cluster::ClusterRole.new(final_options).tap do |role|\n if options[:resources].present? && options[:verbs].present?\n role.resources(options[:resources], names: options[:resource_names], verbs: options[:verbs], api_groups: options[:api_groups])\n end\n\n role.configure(&block)\n end\n end",
"def provider\n 'AWS'\n end",
"def provider\n \"AWS\"\n end",
"def bindTo(entitytype, entityname)\n if entitytype == \"instance_profile\"\n begin\n resp = MU::Cloud::AWS.iam(credentials: @credentials).get_instance_profile(\n instance_profile_name: entityname\n ).instance_profile\n\n if !resp.roles.map { |r| r.role_name}.include?(@mu_name)\n MU::Cloud::AWS.iam(credentials: @credentials).add_role_to_instance_profile(\n instance_profile_name: entityname,\n role_name: @mu_name\n )\n end\n rescue StandardError => e\n MU.log \"Error binding role #{@mu_name} to instance profile #{entityname}: #{e.message}\", MU::ERR\n raise e\n end\n elsif [\"user\", \"group\", \"role\"].include?(entitytype)\n mypolicies = MU::Cloud::AWS.iam(credentials: @credentials).list_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\"\n ).policies\n mypolicies.reject! { |p|\n !p.policy_name.match(/^#{Regexp.quote(@mu_name)}(-|$)/)\n }\n\n if @config['attachable_policies']\n @config['attachable_policies'].each { |policy_hash|\n policy = policy_hash[\"id\"]\n p_arn = if !policy.match(/^arn:/i)\n \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/\"+policy\n else\n policy\n end\n\n subpaths = [\"service-role\", \"aws-service-role\", \"job-function\"]\n begin\n mypolicies << MU::Cloud::AWS.iam(credentials: @credentials).get_policy(\n policy_arn: p_arn\n ).policy\n rescue Aws::IAM::Errors::NoSuchEntity => e\n if subpaths.size > 0\n p_arn = \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/#{subpaths.shift}/\"+policy\n retry\n end\n raise e\n end\n }\n end\n\n if @config['raw_policies']\n raw_arns = MU::Cloud::AWS::Role.manageRawPolicies(\n @config['raw_policies'],\n basename: @deploy.getResourceName(@config['name']),\n credentials: @credentials\n )\n raw_arns.each { |p_arn|\n mypolicies << MU::Cloud::AWS.iam(credentials: @credentials).get_policy(\n policy_arn: p_arn\n ).policy\n }\n end\n\n mypolicies.each { |p|\n if entitytype == \"user\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_user_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\",\n user_name: entityname\n )\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching IAM policy #{p.policy_name} to user #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_user_policy(\n policy_arn: p.arn,\n user_name: entityname\n )\n end\n elsif entitytype == \"group\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_group_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\",\n group_name: entityname\n )\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to group #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_group_policy(\n policy_arn: p.arn,\n group_name: entityname\n )\n end\n elsif entitytype == \"role\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_role_policies(\n role_name: entityname\n )\n\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to role #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_role_policy(\n policy_arn: p.arn,\n role_name: entityname\n )\n end\n end\n }\n else\n raise MuError, \"Invalid entitytype '#{entitytype}' passed to MU::Cloud::AWS::Role.bindTo. Must be be one of: user, group, role, instance_profile\"\n end\n cloud_desc(use_cache: false)\n end",
"def create_role(auth, server_id, name, color, hoist, mentionable, permissions, reason = nil)\n MijDiscord::Core::API.request(\n :guilds_sid_roles,\n server_id,\n :post,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/roles\",\n { color: color, name: name, hoist: hoist, mentionable: mentionable, permissions: permissions }.to_json,\n Authorization: auth,\n content_type: :json,\n 'X-Audit-Log-Reason': reason\n )\n end",
"def list_virtual_machines\n roles = []\n cloud_service = Azure::CloudServiceManagementService.new\n cloud_services = cloud_service.list_cloud_services\n cloud_services.each do |cloud_service|\n request_path = \"/services/hostedservices/#{cloud_service.name}/deploymentslots/production\"\n request = ManagementHttpRequest.new(:get, request_path)\n request.warn = true\n response = request.call\n roles << Serialization.virtual_machines_from_xml(response,cloud_service.name)\n end\n \n vnet_service = Azure::VirtualNetworkManagementService.new\n virtual_networks = vnet_service.list_virtual_networks\n \n roles.each do |role|\n next if role.nil?\n vnet = virtual_networks.select do |network|\n network.name == role.virtual_network_name\n end\n\n role.virtual_network = vnet.first unless vnet.nil? || vnet.empty?\n end\n\n roles.compact\n end",
"def new_auto_scaling \n AWS::AutoScaling.new(:auto_scaling_endpoint => \"autoscaling.#{AMI_REGION}.amazonaws.com\")\nend",
"def guild_role\n\t\t@guild_role\n\tend",
"def instances_for_role(role, state = \"running\")\n instances_for_filter(\"tag:role\", role, state)\n end",
"def fetch_from_ec2_loadbalancer\n instances_for_deploy = []\n loadbalancer lb_webserver, :web\n instances_for_deploy\nend",
"def fetch_from_ec2_loadbalancer\n instances_for_deploy = []\n loadbalancer lb_webserver, :web\n instances_for_deploy\nend",
"def slave?\n role.to_s == \"slave\"\n end",
"def get_server_ip(boxes, hostname='')\n default_server_ip = nil\n boxes.each_with_index do |box, i|\n if not box['role'].nil? and box['role'] == 'server'\n ip = box['ip'] ? box['ip'] : \"#{$ip_prefix}.#{i+1}#{i+1}\"\n default_server_ip = ip if default_server_ip.nil?\n if hostname == \"#{box['name']}-%02d\" % i\n return ip\n end\n end\n end\n return default_server_ip\nend",
"def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.generate_init,\n instance_type: \"t2.small\",\n subnet: self.subnet.driver_id\n )\n end",
"def create\n chef_server_rest.post(\"roles\", self)\n self\n end",
"def get_ec2_values \n cloud[:public_ip][0] = ec2['public_ipv4']\n cloud[:private_ip][0] = ec2['local_ipv4']\n cloud[:provider] = \"ec2\"\nend",
"def kube2iam_params(config)\n {\n 'host' => {\n 'iptables' => true,\n 'interface' => 'eni+'\n },\n 'extraArgs' => {\n 'base-role-arn' => \"arn:aws:iam::#{account_number}:role/\",\n 'default-role' => Create::NodeRoleFinder.call(config)\n }.compact\n }\n end",
"def function_name_role\n {\n 'Type' => 'AWS::IAM::Role',\n 'Properties' => {\n 'ManagedPolicyArns' => [\n 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'\n ],\n 'AssumeRolePolicyDocument' => lambda_service_can_assume_role\n }\n }\n end",
"def provider\n 'AWS'\n end",
"def provider\n 'AWS'\n end",
"def roles\n @run_list.select do |rl|\n rl.start_with?('r_', 'p_', 'base_', 'os_', 'os-')\n end\n end",
"def propagate_roles_needed(task_name) \n \n #All recipes besides server have the same name in their body; thus task_name usually is\n #Recipe.name. However, if you are executing a task that appears\n #as 'server_display' in the dropdown menu, it is actually named 'server' in the \n #recipes and in the database.\n if(task_name!=\"server_display\")\n recipe_to_run=Recipe.find_by_name(task_name) \n else \n recipe_to_run = Recipe.find_by_name(\"server\")\n if !recipe_to_run.role_needed then\n #Check if the recipe chosen to run on this deployment is a predefined recipe\n #that does not require a parameter, i.e. a specific ip_address list.\n #check to see that current_stage has all roles needed for the recipes it has,\n #otherwise propagate them.\n recipe_types = recipe_to_run.server_types #aggregating the server_types for all recipes in this stage\n recipe_types.each{|t| \n if !current_stage.roles.map{|r|r.name}.include?(t.name)then\n \n #propagate a role for every host that fits type t:\n t.hosts.each do |h|\n if(t.name==\"db\")\n @role = current_stage.roles.build({\"no_release\"=>\"0\", \"name\"=>t.name, \"primary\"=>\"1\", \"ssh_port\"=>\"\", \"no_symlink\"=>\"0\", \"host_id\"=>h.id})\n else\n @role = current_stage.roles.build({\"no_release\"=>\"0\", \"name\"=>t.name, \"primary\"=>\"0\", \"ssh_port\"=>\"\", \"no_symlink\"=>\"0\", \"host_id\"=>h.id})\n end\n if(!@role.save)\n RAILS_DEFAULT_LOGGER.error(\"could not save the given role #{t.name} on host #{h.name}\");\n end\n end\n \n end\n \n }\n end \n end\n end",
"def bindTo(entitytype, entityname)\n if entitytype == \"instance_profile\"\n begin\n resp = MU::Cloud::AWS.iam(credentials: @config['credentials']).get_instance_profile(\n instance_profile_name: entityname\n ).instance_profile\n\n if !resp.roles.map { |r| r.role_name}.include?(@mu_name)\n MU::Cloud::AWS.iam(credentials: @config['credentials']).add_role_to_instance_profile(\n instance_profile_name: entityname,\n role_name: @mu_name\n )\n end\n rescue Exception => e\n MU.log \"Error binding role #{@mu_name} to instance profile #{entityname}: #{e.message}\", MU::ERR\n raise e\n end\n elsif [\"user\", \"group\", \"role\"].include?(entitytype)\n mypolicies = MU::Cloud::AWS.iam(credentials: @config['credentials']).list_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\"\n ).policies\n mypolicies.reject! { |p|\n !p.policy_name.match(/^#{Regexp.quote(@mu_name)}-/)\n }\n\n if @config['import']\n @config['import'].each { |policy|\n if !policy.match(/^arn:/i)\n p_arn = \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@config[\"region\"]) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/\"+policy\n end\n retried = false\n begin\n mypolicies << MU::Cloud::AWS.iam(credentials: @config['credentials']).get_policy(\n policy_arn: p_arn\n ).policy\n rescue Aws::IAM::Errors::NoSuchEntity => e\n if !retried\n p_arn = \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@config[\"region\"]) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/service-role/\"+policy\n retried = true\n retry\n end\n raise e\n end\n }\n end\n\n mypolicies.each { |p|\n if entitytype == \"user\"\n resp = MU::Cloud::AWS.iam(credentials: @config['credentials']).list_attached_user_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\",\n user_name: entityname\n )\n if !resp or !resp.attached_policies.map { |p| p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching IAM policy #{p.policy_name} to user #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @config['credentials']).attach_user_policy(\n policy_arn: p.arn,\n user_name: entityname\n )\n end\n elsif entitytype == \"group\"\n resp = MU::Cloud::AWS.iam(credentials: @config['credentials']).list_attached_group_policies(\n path_prefix: \"/\"+@deploy.deploy_id+\"/\",\n group_name: entityname\n )\n if !resp or !resp.attached_policies.map { |p| p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to group #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @config['credentials']).attach_group_policy(\n policy_arn: p.arn,\n group_name: entityname\n )\n end\n elsif entitytype == \"role\"\n resp = MU::Cloud::AWS.iam(credentials: @config['credentials']).list_attached_role_policies(\n role_name: entityname\n )\n\n if !resp or !resp.attached_policies.map { |p| p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to role #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @config['credentials']).attach_role_policy(\n policy_arn: p.arn,\n role_name: entityname\n )\n end\n end\n }\n else\n raise MuError, \"Invalid entitytype '#{entitytype}' passed to MU::Cloud::AWS::Role.bindTo. Must be be one of: user, group, role, instance_profile\"\n end\n end",
"def role_dmtcpsnooze\n $myxp.get_deployed_nodes('capi5k-init')\nend",
"def has_role settings, role, make_security_group=nil\n security_group role if make_security_group\n settings[:user_data][:attributes][:run_list] << \"role[#{role}]\"\nend",
"def accept_role role\n self.roles.push role\n end",
"def vservers\n @vservers=get_endpoint('vservers').keys\n end",
"def add_role_action(external_user, service_id, role)\n rc = @srv_pool.get(service_id, external_user) do |service|\n unless service.running?\n break OpenNebula::Error.new(\n \"Cannot modify roles in state: #{service.state_str}\"\n )\n end\n\n role = service.add_role(role)\n\n break role if OpenNebula.is_error?(role)\n\n service.update\n\n rc = service.deploy_networks(false)\n\n if OpenNebula.is_error?(rc)\n service.set_state(Service::STATE['FAILED_DEPLOYING'])\n service.update\n\n break rc\n end\n\n service.update\n\n add_role(external_user, service, role)\n end\n\n Log.error LOG_COMP, rc.message if OpenNebula.is_error?(rc)\n\n rc\n end",
"def deploy_to_roles(base_roles=self.roles)\n base_roles.dup.select { |role| not self.excluded_hosts.include?(role.host) }\n end",
"def hosts\n @salticid.hosts.select do |host|\n host.roles.include? self\n end\n end",
"def start_cloud(resource, vm_ips, vm_ip_roles)\n\n puts \"Starting the cloud\"\n \n # ...\n\n end",
"def is_cassandra_node settings\n has_role settings, \"cassandra_node\"\n security_group 'cassandra_node' do\n authorize :group_name => 'cassandra_node'\n end\nend",
"def setup_role \n if self.role_ids.empty? \n self.role_ids = [2] \n end\n end"
] | [
"0.6746659",
"0.65605664",
"0.6216241",
"0.6099661",
"0.6055757",
"0.59555304",
"0.59527224",
"0.5915317",
"0.58803904",
"0.5860618",
"0.5837443",
"0.5830239",
"0.57658935",
"0.57559943",
"0.5696148",
"0.56837744",
"0.56789553",
"0.56000584",
"0.555622",
"0.5514585",
"0.550062",
"0.540765",
"0.540765",
"0.5401946",
"0.53941226",
"0.5384383",
"0.5379833",
"0.5364212",
"0.53413016",
"0.53121525",
"0.5303258",
"0.5296864",
"0.52646595",
"0.52487355",
"0.523692",
"0.5234535",
"0.52332574",
"0.5231263",
"0.5228548",
"0.5217648",
"0.5217648",
"0.52134764",
"0.5195454",
"0.5194016",
"0.5184871",
"0.51775414",
"0.51721257",
"0.51691",
"0.51511765",
"0.514284",
"0.51378435",
"0.5136345",
"0.51347375",
"0.5134237",
"0.51329833",
"0.512987",
"0.5129712",
"0.5129561",
"0.5119463",
"0.51172",
"0.51164585",
"0.5114545",
"0.51137227",
"0.51136553",
"0.51136553",
"0.5112269",
"0.5107262",
"0.50988865",
"0.5091044",
"0.50901043",
"0.50843894",
"0.5076829",
"0.50730777",
"0.5070967",
"0.50538003",
"0.50530267",
"0.5052527",
"0.50427926",
"0.50427926",
"0.50372183",
"0.50354236",
"0.50343513",
"0.50324917",
"0.50323397",
"0.5026996",
"0.5024458",
"0.5022327",
"0.5022327",
"0.5009644",
"0.50086904",
"0.4998613",
"0.49938557",
"0.4993798",
"0.49854922",
"0.49846983",
"0.49811795",
"0.49769256",
"0.49759483",
"0.49713728",
"0.4971205",
"0.49540454"
] | 0.0 | -1 |
Migrating this to `authorizerhomerooms` | def authorized_homerooms
if EnvironmentVariable.is_true('ENABLE_HOMEROOM_AUTHORIZATION_V2')
authorizer.homerooms
else
authorizer.allowed_homerooms_DEPRECATED(acknowledge_deprecation: true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized_by(authorizer)\n authorizer.to_s.camelize.constantize # get authorizer loaded\n alias_method :old_users, :users\n alias_method :old_method_missing, :method_missing\n include TransitiveAuthorization::Authorizee::InstanceMethods\n self.cattr_accessor :transitive_authorizer\n self.transitive_authorizer = authorizer\n end",
"def authorization(*args, &block); end",
"def authorizations\n @@authorized_actions ||= {}\n @@authorized_actions\n end",
"def authorization; end",
"def authorized(&block)\n authorizer.authorized(&block)\n end",
"def authorized(&block)\n authorizer.authorized(&block)\n end",
"def authorize\n end",
"def authorize\n end",
"def authorizes(*authorizees)\n TransitiveAuthorization::AuthorizedUser.transitive_authorized_user.class_eval do\n alias_method :old_authorizables_for, :authorizables_for\n alias_method :old_has_role?, :has_role?\n alias_method :old_roles_for, :roles_for\n alias_method :old_method_missing, :method_missing\n include TransitiveAuthorization::Authorizer::InstanceMethods\n self.cattr_accessor :transitive_authorizees\n self.transitive_authorizees ||= Array.new\n self.transitive_authorizees << authorizees\n end\n end",
"def documentation_authorizer\n @documentation_authorizer ||= Documentation.config.authorizer.new(controller)\n end",
"def authorize \n self.make 'authorization' \n end",
"def all_authorisor\n -> enforcer, policies, ctx {\n Fn.compose.( finally_fn.(enforcer),\n Fn.fmap_compose.(policies)\n ).(Success(ctx))\n }.curry\n end",
"def apply_authorities(env)\n DogBiscuits.config.authorities_add_new.each do |authority_name|\n term = authority_name.to_s.singularize.to_sym\n next unless env.attributes.key? term\n env.attributes[term].each do |attr|\n add_new(authority_name.to_s, attr)\n end\n end\n end",
"def create_authorizer\n auth = {}\n [\n # ACCOUNT\n :can_create_account?,\n :can_view_account?,\n :can_renew_account?,\n :can_close_account?,\n # RESOURCE\n :can_create_resource?,\n :can_view_resource?,\n :can_release_resource?,\n :can_modify_resource?,\n # LEASE\n :can_create_lease?,\n :can_view_lease?,\n :can_modify_lease?,\n :can_release_lease?,\n ].each do |m| auth[m] = true end\n OMF::SFA::AM::DefaultAuthorizer.new(auth)\n end",
"def create_authorizer\n auth = {}\n [\n # ACCOUNT\n :can_create_account?,\n :can_view_account?,\n :can_renew_account?,\n :can_close_account?,\n # RESOURCE\n :can_create_resource?,\n :can_view_resource?,\n :can_release_resource?,\n :can_modify_resource?,\n # LEASE\n :can_create_lease?,\n :can_view_lease?,\n :can_modify_lease?,\n :can_release_lease?,\n ].each do |m| auth[m] = true end\n OMF::SFA::AM::DefaultAuthorizer.new(auth)\n end",
"def normalize_author(hsh)\n str = hsh['author']\n tokens = repair_and_tokenize_author_text(str)\n authors = []\n current_auth = []\n begin_auth = 1\n tokens.each {|tok|\n if tok =~ /^(&|and)$/i\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n end\n current_auth = []\n begin_auth = 1\n next\n end\n if begin_auth > 0\n current_auth << tok\n begin_auth = 0\n next\n end\n if tok =~ /,$/\n current_auth << tok\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n current_auth = []\n begin_auth = 1\n end\n else\n current_auth << tok\n end\n }\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth unless auth.strip == \"-\"\n end\n hsh['authors'] = authors\n hsh\n end",
"def authorizer\n current_ability\n end",
"def ach_authorizations(entity_id)\n API::request(:get, \"entities/#{entity_id}/ach_authorizations\")\n end",
"def authorize_leader!\n raise CanCan::AccessDenied if current_user.managed_chapters.count.zero?\n end",
"def author_hash; end",
"def authorize_resource(*args); end",
"def resolved_author; end",
"def authorize(verb); send_or_default(\"authorize_#{verb}\",true) ; end",
"def show\n authorize @orden\n end",
"def host_authorization; end",
"def host_authorization; end",
"def index\n @authorizations = Authorization.all\n end",
"def index\n @authorizations = Authorization.all\n end",
"def index\n authorize Order\n super\n end",
"def normalize_author(hsh)\n str = hsh['author']\n tokens = repair_and_tokenize_author_text(str)\n authors = []\n current_auth = []\n begin_auth = 1\n tokens.each {|tok|\n if tok =~ /^(&|and)$/i\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n end\n current_auth = []\n begin_auth = 1\n next\n end\n if begin_auth > 0\n current_auth << tok\n begin_auth = 0\n next\n end\n if tok =~ /,$/\n current_auth << tok\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth\n current_auth = []\n begin_auth = 1\n end\n else\n current_auth << tok\n end\n }\n if !current_auth.empty?\n auth = normalize_author_name(current_auth)\n authors << auth.strip unless auth.strip == \"-\" || auth.strip.blank?\n end\n hsh['authors'] = authors if !authors.empty?\n normalize('author',hsh)\n hsh\n end",
"def authorized_students(homeroom)\n authorized do\n homeroom.students\n .active\n .includes(:event_notes, :interventions, :homeroom)\n .to_a\n end\n end",
"def subauthorities\n SUBAUTHORITIES.keys\n end",
"def authorizer_map(model_class, application_authorizer = nil)\n application_authorizer ||= mapping.model_authorizer\n map_of :@authorizer_map, model_class, application_authorizer\n end",
"def or_authorisor\n -> enforcer, policies, ctx {\n Fn.compose.( any_finally_fn.(enforcer),\n Fn.map.(-> policy { policy.(ctx) } )\n ).(policies)\n }.curry\n end",
"def authorize_for_all_guests\n # Clear all authorizations and create an allow-all entry\n #ContentAuthorization.transaction do\n update_privacy_level(ContentAuthorization::AuthPrivate)\n clear_accessors\n #end\n end",
"def pre_authorize_cb=(_arg0); end",
"def authorize_author\n redirect_to '/login' unless self.user_access > 1 || current_user.access == 3\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 user_action_on_resource_authorized\n end",
"def type_authorization!()\n @type = TAC_PLUS_AUTHOR\n end",
"def authorised_actions\n if auth_notification\n auth_notification.\n actions.map(&method(:transform_action))\n\n else\n []\n\n end\n end",
"def authorize_for_all\n # Clear all authorizations and create an allow-all entry\n ContentAuthorization.transaction do\n update_privacy_level(ContentAuthorization::AuthPublic)\n clear_accessors\n end\n end",
"def setup_object_auth_method\n self.class.send(:define_method, :object_auth) do |meth|\n authorize send(singular), meth\n end\n end",
"def index\n @admins = Admin.order(:email)\n authorize @admins\n end",
"def marc_sortable_author\n lambda do |record, accumulator|\n accumulator << Marc21Semantics.get_sortable_author(record)\n end\n end",
"def authorizations(params = {})\n scope 'default'\n post('authorizations/', params)\n end",
"def author\n user\n end",
"def index\n @claimppriorauthorizations = Claimppriorauthorization.all\n end",
"def host_authorization=(_arg0); end",
"def host_authorization=(_arg0); end",
"def authored_questions\n Question.find_by_author_id(@id)\n end",
"def authorize_for_none\n # Clear all authorizations and create an allow-all entry\n ContentAuthorization.transaction do\n update_privacy_level(ContentAuthorization::AuthInvisible)\n clear_accessors\n end\n end",
"def update_authorizations(role_ids)\n role_ids = role_ids.map {|i| i.to_i }\n roles = self.roles.collect(&:id) # get current role ids\n roles_to_remove = roles - role_ids\n roles_to_add = role_ids - roles\n\n unless roles_to_remove.blank?\n self.authorizations.where(role_id: roles_to_remove).destroy_all\n end\n\n unless roles_to_add.blank?\n roles_to_add.each do |r|\n self.authorizations.create({:role_id => r})\n end\n email_roles_granted(roles_to_add)\n end\n return {:roles_added => roles_to_add, :roles_removed => roles_to_remove}\n end",
"def check_authorizations!\n raise FphsNotAuthorized unless can_create_in_list?\n\n unless list_class.no_master_association || from_master.allows_user_access\n raise FphsNotAuthorized, 'Master does not allow user access'\n end\n\n raise FphsNotAuthorized, \"No access to #{source_type}\" unless can_access_source_type?\n\n raise FphsNotAuthorized, \"No access to #{assoc_name}\" unless can_access_associated_table?\n end",
"def authorize\n yield AuthorizeMe::RoleDefinition.new(self)\n end",
"def authorized(m)\n m.user == current_user\n end",
"def authorize_pot\n authorize @pot, :contribute?\n end",
"def load_authorities(options)\n return unless options[:authorities]\n\n redis = options.fetch(:redis, redis_connect(options))\n Argot::AuthorityEnricher.new(redis: redis).as_block\n end",
"def authorize_link usr = nil, thing = nil, typ = nil\n what_we_know = case thing.class.name\n when 'Store'\n {:target_id => thing.id, :target_type => 'Store'}\n when 'Location', 'String', 'Fixnum'\n {:target_id => (thing.is_a?(Location) ? thing.id : thing), :target_type => 'Location'}\n else\n {}\n end\n what_we_know.merge!(:user_id => usr.id) if usr\n what_we_know.merge!(:authorization_type => typ) if typ\n if usr && thing && typ\n if Authorization.find_by_authorization_type_and_target_id_and_target_type_and_user_id(typ, what_we_know[:target_id], what_we_know[:target_type], usr.id)\n \"#{usr.login} can #{Authorization.type_hash[typ]} at #{what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\"\n else\n '<span id=\"' + \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\" + '\">' + link_to_remote(\"authorize #{usr.login}#{' (' + usr.name + ') ' unless usr.name.blank?} to #{Authorization.type_hash[typ]} at {what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name}\",\n :url => authorizations_path(:authorization => what_we_know), :update => \"user_#{usr.id}_#{what_we_know[:target_type].downcase}_#{what_we_know[:target_id]}_#{typ}\") + '</span>'\n end\n else\n link_to \"authorize#{' ' + usr.login if usr}#{' (' + usr.name + ')' unless !usr || usr.name.blank?}#{' to ' + Authorization.type_hash[typ] if typ}#{' at ' + what_we_know[:target_type].constantize.send(:find, what_we_know[:target_id]).name if thing}\", new_authorization_path(:authorization => what_we_know)\n end\n end",
"def authored_articles\n Article.where(author: self)\n end",
"def build_authorization(verb, resource_id, date, master_key)\r\n text = \"#{(verb || \"\").downcase}\\ndocs\\n#{(resource_id || \"\")}\\n#{date.downcase}\\n\\n\"\r\n\r\n key = Base64.urlsafe_decode64 master_key\r\n hmac = OpenSSL::HMAC.digest 'sha256', key, text\r\n signature = Base64.encode64(hmac).strip\r\n\r\n return ERB::Util.url_encode \"type=master&ver=1.0&sig=#{signature}\"\r\n end",
"def has_common_coauthor_with(other_authors)\n end",
"def pre_authorize_cb; end",
"def index\n @authorities = Authority.all\n end",
"def index\n @authorities = Authority.all\n end",
"def enter_pahma_authorizations(test_data)\n authorizations = test_data[UseOfCollections::AUTHORIZATION_GRP.name] || [UseOfCollections.empty_authorization]\n prep_fieldsets_for_test_data([fieldset(UseOfCollections::AUTHORIZATION_GRP.name)], authorizations)\n authorizations.each_with_index do |auth, index|\n enter_auto_complete(authorized_by_input(index), authorized_by_options(index), auth[UseOfCollections::AUTHORIZED_BY.name], 'PAHMA Persons')\n wait_for_element_and_type(authorization_date_input(index), auth[UseOfCollections::AUTHORIZATION_DATE.name])\n hit_enter\n wait_for_element_and_type(authorization_note_input(index), auth[UseOfCollections::AUTHORIZATION_NOTE.name])\n wait_for_options_and_select(authorization_status_input(index), authorization_status_options(index), auth[UseOfCollections::AUTHORIZATION_STATUS.name])\n end\n end",
"def authorship_filter\n unless helpers.can_delete_phrase? @phrase\n flash[:danger] = 'You are not author of the phrase!'\n redirect_to root_path\n end\n end",
"def searchauthor\n end",
"def authorization_object\n nil\n end",
"def authorization_object\n nil\n end",
"def authorized_for_roles(*args)\n # From: http://stackoverflow.com/a/6076035/999973\n # args.any? { |role_name| ROLES.include? role_name }\n # ROLES = %w[admin moderator editor author banned] in user model\n # calling it:\n # before_filter(only: [:edit, :update, :destroy]) {|c| c.authorized_for_roles \"admin\", \"editor\"}\n \n # args.any? { |role_name| current_user.role == role_name }\n \n\n unless signed_in?\n self.current_user = User.create( name: \"Guest\" )\n redirect_to(root_path) unless args.any? { |role_name| current_user.role == role_name }\n self.current_user = nil\n return\n end\n\n redirect_to(root_path) unless args.any? { |role_name| current_user.role == role_name }\n end",
"def role_symbols\n (roles || []).map {|r| r.name.to_sym} + [self.is_author? ? :author : []].flatten\n end",
"def index\n @claimauthorizations = Claimauthorization.all\n end",
"def author_count\n revisions = Marginalia.revisions(params[:id])\n authors = []\n revisions.collect {|rev| authors << rev['user']}\n authors.uniq!\n render :text => authors.length\n end",
"def show\n authorize @primer\n end",
"def reply_author(reply)\n\t\tlogged_in? && current_user.id == reply.user_id\n\tend",
"def author_login\r\n user.login if user\r\n end",
"def authorization\r\n@env['HTTP_AUTHORIZATION'] ||\r\n@env['X-HTTP_AUTHORIZATION'] ||\r\n@env['X_HTTP_AUTHORIZATION'] ||\r\n@env['REDIRECT_X_HTTP_AUTHORIZATION']\r\nend",
"def reply_author(reply)\n user_signed_in? && current_user.id == reply.user_id\n end",
"def authorization(id)\n get \"/authorizations/#{id}\"\n end",
"def authorize_users\n authorize :user\n end",
"def author; end",
"def author\n ['@',self.user.id, self.user.name.split().join].join('-')\n end",
"def author\n yield if block_given?\n end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def authorize\n params[:access_token] ||= params[:oauth_token]\n super\n end",
"def authors\n space_users.all({ :role.not => :member }).collect { |m| m.user }\n end",
"def auth\n end",
"def auth\n end",
"def add_authorizing_css_classes!(options, action, object)\r\n roles = object.role_authorizing(action).expand\r\n \r\n options[:class] ||= ''\r\n options[:class] = options[:class].split(/ /)\r\n options[:class] << 'visible-for' << roles.map(&:to_css_class).join(' ')\r\n options[:class] = options[:class].flatten.uniq.join(' ')\r\n end",
"def index\n authorize Authentication, :index?\n @authentications = policy_scope(Authentication)\n end",
"def list\n response = Tiptaplab.api.make_call(\"users/authorizations\")\n response.keys\n end",
"def authorization_mode; end",
"def to_authoring_hash\n hash = to_hash\n hash[:id] = id\n hash[:linked_interactive_id] = linked_interactive_id\n hash[:linked_interactive_type] = linked_interactive_type\n hash[:aspect_ratio] = aspect_ratio\n hash[:interactive_item_id] = interactive_item_id\n hash[:linked_interactive_item_id] = linked_interactive_item_id\n # Note that linked_interactives is independent from linked_interactive_id and linked_interactive_type fields\n hash[:linked_interactives] = linked_interactives_list\n hash\n end",
"def implicit_authorization_target\n # no-op\n end",
"def index\n # @users = User.all\n # authorize @users \n @users = policy_scope(User)\n authorize @users\n end",
"def show\n authorize! :ver, @usuario_prestamo\n end",
"def authorized_by(user)\n user.id == self.id\n end",
"def author_word_counts\n joined_authors.map { |author| [author.username, word_count_for(author)] }.sort_by{|a| -a[1] }\n end"
] | [
"0.6965431",
"0.63082737",
"0.62287205",
"0.61290187",
"0.59146535",
"0.59146535",
"0.5896997",
"0.5896997",
"0.58728963",
"0.5806797",
"0.5795525",
"0.57881975",
"0.57546115",
"0.5666361",
"0.5666361",
"0.5648755",
"0.563015",
"0.5618461",
"0.559866",
"0.55767435",
"0.55689144",
"0.5547122",
"0.55168605",
"0.5514433",
"0.55123913",
"0.55123913",
"0.55042624",
"0.55042624",
"0.54859656",
"0.5483117",
"0.5477015",
"0.54288787",
"0.54269946",
"0.5426897",
"0.5425699",
"0.54193",
"0.54161674",
"0.54110706",
"0.54110706",
"0.5407406",
"0.53895694",
"0.5338256",
"0.53305554",
"0.5308145",
"0.5304432",
"0.52981764",
"0.52947164",
"0.5285539",
"0.52797794",
"0.5277559",
"0.5277559",
"0.5267103",
"0.52428347",
"0.5235791",
"0.5231442",
"0.5229533",
"0.52289456",
"0.5223374",
"0.52134037",
"0.5203893",
"0.51898223",
"0.51843226",
"0.5183318",
"0.51832426",
"0.51715964",
"0.51715964",
"0.51705706",
"0.51701945",
"0.5169257",
"0.5169206",
"0.5169206",
"0.5157067",
"0.51485425",
"0.5148079",
"0.51437604",
"0.5128376",
"0.512752",
"0.51219344",
"0.5119413",
"0.5099347",
"0.50931484",
"0.508976",
"0.5083372",
"0.5081997",
"0.50810105",
"0.5078316",
"0.5074235",
"0.5069298",
"0.50604576",
"0.50604576",
"0.50599533",
"0.505227",
"0.5049274",
"0.50317734",
"0.5031733",
"0.5030297",
"0.5029398",
"0.5028279",
"0.5025906",
"0.50207233"
] | 0.7283598 | 0 |
Query for students through homeroom, but scoped within studentlevel authorization check. This is essentially doublewrapping the authorizaiton checks; the homeroom authorization check should separately only allow access when the educator can access all students in the homeroom. | def authorized_students(homeroom)
authorized do
homeroom.students
.active
.includes(:event_notes, :interventions, :homeroom)
.to_a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def school_students(query={})\n self.simple_client.get(\"/api/v1/schools/my/students?#{query.to_query}\")\n end",
"def query_student(hQuery)\n result = []\n\n hQuery[:status] = :active unless hQuery.key?(:status)\n\n @data[:students].each do |hValue|\n elem = hValue\n hQuery.each do |query_key, query_value|\n elem = nil if not_in_query?(hQuery, hValue, query_key, query_value)\n end\n result << elem if elem\n end\n result\n end",
"def students\n filters = []\n filters.push(\"{SCHOOL_TFPID} = '#{goddamn_school}'\") if goddamn_school\n Student.some(\n shard: self.goddamn_city,\n sort: [\"Name\", :asc],\n filterByFormula: \"AND(#{filters.join(',')})\"\n )\n end",
"def index\n if current_user.admin? or current_user.editor? #checks if user is admin, if so displays all of the students in database.\n @students = Student.all\n if params[:search]\n @students = Student.search(params[:search]).order(\"created_at DESC\")\n else\n @students = Student.all.order('created_at DESC')\n end\n elsif user_signed_in?\n @students = Student.all.where(:user_id => current_user.id) #Only displays the the users student. \n end\n\n\n authorize @students\n end",
"def my_students(query={})\n self.simple_client.get(\"/api/v1/students?#{query.to_query}\")\n end",
"def show\n @user = User.shod(params[:id])\n @student = @user.student\n @employee = User.where(role: 'Employee').take\n authorize! :read, @user\n end",
"def students\n if current_user.is_admin?\n @students= User.find(:all, :conditions => \"is_teacher = '0' and is_admin = '0'\")\n respond_to do |format|\n format.xml { render :xml => @students }\n end\n else\n respond_to do |format|\n format.xml { render :text => \"error\" }\n end\n end\n end",
"def authorized_homerooms\n if EnvironmentVariable.is_true('ENABLE_HOMEROOM_AUTHORIZATION_V2')\n authorizer.homerooms\n else\n authorizer.allowed_homerooms_DEPRECATED(acknowledge_deprecation: true)\n end\n end",
"def set_hs_students_from_housing\n high_school_students_from_housing = CeqrData::ScaHousingPipelineByBoro.version(\n data_package.table_for(\"sca_housing_pipeline_by_boro\")\n ).high_school_students_from_new_housing_by_boro(project.borough)\n\n hs_students = high_school_students_from_housing.map{|s| s[:hs_students]}\n\n self.hs_students_from_housing = hs_students.first\nend",
"def show\n authorize @institute\n @admins = User.where(role:3,institute_id: @institute.id)\n @students = User.where(role:1,institute_id: @institute.id)\n end",
"def index\n \n parent_user = User.find( params[:parent_id] )\n\n\t# check that the issuer of the request has both the username and ID of the parent, prevent attack\n if params[:parent_login].gsub(/ /,'') != parent_user.login.gsub(/ /,'')\n \tlog_attack \"Student index() for parent \" + params[:parent_id] + \" : \" + params[:parent_login] + \" - parent_user.login = \" + parent_user.login \t\n respond_to do |format|\n format.xml { render :xml => errorRsp( \"Security error\") }\n end\n \treturn\n end\n \n \n if params[:parent_id] != nil\n @students = Student.find_all_by_parent_id(params[:parent_id], \n :conditions => { :status => [ \"active\" ] } )\n end\n \n \n if params[:admin_list] != nil\n @students = Student.find_all_by_status( [ \"active\", \"suspended\" ] )\n end\n \n respond_to do |format|\n format.xml { render :xml => @students }\n end\n end",
"def index\n if logged_as_teacher?\n @sidequest= Sidequest.new\n @sidequests = Sidequest.where(teacher_id: session[:user_id])\n end\n if logged_as_student?\n student = Student.find(session[:user_id])\n progres = student.progre\n @sidequests = Sidequest.where(level: progres.lvl, finished: false)\n end\n end",
"def index\n if current_user.roles == 'admin' or current_user.roles == 'editor' #checks if user is admin, if so displays all of the students in database.\n @emergency_contacts = EmergencyContact.all\n elsif user_signed_in?\n @emergency_contacts = EmergencyContact.all.where(:user_id => current_user.id) #Only displays the the users student. \n else\n @emergency_contacts = EmergencyContact.all\n end\n authorize @emergency_contacts\n end",
"def index\n if user_signed_in?\n if current_user.role != 2\n redirect_to root_path\n else\n @institute_user = InstituteUser.find_by user_id: current_user.id\n @institute = Institute.find(@institute_user.institute_id)\n #@students = Student.all\n\n @query = Student.where(\"institute_id = ?\", @institute.id).ransack(params[:q])\n @institute_students = @query.result \n end\n else\n redirect_to root_path\n end\n end",
"def index\n @studies = Study.find_studies_with_details(current_user.superadmin? ? nil : current_user&.id)\n @study_statistics_by_id = Study.get_study_statistics(studies: @studies)\n authorize! :read, StudyCompletion\n end",
"def hals\n @course = Course.find(params[:id])\n # don't show any private hals\n @hals = @course.hals.not_private\n end",
"def is_authorized_for_student(student)\n return true if self.districtwide_access?\n\n return false if self.restricted_to_sped_students && !(student.program_assigned.in? ['Sp Ed', 'SEIP'])\n return false if self.restricted_to_english_language_learners && student.limited_english_proficiency == 'Fluent'\n return false if self.school.present? && self.school != student.school\n\n return true if self.schoolwide_access? || self.admin? # Schoolwide admin\n return true if self.has_access_to_grade_levels? && student.grade.in?(self.grade_level_access) # Grade level access\n return true if student.in?(self.students) # Homeroom level access\n false\n end",
"def show\n @teacher = Teacher.find(params[:id])\n @students = @teacher.students.order('full_name ASC')\n @students_at_school = Student.where(school_id: @teacher.school_id).order('full_name ASC')\n @students_not_in_roster = Student.where(school_id: @teacher.school_id).where.not(id: @teacher.students).order('full_name ASC')\n\n #Whenever this page is visited, it updates the roster for the admin.\n if @teacher.admin\n\n #https://stackoverflow.com/questions/3343861/how-do-i-check-to-see-if-my-array-includes-an-object\n @students_at_school.each do |student|\n unless @students.include?(student)\n @teacher.students << Student.find(student.id)\n end\n end\n \n @students = @students_at_school\n @students_not_in_roster = []\n else\n # add student case\n if params[:add_student] && (params[:add_student_id] != nil)\n @teacher.students << Student.find(params[:add_student_id])\n redirect_to @teacher\n # remove student case\n elsif params[:remove_student] && (params[:remove_student_id] != nil)\n @teacher.students.delete(Student.find(params[:remove_student_id]))\n redirect_to @teacher\n end\n end\n end",
"def index\n authorize Student\n if User.find_by_email(current_user.email).provider == 'facebook' and Student.find_by_email(current_user.email).education == 'DUMMY'\n redirect_to edit_student_path(Student.find_by_email(current_user.email)), notice: 'Please fill out details first !'\n end\n\n @students = Student.all\n # authorize Student\n end",
"def restrict_to_student\n # Get the instructor the message is headed to\n instructor = Instructor.find_by_id params[:user_id]\n\n # Get all instructors that this student has been taught by.\n #\n # SELECT * FROM users JOIN courses ON courses.instructor_id = users.id JOIN histories ON\n # histories.course_id = courses.id WHERE users.type = 'Instructor' AND histories.student_id = id\n #\n # This translates to selecting all instructors that have taught a course that is associated\n # with a history that belongs to the student.\n instructors = Instructor.joins(courses: :histories).where(histories: {user: @auth_user})\n\n # Redirect if the target instructor is not in the list of instructors\n redirect_to messages_path unless instructors.include? instructor\n end",
"def index\n @students = params[:query].present? ? Student.find_by_query(params[:query]) : Student.all_students\n end",
"def index\n @admin_students = Admin::Student.all\n if @admin_classroom.present?\n @admin_students = @admin_classroom.students\n end\n \n end",
"def student_and_homeroom_grade_levels_now(school_id)\n return [] if @educator.homeroom.nil?\n homeroom_grade = @educator.homeroom.grade\n student_grades = @educator.homeroom.students\n .where(school_id: school_id)\n .active\n .map(&:grade)\n\n ([homeroom_grade] + student_grades).uniq\n end",
"def students # Want: student id and student names on Users Table\n return User.joins(:sections).where(:sections => {:id => self.id}).all\n end",
"def is_authorized_for_student?(student)\n begin\n return true if @educator.districtwide_access?\n\n return false if @educator.restricted_to_sped_students && !(student.program_assigned.in? ['Sp Ed', 'SEIP'])\n return false if @educator.restricted_to_english_language_learners && student.limited_english_proficiency == 'Fluent'\n return false if @educator.school_id.present? && student.school_id.present? && @educator.school_id != student.school_id\n\n return true if @educator.schoolwide_access? || @educator.admin? # Schoolwide admin\n return true if @educator.has_access_to_grade_levels? && student.grade.in?(@educator.grade_level_access) # Grade level access\n return true if student.in?(@educator.students) # Homeroom level access\n return true if student.in?(@educator.section_students) # Section level access\n rescue ActiveModel::MissingAttributeError => err\n # We can't do authorization checks on models with `#select` that are missing\n # fields. If this happens, it's probably because the developer is trying to\n # to optimize a query. The authorization layer could only recover by making more\n # queries, so instead we raise and force the developer to figure out how to resolve.\n #\n # See `Authorizer.student_fields_for_authorization` and `Authorizer.educator_field_for_authorization`\n # to see what fields are required on each model.\n raise err\n end\n false\n end",
"def students\n Rollcall::Student.find_all_by_school_id schools\n end",
"def students_for_grade_level_next_year_json\n params.require(:workspace_id)\n params.require(:school_id)\n params.require(:grade_level_next_year)\n school_id = params[:school_id].to_i\n grade_level_next_year = params[:grade_level_next_year]\n\n # Check authorization by grade level, differently than normal.\n students = queries.authorized_students_for_next_year(school_id, grade_level_next_year)\n students_json = ClassListQueries.students_as_json(students)\n\n # educator names\n educators_json = Educator.where(school_id: school_id).as_json(only: [:id, :full_name])\n\n render json: {\n students: students_json,\n educators: educators_json,\n current_educator_id: current_educator.id\n }\n end",
"def index\n @q = current_user.houses.ransack(params[:q])\n @houses = @q.result(distinct: true).page params[:page]\n #@houses = current_user.houses.all.page params[:page]\n authorize @houses\n end",
"def authorized_students_for_next_year(school_id, grade_level_next_year)\n grade_level_now = GradeLevels.new.previous(grade_level_next_year)\n return [] unless is_authorized_for_grade_level_now?(school_id, grade_level_now)\n\n # Query for those students (outside normal authorization rules)\n Student.active.where({\n school_id: school_id,\n grade: grade_level_now\n })\n end",
"def students \n sk = Sektion.where(:teacher_id => self.id).map(&:id)\n sids = StudentRoster.where(:sektion_id => sk).map(&:student_id).uniq\n return Student.where(:id => sids)\n end",
"def guardian_students\n id=session[:user_id]\n @guardian=MgGuardian.find_by(:mg_user_id=>\"#{id}\")\n logger.info(\"=================================================\")\n logger.info(id)\n @sql = \"SELECT S.first_name ,S.last_name,S.admission_number, S.id from mg_students S,mg_guardians G ,mg_student_guardians M Where M.has_login_access=1 And M.mg_guardians_id = #{@guardian.id} And S.id = M.mg_student_id and G.id = M.mg_guardians_id\"\n\n @StudentListQuery=MgStudent.find_by_sql(@sql)\n\n render :layout => false\nend",
"def students\n self.course_person.all(:type => \"student\").persons\n end",
"def list_students_by(year=Date.today.to_s[0,4])\n\t\t#pesquisar por ano e depois pedir os alunos\n\n\t\tclassroom = Classroom.find(:first, :conditions => \"year='#{year}' AND name='#{self.name}'\" )\t\t\n\t\treturn classroom.students\n\tend",
"def home\n @teacher = current_teacher\n @school = School.find( current_teacher.school_id)\n @first_login = params[:first_login] != nil\n @first_home = params[:first_home] != nil\n @view_all = params[:view_all] != nil\n @my_students = Student.where(id: Session.where(session_teacher: @teacher.id).group('session_student').order('count(*)').select('session_student').limit(8))\n @all_students = Student.where(school_id: current_teacher.school_id).order( 'full_name ASC')\n end",
"def index\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n\n @students = $selected_course.students.collect{|student| {name: student.first + ' ' + student.last, student_id: student.id }}\n end",
"def index\n if admin_user\n @classrooms = Classroom.where(school_id: admin_user)\n else\n @classrooms = Classroom.where(user_id: current_user)\n end\n end",
"def students\n course_enrollments.where(course_role: CourseRole.student).map(&:user)\n end",
"def students\n students = self.users.where(\"participants.role_id = 4 and accepted = 2\").order('lastname').all\n return students\n end",
"def index\n authorize! :creat, Administrator\n hospital = Hospital.findn(params[:hospital_id])\n @administrators = hospital.administrators\n end",
"def nest\n authorize :big_wedgie\n @patients=User.find(:all,:conditions=>{:role=>5,:hatched=>false}, :order => \"family_name,given_names\")\n render :layout=>'layouts/standard'\n end",
"def require_student\n redirect_to root_path unless @auth_user && @auth_user.type == 'Student'\n end",
"def student_commitments\n shard_id = goddamn_city\n filters = [\"NOT(NOT({By When}))\", \"NOT({Complete?})\", \"NOT(NOT({WHO}))\"]\n filters.push(\"{SCHOOL_TFPID} = '#{goddamn_school}'\") if goddamn_school\n Commitment.some(\n shard: shard_id,\n sort: [\"By When\", :asc],\n filterByFormula: \"AND(#{filters.join(',')})\"\n )\n end",
"def index\n @user = User.find(@current_user.id)\n @schools = School.all\n if @current_user.usertype == 2\n @school = School.find(SchoolUser.find_by!(:user_id => @current_user.id))\n elsif @current_user.usertype == 3\n @student = Student.find_by!(:user_id => @current_user.id)\n elsif @current_user.usertype == 4\n @ngo = Ngo.find(NgoUser.find_by!(:user_id => @current_user.id))\n end\n @education_levels = EducationLevel.all\n end",
"def index\n if params[:scope] == \"students\"\n @users = User.students.page(params[:page]).order(sort_column + \" \" + sort_direction)\n authorize! :list, :students\n elsif params[:scope] == \"advisors\"\n @users = User.advisors.page(params[:page]).order(sort_column + \" \" + sort_direction)\n authorize! :list, :advisors\n elsif params[:scope] == \"professors\"\n @users = User.professors.page(params[:page]).order(sort_column + \" \" + sort_direction)\n authorize! :list, :professors\n elsif params[:scope] == \"gods\"\n @users = User.gods.page(params[:page]).order(sort_column + \" \" + sort_direction)\n authorize! :list, :gods\n else\n @users = User.accessible_by(current_ability, :index).order(sort_column + \" \" + sort_direction).page(params[:page])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @users }\n end\n end",
"def manager_index \n # Get all departments\n @university = current_user.university\n @departments = @university.departments\n\n # Create a hash with key is department and value is all students object\n @department_students = Hash.new\n @departments.each do |department|\n @department_students[department] = Array.new\n department.users.each do |user|\n if user.role == 'Student'\n @department_students[department].push user\n end\n end\n end\n end",
"def editb\n @teacher = Teacher.find(params[:id])\n @students = @teacher.students.order('full_name ASC')\n @students_at_school = Student.where(school_id: @teacher.school_id).order('full_name ASC')\n @students_not_in_roster = Student.where(school_id: @teacher.school_id).where.not(id: @teacher.students).order('full_name ASC')\n end",
"def show\n #avoid users to see other students courses\n if user_signed_in?\n redirect_to courses_path if !@course.users.include?(current_entity)\n elsif teacher_signed_in?\n redirect_to courses_path if @course.teacher != current_entity\n end\n # redirect_to root_path if current_user.teacher? && !@course.users.include?(current_user)\n # @lessons = Lesson.where(course_id: (params[:id])).order('date DESC')\n end",
"def semList\n @semesters = Semester.all\n authorize @semester\n end",
"def filtered_students\n group_id ? students_from_group(group_id) : course.course_users.student\n end",
"def is_authorized s, rdf_type, allowed_groups\n @authorizations ||= {}\n if @authorizations.has_key? [s, rdf_type, allowed_groups]\n @authorizations[s, rdf_type, allowed_groups]\n else\n\n authorized_query \"ASK WHERE { <#{s}> a <#{rdf_type}> }\", allowed_groups\n end\nend",
"def set_homily\n \n @homily = current_user.homilies.find_by(id: params[:id])\n \n end",
"def index\n if current_user.role.title == 'admin'\n @students = Student.all\n @studentsSorted = @students.sort_by{|s| s[:id]}.reverse\n @groups = Group.all \n elsif current_user.teacher.nil?\n @students = []\n @groups = []\n else\n @students = current_user.teacher.students\n @students.sort! { |a,b| a.groups.where(\"group.idTeacher = ?\", current_user.teacher.id)[0].name.downcase <=> b.groups.where(\"group.idTeacher = ?\", current_user.teacher.id)[0].name.downcase }\n @groups = current_user.teacher.groups\n\n #current_user.teacher.students.each do |s|\n # if (!s.group.nil? && !@groups.include?(s.group))\n # @groups.push(s.group)\n # end\n #end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n if params[:student_id]\n @enrollments = Enrollment.where student_id: params[:student_id]\n @student = Student.find params[:student_id]\n else\n @enrollments = Enrollment.all\n end\n\n end",
"def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def set_student\n @student = Student.find params[:id]\n authorize @student\n end",
"def can_access_student( student)\n # 2 ways to access all student: admin or access_all flag\n if (is_admin? || current_teacher.access_all_students)\n return true\n end\n\n # last gasp: check roster of accessible students\n find_student = RosterStudent.where( teacher_id: current_teacher.id, student_id: student.id)\n if ! find_student.blank?\n return true\n end\n\n false # nope - teacher cannot access this student's data\n end",
"def scoped_collection\n\t\t\tStory.includes(:students)\n\t\tend",
"def index\n @class_rooms = ClassRoom.where(user_id: current_user.id).pluck(:id)\n if params[:is_student].present?\n @class_rooms = current_user.class_rooms.pluck(:id)\n end\n\n if current_user.role == \"groups\"\n @class_rooms = current_user.group.class_room_id\n end\n\n if params[:class_room_id].present?\n @study_cases = StudyCase.where(class_room_id: params[:class_room_id]).order(created_at: :desc).page params[:page]\n else\n @study_cases = StudyCase.where(\"study_cases.class_room_id in (?)\", @class_rooms).order(created_at: :desc).page params[:page]\n end\n end",
"def searchByProf\n if params['teacher_id'] != \"0\" then\n theses = Thesis.where(:teacher_id => params['teacher_id']).includes([:teacher])\n else\n theses = Thesis.includes([:teacher]).all\n end\n json_response(theses.to_json(include: [:teacher]))\n end",
"def students_in_classrooms\n self.classrooms.students\n end",
"def index\n if current_user.district_id and !current_user.admin?\n district = District.find(current_user.district_id)\n @hes = district.hes\n else\n @hes = He.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hes }\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",
"def get_students\n registrations.select{|r| !r.instructor}.map{|r| r.user}\n end",
"def show\n authorize! :read, @student_book\n @student = @student_book.student\n end",
"def index_user\n p \"*\" * 50\n p \"index_user\"\n if current_user.status == \"teacher\" || current_user.admin?# && !current_user?(user)\n user_id = current_user.id\n @user = User.find(user_id)\n @exercises = Exercise.where(user_id: @user.id)\n elsif current_user.status == \"student\"\n redirect_to(current_user)\n end\n \n end",
"def current_user_is_student\n if !current_user || current_user.role != 'student'\n head(403)\n end\n end",
"def qualified_student\n @company = Company.find(params[:id])\n @placement_exam = PlacementExam.find(params[:exam_id])\n @score = StudentScore.where(placement_exams_id: @placement_exam)\n @student_score = @score.where(is_qualify: true)\n end",
"def high_school_students_from_new_housing_by_boro(project_borough)\n @dataset.select(:borough, Sequel[:new_students].as(:hs_students)).where(borough: project_borough)\n end",
"def search\n searcher = @admin || @user\n query = params[:query]\n if query.blank?\n redirect_to(:action => 'index', :admin_id => @admin.id)\n else\n query.strip!\n\n case params[:type]\n when 'student' then\n @students = Student.students_of_teacher(searcher).search_data(query, filtered_params)\n when 'teacher' then\n @teachers = searcher.children.unblocked.search_data(query, filtered_params)\n else\n @students = Student.students_of_teacher(searcher).search_data(query, filtered_params)\n @teachers = searcher.children.unblocked.search_data(query, filtered_params)\n end\n end\n end",
"def students\n @courses = Course.where(\"teacher_id=?\",session[:user].teacher_id)\n student_ids = Array.new\n @courses.each{ |c|\n student_ids.push(c.courseStudents)\n }\n student_ids.each{ |array|\n array.each{ |student|\n @students.push(student)\n }\n }\n @students.uniq!\n end",
"def index\n if coordinator? || admin?\n @groups = Group.all\n elsif professor?\n @groups = Group.where(course_id: Course.where(professor_id: current_user.id).all.ids ).all\n elsif student?\n @groups = User.find(current_user.id).groups.references( :students ).where( students: { user_id: current_user.id })\n\n end\n end",
"def clinical_managers\n\t\tPerson.find(:all, \n\t\t\t\t\t\t\t\t:conditions => \"people.position = 'Clinical Manager' AND house_id = #{self.id}\", \n\t\t\t\t\t\t\t\t:joins => :houses, \n\t\t\t\t\t\t\t\t:order => \"last_name, first_name ASC\")\n\tend",
"def course_students\n return student_terms.find_all_by_term_type(\"Course\")\n end",
"def show_lawyer_list\n authorize!(:show_lawyer_list,current_user) unless current_user.role?:secretary\n #session[:verified_secretary_id1] = params[:service_provider_id]\n if params[:search].nil?\n @employees = Employee.paginate :page => params[:page], :order => 'employees.created_at DESC', :per_page=>20, :include=>[:user=>[:role,:service_provider_employee_mappings]]\n else\n @employees = Employee.get_employees(params)\n end\n end",
"def index\n if current_user.admin? \n @search = SHistorySearch.new(params[:search])\n @s_histories = @search.scope\n\n else\n @staffid= Profile.where(:user_id => current_user.id)\n @typeent= TypeEnt.where(:description => \"Annual Leave\")\n @s_histories = SHistory.where(:staff_id => @staffid, :type_ent => @typeent)\n end\n\n end",
"def get_matching_students\n\t\tstudent\n\tend",
"def index\n @enrollments = Enrollment.joins(:course, :student).select('enrollments.id, enrollments.course_id, courses.course_name, courses.semester, students.first_name, students.last_name, enrollments.student_id').reorder('last_name ASC')\n if (params.has_key?(:semester))\n if (params[:semester] != 'all')\n @enrollments = @enrollments.where(courses: { semester: params[:semester] })\n end\n end\n\n if current_student\n @enrollments = @enrollments.where(enrollments: { student_id: current_student.id })\n end\n end",
"def reading_debug(cohort_options = {})\n grade_now = cohort_options.fetch(:grade_now, nil)\n school_id_now = cohort_options.fetch(:school_id_now, nil)\n students = authorized do\n cohort_students = Student.active\n cohort_students = cohort_students.where(grade: grade_now) if grade_now.present?\n cohort_students = cohort_students.where(school_id: school_id_now) if school_id_now.present?\n cohort_students.to_a\n end\n groups = ReadingQueries.new.groups_for_grid(students)\n [students, groups]\n end",
"def index\n unless (logged_in_as_admin? || logged_in_as_student?)\n flash[:danger] = \"Por favor, realize o login.\"\n redirect_to root_path\n else\n @students = Student.paginate(page: params[:page])\n end\n end",
"def with_access_to_teams_with_any_role\n if c_level?\n organization.teams\n else\n TeamMember.includes(:team).where(user: self).collect(&:team)\n end\n end",
"def search\n @lawyer = User.first\n expertise = Expertise.find_by_id(params[:id])\n @users = UserExpertise.where(expertise_id: expertise)\n end",
"def index\n# authorize! :index, Observation\n if current_user.has_role? :teacher\n @observations = Observation.for_teacher(current_user).complete.most_recent.paginate(:page => params[:page], :per_page => 10)\n elsif current_user.has_role? :principal\n if !current_user.p_school.nil?\n if params[:my_observations]\n @observations = current_user.p_observations.most_recent.filter(params.slice(:active, :for_content_area, :for_grade, :for_school_year, :teacher_search)).paginate(:page => params[:page], :per_page => 10)\n else\n @observations = Observation.for_school(current_user.p_school).most_recent.filter(params.slice(:active, :for_content_area, :for_grade, :for_school_year, :teacher_search)).paginate(:page => params[:page], :per_page => 10)\n end\n else\n flash[:error] = \"You are not currently assigned to a school\"\n redirect_to root_url\n end\n elsif current_user.has_role? :specialist\n if params[:my_observations]\n @observations = Observation.for_specialist(current_user).most_recent.filter(params.slice(:active, :for_school, :for_content_area, :for_grade, :for_school_year, :teacher_search)).paginate(:page => params[:page], :per_page => 10)\n else\n @observations = Observation.most_recent.filter(params.slice(:active, :for_school, :for_content_area, :for_grade, :for_school_year, :teacher_search)).paginate(:page => params[:page], :per_page => 10)\n end\n else\n @observations = Observation.most_recent.filter(params.slice(:active, :for_school, :for_content_area, :for_grade, :for_school_year, :teacher_search)).paginate(:page => params[:page], :per_page => 10)\n end\n \n # School Year Dropdown list\n current_year = Date.current.year\n if Date.current < Date.new(current_year,7,1)\n latest_year = current_year-1\n else\n latest_year = current_year\n end\n \n @year_list = []\n while latest_year >= 2009\n @year_list.push(\"#{latest_year}-#{latest_year+1}\")\n latest_year-=1\n end\n \n @schools = School.active\n end",
"def index\n if params[:student_id] != nil and params[:section_id] != nil\n @class_students = ClassStudent.where(student_id: params[:student_id], section_id: params[:section_id])\n else\n @class_students = ClassStudent.all\n end\n end",
"def add_hash_of_students(student_hash)\n student_hash.each do |grade, students|\n @roster[grade] ||= []\n students.each {|student| @roster[grade] << student}\n end\n end",
"def asst_house_managers\n\t\tPerson.find(:all, \n\t\t\t\t\t\t\t\t:conditions => \"people.position = 'Asst. House Director' AND house_id = #{self.id}\", \n\t\t\t\t\t\t\t\t:joins => :houses, \n\t\t\t\t\t\t\t\t:order => \"last_name, first_name ASC\")\n\tend",
"def index\n @users = BranchOffice.find(params[:branch_office_id]).users.employee\n authorize @users\n end",
"def index\n \n if current_user.admin?\n @students = Student.all.search(params[:search])\n else\n @students = current_user.students.search(params[:search]) \n end\n \n respond_to do |format|\n format.html\n format.js\n end\n \n # flash[:danger] = \"No record found\" if @students.nil? || @students.blank?\n\n end",
"def index\n @admin_student_majors = Admin::StudentMajor.all\n end",
"def find_for_authentication(tainted_conditions); end",
"def require_student_or_admin\n redirect_to root_path unless @auth_user && ['Student', 'Admin'].include?(@auth_user.type)\n end",
"def index\n if granted_for?('root') || granted_for('survey')\n @surveys = Survey.find(:all,:include => [:survey_questions,:survey_answers])\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @surveys }\n end\n else\n access_denied\n end\n end",
"def index\n\n\t\t@resource =\tUser.find_by_authentication_token(params[:auth_token])\n\t\t# byebug\n\t\treturn invalid_user unless @resource\n\t\t@exams = Exam.all\n\t\t# @user = current_user\n\tend",
"def require_student_or_instructor\n redirect_to root_path unless @auth_user && ['Student', 'Instructor'].include?(@auth_user.type)\n end",
"def index\n authorize! :creat, Ward\n @hospitals = Hospital.all\n end",
"def index\n @seshes = current_user.seshes\n end",
"def index\n @products = current_user.products\n @products = @products.where(school_id: params[:school_id]) if @products && params[:school_id].presence && policy(@products).show_school_option? \n @products = @products.where(\"name ilike '%?%'\", params[:title]) if @products && params[:school_id].presence && policy(@products).show_school_option? \n end",
"def my_students\n CourseUser.joins(group_users: :group).merge(Course::GroupUser.normal).\n where(Course::Group.arel_table[:id].in(group_users.manager.pluck(:group_id))).distinct\n end",
"def school_search(params) \n school_search_relation(params)\n end",
"def set_student\n @student = Student.find(params[:id])\n authorize @student\n end",
"def student?\n if self.role and self.role == 4 \n true\n end\n end"
] | [
"0.63462687",
"0.6304662",
"0.61484975",
"0.57862616",
"0.56988627",
"0.5667931",
"0.56361127",
"0.5581746",
"0.5519501",
"0.5499715",
"0.54860336",
"0.5476777",
"0.5427626",
"0.5418739",
"0.5410691",
"0.53927666",
"0.5379627",
"0.53769565",
"0.53667456",
"0.533562",
"0.53337866",
"0.5325641",
"0.5319898",
"0.52909327",
"0.528019",
"0.52778226",
"0.52691007",
"0.5268825",
"0.5232666",
"0.5208139",
"0.5200379",
"0.5183505",
"0.5176851",
"0.5158948",
"0.5158859",
"0.5133799",
"0.5131879",
"0.5116895",
"0.511547",
"0.5105335",
"0.5103397",
"0.5101579",
"0.50920796",
"0.50803006",
"0.5078969",
"0.5077313",
"0.50588053",
"0.50522035",
"0.5047388",
"0.5040272",
"0.5036493",
"0.5035765",
"0.5034814",
"0.5034449",
"0.5014435",
"0.50012743",
"0.49982396",
"0.4997767",
"0.49937764",
"0.4989164",
"0.49856672",
"0.4980838",
"0.4972171",
"0.49711832",
"0.4970754",
"0.49600536",
"0.49587917",
"0.49554044",
"0.4952392",
"0.49514392",
"0.49487156",
"0.49419525",
"0.49385348",
"0.49361476",
"0.4935384",
"0.49270457",
"0.49170977",
"0.49164215",
"0.49094903",
"0.4907481",
"0.49073848",
"0.49067906",
"0.4905953",
"0.48950252",
"0.48943594",
"0.48927343",
"0.48872933",
"0.4887001",
"0.48848572",
"0.48830354",
"0.4880459",
"0.487866",
"0.4875951",
"0.4868123",
"0.4867028",
"0.48669323",
"0.4865857",
"0.4865442",
"0.48639378",
"0.48615697"
] | 0.77949256 | 0 |
Serializes a Student into a hash with other fields joined in (that are used to perform filtering and slicing in the UI). This may be slow if you're doing it for many students without eager includes. | def fat_student_hash(student)
HashWithIndifferentAccess.new(student.as_json({
except: [
:primary_phone,
:primary_email,
:student_address
]
}).merge({
has_photo: student.has_photo,
discipline_incidents_count: student.most_recent_school_year_discipline_incidents_count,
absences_count: student.most_recent_school_year_absences_count,
tardies_count: student.most_recent_school_year_tardies_count,
homeroom_name: student.try(:homeroom).try(:name),
event_notes_without_restricted: student.event_notes_without_restricted,
interventions: student.interventions,
sped_data: sped_data(student)
}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_students(student_ids, section)\n students = Student\n .active\n .where(id: student_ids)\n .includes(:student_section_assignments)\n\n students.map do |student|\n grade_numeric = student.student_section_assignments.find_by_section_id(section.id).grade_numeric\n student.as_json(methods: [\n :has_photo,\n :event_notes_without_restricted,\n :most_recent_school_year_discipline_incidents_count,\n :most_recent_school_year_absences_count,\n :most_recent_school_year_tardies_count\n ]).merge({\n grade_numeric: grade_numeric\n })\n end\n end",
"def student_hash_for_slicing(student)\n student.as_json.merge({\n student_risk_level: student.student_risk_level.as_json,\n discipline_incidents_count: student.most_recent_school_year.discipline_incidents.count,\n absences_count: student.most_recent_school_year.absences.count,\n tardies_count: student.most_recent_school_year.tardies.count,\n homeroom_name: student.try(:homeroom).try(:name)\n })\n end",
"def fat_student_hash(student)\n HashWithIndifferentAccess.new(student_hash_for_slicing(student).merge({\n event_notes_without_restricted: student.event_notes_without_restricted,\n interventions: student.interventions,\n sped_data: student.sped_data,\n }))\n end",
"def fat_student_hash(student)\n HashWithIndifferentAccess.new(student_hash_for_slicing(student).merge({\n interventions: student.interventions,\n student_risk_level: student.student_risk_level.decorate.as_json_with_explanation,\n }))\n end",
"def compute_student_hashes(authorized_student_ids)\n # Students table first\n authorized_students = Student.where(id: authorized_student_ids).includes(:homeroom)\n students_json = authorized_students.as_json({\n except: [\n :primary_phone,\n :primary_email,\n :student_address\n ]\n })\n\n # Optimized computation for aggregates\n aggregates = {\n discipline_incidents_count: DisciplineIncident.where(student_id: authorized_student_ids).where('occurred_at >= ?', first_day_of_school).group(:student_id).count,\n absences_count: Absence.where(student_id: authorized_student_ids).where('occurred_at >= ?', first_day_of_school).group(:student_id).count,\n tardies_count: Tardy.where(student_id: authorized_student_ids).where('occurred_at >= ?', first_day_of_school).group(:student_id).count\n }\n\n # Merge\n authorized_students.each_with_index.map do |student, index|\n HashWithIndifferentAccess.new(students_json[index].merge({\n discipline_incidents_count: aggregates[:discipline_incidents_count].fetch(student.id, 0),\n absences_count: aggregates[:absences_count].fetch(student.id, 0),\n tardies_count: aggregates[:tardies_count].fetch(student.id, 0),\n homeroom_name: student.try(:homeroom).try(:name)\n }))\n end\n end",
"def get_student_section_columns_hash(students)\n students.inject({}) do |map, student|\n map[student[:student_id]] = section_columns_hash(student[:sections])\n map\n end\n end",
"def flat_row_hash(student, all_service_types)\n student_fields = student.as_json.except(*[\n 'created_at',\n 'updated_at',\n 'student_address',\n 'hispanic_latino',\n 'race'\n ])\n\n additional_student_fields = {\n student_risk_level: student.student_risk_level.level,\n discipline_incidents_count: student.most_recent_school_year.discipline_incidents.count,\n absences_count: student.most_recent_school_year.absences.count,\n tardies_count: student.most_recent_school_year.tardies.count,\n homeroom_name: student.try(:homeroom).try(:name)\n }\n\n # unroll all service types\n student_service_type_ids = student.services.active.map(&:service_type_id)\n service_fields = all_service_types.reduce({}) do |hash, service_type|\n service = student.services.active.find {|service| service.service_type_id == service_type.id }\n value = if service.nil? then '' else service.date_started.strftime(\"%Y-%m-%d\") end\n hash[\"#{service_type.name} (active_service_date_started)\"] = value\n hash\n end\n\n # Unroll all event note types.\n # This will include the presence of restricted notes, but only the date and\n # no content.\n all_event_note_types = EventNoteType.all\n event_note_type_ids = student.event_notes.map(&:event_note_type_id)\n event_note_fields = all_event_note_types.reduce({}) do |hash, event_note_type|\n event_note = student.event_notes.find {|event_note| event_note.event_note_type_id == event_note_type.id }\n value = if event_note.nil? then '' else event_note.recorded_at.strftime(\"%Y-%m-%d\") end\n hash[\"#{event_note_type.name} (last_event_note_recorded_at)\"] = value\n hash\n end\n\n student_fields\n .merge(additional_student_fields)\n .merge(service_fields)\n .merge(event_note_fields)\n .stringify_keys!\n end",
"def profile\n student = Student.find(params[:id])\n chart_data = StudentProfileChart.new(student).chart_data\n @serialized_data = {\n current_educator: current_educator,\n student: student.serialized_data,\n notes: student.student_notes.map { |note| serialize_student_note(note) },\n feed: student_feed(student),\n chart_data: chart_data,\n intervention_types_index: intervention_types_index,\n educators_index: educators_index,\n attendance_data: {\n discipline_incidents: student.most_recent_school_year.discipline_incidents,\n tardies: student.most_recent_school_year.tardies,\n absences: student.most_recent_school_year.absences\n }\n }\n end",
"def merge_mutable_fields_for_slicing(student_hashes)\n student_ids = student_hashes.map {|student_hash| student_hash[:id] }\n mutable_fields = mutable_fields_for_slicing(student_ids)\n\n student_hashes.map do |student_hash|\n for_student = {\n event_notes: mutable_fields[:all_event_notes].select {|event_note| event_note.student_id == student_hash[:id] },\n active_services: mutable_fields[:all_active_services].select {|service| service.student_id == student_hash[:id] },\n summer_services: mutable_fields[:all_summer_services].select {|service| service.student_id == student_hash[:id] },\n interventions: mutable_fields[:all_interventions].select {|intervention| intervention.student_id == student_hash[:id] }\n }\n student_hash.merge({\n event_notes: for_student[:event_notes].map {|x| EventNoteSerializer.safe(x).serialize_for_school_overview },\n active_services: for_student[:active_services].map {|x| ServiceSerializer.new(x).serialize_service },\n summer_services: for_student[:summer_services].map {|x| ServiceSerializer.new(x).serialize_service },\n interventions: for_student[:interventions].map {|x| DeprecatedInterventionSerializer.new(x).serialize_intervention },\n })\n end\n end",
"def hash_builder(student)\n student_hash = { id: student.id, name: student.first_name + ' ' + student.s_last_name,\n other_interventions: student.num_other_programs,\n tutor: student.vol_name, first_attempt_average: @acumen_one,\n second_attempt_average: @acumen_two,\n hug_gain: (@acumen_two - @acumen_one).round(2),\n last_year_dra_gains: @last_year_dra_gains,\n fall_dra: @student_record[:fall_dra], winter_dra: @student_record[:winter_dra],\n mid_year_dra_gain: @student_record[:mid_year_dra_gain],\n spring_dra: @student_record[:spring_dra], end_year_dra_gain: @student_record[:end_year_dra_gain],\n fall_rit: @student_record[:fall_rit], winter_rit: @student_record[:winter_rit],\n mid_year_rit_gain: @student_record[:mid_year_rit_gain],\n spring_rit: @student_record[:spring_rit], end_year_rit_gain: @student_record[:end_year_rit_gain],\n fall_rank: @student_record[:fall_rank], winter_rank: @student_record[:winter_rank],\n mid_year_rank_gain: @student_record[:mid_year_rank_gain],\n spring_rank: @student_record[:spring_rank], end_year_rank_gain: @student_record[:end_year_rank_gain],\n fall_lexile: @student_record[:fall_lexile], winter_lexile: @student_record[:winter_lexile],\n spring_lexile: @student_record[:spring_lexile] }\n student_hash\n end",
"def students_by_section\n class_map = Hash.new{ |h,k| h[k] = [] }\n self.followers.includes([:section, :student_user]).each do |f|\n class_map[f.section] << f.student_user\n end\n class_map\n end",
"def student_feed(student, restricted_notes: false)\n {\n event_notes: student.event_notes\n .select {|note| note.is_restricted == restricted_notes}\n .map {|event_note| EventNoteSerializer.new(event_note).serialize_event_note },\n services: {\n active: student.services.active.map {|service| ServiceSerializer.new(service).serialize_service },\n discontinued: student.services.discontinued.map {|service| ServiceSerializer.new(service).serialize_service }\n },\n deprecated: {\n interventions: student.interventions.map { |intervention| DeprecatedInterventionSerializer.new(intervention).serialize_intervention }\n }\n }\n end",
"def to_jaxb_json_hash\n _h = {}\n if !students.nil?\n _ha = Array.new\n students.each { | _item | _ha.push _item.to_jaxb_json_hash }\n _h['students'] = _ha\n end\n return _h\n end",
"def student_list\n Student::all.map do |s|\n s.attributes.except 'id', 'created_at', 'updated_at'\n end\n end",
"def student_feed(student, restricted_notes: false)\n {\n event_notes: student.event_notes\n .select {|note| note.is_restricted == restricted_notes}\n .map {|event_note| EventNoteSerializer.dangerously_include_restricted_note_text(event_note).serialize_event_note },\n transition_notes: student.transition_notes\n .select {|note| note.is_restricted == restricted_notes},\n services: {\n active: student.services.active.map {|service| ServiceSerializer.new(service).serialize_service },\n discontinued: student.services.discontinued.map {|service| ServiceSerializer.new(service).serialize_service }\n },\n deprecated: {\n interventions: student.interventions.map { |intervention| DeprecatedInterventionSerializer.new(intervention).serialize_intervention }\n }\n }\n end",
"def collect_students(section = nil, student_attr = nil)\n @students ||= (\n student_list = data.collect{|row| row[0].to_s.sub(/COMMA\\s*/,', ').strip}\n students = student_list.collect do |student|\n s = section.rollbook_entries.detect{|rbe| rbe.student.send(student_attr) == student}\n s && s.id\n end\n students)\n end",
"def sample_students_json\n raise Exceptions::EducatorNotAuthorized unless current_educator.can_set_districtwide_access?\n\n seed = params.fetch(:seed, '42').to_i\n n = params.fetch(:n, '40').to_i\n authorized_sample_students = authorized do\n Student.active.sample(n, random: Random.new(seed))\n end\n sample_students_json = authorized_sample_students.as_json({\n only: [:id, :grade, :first_name, :last_name],\n include: {\n school: {\n only: [:id, :name, :school_type]\n }\n }\n })\n render json: {\n sample_students: sample_students_json\n }\n end",
"def student_feed(student)\n {\n v1_notes: student.student_notes.map { |note| serialize_student_note(note) },\n v1_interventions: student.interventions.map { |intervention| serialize_intervention(intervention) },\n event_notes: student.event_notes,\n v2_services: if Rails.env.development? then v2_services_fixture else [] end\n }\n end",
"def add_student_attributes(student_hash)\n @twitter = student_hash[:twitter]\n @linkedin = student_hash[:linkedin]\n @github = student_hash[:github]\n @blog = student_hash[:blog]\n @profile_quote = student_hash[:profile_quote]\n @bio = student_hash[:bio]\n @profile_url = student_hash[:profile_url]\n\n end",
"def students # Want: student id and student names on Users Table\n return User.joins(:sections).where(:sections => {:id => self.id}).all\n end",
"def index\n @course = params[:course_id]\n @students = Student.left_join_enrolls @course\n puts @students.as_json\n end",
"def students_with_low_grades_json(time_now, time_threshold, grade_threshold)\n all_assignments = assignments(time_now, time_threshold, grade_threshold)\n by_student = all_assignments.group_by(&:student)\n json = by_student.map do |student, assignments|\n {\n student: student.as_json(:only => [:id, :email, :first_name, :last_name, :grade, :house]),\n assignments: assignments.map {|assignment| serialize_assignment(assignment) }\n }\n end\n json.as_json\n end",
"def set_student\n @student = Student.includes(:scores, :nutritions).find(params[:id])\n end",
"def student\n\n\t\tif(params[:student_user_id].eql?('null') || params[:classroom_id].eql?('null') )\n\t\t\trender json: {status: \"error\", error: \"invalid-student-user-or-classroom\"}\n\t\telse\n\t\t\tstudent = StudentUser.joins(:classrooms)\n\t\t\t\t.joins(\"inner join teacher_users t on classrooms.teacher_user_id = t.id\")\n\t\t\t\t.where(\"t.id = ?\", @current_teacher_user.id)\n\t\t\t\t.where(\"classrooms.id = ?\", params[:classroom_id])\n\t\t\t\t.where(\"student_users.id = ?\" , params[:student_user_id])\n\t\t\t\t.first\n\n\t\t\tif(!student.nil?)\n\t\t\t\tstudent = student.as_json\n\t\t\t\tstudent.delete(\"salt\")\n\t\t student.delete(\"password_digest\")\n\t\t student.delete(\"oauth_expires_at\")\n\t\t student.delete(\"oauth_token\")\n\t\t student.delete(\"updated_at\")\n\t\t student.delete(\"create_at\")\n\n\t\t\t\trender json: {status: \"success\", student: student}\n\t\t\t\n\t\t\telse\n\n\t\t\t\trender json: {status: \"error\", error: \"invalid-student-user-or-classroom\"}\n\n\t\t\tend\n\t\tend\n\t\t\n\t\t\n\tend",
"def set_student\n @student = Student.includes(:person=>[ {photos: :person}, {passports: :person}]).where(id:params[:id]).take\n if @student != nil\n @p_address = Address.where(:person_id => @student.person.id).order(\"addresses.id DESC\").limit(1).where(:a_type=>1).take\n @r_address = Address.where(:person_id => @student.person.id).order(\"addresses.id DESC\").limit(1).where(:a_type=>2).take\n @f_address = Address.where(:person_id => @student.person.id).order(\"addresses.id DESC\").limit(1).where(:a_type=>3).take\n end\n end",
"def sped_data(student)\n {\n sped_level: sped_level(student),\n sped_tooltip_message: sped_tooltip_message(student),\n sped_bubble_class: sped_bubble_class(student)\n }\n end",
"def construct_table_rows(students, grade_entry_form)\n result = {}\n students.each do |student|\n result[student.id] = construct_table_row(student, grade_entry_form)\n end\n\n result\n end",
"def index\n puts render json: @user.students, each_serializer: UserSerializer\n end",
"def student_params\n params.fetch(:student, {}).permit(\n :last_name,\n :first_name,\n :birthdate,\n :email,\n :level_id,\n :accommodations,\n :school,\n :school_grade,\n :highest_math_class,\n :waiver_submitted)\n end",
"def students\n @course = Course.find(params[:id])\n\t\t@students = @course.students\n\t\t@other_students = Student.find(:all, :conditions => [\"id not in (select student_id from courses_students where course_id=?)\", @course.id])\n\n respond_to do |format|\n format.html # students.html.erb\n format.json { render :json => @students }\n end\n end",
"def grades\n object.grades.collect do |grade|\n { :grade => grade, :student => grade.student }\n end\n end",
"def student_to_csv(student)\n\t\tstudent.values\nend",
"def student_params\n params.fetch(:student, {})\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n self\n end",
"def class_json\n clazz = @offering.clazz\n section = clazz.section && clazz.section.length > 0 ? clazz.section : nil\n section = section ? \" (#{section})\" : \"\"\n {\n name: clazz.name + section,\n students: @students\n .sort_by { |s| \"#{s.last_name} #{s.first_name}\".downcase }\n .map { |s| student_json(s) }\n }\n end",
"def attributes\n [\n {\n ldap_uid: enrolled_student_login_id,\n student_id: enrolled_student_student_id,\n first_name: 'First Name',\n last_name: 'Last Name',\n email_address: \"#{enrolled_student_login_id}@example.com\"\n },\n {\n ldap_uid: waitlisted_student_login_id,\n student_id: waitlisted_student_student_id,\n first_name: 'First Wait',\n last_name: 'Last Wait',\n email_address: \"#{waitlisted_student_login_id}@example.com\"\n },\n {\n ldap_uid: another_enrolled_login_id,\n student_id: another_enrolled_student_id,\n first_name: 'Another Name',\n last_name: 'One Last Name',\n email_address: \"#{another_enrolled_login_id}@example.com\"\n }\n ]\n end",
"def students \n sk = Sektion.where(:teacher_id => self.id).map(&:id)\n sids = StudentRoster.where(:sektion_id => sk).map(&:student_id).uniq\n return Student.where(:id => sids)\n end",
"def inspect\n \"Student(#{@id}, #{@name.inspect})\"\n end",
"def inspect\n \"Student(#{@id}, #{@name.inspect})\"\n end",
"def student_chain(student_id, lesson_id, options)\n # put everything in a hash for use in the view.\n @studenthistory = Hash.new\n # keep the student details\n @studenthistory[\"student\"] = Student.find(student_id)\n # get this role\n role = Role.where(student_id: student_id, lesson_id: lesson_id).first\n roles = Role.where(block: role.block)\n # link to lessons for these roles\n lesson_ids = roles.map { |obj| obj.lesson_id }.uniq\n lesson_objs = Lesson.includes(:slot, :students, :tutors, :roles)\n .where( id: lesson_ids)\n .order('slots.timeslot')\n @studenthistory[\"lessons\"] = lesson_objs.map { |obj| [\n obj.id,\n obj.status,\n obj.slot.timeslot,\n obj.slot.location,\n obj.tutroles.map {|r| [r.tutor.pname, r.status]},\n obj.roles.map {|r| [r.student.pname, r.status]},\n #obj.roles.where(student_id: student_id).first.status == nil ?\n # \"\" : obj.roles.where(student_id: student_id).first.status,\n date_to_weekofterm(obj.slot.timeslot) \n ] }\n @studenthistory\n end",
"def add_hash_of_students(student_hash)\n student_hash.each do |grade, students|\n @roster[grade] ||= []\n students.each {|student| @roster[grade] << student}\n end\n end",
"def get_marks_graders_student_table_info(students, grade_entry_form)\n students.map do |student|\n s = student.attributes\n s[:graders] = lookup_graders_for_student(student, grade_entry_form)\n s[:section_name] = student.has_section? ? student.section.name : nil\n s\n end\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each {|k,v| self.send((\"#{k}=\"), v)}\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each {|k,v| self.send((\"#{k}=\"), v)}\n end",
"def courses_json\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n courses = Course.all\n .where(school_id: @school.id)\n .includes(sections: :students)\n\n courses_json = courses.as_json({\n :only => [:id, :course_number, :course_description],\n :include => {\n :sections => {\n :only => [:id, :section_number, :term_local_id, :schedule, :room_number],\n :include => {\n :students => {\n :only => [:id, :grade, :date_of_birth],\n :include => {\n :school => {\n :only => [:id, :name]\n }\n }\n }\n }\n }\n }\n })\n\n render json: {\n courses: courses_json,\n school: @school.as_json(only: [:id, :name])\n }\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each {|key, value| self.send((\"#{key}=\"), value)\n }\n end",
"def show\n @students = Student.joins(:subjects)\n .select('students.name, students.email, students.age, students.gender, students.opinion, subjects.id as subject_id')\n .select('exam_results.name as exam_result_name, subjects.name as subject_name, exam_results.score')\n .select('CAST((exam_results.score / subjects.max_score) * 100 as int) as ratio')\n .where(id: params[:id])\n .order(id: :asc)\n\n avg_result = Student.joins(:subjects)\n .select('subjects.id as subject_id')\n .select('CAST(AVG(exam_results.score) as int) as avg_score') \n .select('MAX(exam_results.score) as max_score')\n .select('MIN(exam_results.score) as min_score')\n .group('subjects.id')\n .order('subjects.id')\n @score_hash = {}\n avg_result.each do |avg_res|\n h = Hash.new\n h[:avg_score] = avg_res.avg_score\n h[:max_score] = avg_res.max_score\n h[:min_score] = avg_res.min_score \n @score_hash[avg_res.subject_id] = h\n end\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each do |k, v|\n self.send((\"#{k}=\"), v)\n end\n end",
"def students\n Rollcall::Student.find_all_by_school_id schools\n end",
"def students\n @courses = Course.where(\"teacher_id=?\",session[:user].teacher_id)\n student_ids = Array.new\n @courses.each{ |c|\n student_ids.push(c.courseStudents)\n }\n student_ids.each{ |array|\n array.each{ |student|\n @students.push(student)\n }\n }\n @students.uniq!\n end",
"def create_hash_class \n\t hash_class = {}\n\t @students_list.select do |student|\n\t\thash_class[student.name] = student.create_score_hash\n\t end\n\t puts \"Class's Hash: #{hash_class}\"\n\tend",
"def show\n @students = StudentInfo.where(referenced_class_id: params[:id]).all\n #puts YAML::dump(@students)\n end",
"def save_students\n\t\tif @students.blank? \n\t\t\t\t\n\t\telse\n\t\t\t@students.each do |student_id|\n\t\t\t\tHasStudent.create(student_id: student_id, course_id: self.id)\n\t\t\tend\n\t\tend\n\tend",
"def index\n s_id = Allotment.where(user_id: current_user.id).pluck(:school_id)\n class_ids = ClassMapping.where(school_id: s_id).pluck(:id)\n @all_students = Student.includes(class_mapping:[:standard, :section]).where( :class_mapping_id => class_ids)\n students = @all_students.map do |student|\n { id:student.id, name: student.name, standard: student.class_mapping.standard.name, section: student.class_mapping.section.name,\n school: s_id}\n end\n\n options = @all_students.map do |student|\n {label:student.class_mapping.standard.name+'-'+student.class_mapping.section.name, value: student.class_mapping_id}\n end\n render component: 'Students', props: { students: students, options: options}\n end",
"def archived_student\n student_attributes = attributes\n student_attributes['student_id'] = id\n archived_student = ArchivedStudent.create(student_attributes)\n end",
"def add_student_attributes(attributes_hash)\n attributes_hash.each {|key,value| self.send((\"#{key}=\"),value)}\n end",
"def serializable_hash(options={})\n data = super(options)\n data.delete('ingest_state')\n if options.has_key?(:include) && options[:include].include?(:ingest_state)\n if self.ingest_state.nil?\n data['ingest_state'] = 'null'\n else\n state = JSON.parse(self.ingest_state)\n data.merge!(ingest_state: state)\n end\n end\n data['intellectual_object_identifier'] = self.intellectual_object.identifier\n if options.has_key?(:include)\n data.merge!(checksums: serialize_checksums) if options[:include].include?(:checksums)\n data.merge!(premis_events: serialize_events) if options[:include].include?(:premis_events)\n end\n data\n end",
"def student_params\n params.require(:student).permit(:first_name, :class_name, :s_last_name, :school_id, :school_name, :user_id, :updated_at,\n :notes, :active, :why_inactive, :second_grade_year, :third_grade_year, :fifth_grade_year,\n :other_program_notes, :num_other_programs, :control_group,\n :graduated, :grade, :vol_name, :vol_email, :file, :vol_phone, :thing_to_do, :vol_ids => [], :student_ids => [])\n end",
"def student_params\n params.require(:student).permit(:household_id, :first_name, :last_name, :dob, :cell_phone, :email, :grade, :gender, :emergency_contact_name, :emergency_contact_phone, :has_birth_certificate, :allergies, :medications, :security_question, :security_response, :active, :school_id, :_destroy, registrations_attributes: [:id, :bracket_id, :has_report_card, :has_proof_of_insurance, :insurance_provider, :insurance_policy_no, :family_physician, :physician_phone, :has_physical, :physical_date, :jersey_size, :active, :_destroy])\n end",
"def marshal_dump\n { \n :klass => self.class.to_s, \n :values => @attribute_values_flat, \n :joined => @joined_models\n }\n end",
"def student_params\n params.require(:student).permit(\n %i(id first_name last_name gender date_of_birth place_of_birth course_id) +\n [address: %i(street zip city), contact: %i(email phone mobile)]\n )\n end",
"def student_to_list(student)\n return [\n student[:name],\n student[:cohort],\n student[:dob],\n student[:height],\n student[:cob],\n student[:hobby]\n ]\nend",
"def fetch_students\n @students = []\n CSV.foreach('data/students_info.csv', headers: true, col_sep: ',') do |row|\n @students << { name: row['name'], detention: row['detention'], tt_path: row['tt_path'] }\n end\n end",
"def attributes\n hash = super\n if serialization_options[:include_users] == true\n hash[:users] = self.users\n end\n if serialization_options[:include_scope] == true\n hash[:scope] = self.scope\n end\n return hash\n end",
"def student_params\n params.require(:student).permit(:name, :id_type, :gender, :address, :last_course, :outschool_years, :identification, :born, :etnic, :villa, :born_state, :displaced, :disability, :drop, :pic, :graduated, :why, :residency_state, :zone, :guardian_id, :school_id, :health_care_id, guardian_attributes: [:id_type, :identification, :name, :last_name, :second_name, :gender, :born, :address, :villa, :zone, :department, :municipality, :phone, :cel, :email, :relationship, :student_id])\n end",
"def student_params\n params.require(:student).permit(:student_id, :last_name, :first_name, :home_address, :home_city, :home_state, :home_zip, :school_year_address, :school_year_city, :school_year_zip, :room_number, :home_phone, :cell_phone, :new_student, :returning_student, :athletic_team)\n end",
"def print_student_data(student)\n puts \" - Cohort: #{student[:cohort]}\"\n # puts \" - Hobbies: #{student[:hobbies].join(\", \")}\"\n # puts \" - Height: #{student[:height]}cm\"\n # puts \" - Country of birth: #{student[:birth_country]}\"\nend",
"def create\n\t\tp = params[:student]\n\t\thash = { :original_name => p['original_name'], :sort_name => Student.make_sort_name(p['original_name']), :other_name => p['other_name'],\n\t\t\t:gender => p['gender'] == 'Male' ? 'M' : 'F', :born => VagueDate.factory(p['born']).to_s, :died => VagueDate.factory(p['died']).to_s,\n\t\t\t:home_town => p['home_town']['town'], :home_state => p['home_town']['state'], :home_country => p['home_town']['country'],\n\t\t\t:biographical_notes => p['biographical_notes'], :quotes => p['quotes'], :additional_notes => p['additional_notes'], :private_notes => p['private_notes'], :is_stub => 0\n\t\t}\n\n\t\t@student = Student.new(hash)\n\t\t@student.generate_unique_name()\n\n\t\trespond_to do |format|\n\t\t\tif @student.save\n\t\t\t\tmarriages = parse_array(p['marriage'])\n\t\t\t\tmarriages.each {|marriage|\n\t\t\t\t\tif !marriage['name'].blank?\n\t\t\t\t\t\tMarriage.create_marriage(@student, { :name => marriage['name'] }, marriage['date'])\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tresidences = parse_array(p['residence'])\n\t\t\t\tresidences.each {|residence|\n\t\t\t\t\tif !residence.blank?\n\t\t\t\t\t\tStudentResidence.create_residence(@student, residence)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tBrowse.student_changed(@student, nil)\n\t\t\t\tsolr().add_object(@student.to_solr())\n\n\t\t\t\tformat.html { redirect_to(@student, :notice => 'The student was successfully created.') }\n\t\t\telse\n\t\t\t\tformat.html {\n\t\t\t\t\t@page_title = 'Student'\n\t\t\t\t\tnew_setup()\n\t\t\t\t\trender :action => \"new\"\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\tend",
"def show\n render json: @student\n end",
"def serializable_hash(*)\n\n excludes = ['id', 'created_at', 'updated_at', 'from_searcher', 'searcher_key']\n output = super.except(*excludes)\n output.merge!(search_data) if search_data\n\n # Flatten the extra data fields into output\n return output\n\n end",
"def save_student_profile(id)\n student = id\n end",
"def student_params\n params.require(:student).permit(:nic, :name, :surname, :default_discount, :default_payment_type,\n :scholar_phone_number, :phone_number, :address, :town, :province, :zip_code,\n :details, :iban, :account_holder,\n student_activity_sign_ups_attributes: [ :id, :_destroy, :activity_id,\n :started_at, :ended_at,\n :activity_discount, :payment_type ] )\n end",
"def show\n respond_to do |format|\n format.html\n format.json {render json: @student, serializer: StudentSerializer, include: '**'}\n end\n end",
"def serializable_hash options=nil\n hash = super\n eav_attributes_list.each do |attribute|\n hash[attribute] = self.send(attribute)\n end\n\n hash\n end",
"def lasids\n render json: Student.all.pluck(:local_id) # not just active students\n end",
"def serializable_hash\n all = super\n attrs_to_serialize = filtered_attributes(all.keys, scope)\n all.slice(*attrs_to_serialize)\n end",
"def student_params\n params.require(:student).permit(:name, :birth_city, :birth_state, :birth_date, :address_street, :address_number, :address_complex, :address_cp, :address_phone, :email, :facebook, :personal_phone, :father_name, :father_live, :father_occupation, :father_phone, :mother_name, :mother_live, :mother_occupation, :mother_phone, :tutor_name, :tutor_parenthood, :previous_school, :previous_school_type, :scolarship, :security_institution, :medical_condition)\n end",
"def lasids\n render json: Student.pluck(:local_id)\n end",
"def make_student(name, height, courses, hobbies)\n {\n name: name,\n height: height,\n courses: courses,\n hobbies: hobbies\n }\nend",
"def student_params\n params.require(:student).permit(:name, :email, :password, :teacher_id,\n grades_attributes[:student_id, :assignment_name, :grade])\n end",
"def student_params\n params.require(:student).permit(:birthday, :card_id, :course_id, schools: [:note, :school_id, :enterance_year],\n name:[:first_name, :family_name, :first_name_kana, :family_name_kana], contact_information:[:mail],\n )\n end",
"def student_params\n\t\t#students requires parameters, and you can have 5 - including course attributes (name of course), and cohort attributes\n\t\tparams.require(:student).permit(:first_name, :last_name, :id, :photo, courses_attributes: [:name], cohorts_attributes: [:season, :year], contacts_attributes: [:category, :info, :id])\n\t#wraps up student parameters aciton\n\tend",
"def student_params\n params.require(:student).permit(:student_name, :school_id, course_ids: [])\n end",
"def student_params\n params.require(:student).permit(:first_name, :last_name, :cell_phone, :home_phone, :address, :zipcode, :social_security_number, :birth_date, :email, :current_school, :previous_school, :grade_level, :point_of_contact, :ymen_start_date, :church, :resume_completed, :leadership_roles, :other_organizations_involved, :num_current_mentors, :names_of_current_mentors, :family_notes, :other_notes)\n end",
"def start_session\n render json: @student, serializer: StudentSerializerSession\n end",
"def as_json(options={})\n result = super(:methods => [:skill_list, :interest_list, :year_group_list])\n result[:logo_url] = logo.url(:large)\n result[:logo_url_medium] = logo.url(:medium)\n if options.has_key? :student_id\n result[:rating] = rating(options[:student_id])\n end\n\n result[:stat_count] = @stat_count\n\n return result\n end",
"def update_student(id, fields)\n list = query_student(:id => id)\n list[0].merge(fields) if list.length == 1\n save_data\n end",
"def to_hash\n ret = HashWithIndifferentAccess.new\n ret.merge!(self.attributes_for_hash)\n ret.merge!(self.associations_for_hash)\n ret.merge!(self.add_on_data_for_hash)\n ret.merge!(self.association_foreign_keys_for_hash)\n ret\n end",
"def students\n CrmLegacyContact.paginate(select: [:first_name, :last_name],\n where: {local_status: :student},\n sort: [:first_name, :asc],\n account_name: self.name,\n per_page: 1000)\n end",
"def student_params\n params.require(:student).permit(:name, :surname, :genre_id, :date_of_birth, :telephone, :email, :passport_number, :passport_expiration_date, :address, :are_you_in_china, :photo, :passport_picture, :boursier_id, :typebourse_id, :faireanneelangue_id, :language_province, :year_of_chinese_language, :university_of_chinese_language_year, :starting_year_major, :province_id, :university_major, :major, :langueformation_id, :major_duration, :graduation_year, :niveauformation_id, :user_id)\n end",
"def student_params\n params.require(:student).permit(:first_name, :last_name, :birth_date, :email, :ip_address, :group_id, :registered_at, :average_grade)\n end",
"def _serialize(entity)\n serialized = @mapped_collection.serialize(entity)\n serialized.delete(:id)\n serialized[:_id] = Collection.to_mongodb_id(entity.id) unless entity.id.nil?\n serialized\n end",
"def student_params\n params.require(:student).permit(:code, :name, :course_id, :user_id)\n end",
"def student_params\n params.require(:student).permit(:name, :standard_id, :school_id)\n end",
"def student_names\n self.students.map do |student|\n student.name\n end\n end",
"def to_hash()\n return {\n id: @id,\n name: @name,\n contact: @contact,\n post_code: @post_code,\n }\n end",
"def student_params\n params.require(:student).permit(:id_number, :enrollment_status, :first_name, :middle_name, :last_name, :admission_date, :batch_number, :year_level, :section, :gender, :birthdate, :nationality, :birth_place, :religion, :street, :barangay, :city, :postal_code, :country, :lancaster_resident, :landline, :mobile, :email, :full_name, :institution_name, :year_level, :school_year, :grade, :general_avg)\n end",
"def students\n filters = []\n filters.push(\"{SCHOOL_TFPID} = '#{goddamn_school}'\") if goddamn_school\n Student.some(\n shard: self.goddamn_city,\n sort: [\"Name\", :asc],\n filterByFormula: \"AND(#{filters.join(',')})\"\n )\n end",
"def show\n student = Student.find(params[:id])\n render json: student\nend",
"def student_params\n params.require(:student).permit(:first_name, :last_name, :email, :password, :linkedin, :github, :website, :contact, :description, :event_id, :school, :qualification, :degree, :graduation, :profile_pic_url, :course_id, :one_liner, :link, :video, :project_ids => [], :language_ids => [])\n end"
] | [
"0.74007237",
"0.7180264",
"0.7028448",
"0.69895357",
"0.6417459",
"0.63001305",
"0.6236654",
"0.62192965",
"0.6130004",
"0.60334575",
"0.5991246",
"0.59414005",
"0.59389347",
"0.59350747",
"0.5875466",
"0.5874363",
"0.5831538",
"0.57497793",
"0.5737095",
"0.56373227",
"0.56134474",
"0.5577197",
"0.55398154",
"0.5537411",
"0.5473963",
"0.54303396",
"0.5396487",
"0.535877",
"0.5356221",
"0.53441495",
"0.5343793",
"0.5328288",
"0.5294804",
"0.5290757",
"0.5283215",
"0.5280029",
"0.52653795",
"0.5264907",
"0.5264907",
"0.526259",
"0.5232447",
"0.5229475",
"0.52185684",
"0.5214771",
"0.52140397",
"0.52077717",
"0.5197932",
"0.5197788",
"0.5197403",
"0.519088",
"0.51862115",
"0.5182431",
"0.5180907",
"0.5177383",
"0.51722395",
"0.5154746",
"0.51494884",
"0.5147176",
"0.5143654",
"0.51406646",
"0.51331544",
"0.5131269",
"0.5124323",
"0.5122209",
"0.51189286",
"0.5117325",
"0.510861",
"0.50972784",
"0.50904864",
"0.5086547",
"0.50845945",
"0.50815153",
"0.50804",
"0.5077486",
"0.5054848",
"0.5051675",
"0.5033838",
"0.5029286",
"0.50275487",
"0.50221604",
"0.5020809",
"0.50169015",
"0.501568",
"0.50100774",
"0.50100064",
"0.50089276",
"0.5007853",
"0.5007218",
"0.5006483",
"0.5001865",
"0.500154",
"0.49955162",
"0.4995028",
"0.49944043",
"0.49880376",
"0.49845684",
"0.49814734",
"0.49804977",
"0.49773487",
"0.49765572"
] | 0.7238609 | 1 |
This only matches on homeroom_id, not `slug`, since this has led to bugs from type coercion and from collisions on ids and slugs. Works around FriendlyId, which we should move away from. Type coercion can lead to bugs like: > Homeroom.find_by_id('7263') => So ensure that this any id lookup is really an integer and manually convert these types. See for more. | def find_homeroom_by_id(homeroom_id)
strict_homeroom_id = homeroom_id.to_i.to_s.to_i
if homeroom_id.to_s == strict_homeroom_id.to_s
homeroom = Homeroom.find_by_id(strict_homeroom_id) # FriendlyId patches #find, so this is more explicit
return homeroom if homeroom.present? && homeroom.id == strict_homeroom_id
end
raise ActiveRecord::RecordNotFound
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_better_id?\n slug and found_using_numeric_id? || found_using_outdated_friendly_id?\n end",
"def normalize_friendly_id(string)\n if slug.blank?\n super\n else\n super(slug)\n end\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\n end",
"def to_param\n slug ? slug.to_friendly_id : id.to_s\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\nend",
"def friendly_id\n slug(true).to_friendly_id\n end",
"def unfriendly_id?; end",
"def slug_base_string\n self.id || sluggify\n end",
"def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end",
"def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end",
"def to_param_from_slug\n slug? ? slug.to_friendly_id : id.to_s\n end",
"def to_param\n slug || id\n end",
"def id\n slug\n end",
"def normalize_friendly_id(string)\n super[0..59]\n end",
"def normalize_friendly_id(input)\n input.to_s.to_slug.normalize.to_s\n end",
"def normalize_friendly_id(input)\n input.to_s.to_slug.normalize.to_s\n end",
"def normalize_friendly_id(input)\n input.to_s.to_slug.normalize.to_s\n end",
"def normalize_friendly_id(slug_str)\n super.gsub(\"-\", \"\")\n end",
"def find_by_friendly_id(id); end",
"def normalize_friendly_id(slug_string)\n FriendlyIdPath.normalize_friendly_id(slug_string)\n end",
"def id\n object.slug\n end",
"def id\n object.slug\n end",
"def found_using_friendly_id?\n finder_slug\n end",
"def is_valid_slug?(slug)\n BSON::ObjectId.legal?(slug) || !(%r(^[a-z0-9-]+$) =~ slug).nil?\n end",
"def slug?(arg)\n false if Integer(arg)\n rescue ArgumentError, TypeError\n true\n end",
"def normalize_friendly_id(input)\n input\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def normalize_friendly_id(text)\n text.to_s.to_slug.normalize.to_s\n end",
"def normalize_friendly_id(text)\n text.to_s.to_slug.normalize.to_s\n end",
"def normalize_friendly_id(string)\n name\n end",
"def found_using_numeric_id?\n !found_using_friendly_id?\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def normalize_friendly_id(slug_string)\n return super if self.language_code ? self.language_code == \"en\" : I18n.locale_language == :en\n options = friendly_id_config.babosa_options\n language = Utility.english_language_name(self.language_code || I18n.locale_language) || :english\n slug_string.normalize! options.merge(:transliterations => \"#{language}\".underscore.to_sym)\n end",
"def slug_candidates\n [\n :title,\n [:title, :id],\n ]\n end",
"def normalize_friendly_id(string)\n super.delete(\"-\")\n end",
"def slug_text\n base = send friendly_id_options[:column]\n if self.friendly_id_options[:strip_diacritics]\n base = Slug::strip_diacritics(base)\n end\n if self.friendly_id_options[:strip_non_ascii]\n base = Slug::strip_non_ascii(base)\n end\n base = Slug::normalize(base)\n \n if base.length > friendly_id_options[:max_length]\n base = base[0...friendly_id_options[:max_length]]\n end\n if friendly_id_options[:reserved].include?(base)\n raise FriendlyId::SlugGenerationError.new(\"The slug text is a reserved value\")\n end\n return base\n end",
"def found_using_outdated_friendly_id?\n finder_slug.id != slug.id\n end",
"def normalize_friendly_id(input)\n input.to_s.to_slug.normalize(transliterations: :greek).to_s\n end",
"def slug_candidates\n [\n :title,\n [:title, :id],\n ]\n end",
"def friendly_id; end",
"def slugify(data) #TODO: Research use of variable polymorphicObjectType\n return @client.raw(\"post\", \"/helpers/slugify\", nil, data_transform(data))\n end",
"def normalize_friendly_id(string)\n super.gsub(\"-\", \".\")\n end",
"def normalize_friendly_id(string); string.upcase.gsub(\"-\", \".\") end",
"def slug\n @slug ||= begin\n raw = self['identifier'].find { |id| id.start_with?('slug:') }\n Spot::Identifier.from_string(raw).value unless raw.nil?\n end\n end",
"def slug_by_title\n \"#{title.gsub(/[^a-zA-Z0-9]/, '-')}-#{id}\"\n end",
"def slug_by_title\n \"#{title.gsub(/[^a-zA-Z0-9]/, '-')}-#{id}\"\n end",
"def friendly_id\n send friendly_id_config.query_field\n end",
"def slug_candidates\n [:name, [:name, :id_for_slug]]\n end",
"def normalize_friendly_id(input)\n input.to_s.to_url\n end",
"def normalize_friendly_id(input)\n input.to_s.to_url\n end",
"def normalize_friendly_id(input)\n input.to_s.to_url\n end",
"def normalize_friendly_id(input)\n input.to_s.to_url\n end",
"def to_param # overridden\n slug\n end",
"def real_id(model_name, friendly_id)\n if friendly_id.to_s.to_i == 0\n obj = model_name.constantize.find(friendly_id)\n if obj\n return obj.id\n end\n end\n friendly_id\n end",
"def to_param\n slug # or \"#{id}-#{name}\".parameterize\n end",
"def slugify(data)\n # TODO: Research use of variable polymorphicObjectType\n @client.raw('post', '/helpers/slugify', nil, data_transform(data))\n end",
"def to_param\n slug = identifier.find { |id| id.start_with? 'slug:' }\n return super unless slug.present?\n\n Spot::Identifier.from_string(slug).value\n end",
"def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end",
"def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end",
"def normalize_friendly_id(input)\n if self.website.primary_language\n language = self.website.primary_language.language\n if language.code == \"russian\"\n return input.to_s.to_slug.normalize(transliterations: :russian).to_s\n elsif language.code == \"ukrainian\"\n return input.to_s.to_slug.normalize(transliterations: :ukrainian).to_s\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n else\n # default is english\n return input.to_slug.normalize.to_s\n end\n end",
"def compute_slug\n \"#{normalize_slug_base_string}-#{self.id || sluggify}\"\n end",
"def find_slug_matches(id)\n Hash[*(many.find_by_slug(id).map {|results| [results['category_id'], results['id']]}).flatten]\n end",
"def friendly_find(slugged_id)\n model.friendly.find(slugged_id)\n end",
"def slug_candidates\n [\n :username,\n [:username, :id]\n ]\n end",
"def should_generate_new_friendly_id?\n slug.blank?\n end",
"def should_generate_new_friendly_id?\n slug.blank?\n end",
"def normalize_friendly_id(string)\n\t super[0..20]\n\tend",
"def friendly_id_config; end",
"def set_homy\n @homy = Homy.friendly.find(params[:id])\n end",
"def to_param\n id.to_s + \"-\" + slug\n end",
"def to_param\n id.to_s + \"-\" + slug\n end",
"def slug\n fetch[:slug]\n rescue NoMethodError\n nil\n end",
"def find_by_slug_id(id)\n if Moped::BSON::ObjectId.legal?(id)\n Topic.find(id)\n else\n Topic.where(:slug_pretty => id.parameterize).first\n end\n end",
"def normalize_friendly_id(input)\n input.to_s.to_slug.transliterate(:russian).normalize.to_s\n end",
"def sanitize_relationship(value)\n if value.is_a?(Elmas::Resource)\n return value.id # Turn relation into ID\n elsif value.is_a?(Array)\n return sanitize_has_many(value)\n elsif value.is_a?(Time) || value.is_a?(Date) || value.is_a?(DateTime)\n return sanitize_date_time(value)\n elsif value.is_a?(String) && value.match(/(Date\\()/)\n number = value.scan(/\\d+/).first.to_i / 1000.0\n Time.zone = ActiveSupport::TimeZone.new(\"Europe/Amsterdam\")\n return sanitize_date_time(Time.zone.at(number))\n else\n return value\n end\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def to_param\n slug\n end",
"def find_unique_slug\n UniqueSlug.new(self).find_unique\n end",
"def fix_slug\n # If title is present and slug not set\n if title.present? && !slug.present?\n fixed_slug = Article.stripper(self.title)\n end\n if slug.present?\n # Make sure slug matches format\n fixed_slug = Article.stripper(self.slug)\n end\n self.slug = fixed_slug\n end",
"def apply_slug_limit(candidate, uuid); end",
"def guess_identifier_type ident\n # Note identifier normalisation in HydraDurham::IdentifierNormalisation.\n # These rules are a little excessive assuming normalisation has been done\n # already since website form identifires shouldn't be present anymore.\n # However it won't hurt to be prepared for those as well.\n rules=[{regex: /^doi:(.*)/i, type: 'DOI', value: '\\1' },\n {regex: /^info:doi\\/(.*)/i, type: 'DOI', value: '\\1' },\n {regex: /^.*dx\\.doi\\.org\\/(.*)/i, type: 'DOI', value: '\\1' },\n {regex: /^ark:(.*)/i, type: 'ARK', value: 'ark:\\1' },\n {regex: /^arxiv:(.*)/i, type: 'arXiv', value: 'arXiv:\\1'},\n {regex: /^.*arxiv\\.org\\/[^\\/]+\\/(.*)/i, type: 'arXiv', value: 'arXiv:\\1'},\n 'issn', 'isbn', 'istc', 'lissn',\n {prefix: 'urn:lsid:', type: 'LSID', keep_prefix: true}, 'pmid',\n {regex: /^purl:(.*)/i, type: 'PURL', value: '\\1'},\n {regex: /(.*([\\W]|^)purl\\W.*)/i, type: 'PURL', value: '\\1'},\n 'upc',\n {prefix: 'urn', type: 'URN', keep_prefix: true}, # urn should be after LSID because LSID also starts with urn\n {regex: /(https?:)(.*)/i, type: 'URL', value: '\\1\\2'} ,\n {regex: /(.*)/, type: 'Handle', value: '\\1'} \n ]\n\n rules.each do |rule|\n if rule.class==String\n rule={ prefix: \"#{rule}:\", type: rule.upcase }\n end\n if rule.key? :regex\n if rule[:regex] =~ ident\n return { id_type: rule[:type], id: (ident.sub rule[:regex], rule[:value])}\n end\n else\n if ident.downcase.start_with?(rule[:prefix])\n if rule[:keep_prefix]\n return { id_type: rule[:type], id: ident }\n else\n return { id_type: rule[:type], id: ident[(rule[:prefix].length) .. -1]}\n end\n end\n end\n end\n end",
"def should_generate_new_friendly_id?\n slug.blank?\n end",
"def should_generate_new_friendly_id?\n slug.blank?\n end",
"def slug=(_arg0); end"
] | [
"0.64700574",
"0.6356033",
"0.6177835",
"0.6177835",
"0.614941",
"0.6125775",
"0.6081726",
"0.6028007",
"0.60253155",
"0.60057575",
"0.60057575",
"0.60057575",
"0.5969563",
"0.5931023",
"0.59244037",
"0.58928925",
"0.58928925",
"0.58928925",
"0.58888435",
"0.5870374",
"0.5867815",
"0.5824412",
"0.5824412",
"0.5801176",
"0.5781517",
"0.57458127",
"0.57325846",
"0.57262725",
"0.56927866",
"0.5681417",
"0.56706345",
"0.56571096",
"0.5655823",
"0.56264967",
"0.5623698",
"0.55916476",
"0.55816805",
"0.5564591",
"0.55335003",
"0.55089086",
"0.5493823",
"0.54797065",
"0.54692924",
"0.5458332",
"0.54572874",
"0.54537433",
"0.5451932",
"0.5451932",
"0.54475904",
"0.5432457",
"0.54119074",
"0.54119074",
"0.54119074",
"0.54119074",
"0.54057324",
"0.5400265",
"0.5399732",
"0.5397884",
"0.5381982",
"0.5377614",
"0.5377614",
"0.5377614",
"0.5370911",
"0.53633714",
"0.5356478",
"0.5346208",
"0.53389764",
"0.53389764",
"0.53372526",
"0.5333441",
"0.5333081",
"0.5319862",
"0.5319862",
"0.5297292",
"0.52869064",
"0.5282732",
"0.52697563",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5267362",
"0.5261655",
"0.52491164",
"0.52432895",
"0.52390236",
"0.5230769",
"0.52210164",
"0.52184814"
] | 0.6300812 | 2 |
SpEd Data as defined by Somerville Schools | def sped_data(student)
{
sped_level: sped_level(student),
sped_tooltip_message: sped_tooltip_message(student),
sped_bubble_class: sped_bubble_class(student)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sld; end",
"def sp\n\t\t# --Stallция Preφιcς--\n\t\ts = ['S', 'Z', 'C', 'S']\n\t\tt = ['t', 'zt', 'ct', 'st']\n\t\ta = ['a', 'å', 'ä', 'ą']\n\t\tl = ['l', 'll', 'л', 'лл', 'lъ', 'llъ', 'лъ', 'ллъ',]\n\t\tc = ['c', 'z', 's', 'c', 'z', 'ц']\n\t\ti = ['i', '', 'и']\n\t\tja = ['a', 'ja', 'ya', 'ia', 'иa','я', 'ѧ']\n\t\tpp = ['P', 'П', 'Ψ', 'Ξ']\n\t\tr = ['r', 'р']\n\t\te = ['e', 'ϵ', 'ε']\n\t\tfi = ['f', 'ff', 'ф', 'φ', 'ѳ', 'þ', 'ξ']\n\t\tjota = ['i', 'и', 'ι', 'ї', 'ј']\n\t\tis = ['s', 'z', 'c', 'σ', 'ς',\n\t\t\t\t'ss', 'sz', 'sσ', 'sς', 'zs', 'cs', 'σs',\n\t\t\t\t'zz', 'zc', 'zσ', 'zς', 'cz', 'σz',\n\t\t\t\t'cc', 'cσ', 'cς', 'sc', 'σc',\n\t\t\t\t'σσ', 'σς', 'ςς',\n\t\t\t\t'ssz', 'ssσ', 'ssς', 'zss', 'css', 'σss',\n\t\t\t\t'scz']\n\t\tsparray = [s, t, a, l, c, i, ja, [\"\\n\"], pp, r, e, fi, jota, is]\n\t\tcilibles = []\n\t\tfor i in sparray\n\t\t\tcilibles.push(i[rand(i.length)])\n\t\tend\n\t\t@spreffis = cilibles.join\n\t\t@spinitial = cilibles[0] + cilibles[8]\n\tend",
"def summer_olympics_sport; end",
"def stderrs; end",
"def summer_paralympics_sport; end",
"def idols_data\n\n\t\t[[ \"Last name\", \"First name\", \"Description\" ]] + [[ @view_context.number_to_currency(1), 2, 3] ] +\n\t\t@idols.map { |idol| [idol.last_name, idol.first_name, idol.talents.first.description] }\n\n\tend",
"def schubert; end",
"def sid_column\n end",
"def ssmed_params\n params.require(:ssmed).permit(\n :ssmedprint, :ssmedcomment, :election_year_id, :county, :current_step\n )\n end",
"def spanish_citizen_number; end",
"def the_stans(data)\nend",
"def schumann; end",
"def pcode4\n school.sierra_code\n end",
"def sv\n field_fetch('SV').sub(/;/,'')\n end",
"def sid\n data['sid']\n end",
"def ob_sssr\n @ob.get_sssr.to_a\n end",
"def sld\n self.domain.sld\n end",
"def parse_sqft\n end",
"def parse_sqft\n end",
"def to_escp\n @data\n end",
"def winter_olympics_sport; end",
"def site_data; end",
"def sospa(location)\n string = location[1..-1]\n col = location[0].to_i\n row = (string.length.to_f / col).floor\n remainder = string.length % col\n address = [[nil]*col]*(row+1)\n\n sizes = [row+1] * remainder + [row] * (col - remainder)\n pos = 0\n sizes.each_with_index { |size, i|\n size.times { |index| address[col * index + i] = string[pos + index] }\n pos += size\n }\n\n address = CGI::unescape(address.join).gsub('^', '0')\n rescue\n raise location\n end",
"def data\n # STUB\n end",
"def spa\n return @spa\n end",
"def national_sport; end",
"def spanish_foreign_citizen_number; end",
"def sn\n end",
"def evalue;\t\t@hsps.first.evalue;\t\tend",
"def primary_school; end",
"def strand; @data[8]; end",
"def data_sponsor\n params.require(:Sponsor).permit(:research_application_id, :fname, :midinit, :lname, :address, :city, :state, :zipcode, :hphone, :email_addr)\n end",
"def data\n @locais.values\n end",
"def description\n @sg.description\n end",
"def description\n @sg.description\n end",
"def ssp\n authorize! :read, Evaluation\n @nist_hash = Constants::NIST_800_53\n @symbols = @evaluation.symbols\n @evaluation.profiles.each do |profile|\n families, nist = profile.control_families\n next if families.empty?\n\n @nist_hash['children'].each do |cf|\n family_value = 0\n cf['children'].each do |control|\n if families.include?(control['name'])\n control['controls'] = nist[control['name']]\n control['value'] = control['controls'].size\n family_value += control['controls'].size\n else\n control['value'] = 0\n end\n end\n cf['value'] = family_value\n end\n end\n end",
"def summer_paralympics_sport\n fetch('sport.summer_paralympics')\n end",
"def scientist; end",
"def st_members \n @st_members = SiteText.second\n end",
"def pst\n @pubmed['PST'].strip\n end",
"def ssr\n r2*sst\n end",
"def winter_paralympics_sport; end",
"def student_id\r\n\t\t\t \t51771125.51772509\r\n\t\t end",
"def render_mastersthesis(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n end\n\n r += p.title.detex.titlecase + \". \"\n\n if field(p,\"Type\") then\n r += text_for_field(\"Type\", p).titlecase.detex + \", \"\n else\n r += \"Master's thesis, \"\n end\n\n r += text_for_field(\"School\", p, :postfix => \", \").detex\n r += text_for_field(\"Address\", p, :postfix => \", \").detex\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \").detex\n return r\n\nend",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def sf\n return self[:sf]\n end",
"def school; end",
"def pst\n @pubmed['PST'].strip\n end",
"def french_ssn_info(ssn)\n return 'The number is invalid' if ssn.empty?\n\n # key = data[:key]\n\n\n data = ssn.match(PATTERN)\n if ssn_is_valid?(ssn, data[:key].to_i)\n gender = data[:gender] == \"1\" ? \"man\" : \"woman\"\n month = Date::MONTHNAMES[data[:month].to_i]\n department = DEPARTMENTS[data[:department]]\n year = data[:year].to_i + 1900\n return \"a #{gender}, born in #{month}, #{year} in #{department}.\"\n else\n return \"The number is invalid\"\n end\nend",
"def student_id\r\n\t\t\treturn 51875531\r\n\t\tend",
"def scf\n end",
"def set_future_enrollment_new_housing\n # subdistrict_pairs are e.g. \"(<district>, <subdistrict>)\" and defined in private methods\n future_enrollment_new_housing_by_subdistrict = CeqrData::ScaHousingPipelineBySd.version(\n data_package.table_for(\"sca_housing_pipeline_by_sd\")\n ).ps_is_students_from_new_housing_by_subdistrict(subdistrict_pairs)\n\n self.future_enrollment_new_housing = future_enrollment_new_housing_by_subdistrict.map do |e|\n {\n level: e[:level],\n district: e[:district],\n subdistrict: e[:subdistrict],\n students: e[:students]\n }\n end\nend",
"def index\n @ssds = Ssd.all\n end",
"def sic_code; end",
"def street_address\n\t\treturn \"#96, Railway Layout, Vijaynagar\"\n\tend",
"def coordinates\n raw_coords = multivalue_field('coordinates_ssim')\n coords = []\n raw_coords.each do |raw_coord|\n split_coord = raw_coord.split('|')\n coords << { :name => split_coord[0], :lat => split_coord[1], :lon => split_coord[2] }\n end\n coords\n end",
"def edat\n @pubmed['EDAT'].strip # in the form 20070802\n end",
"def spg_ep1_5\n spg_1_5= {}\n if articulos.size >= 1 \n articulo = articulos.first\n spg_1_5[:codestpro1] = articulo.codestpro1 \n spg_1_5[:codestpro2] = articulo.codestpro2\n spg_1_5[:codestpro3] = articulo.codestpro3\n spg_1_5[:codestpro4] = articulo.codestpro4\n spg_1_5[:codestpro5] = articulo.codestpro5\n end \n spg_1_5\n end",
"def handle_ead_loc(ead_loc)\n df('856', '4', '2').with_sfs(\n ['z', \"Finding aid online:\"],\n ['u', ead_loc]\n ) if ead_loc\n end",
"def build_segrec(num, name, loc, size, type, data=nil)\n\t\tseg = Hash.new\n\t\t\n\t\tseg[:segno] = num\n\t\tseg[:name] = name\n\t\tseg[:loc] = loc\n\t\tseg[:size] = size\n\t\tseg[:type] = type\n\t\tseg[:data] = data unless data == nil\n\t\treturn seg\n\tend",
"def sc\n field_fetch('SC')\n end",
"def eds\n @eds_session = get_eds_session\n @eds_fields = get_eds_fields\n end",
"def isp; end",
"def isp; end",
"def edat\n @pubmed['EDAT'].strip # in the form 20070802\n end",
"def newspaper\n 'Newspaper' if record.leader[7] == 's' && record['008'] && record['008'].value[21] == 'n'\n end",
"def set_sd\n @sd = Sd.find(params[:id])\n end",
"def straights\n @analysis[:straights]\n end",
"def street_name; end",
"def spren; end",
"def es_code\n id.to_s\n end",
"def set_semesters\n\t\tif is_student\n\t\t @semesters = Array.new\n\t\t counter = @current_user.enrollment_time\n\t\t counter_limit = @current_user.graduation_time\n\t\t while counter <= counter_limit do\n\t\t @semesters << \"#{counter}s\"\n\t\t @semesters << \"#{counter}f\"\n\t\t counter = counter+1\n\t\t end\n\t\t @semesters.pop\n\t\t @semesters.shift\n\t\tend\n\tend",
"def snr\n part.nr\n end",
"def unusual_sport; end",
"def cvss(data)\n\tav = data[\"av2\"]\n\tac = data[\"ac2\"]\n\tau = data[\"au2\"]\n\tc = data[\"c2\"]\n\ti = data[\"i2\"]\n\ta = data[\"a2\"]\n\te = data[\"e2\"]\n\trl = data[\"rl2\"]\n\trc = data[\"rc2\"]\n\tcdp = data[\"cdp\"]\n\ttd = data[\"td\"]\n\tcr = data[\"cr2\"]\n\tir = data[\"ir2\"]\n\tar = data[\"ar2\"]\n\n\tif ac == \"High\"\n\t cvss_ac = 0.35\n\telsif ac == \"Medium\"\n\t cvss_ac = 0.61\n\telse\n\t cvss_ac = 0.71\n\tend\n\n\tif au == \"None\"\n\t cvss_au = 0.704\n\telsif au == \"Single\"\n\t cvss_au = 0.56\n\telse\n\t cvss_au = 0.45\n\tend\n\n\tif av == \"Local\"\n\t cvss_av = 0.395\n\telsif av == \"Local Network\"\n\t cvss_av = 0.646\n\telse\n\t cvss_av = 1\n\tend\n\n\tif c == \"None\"\n\t cvss_c = 0\n\telsif c == \"Partial\"\n\t cvss_c = 0.275\n\telse\n\t cvss_c = 0.660\n\tend\n\n\tif i == \"None\"\n\t cvss_i = 00\n\telsif i == \"Partial\"\n\t cvss_i = 0.275\n\telse\n\t cvss_i = 0.660\n\tend\n\n\tif a == \"None\"\n\t cvss_a = 0\n\telsif a == \"Partial\"\n\t cvss_a = 0.275\n\telse\n\t cvss_a = 0.660\n\tend\n\n\n\t# temporal score calculations\n\tif e == \"Unproven Exploit Exists\"\n\t cvss_e = 0.85\n\telsif e == \"Proof-of-Concept Code\"\n\t cvss_e = 0.90\n\telsif e == \"Functional Exploit Exists\"\n\t cvss_e = 0.95\n\telse\n\t cvss_e = 1\n\tend\n\n\tif rl == \"Official Fix\"\n\t cvss_rl = 0.87\n\telsif rl == \"Temporary Fix\"\n\t cvss_rl = 0.90\n\telsif rl == \"Workaround\"\n\t cvss_rl = 0.95\n\telse\n\t cvss_rl = 1\n\tend\n\n\tif rc == \"Unconfirmed\"\n\t cvss_rc = 0.90\n\telsif rc == \"Uncorroborated\"\n\t cvss_rc = 0.95\n\telse\n\t cvss_rc = 1\n\tend\n\n\n\t#environemental\n\tif cdp == \"Low\"\n\t cvss_cdp = 0.1\n\telsif cdp == \"Low-Medium\"\n\t cvss_cdp = 0.3\n\telsif cdp == \"Medium-High\"\n\t cvss_cdp = 0.4\n\telsif cdp == \"High\"\n\t cvss_cdp = 0.5\n\telse\n\t cvss_cdp = 0\n\tend\n\n\tif td == \"None\"\n\t cvss_td = 0\n\telsif td == \"Low\"\n\t cvss_td = 0.25\n\telsif td == \"Medium\"\n\t cvss_td = 0.75\n\telse\n\t cvss_td = 1\n\tend\n\n\tif cr == \"Low\"\n\t cvss_cr = 0.5\n\telsif cr == \"High\"\n\t cvss_cr = 1.51\n\telse\n\t cvss_cr = 1\n\tend\n\n\tif ir == \"Low\"\n\t cvss_ir = 0.5\n\telsif ir == \"High\"\n\t cvss_ir = 1.51\n\telse\n\t cvss_ir = 1\n\tend\n\n\tif ar == \"Low\"\n\t cvss_ar = 0.5\n\telsif ar == \"High\"\n\t cvss_ar = 1.51\n\telse\n\t cvss_ar = 1\n\tend\n\n\n\tcvss_impact = 10.41 * (1 - (1 - cvss_c) * (1 - cvss_i) * (1 - cvss_a))\n\tcvss_exploitability = 20 * cvss_ac * cvss_au * cvss_av\n\tif cvss_impact == 0\n\t cvss_impact_f = 0\n\telse\n\t cvss_impact_f = 1.176\n\tend\n\tcvss_base = (0.6*cvss_impact + 0.4*cvss_exploitability-1.5)*cvss_impact_f\n\n\tcvss_temporal = cvss_base * cvss_e * cvss_rl * cvss_rc\n\n\tcvss_modified_impact = [10, 10.41 * (1 - (1 - cvss_c * cvss_cr) * (1 - cvss_i * cvss_ir) * (1 - cvss_a * cvss_ar))].min\n\n\tif cvss_modified_impact == 0\n\t cvss_modified_impact_f = 0\n\telse\n\t cvss_modified_impact_f = 1.176\n\tend\n\n\tcvss_modified_base = (0.6*cvss_modified_impact + 0.4*cvss_exploitability-1.5)*cvss_modified_impact_f\n\tcvss_adjusted_temporal = cvss_modified_base * cvss_e * cvss_rl * cvss_rc\n\tcvss_environmental = (cvss_adjusted_temporal + (10 - cvss_adjusted_temporal) * cvss_cdp) * cvss_td\n\n\tif cvss_environmental\n\t cvss_total = cvss_environmental\n\telsif cvss_temporal\n\t cvss_total = cvss_temporal\n\telse\n\t cvss_total = cvss_base\n\tend\n\n#if cvss_total == 0\n#data[\"risk_cvss_v2\"]=0\n##data[\"risk\"]=0\n\n#elsif (cvss_total >= 0.1 and cvss_total <= 3.9)\n#data[\"risk_cvss_v2\"]=1\n#data[\"risk\"]=1\n\n#elsif (cvss_total >= 4.0 and cvss_total <= 6.9)\n#data[\"risk_cvss_v2\"]=2\n#data[\"risk\"]=2\n\n#elsif (cvss_total >= 7.0 and cvss_total <= 8.9)\n#data[\"risk_cvss_v2\"]=3\n#data[\"risk\"]=3\n\n#else\n#data[\"risk_cvss_v2\"]=4\n#data[\"risk\"]=4\n#end\n\n data[\"risk_cvss_v2\"]=data[\"risk\"]\n\n\tdata[\"cvss_base2\"] = sprintf(\"%0.1f\" % cvss_base)\n\tdata[\"cvss_impact2\"] = sprintf(\"%0.1f\" % cvss_impact)\n\tdata[\"cvss_exploitability2\"] = sprintf(\"%0.1f\" % cvss_exploitability)\n\tdata[\"cvss_temporal2\"] = sprintf(\"%0.1f\" % cvss_temporal)\n\tdata[\"cvss_environmental2\"] = sprintf(\"%0.1f\" % cvss_environmental)\n\tdata[\"cvss_modified_impact2\"] = sprintf(\"%0.1f\" % cvss_modified_impact)\n\tdata[\"cvss_total2\"] = sprintf(\"%0.1f\" % cvss_total)\n\n\treturn data\nend",
"def csr; sparam(5); end",
"def data\n \"_target: #{target}\\ndatacite.creator: #{creator}\\ndatacite.title: #{title}\\ndatacite.publisher: #{publisher}\\ndatacite.publicationyear: #{publicationyear}\\n\"\n end",
"def sea; end",
"def student_id_to_sub_column\n self.student_id_schoolname = self.student_id[0..1]\n self.student_id_date = Date.strptime(self.student_id[2..9], \"%Y%m%d\")\n self.student_id_serial = self.student_id[10..11]\n end",
"def sport; end"
] | [
"0.57599723",
"0.5654223",
"0.5592384",
"0.55232763",
"0.5443806",
"0.5325148",
"0.5241047",
"0.52281827",
"0.52018094",
"0.5200175",
"0.5169785",
"0.5169777",
"0.51659054",
"0.5161655",
"0.515208",
"0.5147694",
"0.5135845",
"0.5131139",
"0.5131139",
"0.51245856",
"0.511807",
"0.5085833",
"0.50699806",
"0.506589",
"0.5058614",
"0.505292",
"0.5027107",
"0.50060385",
"0.49992824",
"0.49928224",
"0.49874955",
"0.498339",
"0.49830627",
"0.49661335",
"0.49661335",
"0.4965884",
"0.49614695",
"0.4957939",
"0.49553046",
"0.4940353",
"0.4933203",
"0.4929967",
"0.49192396",
"0.4917025",
"0.49131167",
"0.49131167",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.49114525",
"0.4900728",
"0.48998827",
"0.4897487",
"0.48824218",
"0.48777112",
"0.48475814",
"0.48446307",
"0.48432618",
"0.48399895",
"0.48393643",
"0.483187",
"0.48313138",
"0.4831153",
"0.4828004",
"0.48279947",
"0.48273656",
"0.48207867",
"0.48207867",
"0.4819783",
"0.4808021",
"0.48039916",
"0.4799903",
"0.47964007",
"0.47884905",
"0.47870326",
"0.47846422",
"0.47812346",
"0.47720972",
"0.47716063",
"0.47626406",
"0.47588244",
"0.47573817",
"0.47542903",
"0.47527173"
] | 0.640719 | 0 |
some helper methods that may be generally useful | def real_close(r1,r2)
(r1 - r2).abs < GeometryExpression::Epsilon
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def who_we_are\r\n end",
"def schubert; end",
"def custom; end",
"def custom; end",
"def formation; end",
"def extra; end",
"def weber; end",
"def suivre; end",
"def operations; end",
"def operations; end",
"def common\n \n end",
"def terpene; end",
"def identify; end",
"def parts; end",
"def parts; end",
"def parts; end",
"def stderrs; end",
"def anchored; end",
"def checks; end",
"def wrapper; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def ignores; end",
"def specialty; end",
"def missing; end",
"def intensifier; end",
"def romeo_and_juliet; end",
"def implementation; end",
"def implementation; end",
"def missing?; end",
"def sitemaps; end",
"def berlioz; end",
"def generic?; true; end",
"def internal; end",
"def formats; end",
"def formats; end",
"def fallbacks; end",
"def fallbacks; end",
"def overload; end",
"def issn; end",
"def informational?; end",
"def trd; end",
"def returns; end",
"def alternatives; end",
"def rest_positionals; end",
"def file_utils; end",
"def extended(*) end",
"def tiny; end",
"def jack_handey; end",
"def parslets; end",
"def ismn; end",
"def ibu; end",
"def fallbacks=(_arg0); end",
"def used?; end",
"def simple_blind_ror\n \n end",
"def name_safe?; end",
"def malts; end",
"def as_you_like_it_quote; end",
"def processor; end",
"def user_os_complex\r\n end",
"def strings; end",
"def silly_adjective; end",
"def verdi; end",
"def isolated; end",
"def isolated; end",
"def missed?; end",
"def exceptions; end",
"def extra_args; end",
"def transformations; end",
"def operation; end",
"def zuruecksetzen()\n end",
"def plain; end",
"def usage; end",
"def usage; end",
"def required_positionals; end",
"def offences_by; end",
"def refutal()\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def bs; end",
"def overrides; end",
"def buzzword; end",
"def buzzword; end",
"def how_it_works\r\n end",
"def loc; end",
"def loc; end",
"def loc; end",
"def internal?; end"
] | [
"0.7047123",
"0.6436291",
"0.6436291",
"0.6436291",
"0.6331897",
"0.62676924",
"0.62676924",
"0.62676924",
"0.62676924",
"0.6073839",
"0.60599875",
"0.60171413",
"0.60171413",
"0.5975093",
"0.59681225",
"0.5929333",
"0.58616954",
"0.5861506",
"0.5861506",
"0.5793562",
"0.5788918",
"0.57800615",
"0.5751991",
"0.5751991",
"0.5751991",
"0.57518566",
"0.57509124",
"0.5748188",
"0.57394785",
"0.5708285",
"0.5708285",
"0.5708285",
"0.5708285",
"0.5696455",
"0.5627801",
"0.5607647",
"0.55968994",
"0.5579527",
"0.5563995",
"0.5563995",
"0.5554137",
"0.55324084",
"0.55036294",
"0.5503189",
"0.5493163",
"0.54707116",
"0.54707116",
"0.5468984",
"0.5468984",
"0.54689837",
"0.5465696",
"0.545756",
"0.5457051",
"0.54530764",
"0.54452604",
"0.5441861",
"0.54294014",
"0.5411041",
"0.53849393",
"0.5383834",
"0.5379533",
"0.53725964",
"0.5371809",
"0.53659964",
"0.5357524",
"0.5356576",
"0.53500795",
"0.53483975",
"0.5348346",
"0.5334256",
"0.5325846",
"0.53254104",
"0.5316177",
"0.5315065",
"0.53130996",
"0.53130996",
"0.53049576",
"0.5304926",
"0.5301523",
"0.529196",
"0.5284082",
"0.52813774",
"0.52763987",
"0.52710134",
"0.52710134",
"0.52661264",
"0.5261005",
"0.5260116",
"0.525843",
"0.525843",
"0.525843",
"0.525843",
"0.52569675",
"0.5254161",
"0.52517503",
"0.52517503",
"0.5250058",
"0.5246739",
"0.5246739",
"0.5246739",
"0.52253556"
] | 0.0 | -1 |
two_points_to_line could return a Line or a VerticalLine | def two_points_to_line(x1,y1,x2,y2)
if real_close(x1,x2)
VerticalLine.new x1
else
m = (y2 - y1).to_f / (x2 - x1)
b = y1 - m * x1
Line.new(m,b)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def segment_to_line(x1, y1, x2, y2)\n raise 'Need two distinct points to define a segment' if x1 == x2 && y1 == y2\n\n # Vertical/horizontal/oblique lines\n if y1 == y2\n [0.0, 1.0, y1]\n elsif x1 == x2\n [1.0, 0.0, x1]\n else\n [y1 - y2, x2 - x1, x2 * y1 - x1 * y2]\n end\n end",
"def get_line(x0,x1,y0,y1)\n points = []\n steep = ((y1-y0).abs) > ((x1-x0).abs)\n if steep\n x0,y0 = y0,x0\n x1,y1 = y1,x1\n end\n if x0 > x1\n x0,x1 = x1,x0\n y0,y1 = y1,y0\n end\n deltax = x1-x0\n deltay = (y1-y0).abs\n error = (deltax / 2).to_i\n y = y0\n ystep = nil\n if y0 < y1\n ystep = 1\n else\n ystep = -1\n end\n for x in x0..x1\n if steep\n points << {:x => y, :y => x}\n else\n points << {:x => x, :y => y}\n end\n error -= deltay\n if error < 0\n y += ystep\n error += deltax\n end\n end\n return points\nend",
"def get_line(x0,x1,y0,y1)\n \t\tpoints = []\n\t\tsteep = ((y1-y0).abs) > ((x1-x0).abs)\n\t\tif steep then\n\t\t\tx0,y0 = y0,x0\n\t\t\tx1,y1 = y1,x1\n\t\tend\n\t\tif x0 > x1\n\t\t\tx0,x1 = x1,x0\n\t\t\ty0,y1 = y1,y0\n\t\tend\n\t\tdeltax = x1-x0\n\t\tdeltay = (y1-y0).abs\n\t\terror = (deltax / 2).to_i\n\t\ty = y0\n\t\tystep = nil\n\t\tif y0 < y1 then\n\t\t\tystep = 1\n\t\telse\n\t\t\tystep = -1\n\t\tend\n\t\tfor x in x0..x1\n\t\t\tif steep then\n\t\t\t\tpoints << {:x => y, :y => x}\n\t\t\telse\n\t\t\t\tpoints << {:x => x, :y => y}\n\t\t\tend\n\t\t\terror -= deltay\n\t\t\tif error < 0 then\n\t\t\t\ty += ystep\n\t\t\t\terror += deltax\n\t\t\tend\n\t\tend\n\t\treturn points\n\tend",
"def line(x, y)\n [x.value, y.value]\n end",
"def add_line(point1, point2)\n end",
"def lines\n points.each_cons(2).map {|a,b| Line.new a, b}\n end",
"def lines\n points.each_cons(2).map {|a,b| Line.new a, b}\n end",
"def parallel_line(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n Line.new(point, point + self.direction.to_point)\n end",
"def line(screen, p1, p2)\n\t\t# convert coords\n\t\tx1d, y1d = convert_coords(screen, p1[0], p1[1], p1[2])\n\t\tx2d, y2d = convert_coords(screen, p2[0], p2[1], p2[2])\n\t\t# draw line\n\t\tscreen.line(x1d, y1d, x2d, y2d)\n\tend",
"def to_line(*args)\n raise NotImplementedError.new 'No line conversion method defined!'\n end",
"def line(canvas, p1, p2, color)\n canvas.line(\n clamp(p1[0].round, 0, canvas.width-1),\n clamp(p1[1].round, 0, canvas.height-1),\n clamp(p2[0].round, 0, canvas.width-1),\n clamp(p2[1].round, 0, canvas.height-1),\n color)\n end",
"def normalizeLine(c1,c2)\n x = c2[0] - c1[0]\n y = c2[1] - c1[1]\n\n # make sure we didn't wrap one way or the other.\n # taking the shortest great circle distance.\n x = x <= -180 ? x + 360 : x\n x = x >= 180 ? x - 360 : x\n return [[0,0],[x,y]]\n end",
"def draw_line(start, endpoint)\n start = start.to_coords if start.respond_to?(:to_coords)\n start = start.to_ary # ... end\nend",
"def perpendicular_line(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n # any two lines in R^2 intersect, so blindly making\n # a line through p in an orthogonal direction will work\n Line.new(point, point + self.direction.orthogonal_direction.to_point)\n end",
"def draw_line(p1, p2)\n xs = arrange(p1.first, p2.first)\n ys = arrange(p1.last, p2.last)\n\n xs = xs * ys.size if ys.size > xs.size\n ys = ys * xs.size if xs.size > ys.size\n\n xs.zip(ys).each{|point| draw(point) }\n end",
"def line(a, b)\n return [a] if a == b\n a = offset_to_cube a\n b = offset_to_cube b\n n = cube_distance a, b\n (0..n).each_with_object([]) do |i, results|\n cube_coords = cube_round cube_lerp(a, b, 1.0 / n * i)\n results << cube_to_offset(cube_coords)\n end\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def hline y, c, x1 = 0, x2 = h\n line x1, y, x2, y, c\n end",
"def line(x1, y1, x2, y2)\n CGContextAddLines(@ctx, [NSPoint.new(x1, y1), NSPoint.new(x2, y2)], 2)\n CGContextDrawPath(@ctx, KCGPathStroke) # apply stroke\n endpath\n\n end",
"def calculate_points(lines)\n points = lines.map do |line|\n if line.p1.x == line.p2.x\n ys = Range.new(*[line.p1.y, line.p2.y].sort).to_a\n xs = [line.p1.x] * ys.size\n elsif line.p1.y == line.p2.y\n xs = Range.new(*[line.p1.x, line.p2.x].sort).to_a\n ys = [line.p1.y] * xs.size\n else\n # Diagonal line\n # Sort by x axis\n p1, p2 = [line.p1, line.p2].sort_by(&:x)\n xs = Range.new(*[p1.x, p2.x]).to_a\n if p1.y > p2.y \n # negative slope (reverse so we can still use range)\n ys = Range.new(*[p2.y, p1.y]).to_a.reverse\n else\n # positive slope\n ys = Range.new(*[p1.y, p2.y]).to_a\n end\n end\n xs.zip(ys).map { |c| Point.new(*c) }\n end\nend",
"def points_on_a_line(x0, y0, x1, y1)\n raise NotImplementedError\n dx = (x1 - x0).abs\n dy = -(y1 - y0).abs\n step_x = x0 < x1 ? 1 : -1\n step_y = y0 < y1 ? 1 : -1\n err = dx + dy\n coords = Array.new\n coords << [x0, y0]\n (\n begin\n e2 = 2 * err\n\n if e2 >= dy\n err += dy\n x0 += step_x\n end\n\n if e2 <= dx\n err += dx\n y0 += step_y\n end\n\n coords << [x0, y0]\n end\n\n ) until (x0 == x1 && y0 == y1)\n coords\n end",
"def line(x1, y1, x2, y2, opts = {})\n Shoes::Line.new app, Shoes::Point.new(x1, y1), Shoes::Point.new(x2, y2), style.merge(opts)\n end",
"def line_two\n @line_two\n end",
"def line_to(x, y)\n cur_page.line_to(x, y)\n end",
"def line_angle(p1,p2)\n v1 = RBA::DPoint.new(1,0)\n v2 = p2-p1\n return vector_angle(v1,v2)\n end",
"def Line(x1, y1, x2, y2)\n\t\t#Draw a line\n\t\tout(sprintf('%.2f %.2f m %.2f %.2f l S', x1 * @k, (@h - y1) * @k, x2 * @k, (@h - y2) * @k));\n\tend",
"def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end",
"def line(canvas, pt1, pt2, opt={})\n color = opt[:color] || opt[:c]\n color = canvas.type == :ppm ? [canvas.maxgray, canvas.maxgray, canvas.maxgray] : canvas.type == :pgm ? canvas.maxgray : 1 unless opt.has_key?(:color) || opt.has_key?(:c)\n\n @generator.parse_options({:h => canvas.height, :w => canvas.width, :d => 50})\n line = @generator.line(pt1[0], pt1[1], pt2[0], pt2[1]).pixels.dup\n original = canvas.pixels.dup\n \n edited = original.map.with_index { |row, y| row.map.with_index { |pixel, x| (line[y][x] == 1) ? color : pixel}}\n return PNM.create(edited, {:type => canvas.type, :maxgray => canvas.maxgray})\n end",
"def polyline(x, y, linewidth = nil, line_z = nil)\n # GR.jl - Multiple dispatch\n n = equal_length(x, y)\n if linewidth.nil? && line_z.nil?\n super(n, x, y)\n else\n linewidth ||= GR.inqlinewidth\n linewidth = if linewidth.is_a?(Numeric)\n Array.new(n, linewidth * 100)\n else\n raise ArgumentError if n != linewidth.length\n\n linewidth.map { |i| (100 * i).round }\n end\n line_z ||= GR.inqcolor(989) # FIXME\n color = if line_z.is_a?(Numeric)\n Array.new(n, line_z)\n else\n raise ArgumentError if n != line_z.length\n\n to_rgb_color(line_z)\n end\n z = linewidth.to_a.zip(color).flatten # to_a : NArray\n gdp(x, y, GDP_DRAW_LINES, z)\n end\n end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def line_point_distance(line_start, line_end, point)\n top = ((line_end.y - line_start.y) * point.x) -\n ((line_end.x - line_start.x) * point.y) +\n (line_end.x * line_start.y) - \n (line_end.y * line_start.x)\n bottom = ((line_end.y - line_start.y) ** 2 +\n (line_end.x - line_start.x) ** 2) ** 0.5\n return (top / bottom).abs\n end",
"def vline(x, y1, y2, c)\n x, y1, y2 = x.to_i, y1.to_i, y2.to_i\n\n unless self.bounds?(x, y1) && self.bounds?(x, y2)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (y1..y2).each {|y| self[y, x] = c}\n end",
"def lineto(point={})\n set RGhost::Line.make_command(:lineto,point)\n end",
"def as_line_string\n GeoRuby::SimpleFeatures::LineString.from_points(@points)\n end",
"def line(xx1, yy1, xx2, yy2)\n return \"some y out of range\" unless (0..@height).include?(yy1) && (0..@height).include?(yy2) \n return \"some x out of range\" unless (0..@width).include?(xx1) && (0..@width).include?(xx2)\n\n x1 = [xx1, xx2].min\n x2 = [xx1, xx2].max\n y1 = [yy1, yy2].min\n y2 = [yy1, yy2].max\n\n m = (y2.to_f - y1) / (x2 - x1)\n b = y2 - m * x2\n pixels = Array.new(@width, Array.new(@height, 0))\n\n (x1..x2).each do |x|\n column = Array.new(@height, 0)\n (y1..y2).each do |y|\n pixel = 0\n @density.times do |i|\n xx = (x + i.to_f / @density)\n yy = m * xx + b\n if yy >= y && yy < y + 1\n pixel = 1\n break\n end\n end\n column[y] = pixel\n end\n pixels[x] = column\n end\n\n PNM.create(pixels.transpose, {:type => :pbm})\n end",
"def line x1, y1, x2, y2, c\n h = self.h\n screen.draw_line x1, h-y1, x2, h-y2, color[c], :antialiased\n end",
"def sideline_seg( side )\n l = nil\n case side\n when :u; l = Gseg.new_by_pos( x1y1, x2y1 )\n when :d; l = Gseg.new_by_pos( x1y2, x2y2 )\n when :l; l = Gseg.new_by_pos( x1y1, x1y2 )\n when :r; l = Gseg.new_by_pos( x2y1, x2y2 )\n else; l = nil\n end\n l\n end",
"def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end",
"def distance_of_point_to_line(point, line, point_on_line)\n (point - point_on_line).dot((line).normal_unit).abs\n end",
"def line(x0, y0, x1, y1)\n # clean params\n x0, y0, x1, y1 = x0.to_i, y0.to_i, x1.to_i, y1.to_i\n y0, y1, x0, x1 = y1, y0, x1, x0 if y0>y1\n sx = (dx = x1-x0) < 0 ? -1 : 1 ; dx *= sx ; dy = y1-y0\n\n # special cases\n x0.step(x1,sx) { |x| point x, y0 } and return if dy.zero?\n y0.upto(y1) { |y| point x0, y } and return if dx.zero?\n x0.step(x1,sx) { |x| point x, y0; y0 += 1 } and return if dx==dy\n\n # main loops\n point x0, y0\n\n e_acc = 0\n if dy > dx\n e = (dx << 16) / dy\n y0.upto(y1-1) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n x0 += sx if (e_acc <= e_acc_temp)\n point x0, (y0 += 1), intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0+sx, y0, intensity(@color,(0xFF-w))\n end\n point x1, y1\n return\n end\n\n e = (dy << 16) / dx\n x0.step(x1-sx,sx) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n y0 += 1 if (e_acc <= e_acc_temp)\n point (x0 += sx), y0, intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0, y0+1, intensity(@color,(0xFF-w))\n end\n point x1, y1\n end",
"def distance_from_line(point_a,point_b)\n \n # Define the line as the vector between two points\n line_vector = point_b - point_a\n\n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # The magnitude of the cross product is equal to the area of the parallelogram described\n # by the two vectors. Dividing by the line length gives the perpendicular distance.\n (line_vector.cross(point_vector).magnitude / line_vector.magnitude).abs\n end",
"def divide_line_into_points(lat1, lon1, lat2, lon2, distance)\n # puts \"in line #{lat1}, #{lon1}, #{lat2}, #{lon2}, #{distance}\"\n points = []\n\n num_points = (RoadRollerHelper.get_line_length(lat1, lon1, lat2, lon2)/distance).to_i\n\n i = 1\n #puts \"#{RoadRollerHelper.get_line_length(lat1, lon1, lat2, lon2)} #{distance}\"\n while (i <= num_points)\n #puts \"#{i} #{num_points}\"\n lat, lon = get_new_point(lat1, lon1, lat2, lon2, distance*i)\n #puts \"lat, lon => #{lat} #{lon}\"\n points.push([lat, lon])\n i=i+1\n end\n puts \"num_points = #{num_points} #{points.length}\"\n return points\n end",
"def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend",
"def polyline(x, y)\n n = equal_length(x, y)\n super(n, x, y)\n end",
"def get_intersecting_line entity, connnectLine\n entity_x = entity.get_x\n entity_y = entity.get_y\n\n edges = []\n\n #Top edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x + ENTITY_WIDTH, entity_y)\n #Bottom edge\n edges << (Line2D::Double.new entity_x, entity_y + ENTITY_HEIGHT, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n #Left edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x, entity_y + ENTITY_HEIGHT)\n #Right edge\n edges << (Line2D::Double.new entity_x + ENTITY_WIDTH, entity_y, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n\n edges.each do |e|\n return e if connnectLine.intersects_line e\n end\n\n end",
"def vertical_line(column, first_row, second_row, colour)\n raise ArgumentError, 'invalid starting position' unless valid_coordinates?(first_row, column)\n raise ArgumentError, 'invalid end position' unless valid_coordinates?(second_row, column)\n raise ArgumentError, 'colour not set' unless colour\n\n (first_row..second_row).each do |i|\n self[column, i] = colour\n end\n end",
"def draw_line(x1, y1, x2, y2, options = {})\n options[:line_color] ||= RFPDF::COLOR_PALETTE[:black]\n options[:line_width] ||= 0.5\n set_draw_color_a(options[:line_color])\n SetLineWidth(options[:line_width])\n Line(x1, y1, x2, y2)\n end",
"def vertical_line (board)\n transposed_board = board.transpose\n return horizontal_line (transposed_board)\n end",
"def line_to_segment(a, b, c)\n raise 'Invalid line (a or b must be nonzero)' if a == 0 && b == 0\n\n if a == 0\n y = c.to_f / b\n [0.0, y, 1.0, y]\n elsif b == 0\n x = c.to_f / a\n [x, 0.0, x, 1.0]\n else\n [0.0, c.to_f / b, 1.0, (c - a).to_f / b]\n end\n end",
"def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end",
"def translate_to_point(*location)\n p = Point.new(*location)\n Line.new(p, Point.new(p.x + (x2 - x1), p.y + (y2 - y1)))\n end",
"def draw_line(x1, y1, x2, y2)\n if (x2-x1).abs > 0.95 * @max_width || (y2-y1).abs > 0.95 * @max_height\n return\n end\n\n\n x1 = scale(x1)\n y1 = scale(y1)\n x2 = scale(x2)\n y2 = scale(y2)\n\n strokeWeight(1)\n\n stroke(255)\n line(x1, y1, x2, y2)\n #stroke(0xff, 0xff, 0xff)\n #ellipse(x2, y2, 2, 2)\n end",
"def CreateLineElement2(arg0, arg1, arg2)\n ret = _invoke(1610743982, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def hline(x1, x2, y, c)\n x1, x2, y = x1.to_i, x2.to_i, y.to_i\n\n unless self.bounds?(x1, y) && self.bounds?(x2, y)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (x1..x2).each {|x| self[y, x] = c}\n end",
"def vline(x, y, height, options = {})\n options = LINE_OPTIONS.merge(options)\n\n \"<line x1=\\\"#{x}\\\" y1=\\\"#{y}\\\" x2=\\\"#{x}\\\" y2=\\\"#{y+height}\\\" \n style=\\\"stroke:#{options[:stroke]};\n stroke-width:#{options[:stroke_width]};\n stroke-linecap:#{options[:stroke_linecap]};\n stroke-opacity:#{options[:stroke_opacity]};\n stroke-dasharray:#{options[:dasharray]}\\\"/>\"\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def draw_line(x1,y1,x2,y2,r,g,b,graph_function=false)\n if ( @line_dot_size > 1 )\n self.draw_dotted_line(x1,y1,x2,y2,@line_dot_size,r,g,b,graph_function)\n else\n r = 0 if ( r < 0 )\n r = 255 if ( r > 255 )\n g = 0 if ( g < 0 )\n g = 255 if ( g > 255 )\n b = 0 if ( b < 0 )\n b = 255 if ( b > 255 )\n distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))\n if ( distance == 0 )\n #return -1\n else\n xstep = (x2-x1) / distance\n ystep = (y2-y1) / distance\n i =0\n while i<=distance\n x = i * xstep + x1\n y = i * ystep + y1\n if((x >= @g_area_x1 && x <= @g_area_x2&& y >= @g_area_y1 && y <= @g_area_y2) || !graph_function )\n if ( @line_width == 1 )\n self.draw_antialias_pixel(x,y,r,g,b)\n else\n start_offset = -(@line_width/2)\n end_offset = (@line_width/2)\n j = start_offset\n while j<=end_offset\n self.draw_antialias_pixel(x+j,y+j,r,g,b)\n end\n end\n end\n i =i+1\n end\n end\n end\n end",
"def egde(x1, y1, x2, y2)\n ConsoleDraw::Figures::Line.new(x1, y1, x2, y2).calculate_coordinates\n end",
"def get_line_coords(x, y)\n line = [[x,y]]\n loop do\n next_x, next_y = yield x, y\n @box[next_x] && @box[next_x][next_y] ? line << [next_x, next_y] : break\n x, y = next_x, next_y\n end\n line\n end",
"def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end",
"def distance_from_line_segment(point_a,point_b)\n\n # Define the line as the vector between two points\n line_vector = point_b - point_a\n \n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # Determine if self falls within the perpendicular 'shadow' of the line by calculating\n # the projection of the point vector onto the line.\n #\n # The dot product divided by the magnitude of the line gives the absolute projection\n # of the point vector onto the line.\n #\n # Dividing again by the line magnitude gives the relative projection along the line, \n # i.e. the ratio of the projection to the line. Values between 0-1 indicate that the\n # point falls within the perpendicular shadow.\n #\n projection_ratio = line_vector.dot(point_vector) / line_vector.magnitude ** 2\n\n if projection_ratio >= 1\n # The point is beyond point b, calculate distance to point b\n distance = (point_b - self).magnitude\n elsif projection_ratio <= 0\n # The point is beyond point a, calculate distance to point a\n distance = (point_a - self).magnitude\n else\n # The point is in the shadow of the line, return the perpendicular distance\n distance = line_vector.cross(point_vector).magnitude / line_vector.magnitude\n end\n\n return distance.abs\n end",
"def line(x, y, angle, length)\n cur_page.line(x, y, angle, length)\n end",
"def project_to_line\n end",
"def best_line(points)\n mean_x, mean_y = mean(points)\n slope = find_slope(mean_x, mean_y, points)\n if slope\n y_intercept = mean_y - slope * mean_y\n [slope, y_intercept]\n \"y = #{slope}*x - y_intercept\"\n else\n \"x = #{mean_x}\"\n end\nend",
"def line_distance(node_one, node_two)\n\t\tx_one = node_one.position[0]\n\t\tx_two = node_two.position[0]\n\n\t\ty_one = node_one.position[1]\n\t\ty_two = node_two.position[1]\n\n\t\tMath.hypot(x_one - x_two, y_one - y_two)\n\tend",
"def line(points, colour)\n\tpoints.each do |point|\n\t paint(point[0], point[1], colour)\n\tend\n end",
"def polyline points, options, &block\n \n # build a line\n line = Line.new options[:name]\n \n # build up a points float buffer\n pbuf = BufferUtils.createVector3Buffer(points.length / 2)\n puts \"arrived\"\n c = 0\n points.each do |v|\n pbuf.put v\n c += 1\n pbuf.put 0 if c % 2 == 0\n end\n \n # set the width\n if options.has_key? :line_width\n line.set_line_width(options[:line_width])\n end\n \n # set up the colors\n if options.has_key? :colors\n line.set_color_buffer(BufferUtils.create_float_buffer(options[:colors].to_java ColorRGBA))\n elsif options.has_key? :color\n line.set_default_color(options[:color])\n end\n \n #textures\n if options.has_key? :texture_points\n buffer = BufferUtils.createVector2Buffer options[:texture_points].length\n buffer.put options[:texture_points]\n line.set_texture_coords(TexCoords.new(buffer))\n end\n \n # index buffer\n ibuf = BufferUtils.createIntBuffer((0..(points.length / 2) - 1).to_a.to_java :int)\n \n # finish building the quad\n line.reconstruct(pbuf, nil, line.get_color_buffer, line.get_texture_coords[0])\n line.set_index_buffer ibuf\n \n # block invoke\n line.instance_eval(&block) if block\n \n line\n end",
"def draw_line(x1,y1,x2,y2,r,g,b,graph_function=false)\r\n if ( @line_dot_size > 1 )\n self.draw_dotted_line(x1,y1,x2,y2,@line_dot_size,r,g,b,graph_function)\n else\n r = 0 if ( r < 0 ) \n r = 255 if ( r > 255 ) \r\n g = 0 if ( g < 0 ) \n g = 255 if ( g > 255 ) \r\n b = 0 if ( b < 0 ) \n b = 255 if ( b > 255 ) \r\n distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) \r\n if ( distance == 0 )\r\n #return -1\n else \r\n xstep = (x2-x1) / distance\r\n ystep = (y2-y1) / distance\r\n i =0\n while i<=distance \r\n x = i * xstep + x1\r\n y = i * ystep + y1\r\n if((x >= @garea_x1 && x <= @garea_x2&& y >= @garea_y1 && y <= @garea_y2) || !graph_function )\r\n if ( @line_width == 1 )\r\n self.draw_antialias_pixel(x,y,r,g,b)\n else\r\n start_offset = -(@line_width/2) \n end_offset = (@line_width/2)\n j = start_offset\n while j<=end_offset\n self.draw_antialias_pixel(x+j,y+j,r,g,b)\n end \r\n end\r\n end\n i =i+1\r\n end\n end \n end \r\n end",
"def find_edge_intersecting_with_line(poly_verts, line_start, line_end)\n count = poly_verts.count\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n contact_loc = line_line_intersection(face_start, face_end, line_start, line_end)\n\n if contact_loc\n edge = Edge.new(face_start, face_end)\n edge.contact_loc = contact_loc\n return edge\n end\n end\n\n nil\n end",
"def draw_line(x1, y1, x2, y2, color)\n validate_coordinates!(x1, y1, x2, y2)\n validate_color!(color)\n\n area.draw_line(x1: x1, y1: y1, x2: x2, y2: y2, color: color)\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def line(id, from:[0,0], **attrs)\n draw_init\n unless to = attrs.delete(:to)\n raise ArgumentError, \"Argument 'to' is required\"\n end\n n1_id, n2_id = [1, 2].map { |i| \"#{id}#{i}\".to_id }\n point(n1_id, x:from[0], y:from[1],\n color:\"#FFFFFF00\", fillcolor:\"#FFFFFF00\")\n point(n2_id, x:to[0], y:to[1],\n color:\"#FFFFFF00\", fillcolor:\"#FFFFFF00\")\n attrs.update(arrowhead:\"none\")\n edge(:\"#{n1_id}_#{n2_id}\", attrs)\n end",
"def divide_linestring_into_points(road, distance)\n points = road.points\n\n i = 0\n linestring_points = []\n while( i < points.length - 1)\n start_point = points[i]\n end_point = points[i+1]\n distance_degrees = RoadRollerHelper.meters_to_degrees(distance, start_point.y)\n #puts \"%%%% #{RoadRollerHelper.get_line_length(start_point.y, start_point.x, end_point.y, end_point.x)} + #{distance_degrees}\"\n linestring_points = linestring_points + divide_line_into_points(start_point.y, start_point.x, end_point.y, end_point.x, distance_degrees)\n i=i+1\n end\n\n puts \"linestring_points = #{linestring_points.length}\"\n return linestring_points\n end",
"def get_hatch_points_y(points, y)\r\n plane = [Geom::Point3d.new(0, y, 0), Geom::Vector3d.new(0,1,0)]\r\n pts = []\r\n for i in 0..points.length-1 do\r\n y1 = points[i-1].y\r\n y2 = points[i].y\r\n # very small differences in Y values will cause the following tests to 'next' when they should not\r\n # ie Y might display as 2.9mm but be 1e-17 different than the point.y, and y < y1 so you get no point\r\n # where you want a point\r\n # rather use signed differences\r\n# next if (y1 == y2)\r\n# next if ((y1 > y2) && ((y > y1) || (y < y2)))\r\n# next if ((y1 < y2) && ((y < y1) || (y > y2)))\r\n#puts \"y1 #{y1} y2 #{y2}\" \r\n# dif = (y1-y2).abs\r\n if ((y1 - y2).abs < 0.001) # small enough?\r\n next\r\n end\r\n d1 = y - y1\r\n d2 = y - y2\r\n if ((y1 > y2) && ((d1 > 0.0001) || (d2 < -0.0001)))\r\n next\r\n end\r\n if ((y1 < y2) && ((d1 < -0.0001) || (d2 > 0.0001)))\r\n next\r\n end\r\n\r\n line = [points[i-1], points[i]]\r\n pt = Geom::intersect_line_plane(line, plane)\r\n# if ((pt.x < 237.0) || (pt.x > 366.0))\r\n# puts \"y1#{y1} y2#{y2} dif#{dif.to_mm} pt #{pt} Y #{y.to_mm} line #{line}\"\r\n# end\r\n if (pt)\r\n pts << pt\r\n end\r\n end #for\r\n pts.uniq!\r\n return pts.sort{|a,b| a.x <=> b.x}\r\n end",
"def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end",
"def line x1, y1, x2, y2, c\n screen.draw_line x1, y1, x2, y2, color[c], :antialiased\n end",
"def relate_price_to_line\n @price_list.each do |price|\n next unless price.respond_to?(:from_line_index)\n\n price_range = (price.from_line_index.to_i..price.to_line_index.to_i)\n price.line_list = @route_list[0].line_list.select { |line| price_range.include?(line.index.to_i) }\n end\n end",
"def face_to_lines(face)\n Kernel.raise \"non tris not supported\" if face.verts.length != 3\n v1, v2, v3 = face.verts.map { |vert| [vert.render_x, vert.render_y, vert.y] }.sort_by { |vert| vert.y }\n cross = VectorMath::normalize(VectorMath::cross3((face.verts[1] - face.verts[0]).row_vector, (face.verts[2] - face.verts[0]).row_vector))\n r = 254 * VectorMath::dot(cross,[0.0, 1.0, 0.0]).abs + 1\n g = 254 * VectorMath::dot(cross,[1.0, 0.0, 0.0]).abs + 1\n b = 254 * VectorMath::dot(cross,[0.0, 0.0, 1.0]).abs + 1\n g = b = r\n out = draw_tri(v1.x,v1.y,v2.x,v2.y,v3.x,v3.y,r,g,b)\nend",
"def vertical_line(options={:start_in => :limit_left, :size => :area_y})\n set RGhost::VerticalLine.new(options)\n end",
"def draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)\n @graphics.draw_line(x1, y1, c1, x2, y2, c2, z, AM_MODES[mode])\n end",
"def Point2dFromXY(arg0, arg1)\n ret = _invoke(1610743822, [arg0, arg1], [VT_R8, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def line_to(x, y)\n update_bounds_rect(@x, @y, x, y)\n @x, @y = x, y\n @gui.line_to(x, y)\n self\n end",
"def lines\n raise 'invalid polygon' unless valid?\n 0.upto(points.size - 1).collect do |i|\n Line.new(points[i % n], points[(i + 1) % n])\n end\n end",
"def get_polyline_on_edges(p_hash)\n # initialize with the given hash\n hcl = p_hash [\"hexagone_depart\"].split(';')\n hexagon = hn_from_hcl(hcl.first.to_i, hcl.last.to_i) \n vertex = p_hash [\"angle_depart\"]\n directions = Service.uncompressed_directions(p_hash [\"liste_directions\"])\n # provide the beginning of the polyline\n polyline_points = \"#{x_vertex(hexagon, vertex.swapcase.intern)},#{y_vertex(hexagon, vertex.swapcase.intern)} \"\n # for each direction, find the new hexagon and vertex, then provide the next set of coordinates\n directions.split(',').each do |direction|\n case direction + vertex\n when \"NN\", \"NONE\" then hexagon = adjacent(hexagon, :ne) \n when \"NENE\", \"NSE\" then hexagon = adjacent(hexagon, :e) \n when \"NES\", \"SESE\" then hexagon = adjacent(hexagon, :se) \n when \"SS\", \"SESO\" then hexagon = adjacent(hexagon, :so) \n when \"SNO\", \"SOSO\" then hexagon = adjacent(hexagon, :o) \n when \"SON\", \"NONO\" then hexagon = adjacent(hexagon, :no)\n end \n vertex = case direction\n when \"N\" then \"NO\" \n when \"NE\" then \"N\" \n when \"SE\" then \"NE\" \n when \"S\" then \"SE\" \n when \"SO\" then \"S\" \n when \"NO\" then \"SO\"\n end \n polyline_points << \"#{x_vertex(hexagon, vertex.swapcase.intern)},#{y_vertex(hexagon, vertex.swapcase.intern)} \"\n end\n # and return the string of coordinates\n return polyline_points.chop\n end",
"def draw_line(start_x, start_y, end_x, end_y, image)\n line = Magick::Draw.new\n line.polyline(start_x, start_y, end_x, end_y)\n line.draw(image)\nend",
"def travel_diff(line1, line2)\n\t\tputs \"You will need to change trains at UNION SQUARE!\"\n\t\tputs \"Board the train at #{$subway_station[$get_on - 1]}\"\n\t\tend_point_diff = line2.index $subway_station[$get_off - 1]\n\t\tstart_point_diff = line2.index $intersect\n\n\t\t### STARTING LINE IS WHICH?\n\t\tif line1 == $line_n\n\t\t\tlist_stops_int(4, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\n\t\telsif line1 == $line_l\n\t\t\tlist_stops_int(2, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\n\t\telsif line1 == $line_6\n\t\t\tlist_stops_int(3, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\t\tend\n\tend",
"def onMouseMove(flags, x, y, view)\n if( @state == 0 )\n # We are getting the first end of the line. Call the pick method\n # on the InputPoint to get a 3D position from the 2D screen position\n # that is passed as an argument to this method.\n @ip.pick view, x, y\n if( @ip != @ip1 )\n # if the point has changed from the last one we got, then\n # see if we need to display the point. We need to display it\n # if it has a display representation or if the previous point\n # was displayed. The invalidate method on the view is used\n # to tell the view that something has changed so that you need\n # to refresh the view.\n view.invalidate if( @ip.display? or @ip1.display? )\n @ip1.copy! @ip\n\n # set the tooltip that should be displayed to this point\n view.tooltip = @ip1.tooltip\n end\n else\n # Getting the second end of the line\n # If you pass in another InputPoint on the pick method of InputPoint\n # it uses that second point to do additional inferencing such as\n # parallel to an axis.\n @ip2.pick view, x, y, @ip1\n view.tooltip = @ip2.tooltip if( @ip2.valid? )\n view.invalidate\n\n # Update the length displayed in the VCB\n if( @ip2.valid? )\n length = @ip1.position.distance(@ip2.position)\n Sketchup::set_status_text length.to_s, SB_VCB_VALUE\n end\n\n # Check to see if the mouse was moved far enough to create a line.\n # This is used so that you can create a line by either dragging\n # or doing click-move-click\n if( (x-@xdown).abs > 10 || (y-@ydown).abs > 10 )\n @dragging = true\n end\n end\n end",
"def lineto(x, y)\n CGContextAddLineToPoint(@ctx ,x, y)\n end",
"def rlineto(point={})\n set RGhost::Line.make_command(:rlineto,point)\n end",
"def line\n lines.line(y)\n end",
"def draw_vertical(start_line, end_line, start_char)\n start_line.upto(end_line) do |line_idx| \n @lines[line_idx][start_char] = PATH_CHAR \n end\n end",
"def ==(other)\n return false unless other.is_a?(Line)\n Point.is_collinear?(self.p1, other.p1, self.p2, other.p2)\n end"
] | [
"0.8462112",
"0.8452559",
"0.8433226",
"0.8380715",
"0.7575376",
"0.6964064",
"0.6899736",
"0.66776496",
"0.6625103",
"0.64518577",
"0.64518577",
"0.63937855",
"0.6326386",
"0.6274274",
"0.62541175",
"0.6214541",
"0.6125935",
"0.6125211",
"0.6080139",
"0.60770565",
"0.60354006",
"0.60354006",
"0.6019114",
"0.6013472",
"0.60095984",
"0.5967101",
"0.5965852",
"0.5962881",
"0.5955865",
"0.5949362",
"0.59444755",
"0.5902418",
"0.59016514",
"0.58821756",
"0.58821756",
"0.587706",
"0.582874",
"0.5824888",
"0.58160454",
"0.58033717",
"0.5789637",
"0.5784902",
"0.5776809",
"0.5762809",
"0.5760434",
"0.5736913",
"0.57352227",
"0.5732884",
"0.57230204",
"0.57225937",
"0.5720716",
"0.57007325",
"0.56965923",
"0.56731814",
"0.56651294",
"0.5650624",
"0.5627661",
"0.56261826",
"0.5619856",
"0.56092787",
"0.5605928",
"0.5605928",
"0.5605928",
"0.5598201",
"0.5559156",
"0.5555352",
"0.55502915",
"0.5533045",
"0.55297774",
"0.55239147",
"0.55212003",
"0.5517201",
"0.5499916",
"0.54989254",
"0.54906344",
"0.5477833",
"0.54742867",
"0.54666847",
"0.545245",
"0.543743",
"0.54164505",
"0.54152536",
"0.5393927",
"0.53911805",
"0.53739285",
"0.53730476",
"0.53591603",
"0.5343806",
"0.53279895",
"0.5315382",
"0.5306726",
"0.529575",
"0.5290421",
"0.5278803",
"0.52710027",
"0.52578485",
"0.52325374",
"0.52248067",
"0.52224606",
"0.52198696"
] | 0.84063846 | 3 |
we put this in this class so all subclasses can inherit it: the intersection of self with a NoPoints is a NoPoints object | def intersectNoPoints np
np # could also have NoPoints.new here instead
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def points; end",
"def points #:nodoc:\n [self]\n end",
"def points #:nodoc:\n [self]\n end",
"def intersectPoint p\n if real_close_point(x,y,p.x,p.y) then self\n else NoPoints.new\n end\n end",
"def base_points\n points\n end",
"def points\n -1\n end",
"def initialize(points)\n @points = points\n end",
"def initialize(pts = nil)\n self.points = Array.new\n self.add_points pts if pts\n end",
"def initialize()\n @points = []\n end",
"def ne(_obj)\n raise NotImplementedError\n end",
"def not_in(_obj)\n raise NotImplementedError\n end",
"def initialize(points, colour) #position, points, colour)\n super(colour) #position, colour)\n @points = points\n #puts \"PointsPart\"\n #@points.each { |p| puts \"(#{p.x}, #{p.y})\" }\n end",
"def superclass() end",
"def set_points\n self.points ||= 0.0\n end",
"def not\n self.class.not(self)\n end",
"def initialize\n @x = 0\n @y = 0\n set_obj(self)\n end",
"def points\n []\n end",
"def initialize(center)\n @center = center\n @points = []\n end",
"def not_null\n bad_boi_points ||=0\n good_boi_points ||=0\n end",
"def draw n\n raise NotImplementedError, \"Subclass Responsibility\"\n end",
"def initialize(x, y)\n @x = x\n @y = y\n @hit = false\n end",
"def ignores; end",
"def missing_point?\n from.nil? || to.nil?\n end",
"def initialize\n @x\n @y\n @facing\n @placed = false\n end",
"def initialize(x,y)\n@x,@y = x, y\n# Initialize method\n# Sets initial values for instance variables\n# Use the class variables in this instance method to collect data\n@@n += 1\n# Keep track of how many Points have been created\n@@totalX += x\n# Add these coordinates to the totals\n@@totalY += y\nend",
"def points\n 1\n end",
"def superclass\n\t\t\t\treturn Object\n\t\t\tend",
"def initialize(*points_or_lines)\n @points = []\n points_or_lines.each { |pol| self << pol }\n end",
"def collision_rect\r\r\n #return @custom_collision if @custom_collision.size > 0\r\r\n return super\r\r\n end",
"def include?(point)\n self.points.include? point\n end",
"def get_intersection\n end",
"def inherit(node)\n ping.remove\n super\n end",
"def initialize(points)\n @points = points.map.with_index { |(x, y, name), idx|\n Point.new(x, y, idx).tap { |p| p.name = name if name }\n }\n @sorted_points = @points.sort # Point implements <=> to sort by X and break ties by Y\n triangulate(@sorted_points)\n end",
"def starship; end",
"def intersection(other)\n if other.is_a?(Point)\n return points_intersection(self, other)\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between Point and #{ other.class } is not defined\"\n end",
"def initialize(point)\n @point = point\n end",
"def hitTest(point, withEvent:event)\n s = super\n if s == self && @userInteractionEnabled == false\n return nil\n end\n s\n end",
"def initialize(p1, p2)\n @p1 = Point.new(p1)\n @p2 = Point.new(p2)\n end",
"def initialize_points\n self.current_points = 0\n self.expiring_points = 0\n end",
"def empty_neighbours point\n neighbours(point).select do |(x, y)|\n at(x, y) < 0\n end\n end",
"def inherited(_sub)\n raise Error, \"cannot subclass #{self}\" unless self == Object\n end",
"def normal(p)\n # Must be overriden by subclasses\n end",
"def initialize(_x = 0, _y = 0)\n if `typeof(#{_x})` == \"object\"\n super(_x)\n else\n @native = `new Phaser.Point(#{_x}, #{_y})`\n super(@native)\n end\n end",
"def overrides; end",
"def initialize(*)\n super\n reduce(public, any)\n end",
"def set_points!\n self.points = 0 unless self.points.presence\n end",
"def initialize\n super\n @sub = Subordinate2.new\n end",
"def == (other)\n @points == other.points\n end",
"def point( *args ) @g.class.new( *args ); end",
"def initialize(x,y) # Initialize method\n @x,@y = x,y # Sets initial values for instance variables\n \n # Use the class variables in this instance method to collect data\n @@n += 1 # Keep track of how many Points have been created\n @@totalX += @x # Add these coordinates to the totals \n end",
"def initialize(point1, point2, point3)\n\t\t@point1 = point1\n\t\t@point2 = point2\n\t\t@point3 = point3\n\t\t@area = 0\n\t\tfind_area\n\tend",
"def collision obj\n\t\tend",
"def inherited(base); end",
"def initialize(point1, point2)\n @p1 = point1; @p2 = point2\n \n check_input_points!\n validate!\n end",
"def add_point\n end",
"def set_defaults\n super\n self.distance_from_intersection ||= 0\n self.lateral_offset ||= 0\n end",
"def initialize(*args)\n x = []\n y = []\n args.each do |arg|\n case arg\n when Boundable\n x += arg.loose_bounds.collect { |p| p.x }\n y += arg.loose_bounds.collect { |p| p.y }\n when Point\n x.push arg.x\n y.push arg.y\n end\n end\n @min = Point.new(x.min, y.min)\n @max = Point.new(x.max, y.max)\n end",
"def a_point_belongs_to_ship(a_point)\n\toccupied_points.any? { |point| point.is_equal(a_point) } \n end",
"def is_null()\n res = super(context,self)\n return res\n end",
"def initialize(x,y)\n @x,@y = x, y # Sets initial values for instance variables\n \n # Use the class variables in this instance method to collect data\n @@n += 1 # Keep track of how many Points have been created\n @@totalX += x # Add these coordinates to the totals\n @@totalY += y\n end",
"def default_points\n \tself.point_bank = 1000\n end",
"def initialize(x,y) # Initialize method\n @x,@y = x, y # Sets initial values for instance variables\n\n # Use the class variables in this instance method to collect data\n @@n += 1 # Keep track of how many Points have been created\n @@totalX += x # Add these coordinates to the totals\n @@totalY += y\n end",
"def initialize(x,y)\n @x,@y = x, y # Sets initial values for instance variables\n # Use the class variables in this instance method to collect data\n @@n += 1 # Keep track of how many Points have been created\n @@totalX += x # Add these coordinates to the totals\n @@totalY += y\n PointStats.instance.record(self)\n end",
"def private; end",
"def opposite(p)\n return CGAL::Point_2.build(self.y, self.x)\n end",
"def base; self; end",
"def method_missing(*)\n invertable nil\n end",
"def special\n override\n end",
"def missing; end",
"def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end",
"def begingraphics(*)\n super\n end",
"def geom\n _point || _box\n end",
"def is_undefined()\n res = super(context,self)\n return res\n end",
"def initialize(type)\n @type = type\n @squares = []\n #Base point, all other points must have coordinates (0+-,0+), base is top-left most point of the shape\n @squares << Pentomino::Point.new(0,0)\n end",
"def initialize(points)\n @@hull_id ||= 0\n @hull_id = @@hull_id\n @@hull_id += 1\n\n @points = points.dup\n @leftmost = points.first\n @rightmost = points.last\n\n points.each do |p| p.hull = self end\n end",
"def full_object\n fail NotImplementedError\n end",
"def ==(other_point)\r\n if other_point.class != self.class\r\n false\r\n else\r\n @x == other_point.x and @y == other_point.y and @z == other_point.z and @m == other_point.m\r\n end\r\n end",
"def skip_leader\n raise NotImplementedError\n end",
"def my_soa\n if self.soa.empty?\n self.inherit_from.my_soa\n else\n self.soa\n end\n end",
"def add!(p)\n@x += p.x\n@y += p.y\nself\nend",
"def suitable_for_none?\n \treturn self.disciplines.empty?\n end",
"def initialize\n super()\n Compo::Composites::Parentless.for(self)\n end",
"def <=>(other)\n# Define the <=> operator\nreturn nil unless other.instance_of? Point\nself.x**2 + self.y**2 <=> other.x**2 + other.y**2\nend",
"def points\n object.polygon.points\n end",
"def < (point2)\n end",
"def unclustered_points\n points.select {|point| not point.clustered? }\n end",
"def identity\r\n new_point = Marshal.load(Marshal.dump(self))\r\n new_point.x = 0\r\n new_point.y = 0\r\n new_point.x = @x / @x.abs if @x != 0\r\n new_point.y = @y / @y.abs if @y != 0\r\n return new_point\r\n end",
"def used\n raise NotImplementedError\n end",
"def _associated_objects_use_same_server?\n return super if defined?(super)\n false\n end",
"def no_extensions\n self.class.base_vertex_wrapper.new graph, element\n end",
"def internship_passed; end",
"def set_default_current_points \n self.current_points = 0\n end",
"def -(other)\n case other\n when Point\n Point.new(x - other.x, y - other.y)\n when Numeric\n Point.new(x - other, y - other)\n when Array\n self - Geom2D::Point(other)\n else\n raise ArgumentError, \"Invalid argument class, must be Numeric or Point\"\n end\n end",
"def dont_care\n each(&:dont_care)\n myself\n end",
"def initialize(target=nil, &data_block)\n super()\n @drawPoints = true\n @domain = target.domain if target\n @range = target.range if target\n @data_block = data_block\n @target = target\n end",
"def polymarker(x, y)\n n = equal_length(x, y)\n super(n, x, y)\n end"
] | [
"0.704855",
"0.704855",
"0.704855",
"0.6201722",
"0.6112243",
"0.6112243",
"0.6092155",
"0.57806504",
"0.57174975",
"0.5679841",
"0.56783336",
"0.5502878",
"0.54234487",
"0.54140586",
"0.5407734",
"0.5407371",
"0.5377398",
"0.5372",
"0.53660744",
"0.5349252",
"0.533825",
"0.5328454",
"0.531467",
"0.5284449",
"0.5275815",
"0.5268367",
"0.5259408",
"0.52583075",
"0.5247091",
"0.5234768",
"0.5226142",
"0.522151",
"0.52073985",
"0.5204997",
"0.52045673",
"0.51781356",
"0.5176961",
"0.5176886",
"0.51749456",
"0.51599383",
"0.51528186",
"0.51522297",
"0.5151288",
"0.51433116",
"0.51367027",
"0.51252604",
"0.5124471",
"0.51179624",
"0.5110826",
"0.5109689",
"0.51061064",
"0.5105526",
"0.5095518",
"0.5079269",
"0.5074224",
"0.50669503",
"0.50577563",
"0.50576437",
"0.50566053",
"0.5053648",
"0.5053244",
"0.5050484",
"0.5043675",
"0.5040307",
"0.50365406",
"0.5035453",
"0.50331014",
"0.5027856",
"0.5024392",
"0.50237954",
"0.5018452",
"0.5015076",
"0.5013982",
"0.50106543",
"0.5007472",
"0.5006426",
"0.500601",
"0.50022495",
"0.499726",
"0.49927133",
"0.4988044",
"0.49838606",
"0.49830675",
"0.49809477",
"0.49781758",
"0.49722743",
"0.4972115",
"0.49576005",
"0.49529725",
"0.4950202",
"0.49410152",
"0.49370822",
"0.49360695",
"0.49343663",
"0.49310985",
"0.49277526",
"0.49273884",
"0.49271628",
"0.49234825"
] | 0.70432645 | 4 |
we put this in this class so all subclasses can inhert it: the intersection of self with a LineSegment is computed by first intersecting with the line containing the segment and then calling the result's intersectWithSegmentAsLineResult with the segment | def intersectLineSegment seg
line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))
line_result.intersectWithSegmentAsLineResult seg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end",
"def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end",
"def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end",
"def line_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n\n end",
"def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end",
"def intersection_point(segment)\n # numerator = (line.point1.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (line.point1.x - point1.x)\n # denominator = (point2.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (point2.x - point1.x)\n #\n # t = numerator.to_f / denominator\n #\n # x = point1.x + t * (point2.x - point1.x)\n # y = point1.y + t * (point2.y - point1.y)\n #\n # Point.new(x, y)\n\n x1, y1, x2, y2 = point1.x, point1.y, point2.x, point2.y\n x3, y3, x4, y4 = segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y\n\n x12 = x1 - x2\n x34 = x3 - x4\n y12 = y1 - y2\n y34 = y3 - y4\n\n c = x12 * y34 - y12 * x34\n\n raise Exception.new('Segments are parallel.') if c.zero?\n\n a = x1 * y2 - y1 * x2\n b = x3 * y4 - y3 * x4\n\n x = (a * x34 - b * x12) / c\n y = (a * y34 - b * y12) / c\n\n Point.new(x, y)\n end",
"def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end",
"def intersection( to )\n\n # Bullet line between box center and to-point.\n bline = Gseg.new( self.pos.to_gpos, to )\n\n # Find which side of self intersects with bline.\n side = nil\n [ :r, :l, :u, :d ].each do |sidesym|\n trial = self.sideline_seg( sidesym )\n if trial.intersects_with?( bline )\n side = trial\n break\n end\n end\n\n side.intersection_point_with( bline )\n end",
"def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4)\n # calculate vector products\n d1 = (x3 - x1) * (y4 - y1) - (x4 - x1) * (y3 - y1)\n d2 = (x3 - x2) * (y4 - y2) - (x4 - x2) * (y3 - y2)\n d3 = (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n d4 = (x1 - x4) * (y2 - y4) - (x2 - x4) * (y1 - y4)\n # check vector product results\n if (d1 > 0 && d2 < 0 || d1 < 0 && d2 > 0) &&\n (d3 > 0 && d4 < 0 || d3 < 0 && d4 > 0)\n # intersection exists\n return true\n end\n # if at least one point of one line lies on the other line\n if d1 == 0 && (x3 < x4 ? x3 : x4) <= x1 && x1 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y1 && y1 <= (y3 > y4 ? y3 : y4) ||\n d2 == 0 && (x3 < x4 ? x3 : x4) <= x2 && x2 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y2 && y2 <= (y3 > y4 ? y3 : y4) ||\n d3 == 0 && (x1 < x2 ? x1 : x2) <= x3 && x3 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y3 && y3 <= (y1 > y2 ? y1 : y2) ||\n d4 == 0 && (x1 < x2 ? x1 : x2) <= x4 && x4 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y4 && y4 <= (y1 > y2 ? y1 : y2)\n # intersection exists\n return true\n end\n # intersection does not exist\n return false\n end",
"def intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end",
"def lineIntersects _args\n \"lineIntersects _args;\" \n end",
"def terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n # Is the intersect at one of +new_seg+ terminii?\n # If so, split +seg+ into two segs at pt_intersect.\n if pt_intersect == new_seg.pt1 || pt_intersect == new_seg.pt2\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n return []\n end\n\n # Does a +seg+ terminus lie along *new_seg+?\n #\n # If so, add +seg+ to the +new_list+ and return the two part of the slit +new_seg+\n if pt_intersect == seg.pt1 || pt_intersect == seg.pt2\n new_list << seg\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n end\n\n return nil\n end",
"def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend",
"def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end",
"def bbpLineIntersect(point_a, point_b, point_c, point_d, hit_point, second_hit_point)\n\n rise 'Method not implemented'\n end",
"def intersection_segment(pt1, pt2, pt3, pt4)\n pt = intersection(pt1, pt2, pt3, pt4)\n \n segment_length = pt3.dist_to(pt4)\n \n dist3 = pt.dist_to(pt3)\n dist4 = pt.dist_to(pt4)\n \n if dist3 + dist4 == segment_length\n pt\n else\n nil\n end\n \n # slope = pt4.slope_to(pt3)\n # \n # y1 = pt.x * slope + pt3.y\n # y2 = pt.x * slope + pt4.y\n # \n # y1 == pt.y or y2 == pt.y\n end",
"def line_intersection(l1, l2)\n x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0]\n y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1]\n\n denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)\n return false if denominator == 0\n dxy12 = (x1*y2 - y1*x2)\n dxy34 = (x3*y4 - y3*x4)\n x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator\n y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator\n WorldGen::Vector[x.round, y.round]\n end",
"def find_edge_intersecting_with_line(poly_verts, line_start, line_end)\n count = poly_verts.count\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n contact_loc = line_line_intersection(face_start, face_end, line_start, line_end)\n\n if contact_loc\n edge = Edge.new(face_start, face_end)\n edge.contact_loc = contact_loc\n return edge\n end\n end\n\n nil\n end",
"def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end",
"def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end",
"def intersection( to )\n cp = self.pos.to_gpos\n\n line = cp.to_vec( to )\n uline = line.unit\n radius = uline * size.x\n\n ( cp.to_vec + radius ).to_gpos\n end",
"def get_intersecting_line entity, connnectLine\n entity_x = entity.get_x\n entity_y = entity.get_y\n\n edges = []\n\n #Top edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x + ENTITY_WIDTH, entity_y)\n #Bottom edge\n edges << (Line2D::Double.new entity_x, entity_y + ENTITY_HEIGHT, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n #Left edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x, entity_y + ENTITY_HEIGHT)\n #Right edge\n edges << (Line2D::Double.new entity_x + ENTITY_WIDTH, entity_y, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n\n edges.each do |e|\n return e if connnectLine.intersects_line e\n end\n\n end",
"def intersection( to )\n cp = self.pos.to_gpos\n sp = self.size.to_gpos\n line = cp.to_vec( to )\n\n n = line.rad\n a = sp.x\n b = sp.y\n\n div = Math.sqrt( ( b*Math.cos(n) ) ** 2 + ( a*Math.sin(n) ) ** 2 )\n px = ( a * b * Math.cos(n) ) / div\n py = ( a * b * Math.sin(n) ) / div\n\n cp.to_vec + Gvec[ px, py ]\n end",
"def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end",
"def find_intersection_point_with(segment)\n denominator = ((segment.p2.y - segment.p1.y)*(p2.x - p1.x)) - \n ((segment.p2.x - segment.p1.x)*(p2.y - p1.y))\n\n numerator_a = ((segment.p2.x - segment.p1.x)*(p1.y - segment.p1.y)) - \n ((segment.p2.y - segment.p1.y)*(p1.x - segment.p1.x))\n\n numerator_b = ((p2.x - p1.x)*(p1.y - segment.p1.y)) - \n ((p2.y - p1.y)*(p1.x - segment.p1.x))\n\n if denominator == 0.0\n if numerator_a == 0.0 && numerator_b == 0.0\n # 'COINCIDENT'\n return nil\n end\n # 'PARALLEL'\n return nil\n end\n\n ua = numerator_a/denominator\n ub = numerator_b/denominator\n\n # An intersection point exists, given the following conditions\n \n if ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0\n x = point1.x + ua*(p2.x - p1.x)\n y = point1.y + ua*(p2.y - p1.y)\n\n return Point.new(x, y)\n end\n \n # 'NOT_INTERESECTING'\n return nil\n end",
"def intersection(another_segment)\n return TestHalfEdge.he_intersection(@start,@ending,another_segment.start,\n another_segment.ending)\n end",
"def segment_to_line(x1, y1, x2, y2)\n raise 'Need two distinct points to define a segment' if x1 == x2 && y1 == y2\n\n # Vertical/horizontal/oblique lines\n if y1 == y2\n [0.0, 1.0, y1]\n elsif x1 == x2\n [1.0, 0.0, x1]\n else\n [y1 - y2, x2 - x1, x2 * y1 - x1 * y2]\n end\n end",
"def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end",
"def lineIntersectsObjs _args\n \"lineIntersectsObjs _args;\" \n end",
"def get_intersection\n end",
"def intersection(other)\n intersection_result = []\n \n if other.is_a?(Polygon) \n k = other.sides \n else \n k = [other]\n end\n\n self.sides.each do |side|\n k.each do |side1|\n intersection_result += side.intersection(side1)\n end\n end\n\n intersection_result.uniq! do |a|\n if a.is_a?(Point)\n [a.x, a.y]\n else\n [a.p1, a.p2].sort_by {|p| [p.x, p.y]} \n end\n end\n points = []; segments = []\n\n intersection_result.each do |entity|\n points << entity if entity.is_a?(Point)\n segments << entity if entity.is_a?(Segment)\n end\n\n if !points.empty? && !segments.empty?\n points_in_segments = []\n\n points.each do |point|\n segments.each do |segment|\n points_in_segments << point if segment.contains?(point)\n end\n end\n\n points_in_segments.uniq! {|a| [a.x, a.y]}\n if !points_in_segments.empty?\n points_in_segments.each do |p|\n points.delete(p)\n end\n end\n\n return points.sort + segments.sort\n end\n\n return intersection_result.sort\n end",
"def bbpSegmentIntersect(point_a, point_b, point_c, point_d)\n\n rise 'Method not implemented'\n end",
"def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if segments_intersect?(line, rect_line)\n end\n\n false\n end",
"def distance_from_line_segment(point_a,point_b)\n\n # Define the line as the vector between two points\n line_vector = point_b - point_a\n \n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # Determine if self falls within the perpendicular 'shadow' of the line by calculating\n # the projection of the point vector onto the line.\n #\n # The dot product divided by the magnitude of the line gives the absolute projection\n # of the point vector onto the line.\n #\n # Dividing again by the line magnitude gives the relative projection along the line, \n # i.e. the ratio of the projection to the line. Values between 0-1 indicate that the\n # point falls within the perpendicular shadow.\n #\n projection_ratio = line_vector.dot(point_vector) / line_vector.magnitude ** 2\n\n if projection_ratio >= 1\n # The point is beyond point b, calculate distance to point b\n distance = (point_b - self).magnitude\n elsif projection_ratio <= 0\n # The point is beyond point a, calculate distance to point a\n distance = (point_a - self).magnitude\n else\n # The point is in the shadow of the line, return the perpendicular distance\n distance = line_vector.cross(point_vector).magnitude / line_vector.magnitude\n end\n\n return distance.abs\n end",
"def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end",
"def segment_segment_intersection(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn false if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t#(self.cp(bx, by, cx, cy, ax, ay) != self.cp(bx, by, dx, dy, ax, ay)) && (self.cp(dx, dy, ax, ay, cx, cy) != self.cp(dx, dy, bx, by, cx, cy))\n\t\t(self.class.cp(bx, by, cx, cy, ax, ay) != self.class.cp(bx, by, dx, dy, ax, ay)) && (self.class.cp(dx, dy, ax, ay, cx, cy) != self.class.cp(dx, dy, bx, by, cx, cy))\n\tend",
"def process_and_add(new_seg)\n\n # If this is a duplicate, just don't add it.\n return nil if duplicate?(new_seg)\n\n\n # Seek and handle intersections.\n new_list = []\n reprocess = []\n @segs.each do |seg|\n pt_intersect = seg.intersection(new_seg)\n unless pt_intersect\n new_list << seg\n next\n end\n\n # No splits if they just intersect at terminii. \n next if terminus_terminus_intersect(pt_intersect, new_list, seg, new_seg)\n # Separate handing of intersection at a terminus\n if rv = terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n if rv.size > 1\n new_seg = rv.shift\n reprocess << rv\n end\n else\n # Must be a line/line intersect.\n rv = line_line_intersect(pt_intersect, new_list, seg, new_seg)\n new_seg = rv.shift\n reprocess << rv\n end\n \n end\n new_list << new_seg\n @segs = new_list\n\n if reprocess.size == 0\n return nil\n else\n return reprocess.flatten\n end\n end",
"def intersection(other)\n if other.is_a?(Point)\n return points_intersection(self, other)\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between Point and #{ other.class } is not defined\"\n end",
"def extended_segment_intersection?(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn true if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t(cp(bx, by, cx, cy, ax, ay) != cp(bx, by, dx, dy, ax, ay)) || (cp(dx, dy, ax, ay, cx, cy) != cp(dx, dy, bx, by, cx, cy))\n\tend",
"def distance_from_line(point_a,point_b)\n \n # Define the line as the vector between two points\n line_vector = point_b - point_a\n\n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # The magnitude of the cross product is equal to the area of the parallelogram described\n # by the two vectors. Dividing by the line length gives the perpendicular distance.\n (line_vector.cross(point_vector).magnitude / line_vector.magnitude).abs\n end",
"def intersection(lat, lng, r)\n \n # Convert degrees to meters\n x1 = Segment.length([lat, lng], [lat, @a[1]]) # lng\n x1 *= -1 if lng > @a[1]\n\n y1 = Segment.length([lat, lng], [@a[0], lng]) # lat\n y1 *= -1 if lat > @a[0]\n \n x2 = Segment.length([lat, lng], [lat, @b[1]]) # lng\n x2 *= -1 if lng > @b[1]\n\n y2 = Segment.length([lat, lng], [@b[0], lng]) # lat\n y2 *= -1 if lat > @b[0]\n \n # Circle equation: lat**2 + lng**2 = r**2\n # Segment equation: lat = y1 + (lng-x1)/(x2-x1) * (y2-y1)\n # See also: http://mathworld.wolfram.com/Circle-LineIntersection.html\n \n dx = x2 - x1\n dy = y2 - y1\n dr = Math.sqrt(dx**2 + dy**2) # Caution: this is estimation\n d = x1*y2 - x2*y1 \n delta = r**2 * dr**2 - d**2 \n\n sgn = lambda{ |x| x < 0 ? -1 : 1 }\n coordinates = lambda do |sign|\n x = (d*dy + sign * sgn[dy] * dx * Math.sqrt(delta)) / dr**2\n y = (-d*dx + sign * dy.abs * Math.sqrt(delta)) / dr**2\n\n intersection_lat = 180*y / (Math::PI * R) + lat\n intersection_lng = x / ( Math.cos(intersection_lat*Rad)*R) * (180/Math::PI) + lng\n \n [intersection_lat, intersection_lng] if (@a[1]..@b[1]).include?(intersection_lng) || (@b[1]..@a[1]).include?(intersection_lng) and\n (@a[0]..@b[0]).include?(intersection_lat) || (@b[0]..@a[0]).include?(intersection_lat)\n end\n \n if delta > 0\n # Return closest point (to point @a) of two\n [-1, 1].map{ |sign| coordinates[sign] }.compact.sort_by{|x,y| y }.first\n elsif delta == 0\n # Tangent line: only one point\n coordinates[0]\n else\n # No intersecting points\n nil\n end\n end",
"def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\n end",
"def intersection\n self.reduce(&:intersection)\n end",
"def cover_line(segment)\n l = segment.l\n r = segment.r\n l = 0 if l < 0\n r -= 1\n r = @line.length-1 if r > @line.length-1\n\n for i in l..r\n @line[i] = true\n end\n end",
"def intersect(ray)\n # Must be overriden be subclasses\n end",
"def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\n end",
"def intersection\n @grpc.intersection\n end",
"def intersection(another_geometry)\n raise Error::UnsupportedOperation, \"Method Geometry#intersection not defined.\"\n end",
"def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if line_intersect_line?(line, rect_line)\n end\n\n false\n end",
"def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end",
"def intersectPoint p\n if real_close_point(x,y,p.x,p.y) then self\n else NoPoints.new\n end\n end",
"def parse_intersection\n lines = @location.split(LINE_PATTERN, 2)\n if lines.length == 2\n other = tokenize lines.last\n streets = tokenize lines.first\n else\n other = @tokens\n streets = nil\n end\n parse_zip other\n parse_state other\n if streets\n @address.city = other.join(\" \")\n else\n city = []\n until other.empty? or street_types.key?(other.last.downcase)\n city << other.pop\n end\n if other.count > 2\n @address.city = city.join(\" \")\n streets = other\n end\n end\n if streets\n intersection_index = streets[1..-2].index do |t|\n t =~ CORNER_PATTERN\n end\n if intersection_index\n street1 = streets[0..intersection_index]\n parse_direction_prefix street1\n parse_direction_suffix street1\n @address.street_type = street1.pop if street1.count > 1 and street_types.key?(street1.last.downcase)\n @address.street = street1.join(\" \")\n street2 = streets[(intersection_index + 2)..-1]\n parse_direction_prefix2 street2\n parse_direction_suffix2 street2\n @address.street_type2 = street2.pop if street2.count > 1 and street_types.key?(street2.last.downcase)\n @address.street2 = street2.join(\" \")\n end\n end\n end",
"def intersect?(triangle, lines)\n line1 = [triangle[0], triangle[2]]\n line2 = [triangle[1], triangle[2]]\n \n lines.any? do |line|\n \n int1 = Geom.intersect_line_line line, line1\n int2 = Geom.intersect_line_line line, line2\n \n intersected = false\n \n if(!int1.nil?)\n puts \"#{line1.inspect} intersect #{line.inspect} at #{int1.inspect}\"\n intersected = true if(in_box(line1, int1) && in_box(line, int1))\n end\n \n if (!int2.nil?)\n puts \"#{line2.inspect} intersect #{line.inspect} at #{int2.inspect}\"\n intersected = true if(in_box(line2, int2) && in_box(line, int2))\n end\n \n intersected\n end\n end",
"def line(a, b)\n return [a] if a == b\n a = offset_to_cube a\n b = offset_to_cube b\n n = cube_distance a, b\n (0..n).each_with_object([]) do |i, results|\n cube_coords = cube_round cube_lerp(a, b, 1.0 / n * i)\n results << cube_to_offset(cube_coords)\n end\n end",
"def __intersect__(object)\n object.__intersect_from_array__(self)\n end",
"def parse _line, _next_lines\n raise NotImplementedError, self\n end",
"def intersect(p1, v2, p2)\n # If this vector and v2 doesn't intersect, return early.\n return :no_intersect unless intersect?(p1, v2, p2)\n\n # Calculate t2\n # x1 + a1 * t1 = x2 + a2 * t2\n # t1 = (x1 + a2 * t2 + x2) / a1\n # y1 + b1 * (x1 + a2 * x + x2) / a1 = y2 + b2 * x\n # t2 = (a1 * y1 - a1 * y2 + b1 * x1 + b1 * x2) / (a1 * b2 - a2 * b1)\n t2 = (to_a[0] * p1.y - to_a[0] * p2.y + to_a[1] * p1.x + to_a[1] * p2.x) /\n (to_a[0] * v2.to_a[1] - v2.to_a[0] * to_a[1])\n\n # Use t2 to calculate the intersection\n [\n p2.x + v2.to_a[0] * t2,\n p2.y + v2.to_a[1] * t2,\n p2.z + v2.to_a[2] * t2,\n ]\n end",
"def add_line(point1, point2)\n end",
"def draw_line(x1,y1,x2,y2,r,g,b,graph_function=false)\r\n if ( @line_dot_size > 1 )\n self.draw_dotted_line(x1,y1,x2,y2,@line_dot_size,r,g,b,graph_function)\n else\n r = 0 if ( r < 0 ) \n r = 255 if ( r > 255 ) \r\n g = 0 if ( g < 0 ) \n g = 255 if ( g > 255 ) \r\n b = 0 if ( b < 0 ) \n b = 255 if ( b > 255 ) \r\n distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) \r\n if ( distance == 0 )\r\n #return -1\n else \r\n xstep = (x2-x1) / distance\r\n ystep = (y2-y1) / distance\r\n i =0\n while i<=distance \r\n x = i * xstep + x1\r\n y = i * ystep + y1\r\n if((x >= @garea_x1 && x <= @garea_x2&& y >= @garea_y1 && y <= @garea_y2) || !graph_function )\r\n if ( @line_width == 1 )\r\n self.draw_antialias_pixel(x,y,r,g,b)\n else\r\n start_offset = -(@line_width/2) \n end_offset = (@line_width/2)\n j = start_offset\n while j<=end_offset\n self.draw_antialias_pixel(x+j,y+j,r,g,b)\n end \r\n end\r\n end\n i =i+1\r\n end\n end \n end \r\n end",
"def find_intersection(lx, ly, m, cx, cy, r, dir)\n qa = m*m+1\n qb = 2*(ly*m -lx*m*m - cy*m - cx)\n qc = lx*lx*m*m + -2*lx*ly*m + 2*lx*cy*m +\n ly*ly + -2*ly*cy +\n cy*cy + cx*cx - r*r\n\n x = quadratic(qa, qb, qc, dir)\n y = (x-lx)*m + ly\n [x, y]\n end",
"def line_point_distance(line_start, line_end, point)\n top = ((line_end.y - line_start.y) * point.x) -\n ((line_end.x - line_start.x) * point.y) +\n (line_end.x * line_start.y) - \n (line_end.y * line_start.x)\n bottom = ((line_end.y - line_start.y) ** 2 +\n (line_end.x - line_start.x) ** 2) ** 0.5\n return (top / bottom).abs\n end",
"def draw_line(x1,y1,x2,y2,r,g,b,graph_function=false)\n if ( @line_dot_size > 1 )\n self.draw_dotted_line(x1,y1,x2,y2,@line_dot_size,r,g,b,graph_function)\n else\n r = 0 if ( r < 0 )\n r = 255 if ( r > 255 )\n g = 0 if ( g < 0 )\n g = 255 if ( g > 255 )\n b = 0 if ( b < 0 )\n b = 255 if ( b > 255 )\n distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))\n if ( distance == 0 )\n #return -1\n else\n xstep = (x2-x1) / distance\n ystep = (y2-y1) / distance\n i =0\n while i<=distance\n x = i * xstep + x1\n y = i * ystep + y1\n if((x >= @g_area_x1 && x <= @g_area_x2&& y >= @g_area_y1 && y <= @g_area_y2) || !graph_function )\n if ( @line_width == 1 )\n self.draw_antialias_pixel(x,y,r,g,b)\n else\n start_offset = -(@line_width/2)\n end_offset = (@line_width/2)\n j = start_offset\n while j<=end_offset\n self.draw_antialias_pixel(x+j,y+j,r,g,b)\n end\n end\n end\n i =i+1\n end\n end\n end\n end",
"def intersect(other)\n Intersection.new(self, other)\n end",
"def matching_lines(lined_content, surrounding_lines, query)\n used_lines = []\n lined_content.each_with_index do |line, line_number|\n used_lines.concat bounded_line_numbers(\n line_number,\n 0,\n lined_content.size,\n surrounding_lines\n ) if line.downcase.include?(query.downcase)\n end\n\n used_lines.uniq.sort\n end",
"def perpendicular_segment(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n return point if self.contains?(point)\n \n l = self.perpendicular_line(point)\n p = Line.new(self.p1, self.p2).intersection(l).first\n\n Segment.new(point, p)\n end",
"def process_line(_line)\n raise NotImplementedError\n end",
"def intersects_with(&block)\n [:intersects_with, block]\n end",
"def intersects_with(&block)\n [:intersects_with, block]\n end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def vline x, c, y1 = 0, y2 = w\n line x, y1, x, y2, c\n end",
"def wherecrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return point if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return nil\r\n end",
"def is_on_line?(line)\n to_a.zip(line.point.to_a, line.vector.to_a).map { |a, b, c| (a - b) / c }.uniq.length == 1\n end",
"def intersect(other)\n begin_at = self.begin >= other.begin ? self.begin : other.begin\n end_at = self.end <= other.end ? self.end : other.end\n\n begin_at <= end_at ? self.class.new(begin_at..end_at) : nil\n end",
"def intersect(boundingbox)\n end",
"def sideline_seg( side )\n l = nil\n case side\n when :u; l = Gseg.new_by_pos( x1y1, x2y1 )\n when :d; l = Gseg.new_by_pos( x1y2, x2y2 )\n when :l; l = Gseg.new_by_pos( x1y1, x1y2 )\n when :r; l = Gseg.new_by_pos( x2y1, x2y2 )\n else; l = nil\n end\n l\n end",
"def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend",
"def test_add_midpoint_terminus\n\n expected_segs1 = [LineSeg.new(p(0,0), p(1, 0)), LineSeg.new(p(1, 0), p(2, 0)), LineSeg.new(p(1,0), p(1,1))]\n expected_segs2 = [LineSeg.new(p(0,0), p(1, 0)), LineSeg.new(p(1, 0), p(2, 0)), LineSeg.new(p(1,1), p(1,0))]\n\n # new/1: new segment has its point 1 along the other segment.\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,0)))\n canon.add(LineSeg.new(p(1,0), p(1,1)))\n assert_equal( 3, canon.line_segs.size)\n expect(canon, expected_segs1)\n\n\n # new/2: new segment has its point 2 along the other segment.\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,0)))\n canon.add(LineSeg.new(p(1,1), p(1,0)))\n assert_equal(3, canon.line_segs.size)\n expect(canon, expected_segs2)\n \n # old/1: old segment has its point 1 along the other segment.\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(1,0), p(1,1)))\n canon.add(LineSeg.new(p(0,0), p(2,0)))\n assert_equal(3, canon.line_segs.size)\n expect(canon, expected_segs1)\n\n\n # old/2: old segment has its point 2 along the other segment.\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(1,1), p(1,0)))\n canon.add(LineSeg.new(p(0,0), p(2,0)))\n assert_equal(3, canon.line_segs.size)\n expect(canon, expected_segs2)\n\n\n end",
"def call(search_line:, **options)\n self.combined_options = defaults(**options).merge(\n {\n search_line: search_line\n }\n )\n super\n end",
"def onLine(c1,c2,buffer,c3)\n\n if equalCoordinates?(c1, c2)\n return equalCoordinates?(c1, c3) || buffer > getGeoDistance(c1, c3)\n end\n\n if equalCoordinates?(c1, c3)\n return true\n end\n\n # we get the difference Geodesic angles\n theta1 = getGeoAngle(c1,c2)\n theta2 = getGeoAngle(c1,c3)\n theta3 = theta2-theta1\n\n # buf buf\n # (--- c1 ----------------- c2 ---)\n # * |\n # H(c1-c3) * | H*Sin(theta3)\n # * |\n # c3\n hc1c3 = getGeoDistance(c1,c3)\n hc1c2 = getGeoDistance(c1,c2)\n #\n # if the point is with in a buffer's radius of C1 then it is on the line,\n # Otherwise, its distance from C1 must be less than the distance to C2\n # plus the buffer, and its distance to the C1-C2 line must be less than the buffer.\n # Furthermore this calculation only works if difference in angles is less than PI/2.\n # If the difference in angles is greater than that, then the point is not near\n # the line, unless it was within the buffer radius of C1.\n #\n result = hc1c3 < buffer || abs(theta3) < Math::PI/2 &&\n hc1c3 <= hc1c2 + buffer/2 && abs(Math.sin(theta3) * hc1c3) <= buffer/2\n\n return result\n end",
"def hline(x1, x2, y, c)\n x1, x2, y = x1.to_i, x2.to_i, y.to_i\n\n unless self.bounds?(x1, y) && self.bounds?(x2, y)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (x1..x2).each {|x| self[y, x] = c}\n end",
"def intersect _obj, _args\n \"_obj intersect _args;\" \n end",
"def parallel_line(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n Line.new(point, point + self.direction.to_point)\n end",
"def line x1, y1, x2, y2, c\n h = self.h\n screen.draw_line x1, h-y1, x2, h-y2, color[c], :antialiased\n end",
"def intersection(fa)\n perform_set_operation(:intersection, fa)\n end",
"def find_lines mta, start_station, end_station\n lines = [[],[]]\n mta.each do |line, stations|\n lines[0].push line if stations.include?(start_station)\n lines[1].push line if stations.include?(end_station)\n end\n\n if lines[0] & lines[1] != []\n common_line = lines[0] & lines[1]\n return [ common_line[0], common_line[0] ] # The 1st line both stations are on\n else\n return [ lines[0][0], lines[1][0] ] # The 1st line the staions are found on\n end\nend",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def vline(x, y1, y2, c)\n x, y1, y2 = x.to_i, y1.to_i, y2.to_i\n\n unless self.bounds?(x, y1) && self.bounds?(x, y2)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n (y1..y2).each {|y| self[y, x] = c}\n end",
"def get_line(x0,x1,y0,y1)\n \t\tpoints = []\n\t\tsteep = ((y1-y0).abs) > ((x1-x0).abs)\n\t\tif steep then\n\t\t\tx0,y0 = y0,x0\n\t\t\tx1,y1 = y1,x1\n\t\tend\n\t\tif x0 > x1\n\t\t\tx0,x1 = x1,x0\n\t\t\ty0,y1 = y1,y0\n\t\tend\n\t\tdeltax = x1-x0\n\t\tdeltay = (y1-y0).abs\n\t\terror = (deltax / 2).to_i\n\t\ty = y0\n\t\tystep = nil\n\t\tif y0 < y1 then\n\t\t\tystep = 1\n\t\telse\n\t\t\tystep = -1\n\t\tend\n\t\tfor x in x0..x1\n\t\t\tif steep then\n\t\t\t\tpoints << {:x => y, :y => x}\n\t\t\telse\n\t\t\t\tpoints << {:x => x, :y => y}\n\t\t\tend\n\t\t\terror -= deltay\n\t\t\tif error < 0 then\n\t\t\t\ty += ystep\n\t\t\t\terror += deltax\n\t\t\tend\n\t\tend\n\t\treturn points\n\tend",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def get_line(x0,x1,y0,y1)\n points = []\n steep = ((y1-y0).abs) > ((x1-x0).abs)\n if steep\n x0,y0 = y0,x0\n x1,y1 = y1,x1\n end\n if x0 > x1\n x0,x1 = x1,x0\n y0,y1 = y1,y0\n end\n deltax = x1-x0\n deltay = (y1-y0).abs\n error = (deltax / 2).to_i\n y = y0\n ystep = nil\n if y0 < y1\n ystep = 1\n else\n ystep = -1\n end\n for x in x0..x1\n if steep\n points << {:x => y, :y => x}\n else\n points << {:x => x, :y => y}\n end\n error -= deltay\n if error < 0\n y += ystep\n error += deltax\n end\n end\n return points\nend",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end"
] | [
"0.8360925",
"0.80786705",
"0.8031761",
"0.7940218",
"0.7940218",
"0.7940218",
"0.78853285",
"0.78853285",
"0.78853285",
"0.72723234",
"0.724494",
"0.6960971",
"0.66799736",
"0.65041506",
"0.64518094",
"0.64140725",
"0.63947743",
"0.6331563",
"0.6331269",
"0.63063204",
"0.63051057",
"0.62598145",
"0.62451094",
"0.6201416",
"0.61887527",
"0.6183349",
"0.6159315",
"0.6147096",
"0.60980165",
"0.5993862",
"0.59863335",
"0.5981896",
"0.59600747",
"0.5954581",
"0.5947748",
"0.59152305",
"0.5785034",
"0.5674722",
"0.5657715",
"0.56564695",
"0.55561304",
"0.5554642",
"0.55434865",
"0.55173063",
"0.5510311",
"0.5450864",
"0.53907865",
"0.53886",
"0.53232974",
"0.5288161",
"0.5266765",
"0.5238446",
"0.52234626",
"0.5221689",
"0.520883",
"0.5205843",
"0.5186776",
"0.51847667",
"0.51683927",
"0.5166671",
"0.51365054",
"0.5119378",
"0.50561607",
"0.5055008",
"0.5051816",
"0.5039018",
"0.5029932",
"0.5004908",
"0.4999252",
"0.4984442",
"0.49708462",
"0.49577975",
"0.4951305",
"0.4948523",
"0.49313515",
"0.49313515",
"0.4927854",
"0.4927854",
"0.49183166",
"0.49165833",
"0.49094078",
"0.49063796",
"0.48994732",
"0.48904842",
"0.48902416",
"0.48891878",
"0.4888404",
"0.48777914",
"0.4876297",
"0.48739618",
"0.48633212",
"0.48617634",
"0.48502636",
"0.48468673",
"0.48366117",
"0.48308045",
"0.48288763",
"0.48275876",
"0.48233223",
"0.48228493"
] | 0.7969675 | 3 |
if self is the intersection of (1) some shape s and (2) the line containing seg, then we return the intersection of the shape s and the seg. seg is an instance of LineSegment | def intersectWithSegmentAsLineResult seg
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end",
"def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersectWithSegmentAsLineResult seg\n self\n end",
"def intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end",
"def intersection( to )\n\n # Bullet line between box center and to-point.\n bline = Gseg.new( self.pos.to_gpos, to )\n\n # Find which side of self intersects with bline.\n side = nil\n [ :r, :l, :u, :d ].each do |sidesym|\n trial = self.sideline_seg( sidesym )\n if trial.intersects_with?( bline )\n side = trial\n break\n end\n end\n\n side.intersection_point_with( bline )\n end",
"def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end",
"def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end",
"def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end",
"def intersection_point(segment)\n # numerator = (line.point1.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (line.point1.x - point1.x)\n # denominator = (point2.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (point2.x - point1.x)\n #\n # t = numerator.to_f / denominator\n #\n # x = point1.x + t * (point2.x - point1.x)\n # y = point1.y + t * (point2.y - point1.y)\n #\n # Point.new(x, y)\n\n x1, y1, x2, y2 = point1.x, point1.y, point2.x, point2.y\n x3, y3, x4, y4 = segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y\n\n x12 = x1 - x2\n x34 = x3 - x4\n y12 = y1 - y2\n y34 = y3 - y4\n\n c = x12 * y34 - y12 * x34\n\n raise Exception.new('Segments are parallel.') if c.zero?\n\n a = x1 * y2 - y1 * x2\n b = x3 * y4 - y3 * x4\n\n x = (a * x34 - b * x12) / c\n y = (a * y34 - b * y12) / c\n\n Point.new(x, y)\n end",
"def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end",
"def intersection_segment(pt1, pt2, pt3, pt4)\n pt = intersection(pt1, pt2, pt3, pt4)\n \n segment_length = pt3.dist_to(pt4)\n \n dist3 = pt.dist_to(pt3)\n dist4 = pt.dist_to(pt4)\n \n if dist3 + dist4 == segment_length\n pt\n else\n nil\n end\n \n # slope = pt4.slope_to(pt3)\n # \n # y1 = pt.x * slope + pt3.y\n # y2 = pt.x * slope + pt4.y\n # \n # y1 == pt.y or y2 == pt.y\n end",
"def line_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n\n end",
"def intersection( to )\n cp = self.pos.to_gpos\n sp = self.size.to_gpos\n line = cp.to_vec( to )\n\n n = line.rad\n a = sp.x\n b = sp.y\n\n div = Math.sqrt( ( b*Math.cos(n) ) ** 2 + ( a*Math.sin(n) ) ** 2 )\n px = ( a * b * Math.cos(n) ) / div\n py = ( a * b * Math.sin(n) ) / div\n\n cp.to_vec + Gvec[ px, py ]\n end",
"def find_intersection_point_with(segment)\n denominator = ((segment.p2.y - segment.p1.y)*(p2.x - p1.x)) - \n ((segment.p2.x - segment.p1.x)*(p2.y - p1.y))\n\n numerator_a = ((segment.p2.x - segment.p1.x)*(p1.y - segment.p1.y)) - \n ((segment.p2.y - segment.p1.y)*(p1.x - segment.p1.x))\n\n numerator_b = ((p2.x - p1.x)*(p1.y - segment.p1.y)) - \n ((p2.y - p1.y)*(p1.x - segment.p1.x))\n\n if denominator == 0.0\n if numerator_a == 0.0 && numerator_b == 0.0\n # 'COINCIDENT'\n return nil\n end\n # 'PARALLEL'\n return nil\n end\n\n ua = numerator_a/denominator\n ub = numerator_b/denominator\n\n # An intersection point exists, given the following conditions\n \n if ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0\n x = point1.x + ua*(p2.x - p1.x)\n y = point1.y + ua*(p2.y - p1.y)\n\n return Point.new(x, y)\n end\n \n # 'NOT_INTERESECTING'\n return nil\n end",
"def intersection( to )\n cp = self.pos.to_gpos\n\n line = cp.to_vec( to )\n uline = line.unit\n radius = uline * size.x\n\n ( cp.to_vec + radius ).to_gpos\n end",
"def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4)\n # calculate vector products\n d1 = (x3 - x1) * (y4 - y1) - (x4 - x1) * (y3 - y1)\n d2 = (x3 - x2) * (y4 - y2) - (x4 - x2) * (y3 - y2)\n d3 = (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n d4 = (x1 - x4) * (y2 - y4) - (x2 - x4) * (y1 - y4)\n # check vector product results\n if (d1 > 0 && d2 < 0 || d1 < 0 && d2 > 0) &&\n (d3 > 0 && d4 < 0 || d3 < 0 && d4 > 0)\n # intersection exists\n return true\n end\n # if at least one point of one line lies on the other line\n if d1 == 0 && (x3 < x4 ? x3 : x4) <= x1 && x1 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y1 && y1 <= (y3 > y4 ? y3 : y4) ||\n d2 == 0 && (x3 < x4 ? x3 : x4) <= x2 && x2 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y2 && y2 <= (y3 > y4 ? y3 : y4) ||\n d3 == 0 && (x1 < x2 ? x1 : x2) <= x3 && x3 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y3 && y3 <= (y1 > y2 ? y1 : y2) ||\n d4 == 0 && (x1 < x2 ? x1 : x2) <= x4 && x4 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y4 && y4 <= (y1 > y2 ? y1 : y2)\n # intersection exists\n return true\n end\n # intersection does not exist\n return false\n end",
"def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end",
"def get_intersecting_line entity, connnectLine\n entity_x = entity.get_x\n entity_y = entity.get_y\n\n edges = []\n\n #Top edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x + ENTITY_WIDTH, entity_y)\n #Bottom edge\n edges << (Line2D::Double.new entity_x, entity_y + ENTITY_HEIGHT, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n #Left edge\n edges << (Line2D::Double.new entity_x, entity_y, entity_x, entity_y + ENTITY_HEIGHT)\n #Right edge\n edges << (Line2D::Double.new entity_x + ENTITY_WIDTH, entity_y, entity_x + ENTITY_WIDTH, entity_y + ENTITY_HEIGHT)\n\n edges.each do |e|\n return e if connnectLine.intersects_line e\n end\n\n end",
"def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end",
"def intersection(another_segment)\n return TestHalfEdge.he_intersection(@start,@ending,another_segment.start,\n another_segment.ending)\n end",
"def intersection(other)\n intersection_result = []\n \n if other.is_a?(Polygon) \n k = other.sides \n else \n k = [other]\n end\n\n self.sides.each do |side|\n k.each do |side1|\n intersection_result += side.intersection(side1)\n end\n end\n\n intersection_result.uniq! do |a|\n if a.is_a?(Point)\n [a.x, a.y]\n else\n [a.p1, a.p2].sort_by {|p| [p.x, p.y]} \n end\n end\n points = []; segments = []\n\n intersection_result.each do |entity|\n points << entity if entity.is_a?(Point)\n segments << entity if entity.is_a?(Segment)\n end\n\n if !points.empty? && !segments.empty?\n points_in_segments = []\n\n points.each do |point|\n segments.each do |segment|\n points_in_segments << point if segment.contains?(point)\n end\n end\n\n points_in_segments.uniq! {|a| [a.x, a.y]}\n if !points_in_segments.empty?\n points_in_segments.each do |p|\n points.delete(p)\n end\n end\n\n return points.sort + segments.sort\n end\n\n return intersection_result.sort\n end",
"def sideline_seg( side )\n l = nil\n case side\n when :u; l = Gseg.new_by_pos( x1y1, x2y1 )\n when :d; l = Gseg.new_by_pos( x1y2, x2y2 )\n when :l; l = Gseg.new_by_pos( x1y1, x1y2 )\n when :r; l = Gseg.new_by_pos( x2y1, x2y2 )\n else; l = nil\n end\n l\n end",
"def terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n # Is the intersect at one of +new_seg+ terminii?\n # If so, split +seg+ into two segs at pt_intersect.\n if pt_intersect == new_seg.pt1 || pt_intersect == new_seg.pt2\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n return []\n end\n\n # Does a +seg+ terminus lie along *new_seg+?\n #\n # If so, add +seg+ to the +new_list+ and return the two part of the slit +new_seg+\n if pt_intersect == seg.pt1 || pt_intersect == seg.pt2\n new_list << seg\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n end\n\n return nil\n end",
"def find_edge_intersecting_with_line(poly_verts, line_start, line_end)\n count = poly_verts.count\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n contact_loc = line_line_intersection(face_start, face_end, line_start, line_end)\n\n if contact_loc\n edge = Edge.new(face_start, face_end)\n edge.contact_loc = contact_loc\n return edge\n end\n end\n\n nil\n end",
"def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end",
"def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if segments_intersect?(line, rect_line)\n end\n\n false\n end",
"def segment_segment_intersection(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn false if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t#(self.cp(bx, by, cx, cy, ax, ay) != self.cp(bx, by, dx, dy, ax, ay)) && (self.cp(dx, dy, ax, ay, cx, cy) != self.cp(dx, dy, bx, by, cx, cy))\n\t\t(self.class.cp(bx, by, cx, cy, ax, ay) != self.class.cp(bx, by, dx, dy, ax, ay)) && (self.class.cp(dx, dy, ax, ay, cx, cy) != self.class.cp(dx, dy, bx, by, cx, cy))\n\tend",
"def intersection(shape, rect)\n # if both are rectangles return rectangle intersection result\n return rect_intersection(shape, rect) if shape.is_a?(Rect)\n # temporary variables\n x, y, r, d = shape.x, shape.y, shape.radius, shape.direction\n # iterate through all of rectangle's points\n [rect.x, rect.x+rect.width-1].each {|i| [rect.y, rect.y+rect.height-1].each {|j|\n # if within special circle radius\n if Math.hypot(x - i, y - j) < r ||\n Math.hypot(x - i - 1, y - j) < r ||\n Math.hypot(x - i, y - j - 1) < r ||\n Math.hypot(x - i - 1, y - j - 1) < r\n case d\n when 2 then return true if j - y >= 0 && i - x <= j - y && x - i - 1 <= j - y\n when 4 then return true if x - i - 1 >= 0 && j - y <= x - i - 1 && y - j - 1 <= x - i - 1\n when 6 then return true if i - x >= 0 && j - y <= i - x && y - j - 1 <= i - x\n when 8 then return true if y - j -1 >= 0 && i - x <= y - j - 1 && x - i - 1 <= y - j - 1\n else\n # full circle, intersection exists\n return true\n end\n end}}\n # initialize arrays\n rects, coos, rad = [], [], (r / SQRT_2).to_i\n # radius line end coordinates and rectangles depending on which circle part\n case d\n when 2\n coos.push([x - 1 - rad, y + rad])\n coos.push([2 * x - coos[0][0] - 1, coos[0][1]])\n rects.push(Rect.new(x - 1, y, 2, r))\n when 4\n coos.push([x - 1 - rad, y - 1 - rad])\n coos.push([coos[0][0], 2 * y - coos[0][1] - 1])\n rects.push(Rect.new(x - r, y - 1, r, 2))\n when 6\n coos.push([x+rad.to_i, y - 1 - rad])\n coos.push([coos[0][0], 2 * y - coos[0][1] - 1])\n rects.push(Rect.new(x, y - 1, r, 2))\n when 8\n coos.push([x - 1 - rad, y - 1 - rad])\n coos.push([2 * x - coos[0][0] - 1, coos[0][1]])\n rects.push(Rect.new(x - 1, y - r, 2, r))\n else\n rects.push(Rect.new(x - 1, y, 2, r), Rect.new(x - r - 1, y - 1, r, 2),\n Rect.new(x, y - 1, r, 2), Rect.new(x - 1, y - r - 1, 2, r))\n end\n # intersection exists if intersecting with any of the radius rectangles\n return true if rects.any? {|rec| rect_intersection(rect, rec)}\n # rectangle's border lines\n top_left = [rect.x, rect.y]\n bottom_right = [rect.x + rect.width - 1, rect.y + rect.height - 1]\n bottom_left = [rect.x, rect.y + rect.height - 1]\n top_right = [rect.x + rect.width - 1, rect.y]\n # iterate through rectangle's border lines\n [top_left, bottom_right].each {|i| [bottom_left, top_right].each {|j|\n # iterate through the characteristic lines\n coos.each {|c|\n # if borderline of rectangle intersects with diagonal radius line\n if line_intersection(i[0], i[1], j[0], j[1], c[0], c[1], x, y)\n # intersection exists\n return true\n end}}}\n # intersection does not exist\n return false\n end",
"def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end",
"def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end",
"def extended_segment_intersection?(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn true if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t(cp(bx, by, cx, cy, ax, ay) != cp(bx, by, dx, dy, ax, ay)) || (cp(dx, dy, ax, ay, cx, cy) != cp(dx, dy, bx, by, cx, cy))\n\tend",
"def process_and_add(new_seg)\n\n # If this is a duplicate, just don't add it.\n return nil if duplicate?(new_seg)\n\n\n # Seek and handle intersections.\n new_list = []\n reprocess = []\n @segs.each do |seg|\n pt_intersect = seg.intersection(new_seg)\n unless pt_intersect\n new_list << seg\n next\n end\n\n # No splits if they just intersect at terminii. \n next if terminus_terminus_intersect(pt_intersect, new_list, seg, new_seg)\n # Separate handing of intersection at a terminus\n if rv = terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n if rv.size > 1\n new_seg = rv.shift\n reprocess << rv\n end\n else\n # Must be a line/line intersect.\n rv = line_line_intersect(pt_intersect, new_list, seg, new_seg)\n new_seg = rv.shift\n reprocess << rv\n end\n \n end\n new_list << new_seg\n @segs = new_list\n\n if reprocess.size == 0\n return nil\n else\n return reprocess.flatten\n end\n end",
"def line_intersection(l1, l2)\n x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0]\n y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1]\n\n denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4)\n return false if denominator == 0\n dxy12 = (x1*y2 - y1*x2)\n dxy34 = (x3*y4 - y3*x4)\n x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator\n y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator\n WorldGen::Vector[x.round, y.round]\n end",
"def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end",
"def get_intersection\n end",
"def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend",
"def rec_intersection(rect1, rect2)\n x1 = [rect1[0][0],rect2[0][0]].max\n y1 = [rect1[0][1],rect2[0][1]].max\n y2 = [rect2[1][1],rect1[1][1]].min\n x2 = [rect2[1][0],rect1[1][0]].min\n if rect2[0][0] > rect1[1][0] || rect2[0][1] > rect1[1][1]\n return nil\n else\n return [[x1,y1],[x2,y2]]\n end\nend",
"def line_intersect_rect?(line, rect)\n rect_to_lines(rect).each do |rect_line|\n return true if line_intersect_line?(line, rect_line)\n end\n\n false\n end",
"def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend",
"def intersection(other)\n if other.is_a?(Point)\n return points_intersection(self, other)\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between Point and #{ other.class } is not defined\"\n end",
"def segment_to_line(x1, y1, x2, y2)\n raise 'Need two distinct points to define a segment' if x1 == x2 && y1 == y2\n\n # Vertical/horizontal/oblique lines\n if y1 == y2\n [0.0, 1.0, y1]\n elsif x1 == x2\n [1.0, 0.0, x1]\n else\n [y1 - y2, x2 - x1, x2 * y1 - x1 * y2]\n end\n end",
"def lineIntersects _args\n \"lineIntersects _args;\" \n end",
"def intersect?(triangle, lines)\n line1 = [triangle[0], triangle[2]]\n line2 = [triangle[1], triangle[2]]\n \n lines.any? do |line|\n \n int1 = Geom.intersect_line_line line, line1\n int2 = Geom.intersect_line_line line, line2\n \n intersected = false\n \n if(!int1.nil?)\n puts \"#{line1.inspect} intersect #{line.inspect} at #{int1.inspect}\"\n intersected = true if(in_box(line1, int1) && in_box(line, int1))\n end\n \n if (!int2.nil?)\n puts \"#{line2.inspect} intersect #{line.inspect} at #{int2.inspect}\"\n intersected = true if(in_box(line2, int2) && in_box(line, int2))\n end\n \n intersected\n end\n end",
"def intersection\n self.reduce(&:intersection)\n end",
"def intersection(lat, lng, r)\n \n # Convert degrees to meters\n x1 = Segment.length([lat, lng], [lat, @a[1]]) # lng\n x1 *= -1 if lng > @a[1]\n\n y1 = Segment.length([lat, lng], [@a[0], lng]) # lat\n y1 *= -1 if lat > @a[0]\n \n x2 = Segment.length([lat, lng], [lat, @b[1]]) # lng\n x2 *= -1 if lng > @b[1]\n\n y2 = Segment.length([lat, lng], [@b[0], lng]) # lat\n y2 *= -1 if lat > @b[0]\n \n # Circle equation: lat**2 + lng**2 = r**2\n # Segment equation: lat = y1 + (lng-x1)/(x2-x1) * (y2-y1)\n # See also: http://mathworld.wolfram.com/Circle-LineIntersection.html\n \n dx = x2 - x1\n dy = y2 - y1\n dr = Math.sqrt(dx**2 + dy**2) # Caution: this is estimation\n d = x1*y2 - x2*y1 \n delta = r**2 * dr**2 - d**2 \n\n sgn = lambda{ |x| x < 0 ? -1 : 1 }\n coordinates = lambda do |sign|\n x = (d*dy + sign * sgn[dy] * dx * Math.sqrt(delta)) / dr**2\n y = (-d*dx + sign * dy.abs * Math.sqrt(delta)) / dr**2\n\n intersection_lat = 180*y / (Math::PI * R) + lat\n intersection_lng = x / ( Math.cos(intersection_lat*Rad)*R) * (180/Math::PI) + lng\n \n [intersection_lat, intersection_lng] if (@a[1]..@b[1]).include?(intersection_lng) || (@b[1]..@a[1]).include?(intersection_lng) and\n (@a[0]..@b[0]).include?(intersection_lat) || (@b[0]..@a[0]).include?(intersection_lat)\n end\n \n if delta > 0\n # Return closest point (to point @a) of two\n [-1, 1].map{ |sign| coordinates[sign] }.compact.sort_by{|x,y| y }.first\n elsif delta == 0\n # Tangent line: only one point\n coordinates[0]\n else\n # No intersecting points\n nil\n end\n end",
"def bbpLineIntersect(point_a, point_b, point_c, point_d, hit_point, second_hit_point)\n\n rise 'Method not implemented'\n end",
"def intersectPoint p\n if real_close_point(x,y,p.x,p.y) then self\n else NoPoints.new\n end\n end",
"def lineIntersectsObjs _args\n \"lineIntersectsObjs _args;\" \n end",
"def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end",
"def rec_intersection(rect1, rect2)\n bot_x, bot_y = [rect1[0][0], rect2[0][0]].max, [rect1[0][1], rect2[0][1]].max\n top_x, top_y = [rect1[1][0], rect2[1][0]].min, [rect1[1][1], rect2[1][1]].min\n return nil if bot_x > top_x || bot_y > top_y\n [[bot_x, bot_y], [top_x, top_y]]\nend",
"def intersection(ray)\n a = ray.d.dot(ray.d)\n b = 2.0 * ray.d.dot(ray.o.sub(@c))\n c = @c2 - 2.0 * @c.dot(ray.o) - @r2\n\n d2 = b**2 - 4 * a * c\n return nil unless d2 > 0\n\n t0 = (-b - Math.sqrt(d2)) / (2 * a)\n t1 = (-b + Math.sqrt(d2)) / (2 * a)\n\n t0, t1 = t1, t0 if t0 > t1\n return nil if t1 < ray.tmin || t0 > ray.tmax\n\n t_hit = t0\n if t_hit < ray.tmin\n t_hit = t1\n return nil if t_hit > ray.tmax\n end\n\n p_hit = ray[t_hit]\n n_hit = (p_hit.sub(@c).div @r).to_n\n\n { t: t_hit, p: p_hit, n: n_hit, shape: self }\n end",
"def intersection(another_geometry)\n raise Error::UnsupportedOperation, \"Method Geometry#intersection not defined.\"\n end",
"def shape_include?(shape, point)\n if shape1d?(shape) and point1d?(point) then shape_include_1d?(shape, point)\n elsif shape2d?(shape) and point.point2d? then shape_include_2d?(shape, point)\n else check_pre(false)\n end\nend",
"def seg(*args)\n args = args.flatten\n case args.map { |x| x.class }\n when [Segment]\n args.first\n when [Symbol]\n Segment.from_symbol(args.first)\n when [Point, Point]\n Segment.simple(*args)\n when [NilClass]\n nil\n else\n nil\n end\n end",
"def rec_intersection(rect1, rect2)\n x_min = [rect1[0][0], rect2[0][0]].max\n x_max = [rect1[1][0], rect2[1][0]].min\n\n y_min = [rect1[0][1], rect2[0][1]].max\n y_max = [rect1[1][1], rect2[1][1]].min\n\n return nil if ((x_max < x_min) || (y_max < y_min)) # no overlap\n return [[x_min, y_min], [x_max, y_max]]\nend",
"def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\n end",
"def bbpSegmentIntersect(point_a, point_b, point_c, point_d)\n\n rise 'Method not implemented'\n end",
"def intersect(ray)\n # Must be overriden be subclasses\n end",
"def is_on_line?(line)\n to_a.zip(line.point.to_a, line.vector.to_a).map { |a, b, c| (a - b) / c }.uniq.length == 1\n end",
"def distance_from_line_segment(point_a,point_b)\n\n # Define the line as the vector between two points\n line_vector = point_b - point_a\n \n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # Determine if self falls within the perpendicular 'shadow' of the line by calculating\n # the projection of the point vector onto the line.\n #\n # The dot product divided by the magnitude of the line gives the absolute projection\n # of the point vector onto the line.\n #\n # Dividing again by the line magnitude gives the relative projection along the line, \n # i.e. the ratio of the projection to the line. Values between 0-1 indicate that the\n # point falls within the perpendicular shadow.\n #\n projection_ratio = line_vector.dot(point_vector) / line_vector.magnitude ** 2\n\n if projection_ratio >= 1\n # The point is beyond point b, calculate distance to point b\n distance = (point_b - self).magnitude\n elsif projection_ratio <= 0\n # The point is beyond point a, calculate distance to point a\n distance = (point_a - self).magnitude\n else\n # The point is in the shadow of the line, return the perpendicular distance\n distance = line_vector.cross(point_vector).magnitude / line_vector.magnitude\n end\n\n return distance.abs\n end",
"def intersect(ray)\n return nil # FIX ME !!\n end",
"def rec_intersection(rect1, rect2)\n\txmin = rect1[0][0] > rect2[0][0] ? rect1[0][0] : rect2[0][0]\n\txmax = rect1[1][0] > rect2[1][0] ? rect2[1][0] : rect1[1][0]\n\tymin = rect1[0][1] > rect2[0][1] ? rect1[0][1] : rect2[0][1]\n\tymax = rect1[1][1] > rect2[1][1] ? rect2[1][1] : rect1[1][1]\n\nreturn nil if ((xmax < xmin) || (ymax < ymin))\nreturn [ [xmin, ymin], [xmax, ymax] ]\nend",
"def clip_segment(segment, box)\n xmin, ymin, xmax, ymax = box\n x1, y1, x2, y2 = segment\n\n new_segment = []\n\n if x1 >= xmin && x1 <= xmax && y1 >= ymin && y1 <= ymax\n new_segment += [x1, y1]\n end\n\n if x2 >= xmin && x2 <= xmax && y2 >= ymin && y2 <= ymax\n new_segment += [x2, y2]\n end\n\n return new_segment if new_segment.size == 4\n\n bounds = {\n top: [xmin, ymax, xmax, ymax],\n left: [xmin, ymin, xmin, ymax],\n bottom: [xmin, ymin, xmax, ymin],\n right: [xmax, ymin, xmax, ymax],\n }\n\n bounds.each do |edge, edge_seg|\n if intersection = segment_intersection(segment, edge_seg)\n puts \"Segment intersects with #{edge}\"\n new_segment += intersection\n\n puts \"New segment is #{new_segment.inspect}\"\n return new_segment if new_segment.size == 4\n end\n end\n\n raise 'No segment could be formed'\n end",
"def intersection(fa)\n perform_set_operation(:intersection, fa)\n end",
"def intersect(boundingbox)\n end",
"def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def rec_intersection(r1, r2)\n p1 = [[r1[0][0],r2[0][0]].max , [r1[0][1],r2[0][1]].max]\n p2 = [[r1[1][0],r2[1][0]].min , [r1[1][1],r2[1][1]].min]\n if p1[0] < p2[0] && p1[1] < p2[1]\n return [p1,p2]\n else\n return nil\n end\nend",
"def crosses_line_string?(rhs)\n self_ints = SweeplineIntersector.new(segments).proper_intersections\n self_ints += SweeplineIntersector.new(rhs.segments).proper_intersections\n overlay_ints = SweeplineIntersector.new(segments + rhs.segments).proper_intersections\n\n (overlay_ints - self_ints).each do |int|\n s1s = int.s1.s\n s1e = int.s1.e\n s2s = int.s2.s\n s2e = int.s2.e\n return true unless [s1s, s1e, s2s, s2e].include?(int.point)\n end\n\n false\n end",
"def perpendicular_segment(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point.' unless point.is_a?(Point)\n\n return point if self.contains?(point)\n \n l = self.perpendicular_line(point)\n p = Line.new(self.p1, self.p2).intersection(l).first\n\n Segment.new(point, p)\n end",
"def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end",
"def wherecrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return point if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return nil\r\n end",
"def find_intersection(lx, ly, m, cx, cy, r, dir)\n qa = m*m+1\n qb = 2*(ly*m -lx*m*m - cy*m - cx)\n qc = lx*lx*m*m + -2*lx*ly*m + 2*lx*cy*m +\n ly*ly + -2*ly*cy +\n cy*cy + cx*cx - r*r\n\n x = quadratic(qa, qb, qc, dir)\n y = (x-lx)*m + ly\n [x, y]\n end",
"def cover_line(segment)\n l = segment.l\n r = segment.r\n l = 0 if l < 0\n r -= 1\n r = @line.length-1 if r > @line.length-1\n\n for i in l..r\n @line[i] = true\n end\n end",
"def closest_pt_segment_segment\n pp1 = @p1.curr\n pq1 = @p2.curr\n pp2 = @rca\n pq2 = @rcb\n\n d1 = pq1 - pp1\n d2 = pq2 - pp2\n r = pp1 - pp2\n\n a = d1.dot(d1)\n e = d2.dot(d2)\n f = d2.dot(r)\n\n c = d1.dot(r)\n b = d1.dot(d2)\n denom = a * e - b * b\n\n s = denom != 0.0 ? MathUtil.clamp((b * f - c * e) / denom, 0.0, 1.0) : 0.5\n t = (b * s + f) / e\n\n t, s = t < 0 \\\n ? [0.0, MathUtil.clamp(-c / a, 0.0, 1.0)] \\\n : [1.0, MathUtil.clamp((b - c) / a, 0.0, 1.0)]\n\n c1 = pp1 + (d1 * s)\n c2 = pp2 + (d2 * t)\n c1mc2 = c1 - c2\n c1mc2.dot(c1mc2)\n end",
"def shape_include?(shape, point)\n check_pre((\n (shape?(shape)) and\n (point?(point))\n ))\n\n shape.include?(point)\nend",
"def intersection\n @grpc.intersection\n end",
"def vornoi_region(line, point)\n lengthsq = line.lengthsq\n dp = point.dot(line)\n # If the point is beyond the start of the line, it is in the\n # left vornoi region.\n if dp < 0\n LEFT_VORNOI_REGION\n # If the point is beyond the end of the line, it is in the\n # right vornoi region.\n elsif dp > lengthsq\n RIGHT_VORNOI_REGION\n # Otherwise, it's in the middle one.\n else\n MIDDLE_VORNOI_REGION\n end\n end",
"def contains? position\n # If POI is given instead of location, get location first\n position = position.location if PointOfInterest === position\n\n x = position[0]\n y = position[1]\n\n # Use the raycasting technique to determine if point is inside polygon\n # We are in 2D, which makes it easier.\n # We can also choose the direction of the ray, which makes it almost trivial\n # (Choose ray paralell to x-achis\n intersections = 0\n\n [vertices, vertices.first].flatten.each_cons(2) do |v1, v2|\n # Check if we are inside bounding recangle of 2 vertices\n v1x = v1[0]\n v1y = v1[1]\n v2x = v2[0]\n v2y = v2[1]\n if (v1y < y and y <= v2y) or (v1y >= y and y > v2y)\n # check if we are LEFT of or onthe line from v1 to v2 is at this x coordinate\n cp.polygon(*p.map_vertices.map{|v| v.to_a}.flatten)\n vx = v2x - v1x\n vy = v2y - v1y\n if (x <= v1x and x < v2x)\n intersections +=1\n elsif x >= v1x and x > v2x\n next\n else\n x_line = v1x + vx * (y - v1y) / vy\n if vy == 0 or vx == 0 or x < x_line\n intersections += 1\n end\n end\n end\n end\n return intersections.odd?\n end",
"def intersection_chk (x1, y1, x2, y2, center_x, center_y, radius)\n\n\t#check if the circle is in the bounding box rounded by sw_x, sw_y, ne_x, ne_y (southwest point and northeast point)\n\tif x1 < x2\n\t\tsw_x = x1\n\t\tne_x = x2\n\telse\n\t\tsw_x = x2\n\t\tne_x = x1\n\tend\n\n\tif y1 < y2\n\t\tsw_y = y1\n\t\tne_y = y2\n\telse\n\t\tsw_y = y2\n\t\tne_y = y1\n\tend\n\tsw_x = sw_x - radius\n\tsw_y = sw_y - radius\n\tne_x = ne_x + radius\n\tne_y = ne_y + radius\n\n\tif center_x > ne_x || center_x < sw_x || center_y > ne_y || center_y < sw_y\n\t\treturn -1\n\tend\n\n\t#offset the center to 0,0\n\tx1_ = x1 - center_x\n\ty1_ = y1 - center_y\n\tx2_ = x2 - center_x\n\ty2_ = y2 - center_y\n\n\t#check for intersection\n\tdx = x2_ - x1_\n\tdy = y2_ - y1_\n\tdr = Math.sqrt(dx*dx + dy*dy)\n\td = x1_*y2_ - x2_*y1_\n\tresult = radius*radius*dr*dr - (d*d)\n\tif result < 0\n\t\treturn -1\n\telse\n\t\treturn Math.sqrt(((center_x - x1)*(center_x - x1) + (center_y - y1)*(center_y - y1)).abs)\n\tend\nend",
"def geometry\n linestring\n end",
"def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end",
"def terminus_terminus_intersect(pt_intersect, new_list, seg, new_seg)\n if (new_seg.pt1 == pt_intersect || new_seg.pt2 == pt_intersect) && \n (seg.pt1 == pt_intersect || seg.pt2 == pt_intersect)\n new_list << seg\n return true\n end\n return false\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def rect_intersection(r1, r2)\n return (r1.x + r1.width > r2.x && r1.x < r2.x + r2.width &&\n r1.y + r1.height > r2.y && r1.y < r2.y + r2.height)\n end",
"def included_in?(other_rect)\n self == self.intersects(other_rect)\n end",
"def contains?(x, y)\n line_len = length\n points_distance(@x1, @y1, x, y) <= line_len &&\n points_distance(@x2, @y2, x, y) <= line_len &&\n (((@y2 - @y1) * x - (@x2 - @x1) * y + @x2 * @y1 - @y2 * @x1).abs / line_len) <= 0.5 * @width\n end",
"def iscrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return true if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return false\r\n end",
"def intersects?(other)\n other.vertices.each do |vertex|\n return true if interior?(vertex)\n end\n false\n end",
"def in?(px, py)\n ix, iy = @max+100, @max+100\n nbintersections = 0\n @points.each_index do |index|\n ax, ay = *@points[index]\n bx, by = *@points[(index + 1) % @points.length]\n nbintersections += intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n end\n return (nbintersections%2 == 1)\n end",
"def ==(other)\n return false unless other.is_a?(Line)\n Point.is_collinear?(self.p1, other.p1, self.p2, other.p2)\n end"
] | [
"0.814633",
"0.7911066",
"0.7835549",
"0.78199613",
"0.78199613",
"0.78199613",
"0.7744339",
"0.7744339",
"0.7744339",
"0.70674366",
"0.69469726",
"0.69240534",
"0.689842",
"0.6804724",
"0.68035567",
"0.677119",
"0.67384416",
"0.6578319",
"0.6516282",
"0.643319",
"0.64209926",
"0.6316714",
"0.6293729",
"0.6286728",
"0.62860227",
"0.62735367",
"0.6265377",
"0.622625",
"0.6172154",
"0.6162225",
"0.61356074",
"0.61051756",
"0.60906523",
"0.60664445",
"0.6060893",
"0.60425085",
"0.59770674",
"0.5912139",
"0.5907308",
"0.5897975",
"0.58600765",
"0.5821286",
"0.57420045",
"0.57136625",
"0.57129604",
"0.56605333",
"0.5638415",
"0.5624257",
"0.5547633",
"0.55364966",
"0.5514864",
"0.5508384",
"0.5503724",
"0.5500755",
"0.5477144",
"0.54503685",
"0.54388976",
"0.5432799",
"0.5427227",
"0.53938985",
"0.53538686",
"0.5327156",
"0.5323636",
"0.53038234",
"0.52333796",
"0.5207745",
"0.5196938",
"0.519269",
"0.5157566",
"0.51392466",
"0.5102477",
"0.51008934",
"0.50741434",
"0.50741434",
"0.50741434",
"0.50652325",
"0.5062359",
"0.5059414",
"0.50569844",
"0.50564444",
"0.50477445",
"0.50428134",
"0.5026367",
"0.50180674",
"0.5009544",
"0.49980006",
"0.49852657",
"0.4965349",
"0.49589172",
"0.4951828",
"0.49477887",
"0.49149173",
"0.49149173",
"0.48777688",
"0.48730716",
"0.48435223",
"0.48375845",
"0.48246875",
"0.48066086",
"0.47907323"
] | 0.7803643 | 6 |
verificar token de mierda | def token_verify
#render json: {id: params["user"]["id"], params: params}
user_tmp = User.find(params[:id])
if user_tmp.authentication_token == params[:authentication_token]
$granted = true
render json: false
else
render json: false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token\n end",
"def check_token\n end",
"def token\n @token\n end",
"def token\n @token\n end",
"def token_type; end",
"def token?(token)\n return false\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 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\n @data[:token]\n end",
"def token\n @token.present? ? @token : token_hash\n end",
"def validate token\r\n token =~ /[A-Za-z0-9]/\r\n end",
"def next_token; end",
"def token; config[:token]; end",
"def token?\n @token && !@token.empty?\n end",
"def token(request)\n end",
"def token_get()\n\t\tputs \"Here is the token \" + @token\n\tend",
"def code\n\t\ttoken\n\tend",
"def process_token(tk); end",
"def valid_token?(token)\n exists?(:token => token)\n end",
"def match_token(token)\n return true\n end",
"def token_attribute; end",
"def validate_token_hash; end",
"def token?\n (@token.respond_to?(:empty?) && !@token.empty?)\n end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def tokens; end",
"def token\n item = read\n return item['token'] if item['token']\n token_reset\n read['token']\n end",
"def token(content, kind); end",
"def token\n @attributes[:token]\n end",
"def data\n token\n end",
"def scan_for_t(token); end",
"def isToken(c)\r\n\tvalidTokens = [\"(\", \")\", \"+\", \"-\", \"*\",\r\n\t \"/\", \"^\", \"cos\", \"sin\", \"tan\", \"ln\", \"atan\", \r\n\t \"atan2\", \",\"].include?(c)\r\nend",
"def valid_token\n # generate the token\n self.token=Digest::MD5.hexdigest(\"#{Time.now}-#{self.ad_id}-#{self.publisher_id}\")\n\n # Aux var to the ValidatorLoop\n counter = 0\n\n # Loop which validate the token on the DB\n while true do\n another_access = Access.where(token: self.token).take\n break if another_access.nil?\n self.token=\"#{self.token}#{counter}\"\n counter=counter+1\n end\n end",
"def tokenize\n post(\"token\")[\"token\"]\n end",
"def create_token\n token = SecureRandom.hex(10) #on crée un token de 10 caractères au hasard\n self.token = token #affectation du token à la candidature\n self.save\n end",
"def check_token\n @usuario = Credentials.check_token(authorization: request.headers[\"Authorization\"])\n end",
"def token=(_arg0); end",
"def token=(_arg0); end",
"def token=(_arg0); end",
"def token!\n # at line 1:8: ( T__80 | T__81 | T__82 | EOL | LPAR | RPAR | LLAIZQ | LLADER | COMA | PUNTO | CORDER | CORIZQ | DELIM | ASIGNACION | DOUBLEDOT | COMILLA | OP_REL | OP_ARI | OP_LOG | K_ACCIONARCHIVO | K_ACCIONARREGLO | K_PACKAGE | K_CLASS | K_END | K_DEF | K_VAR | K_REQUIRE | K_IMPLEMENTS | K_EXTENDS | K_IMPRIMIR | K_CONVERSION | K_ASIGNACION | K_RETORNO | K_ACCIONSYS | K_INTERFACE | K_IF | K_TIMES | K_DO | K_EACH | K_ELSE | K_INVOKE | K_NEW | TIPO | K_REFERENCIA | K_INSPECCIONAR | K_MATEMATICA | K_NUM | K_RESIZE | K_ORDENAR | ModoOrd | K_BUSQUEDA | K_TIPOBUSQUEDA | K_WHERE | K_SPLIT | K_BEGIN | K_DIR | K_UNION | K_VISIBILIDAD | K_MODIFICADOR | K_ARRAY | K_PROPIEDAD | K_GET | K_SET | K_VALUE | K_INITIALIZE | K_FUNC | K_VOID | HexLiteral | DecimalLiteral | OctalLiteral | WS | LINE_COMMENT | Identificador )\n alt_28 = 73\n alt_28 = @dfa28.predict( @input )\n case alt_28\n when 1\n # at line 1:10: T__80\n t__80!\n\n\n when 2\n # at line 1:16: T__81\n t__81!\n\n\n when 3\n # at line 1:22: T__82\n t__82!\n\n\n when 4\n # at line 1:28: EOL\n eol!\n\n\n when 5\n # at line 1:32: LPAR\n lpar!\n\n\n when 6\n # at line 1:37: RPAR\n rpar!\n\n\n when 7\n # at line 1:42: LLAIZQ\n llaizq!\n\n\n when 8\n # at line 1:49: LLADER\n llader!\n\n\n when 9\n # at line 1:56: COMA\n coma!\n\n\n when 10\n # at line 1:61: PUNTO\n punto!\n\n\n when 11\n # at line 1:67: CORDER\n corder!\n\n\n when 12\n # at line 1:74: CORIZQ\n corizq!\n\n\n when 13\n # at line 1:81: DELIM\n delim!\n\n\n when 14\n # at line 1:87: ASIGNACION\n asignacion!\n\n\n when 15\n # at line 1:98: DOUBLEDOT\n doubledot!\n\n\n when 16\n # at line 1:108: COMILLA\n comilla!\n\n\n when 17\n # at line 1:116: OP_REL\n op_rel!\n\n\n when 18\n # at line 1:123: OP_ARI\n op_ari!\n\n\n when 19\n # at line 1:130: OP_LOG\n op_log!\n\n\n when 20\n # at line 1:137: K_ACCIONARCHIVO\n k_accionarchivo!\n\n\n when 21\n # at line 1:153: K_ACCIONARREGLO\n k_accionarreglo!\n\n\n when 22\n # at line 1:169: K_PACKAGE\n k_package!\n\n\n when 23\n # at line 1:179: K_CLASS\n k_class!\n\n\n when 24\n # at line 1:187: K_END\n k_end!\n\n\n when 25\n # at line 1:193: K_DEF\n k_def!\n\n\n when 26\n # at line 1:199: K_VAR\n k_var!\n\n\n when 27\n # at line 1:205: K_REQUIRE\n k_require!\n\n\n when 28\n # at line 1:215: K_IMPLEMENTS\n k_implements!\n\n\n when 29\n # at line 1:228: K_EXTENDS\n k_extends!\n\n\n when 30\n # at line 1:238: K_IMPRIMIR\n k_imprimir!\n\n\n when 31\n # at line 1:249: K_CONVERSION\n k_conversion!\n\n\n when 32\n # at line 1:262: K_ASIGNACION\n k_asignacion!\n\n\n when 33\n # at line 1:275: K_RETORNO\n k_retorno!\n\n\n when 34\n # at line 1:285: K_ACCIONSYS\n k_accionsys!\n\n\n when 35\n # at line 1:297: K_INTERFACE\n k_interface!\n\n\n when 36\n # at line 1:309: K_IF\n k_if!\n\n\n when 37\n # at line 1:314: K_TIMES\n k_times!\n\n\n when 38\n # at line 1:322: K_DO\n k_do!\n\n\n when 39\n # at line 1:327: K_EACH\n k_each!\n\n\n when 40\n # at line 1:334: K_ELSE\n k_else!\n\n\n when 41\n # at line 1:341: K_INVOKE\n k_invoke!\n\n\n when 42\n # at line 1:350: K_NEW\n k_new!\n\n\n when 43\n # at line 1:356: TIPO\n tipo!\n\n\n when 44\n # at line 1:361: K_REFERENCIA\n k_referencia!\n\n\n when 45\n # at line 1:374: K_INSPECCIONAR\n k_inspeccionar!\n\n\n when 46\n # at line 1:389: K_MATEMATICA\n k_matematica!\n\n\n when 47\n # at line 1:402: K_NUM\n k_num!\n\n\n when 48\n # at line 1:408: K_RESIZE\n k_resize!\n\n\n when 49\n # at line 1:417: K_ORDENAR\n k_ordenar!\n\n\n when 50\n # at line 1:427: ModoOrd\n modo_ord!\n\n\n when 51\n # at line 1:435: K_BUSQUEDA\n k_busqueda!\n\n\n when 52\n # at line 1:446: K_TIPOBUSQUEDA\n k_tipobusqueda!\n\n\n when 53\n # at line 1:461: K_WHERE\n k_where!\n\n\n when 54\n # at line 1:469: K_SPLIT\n k_split!\n\n\n when 55\n # at line 1:477: K_BEGIN\n k_begin!\n\n\n when 56\n # at line 1:485: K_DIR\n k_dir!\n\n\n when 57\n # at line 1:491: K_UNION\n k_union!\n\n\n when 58\n # at line 1:499: K_VISIBILIDAD\n k_visibilidad!\n\n\n when 59\n # at line 1:513: K_MODIFICADOR\n k_modificador!\n\n\n when 60\n # at line 1:527: K_ARRAY\n k_array!\n\n\n when 61\n # at line 1:535: K_PROPIEDAD\n k_propiedad!\n\n\n when 62\n # at line 1:547: K_GET\n k_get!\n\n\n when 63\n # at line 1:553: K_SET\n k_set!\n\n\n when 64\n # at line 1:559: K_VALUE\n k_value!\n\n\n when 65\n # at line 1:567: K_INITIALIZE\n k_initialize!\n\n\n when 66\n # at line 1:580: K_FUNC\n k_func!\n\n\n when 67\n # at line 1:587: K_VOID\n k_void!\n\n\n when 68\n # at line 1:594: HexLiteral\n hex_literal!\n\n\n when 69\n # at line 1:605: DecimalLiteral\n decimal_literal!\n\n\n when 70\n # at line 1:620: OctalLiteral\n octal_literal!\n\n\n when 71\n # at line 1:633: WS\n ws!\n\n\n when 72\n # at line 1:636: LINE_COMMENT\n line_comment!\n\n\n when 73\n # at line 1:649: Identificador\n identificador!\n\n\n end\n end",
"def check_token(token)\n params = \"token=#{token}&md5=#{Ivona::GetMd5.formula(token)}\"\n HTTParty.get(\"#{BASE_URL}/tokens?#{params}\")\n end",
"def token_key\n @token_key\n end",
"def other_token\n if @token == \"X\"\n \"O\"\n else\n \"X\"\n end\n end",
"def token\n configuration.token\n end",
"def http_get_token\n #verifico che stia arrivando un jwt con formato valido,altrimenti ritorno false\n if params['jwt'].present? && !(params['jwt'] =~ /^[A-Za-z0-9\\-_=]+\\.[A-Za-z0-9\\-_=]+\\.?[A-Za-z0-9\\-_.+=]*$/).nil?\n @http_get_token ||= params['jwt']\n else\n false\n end\n \n end",
"def next_token\n\t\t@token = @input.next_token\n\tend",
"def test_get_token\n # iterate through all the test cases\n token_test_cases.each do |t|\n token = IR.new.get_token_str([t[:str]])\n assert_equal(\n t[:desired_tokens],\n token.map(&:to_s)\n )\n end\n end",
"def test_get_token\n # iterate through all the test cases\n token_test_cases.each do |t|\n token = IR.new.get_token_str([t[:str]])\n assert_equal(\n t[:desired_tokens],\n token.map(&:to_s)\n )\n end\n end",
"def token!\n # at line 1:8: ( T__11 | T__12 | T__13 | T__14 | NUM | VAR | WS )\n alt_4 = 7\n alt_4 = @dfa4.predict( @input )\n case alt_4\n when 1\n # at line 1:10: T__11\n t__11!\n\n when 2\n # at line 1:16: T__12\n t__12!\n\n when 3\n # at line 1:22: T__13\n t__13!\n\n when 4\n # at line 1:28: T__14\n t__14!\n\n when 5\n # at line 1:34: NUM\n num!\n\n when 6\n # at line 1:38: VAR\n var!\n\n when 7\n # at line 1:42: WS\n ws!\n\n end\n end",
"def next_token\n\t\t@tokens.next_token\n\tend",
"def token!\n # at line 1:8: ( T__48 | T__49 | T__50 | T__51 | T__52 | CATEGORY_KEY | LINK_KEY | X_OCCI_ATTRIBUTE_KEY | X_OCCI_LOCATION_KEY | ACTION | ACTIONS | AMPERSAND | AT | ATTRIBUTES | BACKSLASH | CATEGORY | CLASS | COLON | DASH | DOT | EQUALS | GT | HASH | KIND | LINK | LOCATION | LT | MIXIN | PERCENT | PLUS | QUESTION | QUOTE | REL | SCHEME | SELF | SEMICOLON | SLASH | SQUOTE | TERM | TILDE | TITLE | UNDERSCORE | LBRACKET | RBRACKET | LOALPHA | UPALPHA | DIGIT | WS | ESC )\n alt_5 = 49\n alt_5 = @dfa5.predict( @input )\n case alt_5\n when 1\n # at line 1:10: T__48\n t__48!\n\n when 2\n # at line 1:16: T__49\n t__49!\n\n when 3\n # at line 1:22: T__50\n t__50!\n\n when 4\n # at line 1:28: T__51\n t__51!\n\n when 5\n # at line 1:34: T__52\n t__52!\n\n when 6\n # at line 1:40: CATEGORY_KEY\n category_key!\n\n when 7\n # at line 1:53: LINK_KEY\n link_key!\n\n when 8\n # at line 1:62: X_OCCI_ATTRIBUTE_KEY\n x_occi_attribute_key!\n\n when 9\n # at line 1:83: X_OCCI_LOCATION_KEY\n x_occi_location_key!\n\n when 10\n # at line 1:103: ACTION\n action!\n\n when 11\n # at line 1:110: ACTIONS\n actions!\n\n when 12\n # at line 1:118: AMPERSAND\n ampersand!\n\n when 13\n # at line 1:128: AT\n at!\n\n when 14\n # at line 1:131: ATTRIBUTES\n attributes!\n\n when 15\n # at line 1:142: BACKSLASH\n backslash!\n\n when 16\n # at line 1:152: CATEGORY\n category!\n\n when 17\n # at line 1:161: CLASS\n class!\n\n when 18\n # at line 1:167: COLON\n colon!\n\n when 19\n # at line 1:173: DASH\n dash!\n\n when 20\n # at line 1:178: DOT\n dot!\n\n when 21\n # at line 1:182: EQUALS\n equals!\n\n when 22\n # at line 1:189: GT\n gt!\n\n when 23\n # at line 1:192: HASH\n hash!\n\n when 24\n # at line 1:197: KIND\n kind!\n\n when 25\n # at line 1:202: LINK\n link!\n\n when 26\n # at line 1:207: LOCATION\n location!\n\n when 27\n # at line 1:216: LT\n lt!\n\n when 28\n # at line 1:219: MIXIN\n mixin!\n\n when 29\n # at line 1:225: PERCENT\n percent!\n\n when 30\n # at line 1:233: PLUS\n plus!\n\n when 31\n # at line 1:238: QUESTION\n question!\n\n when 32\n # at line 1:247: QUOTE\n quote!\n\n when 33\n # at line 1:253: REL\n rel!\n\n when 34\n # at line 1:257: SCHEME\n scheme!\n\n when 35\n # at line 1:264: SELF\n self!\n\n when 36\n # at line 1:269: SEMICOLON\n semicolon!\n\n when 37\n # at line 1:279: SLASH\n slash!\n\n when 38\n # at line 1:285: SQUOTE\n squote!\n\n when 39\n # at line 1:292: TERM\n term!\n\n when 40\n # at line 1:297: TILDE\n tilde!\n\n when 41\n # at line 1:303: TITLE\n title!\n\n when 42\n # at line 1:309: UNDERSCORE\n underscore!\n\n when 43\n # at line 1:320: LBRACKET\n lbracket!\n\n when 44\n # at line 1:329: RBRACKET\n rbracket!\n\n when 45\n # at line 1:338: LOALPHA\n loalpha!\n\n when 46\n # at line 1:346: UPALPHA\n upalpha!\n\n when 47\n # at line 1:354: DIGIT\n digit!\n\n when 48\n # at line 1:360: WS\n ws!\n\n when 49\n # at line 1:363: ESC\n esc!\n\n end\n end",
"def token_valid?\n raise 'To be implemented in child classes'\n end",
"def token!\n # at line 1:8: ( T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | CONSTANT | ID | TEMPLATE | STRING | COMMENT | WS )\n alt_12 = 16\n alt_12 = @dfa12.predict(@input)\n case alt_12\n when 1\n # at line 1:10: T__10\n t__10!\n\n when 2\n # at line 1:16: T__11\n t__11!\n\n when 3\n # at line 1:22: T__12\n t__12!\n\n when 4\n # at line 1:28: T__13\n t__13!\n\n when 5\n # at line 1:34: T__14\n t__14!\n\n when 6\n # at line 1:40: T__15\n t__15!\n\n when 7\n # at line 1:46: T__16\n t__16!\n\n when 8\n # at line 1:52: T__17\n t__17!\n\n when 9\n # at line 1:58: T__18\n t__18!\n\n when 10\n # at line 1:64: T__19\n t__19!\n\n when 11\n # at line 1:70: CONSTANT\n constant!\n\n when 12\n # at line 1:79: ID\n id!\n\n when 13\n # at line 1:82: TEMPLATE\n template!\n\n when 14\n # at line 1:91: STRING\n string!\n\n when 15\n # at line 1:98: COMMENT\n comment!\n\n when 16\n # at line 1:106: WS\n ws!\n\n end\n end",
"def token!\n # at line 1:8: ( T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | T__20 | T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | T__55 | T__56 | T__57 | T__58 | T__59 | ST | ND | RD | TH | DIGIT | WS | EOL | LETTER )\n alt_7 = 56\n alt_7 = @dfa7.predict( @input )\n case alt_7\n when 1\n # at line 1:10: T__12\n t__12!\n\n when 2\n # at line 1:16: T__13\n t__13!\n\n when 3\n # at line 1:22: T__14\n t__14!\n\n when 4\n # at line 1:28: T__15\n t__15!\n\n when 5\n # at line 1:34: T__16\n t__16!\n\n when 6\n # at line 1:40: T__17\n t__17!\n\n when 7\n # at line 1:46: T__18\n t__18!\n\n when 8\n # at line 1:52: T__19\n t__19!\n\n when 9\n # at line 1:58: T__20\n t__20!\n\n when 10\n # at line 1:64: T__21\n t__21!\n\n when 11\n # at line 1:70: T__22\n t__22!\n\n when 12\n # at line 1:76: T__23\n t__23!\n\n when 13\n # at line 1:82: T__24\n t__24!\n\n when 14\n # at line 1:88: T__25\n t__25!\n\n when 15\n # at line 1:94: T__26\n t__26!\n\n when 16\n # at line 1:100: T__27\n t__27!\n\n when 17\n # at line 1:106: T__28\n t__28!\n\n when 18\n # at line 1:112: T__29\n t__29!\n\n when 19\n # at line 1:118: T__30\n t__30!\n\n when 20\n # at line 1:124: T__31\n t__31!\n\n when 21\n # at line 1:130: T__32\n t__32!\n\n when 22\n # at line 1:136: T__33\n t__33!\n\n when 23\n # at line 1:142: T__34\n t__34!\n\n when 24\n # at line 1:148: T__35\n t__35!\n\n when 25\n # at line 1:154: T__36\n t__36!\n\n when 26\n # at line 1:160: T__37\n t__37!\n\n when 27\n # at line 1:166: T__38\n t__38!\n\n when 28\n # at line 1:172: T__39\n t__39!\n\n when 29\n # at line 1:178: T__40\n t__40!\n\n when 30\n # at line 1:184: T__41\n t__41!\n\n when 31\n # at line 1:190: T__42\n t__42!\n\n when 32\n # at line 1:196: T__43\n t__43!\n\n when 33\n # at line 1:202: T__44\n t__44!\n\n when 34\n # at line 1:208: T__45\n t__45!\n\n when 35\n # at line 1:214: T__46\n t__46!\n\n when 36\n # at line 1:220: T__47\n t__47!\n\n when 37\n # at line 1:226: T__48\n t__48!\n\n when 38\n # at line 1:232: T__49\n t__49!\n\n when 39\n # at line 1:238: T__50\n t__50!\n\n when 40\n # at line 1:244: T__51\n t__51!\n\n when 41\n # at line 1:250: T__52\n t__52!\n\n when 42\n # at line 1:256: T__53\n t__53!\n\n when 43\n # at line 1:262: T__54\n t__54!\n\n when 44\n # at line 1:268: T__55\n t__55!\n\n when 45\n # at line 1:274: T__56\n t__56!\n\n when 46\n # at line 1:280: T__57\n t__57!\n\n when 47\n # at line 1:286: T__58\n t__58!\n\n when 48\n # at line 1:292: T__59\n t__59!\n\n when 49\n # at line 1:298: ST\n st!\n\n when 50\n # at line 1:301: ND\n nd!\n\n when 51\n # at line 1:304: RD\n rd!\n\n when 52\n # at line 1:307: TH\n th!\n\n when 53\n # at line 1:310: DIGIT\n digit!\n\n when 54\n # at line 1:316: WS\n ws!\n\n when 55\n # at line 1:319: EOL\n eol!\n\n when 56\n # at line 1:323: LETTER\n letter!\n\n end\n end",
"def token!\n # at line 1:8: ( T__8 | T__9 | T__10 | T__11 | T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | T__18 | T__19 | T__20 | T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | DIGIT | WS | EOL | LETTER )\n alt_3 = 40\n alt_3 = @dfa3.predict( @input )\n case alt_3\n when 1\n # at line 1:10: T__8\n t__8!\n\n when 2\n # at line 1:15: T__9\n t__9!\n\n when 3\n # at line 1:20: T__10\n t__10!\n\n when 4\n # at line 1:26: T__11\n t__11!\n\n when 5\n # at line 1:32: T__12\n t__12!\n\n when 6\n # at line 1:38: T__13\n t__13!\n\n when 7\n # at line 1:44: T__14\n t__14!\n\n when 8\n # at line 1:50: T__15\n t__15!\n\n when 9\n # at line 1:56: T__16\n t__16!\n\n when 10\n # at line 1:62: T__17\n t__17!\n\n when 11\n # at line 1:68: T__18\n t__18!\n\n when 12\n # at line 1:74: T__19\n t__19!\n\n when 13\n # at line 1:80: T__20\n t__20!\n\n when 14\n # at line 1:86: T__21\n t__21!\n\n when 15\n # at line 1:92: T__22\n t__22!\n\n when 16\n # at line 1:98: T__23\n t__23!\n\n when 17\n # at line 1:104: T__24\n t__24!\n\n when 18\n # at line 1:110: T__25\n t__25!\n\n when 19\n # at line 1:116: T__26\n t__26!\n\n when 20\n # at line 1:122: T__27\n t__27!\n\n when 21\n # at line 1:128: T__28\n t__28!\n\n when 22\n # at line 1:134: T__29\n t__29!\n\n when 23\n # at line 1:140: T__30\n t__30!\n\n when 24\n # at line 1:146: T__31\n t__31!\n\n when 25\n # at line 1:152: T__32\n t__32!\n\n when 26\n # at line 1:158: T__33\n t__33!\n\n when 27\n # at line 1:164: T__34\n t__34!\n\n when 28\n # at line 1:170: T__35\n t__35!\n\n when 29\n # at line 1:176: T__36\n t__36!\n\n when 30\n # at line 1:182: T__37\n t__37!\n\n when 31\n # at line 1:188: T__38\n t__38!\n\n when 32\n # at line 1:194: T__39\n t__39!\n\n when 33\n # at line 1:200: T__40\n t__40!\n\n when 34\n # at line 1:206: T__41\n t__41!\n\n when 35\n # at line 1:212: T__42\n t__42!\n\n when 36\n # at line 1:218: T__43\n t__43!\n\n when 37\n # at line 1:224: DIGIT\n digit!\n\n when 38\n # at line 1:230: WS\n ws!\n\n when 39\n # at line 1:233: EOL\n eol!\n\n when 40\n # at line 1:237: LETTER\n letter!\n\n end\n end",
"def token_from(data)\n extract_from(data, /Token token='(.+)'/).first rescue nil\n end",
"def token\n _response_word.fetch(\"token\", nil)\n end",
"def decode(token)\n \n end",
"def obtener_token\n\n\t\t# Se consumen los espacios en blanco y los comentrios.\n\t\t@entrada =~ /\\A(\\s|\\t|\\n|\\#.*)*/\n\t\t@entrada = $'\n\t\t$&.each_char do |chr|\n\t\t\tif chr == \"\\n\" # Si es salto de linea, se suma 1 a la linea y se resetea la columna.\n\t\t\t\t@linea += 1\n\t\t\t\t@columna = 1\n\t\t\telse\n\t\t\t\t@columna += 1\n\t\t\tend\n\t\tend\n\n\t\t# Si la entrada queda completamente vacia, se retorna nil.\n\t\tif @entrada.empty?\n\t\t\treturn nil\n\t\tend\n\n\t\t# Inicializamos un Error Lexicografico, en caso de no existir ningun match en la entrada.\n\t\tnuevoToken = LexicographError.new(@entrada[0], @linea, @columna)\n\n\t\t# Revisamos si la entrada hace match con algun token.\n\t\t$tokens.each do |token, regex|\n\t\t\tif @entrada =~ regex\n\t\t\t\ttk = Object::const_get(\"Tk#{token}\")\n\t\t\t\tnuevoToken = tk.new($&, @linea, @columna)\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\t# Aumentamos la columna con la longitud del match, o del error, y lo quitamos de la entrada.\n\t\t@columna += nuevoToken.texto.length\n\t\t@entrada = @entrada[nuevoToken.texto.length..@entrada.length-1]\n\n\t\t# Se reporta el error en caso de no existir mathc, o se retorna el token en caso de q si exista un match.\n\t\tif nuevoToken.is_a? LexicographError\n\t\t\t@errores << nuevoToken\n\t\t\traise nuevoToken\n\t\telse\n\t\t\t@tokens << nuevoToken\n\t\t\treturn nuevoToken\n\t\tend\n\tend",
"def token(resource)\n if Gem.win_platform?\n token_windows(resource)\n else\n token_nix(resource)\n end\n end",
"def correct_login_token?(given_token)\n false\n end",
"def scan_for_w(token); end",
"def token!\n # at line 1:8: ( STRING | SHELL_STRING | CMD_OUTPUT | SPACE | COMMAND_END | VARIABLE | GLOB | CHUNK | OPEN_PAR | CLOSE_PAR | PIPELINE_OPERATOR | REDIRECT | COMMENT )\n alt_25 = 13\n alt_25 = @dfa25.predict( @input )\n case alt_25\n when 1\n # at line 1:10: STRING\n string!\n\n when 2\n # at line 1:17: SHELL_STRING\n shell_string!\n\n when 3\n # at line 1:30: CMD_OUTPUT\n cmd_output!\n\n when 4\n # at line 1:41: SPACE\n space!\n\n when 5\n # at line 1:47: COMMAND_END\n command_end!\n\n when 6\n # at line 1:59: VARIABLE\n variable!\n\n when 7\n # at line 1:68: GLOB\n glob!\n\n when 8\n # at line 1:73: CHUNK\n chunk!\n\n when 9\n # at line 1:79: OPEN_PAR\n open_par!\n\n when 10\n # at line 1:88: CLOSE_PAR\n close_par!\n\n when 11\n # at line 1:98: PIPELINE_OPERATOR\n pipeline_operator!\n\n when 12\n # at line 1:116: REDIRECT\n redirect!\n\n when 13\n # at line 1:125: COMMENT\n comment!\n\n end\n end",
"def token\n ready_token\n\n i = @buffer.index(/[\\[\\]()<>{}\\s\\/]/) || @buffer.size\n\n token_chars =\n if i == 0 and @buffer[i,2] == \"<<\" then 2\n elsif i == 0 and @buffer[i,2] == \">>\" then 2\n elsif i == 0 then 1\n else i\n end\n\n strip_space = !(i == 0 and @buffer[0,1] == '(')\n tok = head(token_chars, strip_space)\n\n if tok == \"\"\n nil\n elsif tok[0,1] == \"%\"\n @buffer = \"\"\n token\n else\n tok\n end\n end",
"def crearToken lexema, fila, columna\n\n\t\ttipo = \"\"\n\t\ttipo = $reservadas.fetch(lexema, nil)\n\n\t\tif tipo == nil\n\t\t\tif lexema =~ $string\n\t\t\t\tif lexema =~ $stringErroneo\t# Caracteres que no deben estar escapados\n\t \t\ttipo = \"TkError\"\n\t \telse\n\t \t\ttipo = \"TkString\"\n\t \tend\n\t elsif lexema =~ $identificador\n \t \ttipo = \"TkId\"\n \t \telsif lexema =~ $numero\n \t \ttipo = \"TkNum\"\n \t \telse\n \t \ttipo = \"TkError\"\n \t \tend\n \tend\n\t\ttok = Token.new(lexema,tipo,fila,columna)\n\t\tif tok.tipo == \"TkError\"\n\t\t\t@error << tok\n\t\telse\n\t\t\t@tk << tok\n\t\tend\n\tend",
"def is_token_valid? token\n @browser_token_db.has_token? token\n end",
"def token_uri; end",
"def token\n @token ||= @context[\"value\"]\n end",
"def check_magic_token\n params[:magic_token] == Rails.application.secrets.calendly_magic_token\n end",
"def token!\n # at line 1:8: ( T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | T__47 | T__48 | T__49 | T__50 | T__51 | T__52 | T__53 | T__54 | INTEGER | FLOAT | BOOLEAN | STRING | CHAR | INIT | OPEN | CLOSE | TYPE_INT | TYPE_FLOAT | TYPE_STRING | TYPE_BOOL | TYPE_VOID | ENTITY | COMPONENT | SYSTEM | ENUM | IF | ELSE | RETURN | WHILE | IDENT | WS | COMMENT | MULTILINE_COMMENT | NL )\n alt_9 = 51\n alt_9 = @dfa9.predict( @input )\n case alt_9\n when 1\n # at line 1:10: T__30\n t__30!\n\n\n when 2\n # at line 1:16: T__31\n t__31!\n\n\n when 3\n # at line 1:22: T__32\n t__32!\n\n\n when 4\n # at line 1:28: T__33\n t__33!\n\n\n when 5\n # at line 1:34: T__34\n t__34!\n\n\n when 6\n # at line 1:40: T__35\n t__35!\n\n\n when 7\n # at line 1:46: T__36\n t__36!\n\n\n when 8\n # at line 1:52: T__37\n t__37!\n\n\n when 9\n # at line 1:58: T__38\n t__38!\n\n\n when 10\n # at line 1:64: T__39\n t__39!\n\n\n when 11\n # at line 1:70: T__40\n t__40!\n\n\n when 12\n # at line 1:76: T__41\n t__41!\n\n\n when 13\n # at line 1:82: T__42\n t__42!\n\n\n when 14\n # at line 1:88: T__43\n t__43!\n\n\n when 15\n # at line 1:94: T__44\n t__44!\n\n\n when 16\n # at line 1:100: T__45\n t__45!\n\n\n when 17\n # at line 1:106: T__46\n t__46!\n\n\n when 18\n # at line 1:112: T__47\n t__47!\n\n\n when 19\n # at line 1:118: T__48\n t__48!\n\n\n when 20\n # at line 1:124: T__49\n t__49!\n\n\n when 21\n # at line 1:130: T__50\n t__50!\n\n\n when 22\n # at line 1:136: T__51\n t__51!\n\n\n when 23\n # at line 1:142: T__52\n t__52!\n\n\n when 24\n # at line 1:148: T__53\n t__53!\n\n\n when 25\n # at line 1:154: T__54\n t__54!\n\n\n when 26\n # at line 1:160: INTEGER\n integer!\n\n\n when 27\n # at line 1:168: FLOAT\n float!\n\n\n when 28\n # at line 1:174: BOOLEAN\n boolean!\n\n\n when 29\n # at line 1:182: STRING\n string!\n\n\n when 30\n # at line 1:189: CHAR\n char!\n\n\n when 31\n # at line 1:194: INIT\n init!\n\n\n when 32\n # at line 1:199: OPEN\n open!\n\n\n when 33\n # at line 1:204: CLOSE\n close!\n\n\n when 34\n # at line 1:210: TYPE_INT\n type_int!\n\n\n when 35\n # at line 1:219: TYPE_FLOAT\n type_float!\n\n\n when 36\n # at line 1:230: TYPE_STRING\n type_string!\n\n\n when 37\n # at line 1:242: TYPE_BOOL\n type_bool!\n\n\n when 38\n # at line 1:252: TYPE_VOID\n type_void!\n\n\n when 39\n # at line 1:262: ENTITY\n entity!\n\n\n when 40\n # at line 1:269: COMPONENT\n component!\n\n\n when 41\n # at line 1:279: SYSTEM\n system!\n\n\n when 42\n # at line 1:286: ENUM\n enum!\n\n\n when 43\n # at line 1:291: IF\n if!\n\n\n when 44\n # at line 1:294: ELSE\n else!\n\n\n when 45\n # at line 1:299: RETURN\n return!\n\n\n when 46\n # at line 1:306: WHILE\n while!\n\n\n when 47\n # at line 1:312: IDENT\n ident!\n\n\n when 48\n # at line 1:318: WS\n ws!\n\n\n when 49\n # at line 1:321: COMMENT\n comment!\n\n\n when 50\n # at line 1:329: MULTILINE_COMMENT\n multiline_comment!\n\n\n when 51\n # at line 1:347: NL\n nl!\n\n\n end\n end",
"def token\n authenticated\n end",
"def token!\n # at line 1:8: ( OPERATOR | FLOAT | HEXADECIMAL | DECIMAL | OCTAL | BINARY | WS )\n alt_16 = 7\n alt_16 = @dfa16.predict(@input)\n case alt_16\n when 1\n # at line 1:10: OPERATOR\n operator!\n\n when 2\n # at line 1:19: FLOAT\n float!\n\n when 3\n # at line 1:25: HEXADECIMAL\n hexadecimal!\n\n when 4\n # at line 1:37: DECIMAL\n decimal!\n\n when 5\n # at line 1:45: OCTAL\n octal!\n\n when 6\n # at line 1:51: BINARY\n binary!\n\n when 7\n # at line 1:58: WS\n ws!\n\n end\n end",
"def getToken\n @tokens\n end",
"def valid_token?(token)\n return token =~ /^[\\w\\-\\.~_\\+\\/]+$/\n end",
"def tokenize\n \n end",
"def racc_read_token(t, tok, val); end",
"def valid_token?(token, method = :any)\n tokens = settings.subaru_config[:global][:auth_tokens][method]\n return true if tokens.nil?\n tokens.include?(token)\n end",
"def valid_token?\n env['HTTP_TOKEN']\n end",
"def next_token\n raise NotImplementedError\n end",
"def content_tokens\n alt\n end",
"def tokenize ; end",
"def tokenize ; end",
"def auth_token\n return token if token.present?\n\n false\n # raise(CustomException::MissingToken, 'token is missing')\n end",
"def valid?\n @token.valid?\n end",
"def auth_token(auth)\n validate_auth(auth, %i[token])\n auth[:token]\n end",
"def token_s\n fail 'sub-class to implement'\n end",
"def decodeJWT(token)\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n #Kontrollerar tiden på token\n if payload[0][\"exp\"] >= Time.now.to_i\n payload\n else\n puts \"The token has expired, please log in again to get a new one\"\n false\n end\n #Fångar felet om token var fel\n rescue => error\n puts error\n nil\n end",
"def valid_new_token?(token)\n unique_token?(token) && token_looks_safe?(token)\n end",
"def validation_login\n validate_token User, params[:token]\n end",
"def text_token(text, kind); end"
] | [
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.78079665",
"0.77833176",
"0.7138758",
"0.71051854",
"0.70247096",
"0.6982789",
"0.69513744",
"0.69513744",
"0.6917075",
"0.68719935",
"0.68583953",
"0.68527526",
"0.6833904",
"0.68053216",
"0.6768862",
"0.67654514",
"0.6764971",
"0.6763304",
"0.6726468",
"0.66883206",
"0.66802615",
"0.6664825",
"0.66494066",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66346604",
"0.66298574",
"0.65690804",
"0.6546567",
"0.6527443",
"0.6498187",
"0.64946425",
"0.646681",
"0.64603746",
"0.64456534",
"0.6434558",
"0.64221907",
"0.64221907",
"0.64221907",
"0.6388233",
"0.63806266",
"0.63794464",
"0.6338023",
"0.6328239",
"0.63197803",
"0.63019395",
"0.6298185",
"0.6298185",
"0.62823045",
"0.62811995",
"0.6272437",
"0.6272348",
"0.6267076",
"0.62634104",
"0.62629473",
"0.6255709",
"0.6253889",
"0.6248955",
"0.62381136",
"0.6186522",
"0.6185643",
"0.6179907",
"0.6177419",
"0.6172598",
"0.61680806",
"0.61657435",
"0.6152142",
"0.6151661",
"0.6136018",
"0.6135614",
"0.61316377",
"0.6122272",
"0.61182463",
"0.6107028",
"0.6103451",
"0.6098636",
"0.6096317",
"0.60849977",
"0.6079128",
"0.6073902",
"0.60719323",
"0.60719323",
"0.6060211",
"0.6059725",
"0.605828",
"0.605189",
"0.6049148",
"0.6046863",
"0.60424435",
"0.6041757"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:user_id, :title, :body, :password_confirmation, :password, :perimission_level,:email,:name,:score)
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 query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"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 whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def 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 specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def parameters\n nil\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.7120904",
"0.70538116",
"0.69469863",
"0.6901261",
"0.67348766",
"0.6717708",
"0.66874576",
"0.6676195",
"0.66601187",
"0.65563625",
"0.6525127",
"0.64565873",
"0.64494514",
"0.644928",
"0.64452374",
"0.6433947",
"0.6412815",
"0.6412815",
"0.6391939",
"0.63792473",
"0.63792473",
"0.63738",
"0.6360176",
"0.6354222",
"0.6284756",
"0.6277987",
"0.6245304",
"0.62259704",
"0.62243503",
"0.6223834",
"0.62104595",
"0.62081766",
"0.61759263",
"0.61721593",
"0.6168236",
"0.61587787",
"0.6143901",
"0.6135065",
"0.61204714",
"0.61065775",
"0.60983306",
"0.6073666",
"0.6051939",
"0.6040974",
"0.6036216",
"0.60291374",
"0.6020614",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.60180086",
"0.6017416",
"0.60161096",
"0.6006702",
"0.6002367",
"0.600212",
"0.5996321",
"0.59943277",
"0.59942585",
"0.59858114",
"0.5982845",
"0.59766084",
"0.5973769",
"0.5968758",
"0.59653395",
"0.5964966",
"0.5964966",
"0.5957481",
"0.59511584",
"0.5951042",
"0.5948871",
"0.59427315",
"0.5930573",
"0.5930121",
"0.5926885",
"0.5923959",
"0.59182686",
"0.5916637",
"0.5913613",
"0.5912174",
"0.5906678",
"0.59059656",
"0.5904252",
"0.5901623",
"0.58983696",
"0.58962476",
"0.589576",
"0.5893608"
] | 0.0 | -1 |
GET /featured_clients GET /featured_clients.json | def index
@featured_clients = FeaturedClient.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def show\n render json: @client\n end",
"def get_featured\n render json: Event.where(is_featured: true), status: :ok\n end",
"def show\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render json: @client }\n format.js\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @client }\r\n end\r\n end",
"def create\n @featured_client = FeaturedClient.new(featured_client_params)\n\n respond_to do |format|\n if @featured_client.save\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' }\n format.json { render :show, status: :created, location: @featured_client }\n else\n format.html { render :new }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end",
"def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end",
"def index\n render json: Client.all\n end",
"def show\n @client = clients.find(params[:id])\n end",
"def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end",
"def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def recent\n if current_user.is_admin?\n @clients = Client.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @clients }\n end\n end",
"def update\n respond_to do |format|\n if @featured_client.update(featured_client_params)\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' }\n format.json { render :show, status: :ok, location: @featured_client }\n else\n format.html { render :edit }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def show\n\t\t@client = Client.find(params[:id])\n\t\tif @client.status != 0\n\t\t\trender :json => @client, status: 200\n\t\telse\n\t\t\trender :json => @client.status, status: 400\n\t\tend\n\tend",
"def list_clients(json_payload={})\n conn = @client.get do |req|\n req.url \"/api/v2/client/list?\"\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end",
"def get_clients\n @clients\n end",
"def get_clients\n @clients\n end",
"def clients\n @clients = Vendor.find(params[:id]).clients\n end",
"def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end",
"def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end",
"def for_clients\n raise Forbidden if current_user.is_client_user?\n only_provides :json\n @search_criteria = SearchCriteria.new(params[:search_criteria], current_user)\n display :options => @search_criteria.all_projects.map { |p| { :id => p.id, :name => p.name } }\n end",
"def show\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def index\n get_clientes\n end",
"def featured_games\n FeaturedGameList.new perform_request api_url \"featured-games\"\n end",
"def show\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_client }\n end\n end",
"def show\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_studio_client }\n end\n end",
"def show\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_need }\n end\n end",
"def featured\n request('featured')\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end",
"def index\n #get the featured campaigns\n @campaigns = Campaign.where({ featured: true }).order(\"created_at DESC\").limit(8)\n #create array of objects where we display each campaign's id, name, goal and image_url\n campaigns_hash_array = @campaigns.collect{|campaign| {\"campaign_id\"=> campaign.id, \"campaign_name\" => campaign.name, \"campaign_goal\" => campaign.goal_cents/100, \"campaign_image_url\" => campaign.getimageurl(campaign.image) }}\n if(campaigns_hash_array != nil)\n render json: campaigns_hash_array\n else\n render json: no_featured_campaigns_error, :status => 404\n end\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def destroy\n @featured_client.destroy\n respond_to do |format|\n format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n puts params\n puts params[:filter]\n \n @clients = get_clients \n @client = Client.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"published_dashboards\",\"enabled\":true},\n {\"name\":\"downloadable_reports\",\"enabled\":true},\n {\"name\":\"scheduled_emails\",\"enabled\":true}]\n }.to_json)\n puts response.body\n puts \"Client's features were updated.\" if response.success?\n end",
"def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end",
"def show\n @client = Client.find(params[:id])\n @contracts = Contract.where(:client_id => @client.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def index\n @clients = Client.all\n end",
"def index\n \n @qa_clients = QaClient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qa_clients }\n end\n end",
"def show\n\n @client = Client.find(params[:id])\n end",
"def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end",
"def show\n @client = Client.find(params[:id])\n authorize! :read, @client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def index \n @clients = ApiClient.all\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def index_clients\n @client = Client.all\n end",
"def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientships }\n end\n end",
"def index\n @clients = Client.where(params.except(:action, :controller, :format)).to_a # TODO: remove .to_a when Rails to_json bug fixed\n respond_with(@clients)\n end",
"def show\n @qa_client = QaClient.find(params[:id])\n @qa_activities = @qa_client.qa_activities\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa_client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n end",
"def show\n @client = Client.find_by(id: params[:id])\n end",
"def index\n clients = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients\"\n ).body\n end\n styled_header(\"OAuth Clients\")\n styled_array(clients.map { |client|\n [client[\"name\"], client[\"id\"], client[\"redirect_uri\"]]\n })\n end",
"def index\n @live_clients = LiveClient.all\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def details\n response = CreateSend.get \"/clients/#{client_id}.json\", {}\n Hashie::Mash.new(response)\n end",
"def index\n @clients = Client.page(params[:page] || 1).per(10)\n end",
"def clients\n Harvest::Resources::Client\n end",
"def show\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_release }\n end\n end",
"def show\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n if @client.nil?\n @clients = Client.all\n flash.now[:alert] = \"Les détails du client n'ont pas été trouvés\"\n render \"index\"\n end\n respond_to do |format|\n format.html #show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def show\n @feature = Feature.find(params[:id])\n # @homepage_features = Feature.homepage_list.published\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feature }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n # @client = Client.find(params[:client_id])\n end",
"def show\n @client = Client.find params[:id]\n end",
"def show\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blocking_client }\n end\n end",
"def client_detail\n service_response = UserManagement::GetClientDetail.new(params).perform\n render_api_response(service_response)\n end",
"def show\n client = Client.find(params[:id])\n notifications = Notification.all\n client_notifications = notifications\n .select { |notification| client.companies.include? notification.company }\n render json: client_notifications\n end",
"def index\n @clients = Client.search(params[:search]).order(sort_column + \" \" + sort_direction).page(params[:page]).per(10)\n respond_with(@clients)\n end",
"def show\n @client = Client.find params[:client_id]\n end",
"def index\n render json: Client.where(active:true)\n end",
"def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end",
"def index\n add_breadcrumb(I18n.t('model.list', model: Client.model_name.human))\n\n @clients = Client.all()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def show\n @clientcase = Clientcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @clientcase }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_bug }\n end\n end"
] | [
"0.6933652",
"0.683633",
"0.67539525",
"0.6728703",
"0.66623473",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6604498",
"0.65847147",
"0.6570766",
"0.656262",
"0.6558943",
"0.6556442",
"0.6501677",
"0.64970773",
"0.6423044",
"0.6401207",
"0.6362379",
"0.63543266",
"0.6352246",
"0.63308823",
"0.63179797",
"0.62598413",
"0.62346554",
"0.62346554",
"0.62273085",
"0.621617",
"0.621617",
"0.62009096",
"0.6186216",
"0.61767244",
"0.6144363",
"0.6140428",
"0.6134403",
"0.613065",
"0.6126555",
"0.6110106",
"0.6095349",
"0.60632986",
"0.6057425",
"0.6057425",
"0.6057425",
"0.6057425",
"0.6057425",
"0.6057425",
"0.6057425",
"0.6057425",
"0.605022",
"0.60264474",
"0.60062784",
"0.60044384",
"0.598618",
"0.59667474",
"0.5958655",
"0.5955486",
"0.59535146",
"0.594881",
"0.59474194",
"0.59413975",
"0.59412664",
"0.59402883",
"0.59402883",
"0.59402883",
"0.59402883",
"0.59347385",
"0.593408",
"0.592109",
"0.5911162",
"0.5910982",
"0.5907932",
"0.5905189",
"0.5898279",
"0.5866955",
"0.5866955",
"0.5866955",
"0.5865688",
"0.5859578",
"0.5858267",
"0.5856112",
"0.5841205",
"0.58381504",
"0.5827906",
"0.5819409",
"0.581305",
"0.58062106",
"0.58046657",
"0.5800885",
"0.57969075",
"0.57926047",
"0.57890916",
"0.5779429",
"0.5768652",
"0.5767626",
"0.5761263",
"0.5756508"
] | 0.78416455 | 0 |
GET /featured_clients/1 GET /featured_clients/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @featured_clients = FeaturedClient.all\n end",
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n render json: @client\n end",
"def show\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @client }\r\n end\r\n end",
"def show\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render json: @client }\n format.js\n end\n end",
"def show\n @client = clients.find(params[:id])\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end",
"def show\n\t\t@client = Client.find(params[:id])\n\t\tif @client.status != 0\n\t\t\trender :json => @client, status: 200\n\t\telse\n\t\t\trender :json => @client.status, status: 400\n\t\tend\n\tend",
"def create\n @featured_client = FeaturedClient.new(featured_client_params)\n\n respond_to do |format|\n if @featured_client.save\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' }\n format.json { render :show, status: :created, location: @featured_client }\n else\n format.html { render :new }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n render json: Client.all\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def get_featured\n render json: Event.where(is_featured: true), status: :ok\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end",
"def update\n respond_to do |format|\n if @featured_client.update(featured_client_params)\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' }\n format.json { render :show, status: :ok, location: @featured_client }\n else\n format.html { render :edit }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end",
"def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end",
"def show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end",
"def show\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_studio_client }\n end\n end",
"def show\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_client }\n end\n end",
"def recent\n if current_user.is_admin?\n @clients = Client.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @clients }\n end\n end",
"def show\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_need }\n end\n end",
"def show\n\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n end",
"def show\n @client = Client.find_by(id: params[:id])\n end",
"def show\n @client = Client.find(params[:id])\n\n end",
"def clients\n @clients = Vendor.find(params[:id]).clients\n end",
"def show\n @client = Client.find params[:id]\n end",
"def show\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n # @client = Client.find(params[:client_id])\n end",
"def show\n @client = Client.find params[:client_id]\n end",
"def get_clients\n @clients\n end",
"def get_clients\n @clients\n end",
"def index\n get_clientes\n end",
"def show\n @client = Client.find(params[:id])\n @contracts = Contract.where(:client_id => @client.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_release }\n end\n end",
"def show\n @client = Client.find(params[:id])\n authorize! :read, @client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blocking_client }\n end\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @qa_client = QaClient.find(params[:id])\n @qa_activities = @qa_client.qa_activities\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qa_client }\n end\n end",
"def destroy\n @featured_client.destroy\n respond_to do |format|\n format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n puts params\n puts params[:filter]\n \n @clients = get_clients \n @client = Client.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def index_clients\n @client = Client.all\n end",
"def show\n @cliente = Cliente.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def list_clients(json_payload={})\n conn = @client.get do |req|\n req.url \"/api/v2/client/list?\"\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end",
"def show\n @clientcase = Clientcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @clientcase }\n end\n end",
"def client_detail\n service_response = UserManagement::GetClientDetail.new(params).perform\n render_api_response(service_response)\n end",
"def details\n response = CreateSend.get \"/clients/#{client_id}.json\", {}\n Hashie::Mash.new(response)\n end",
"def show\n @client_number = ClientNumber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_number }\n end\n end",
"def index\n @clients = Client.all\n end",
"def for_clients\n raise Forbidden if current_user.is_client_user?\n only_provides :json\n @search_criteria = SearchCriteria.new(params[:search_criteria], current_user)\n display :options => @search_criteria.all_projects.map { |p| { :id => p.id, :name => p.name } }\n end",
"def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def index\n #get the featured campaigns\n @campaigns = Campaign.where({ featured: true }).order(\"created_at DESC\").limit(8)\n #create array of objects where we display each campaign's id, name, goal and image_url\n campaigns_hash_array = @campaigns.collect{|campaign| {\"campaign_id\"=> campaign.id, \"campaign_name\" => campaign.name, \"campaign_goal\" => campaign.goal_cents/100, \"campaign_image_url\" => campaign.getimageurl(campaign.image) }}\n if(campaigns_hash_array != nil)\n render json: campaigns_hash_array\n else\n render json: no_featured_campaigns_error, :status => 404\n end\n end",
"def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end",
"def show\n @player_client = PlayerClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_client }\n end\n end",
"def index \n @clients = ApiClient.all\n end",
"def show\n \t@wishlist = Wishlist.find(params[:id])\n \t@client = @wishlist.client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wishlist }\n end\n end",
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"published_dashboards\",\"enabled\":true},\n {\"name\":\"downloadable_reports\",\"enabled\":true},\n {\"name\":\"scheduled_emails\",\"enabled\":true}]\n }.to_json)\n puts response.body\n puts \"Client's features were updated.\" if response.success?\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def show\n @client = Client.find(params[:id])\n if @client.nil?\n @clients = Client.all\n flash.now[:alert] = \"Les détails du client n'ont pas été trouvés\"\n render \"index\"\n end\n respond_to do |format|\n format.html #show.html.erb\n format.xml { render :xml => @client }\n end\n end",
"def show\n @paperclip_client = PaperclipClient.find(params[:id])\n @client = @paperclip_client\n\n respond_to do |format|\n format.html { render 'clients/show' }# show.html.erb\n format.xml { render :xml => @paperclip_client }\n end\n end",
"def show\n @client_asset = ClientAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_asset }\n end\n end",
"def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientships }\n end\n end",
"def show\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_type }\n end\n end",
"def index\n \n @qa_clients = QaClient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qa_clients }\n end\n end"
] | [
"0.7750333",
"0.71369797",
"0.70712596",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.6965878",
"0.69514996",
"0.6828995",
"0.68106806",
"0.6802026",
"0.67406523",
"0.6735485",
"0.67273724",
"0.6662405",
"0.66607916",
"0.6652181",
"0.6637546",
"0.6636555",
"0.6593193",
"0.65705556",
"0.656376",
"0.6528573",
"0.6499566",
"0.64983743",
"0.64983743",
"0.6498202",
"0.6470364",
"0.6464022",
"0.6463948",
"0.64596725",
"0.6409685",
"0.64091533",
"0.6407985",
"0.6407985",
"0.6407985",
"0.6407985",
"0.63890046",
"0.63838655",
"0.6330755",
"0.630495",
"0.6275254",
"0.62500525",
"0.62492126",
"0.62250364",
"0.62250364",
"0.6213064",
"0.6209823",
"0.62029594",
"0.61956775",
"0.6191094",
"0.6190544",
"0.6164867",
"0.6162092",
"0.6162092",
"0.6162092",
"0.6162092",
"0.6162092",
"0.6162092",
"0.6162092",
"0.6162092",
"0.61574006",
"0.61574006",
"0.61574006",
"0.6122717",
"0.6108008",
"0.60993224",
"0.6090924",
"0.6090924",
"0.6090924",
"0.6090924",
"0.60902125",
"0.6084722",
"0.6084358",
"0.6080458",
"0.6078127",
"0.6074272",
"0.6071962",
"0.6062831",
"0.6062678",
"0.60539144",
"0.60459876",
"0.60454375",
"0.6038719",
"0.6029449",
"0.6027157",
"0.6024278",
"0.6017833",
"0.6014329",
"0.6014329",
"0.6014091",
"0.60133225",
"0.6012512",
"0.60119045",
"0.6011817",
"0.6008871",
"0.599908"
] | 0.0 | -1 |
POST /featured_clients POST /featured_clients.json | def create
@featured_client = FeaturedClient.new(featured_client_params)
respond_to do |format|
if @featured_client.save
format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' }
format.json { render :show, status: :created, location: @featured_client }
else
format.html { render :new }
format.json { render json: @featured_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"published_dashboards\",\"enabled\":true},\n {\"name\":\"downloadable_reports\",\"enabled\":true},\n {\"name\":\"scheduled_emails\",\"enabled\":true}]\n }.to_json)\n puts response.body\n puts \"Client's features were updated.\" if response.success?\n end",
"def index\n @featured_clients = FeaturedClient.all\n end",
"def update\n respond_to do |format|\n if @featured_client.update(featured_client_params)\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' }\n format.json { render :show, status: :ok, location: @featured_client }\n else\n format.html { render :edit }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def featured_client_params\n params.require(:featured_client).permit(:image, :website_name, :testimonial)\n end",
"def create\n @client = current_user.clients.build(client_params)\n\n if @client.save\n render :create, status: :created\n CareeerMailer.trial_end(current_user.email, @client).deliver_later\n CareeerMailer.welcome(current_user.email, @client).deliver_later\n else\n render json: @client.errors, status: :unprocessable_entity\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_url, notice: 'El cliente se creó correctamente' }\n format.json { render :index, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = current_user.clients.build(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = current_user.clients.build(client_params)\n \n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n @client.campaign_id = session[:campaign_id]\n @groups = Group.all.map {|g| [g.name, g.id]}\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, :notice => 'Client was successfully created.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @featured_client.destroy\n respond_to do |format|\n format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clients = get_clients\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n @clients = get_clients\n newVisitOnCreate(@client)\n #format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n format.js\n else\n #format.html { render action: \"index\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save \n format.html { redirect_to @client, :notice => 'Klijent je uspjesno kreiran.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n\n format.js\n\n format.html { redirect_to root_path, notice: 'Vous avez bien été ajouté à notre newsletter' }\n\n format.json { render :show, status: :created, location: @client }\n\n else\n\n format.html { render :new }\n\n format.json { render json: @client.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: \"Client was successfully created.\" }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n authorize @client\n respond_to do |format|\n if @client.save\n format.html { redirect_back_or_default clients_url, t('Record has been saved') }\n format.json { render :show, status: :created, location: @client }\n format.js { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def create\n #newParams = client_params.as_json\n flash[:notice] = \"Cliente creado\"\n @client = current_freelance.clients.create(client_params)\n\n #@client = current_freelance.clients\n #@client.name = params[:name]\n #@client.surname = params[:surname]\n #@client.username = params[:username]\n #@client.password = params[:password]\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n #format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente cadastrado com sucesso!' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @featured = Featured.new(featured_params)\n @featured.user = current_user\n respond_to do |format|\n if @featured.save\n format.html { redirect_to @featured, notice: 'Featured was successfully created.' }\n format.json { render :show, status: :created, location: @featured }\n else\n format.html { render :new }\n format.json { render json: @featured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n flash[:notice] = 'Client was successfully created.' if @client.save\n respond_with(@client)\n end",
"def create\n @invoice_client = InvoiceClient.new(invoice_client_params)\n\n respond_to do |format|\n if @invoice_client.save\n format.html { redirect_to @invoice_client, notice: 'Invoice client was successfully created.' }\n format.json { render :show, status: :created, location: @invoice_client }\n else\n format.html { render :new }\n format.json { render json: @invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = current_user.clients.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enabled_client = EnabledClient.new(enabled_client_params)\n\n respond_to do |format|\n if @enabled_client.save\n format.html { redirect_to @enabled_client, notice: 'Enabled client was successfully created.' }\n format.json { render :show, status: :created, location: @enabled_client }\n else\n format.html { render :new }\n format.json { render json: @enabled_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_client(name, facebook_id, twitter_handle)\n puts name, facebook_id, twitter_handle\n # Point the HTTP POST method at the clients endpoint of Klipfolio's API.\n response = self.class.post(\"https://app.klipfolio.com/api/1.0/clients\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n \"name\": name,\n \"description\": \"\",\n \"seats\": 5,\n \"status\": \"active\"\n }.to_json)\n puts response.body\n puts \"Client was successfully created.\" if response.success?\n\n # Extract the new client's ID from the HTTP response so that it can be passed to the update_features & update_resources methods.\n client_id = response[\"meta\"][\"location\"]\n client_id.slice!(\"/clients/\")\n p client_id\n\n update_resources(client_id)\n update_features(client_id)\n update_company_properties(client_id, facebook_id, twitter_handle)\n create_group(client_id)\n share_dashboard(client_id)\n end",
"def create\n @client = Client.new(client_params)\n @client.user_id = current_user.id\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client record was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @client = Client.new(client_params)\n\n #se não aguardar carregar os dados\n if @client.state == '...'\n sweetalert_warning('Você precisa informar o CEP e aguardar os dados do endereço serem preenchidos.', 'Aviso!', useRejections: false)\n redirect_to new_client_path and return\n end\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente criado com sucesso.' }\n format.json { render :show, status: :created, location: @client }\n sweetalert_success('Cliente cadastrado com sucesso.', 'Sucesso!', useRejections: false)\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente criado com sucesso.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.create(client_params)\n @clients = Client.all\n flash[:notice]=\"client créé avec succès!!!\"\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to admin_client_path(@client, search: params[:search], page: params[:page]),\n notice: 'Клиент успешно создан.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @live_client = LiveClient.new(live_client_params)\n\n respond_to do |format|\n if @live_client.save\n format.html { redirect_to @live_client, notice: 'Live client was successfully created.' }\n format.json { render :show, status: :created, location: @live_client }\n else\n format.html { render :new }\n format.json { render json: @live_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:domain] = current_user.domain\r\n params[:client][:username] = current_user.username\r\n @client = Client.new(client_params)\r\n\r\n respond_to do |format|\r\n if @client.save\r\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\r\n format.json { render json: @client, status: :created, location: @client }\r\n format.js {}\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @client.errors, status: :unprocessable_entity }\r\n format.js {}\r\n end\r\n end\r\n end",
"def create\n @client = Client.new(client_params)\n authorize! :create, @client\n\n respond_to do |format|\n if not @client.caseworker.can_add_clients?\n @client.errors[:base] << \"You are past your limit. Please come back later.\"\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n elsif @client.save\n format.html { redirect_to @client, :notice => 'Client was successfully created.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @client = current_user.clients.new(client_params)\n\n @client.save\n redirect_to @client\n end",
"def create\n authorize! :create, Client\n build_client\n save_client or render :new\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n\t\tClientMailer.registration_confirmation(@client).deliver\n\t\tCountry.create!({'clientkey'=>@client.id, 'country'=>@client.country})\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.create(client_params)\n # byebug\n if @client.valid?\n render json: { client: ClientSerializer.new(@client) }, status: :created\n else\n render json: { error: 'failed to create account' }, status: :not_acceptable\n end \n end",
"def create\n @budget = Budget.new(budget_params)\n @client = Client.new\n @clients = Client.all\n respond_to do |format|\n if @budget.save\n format.html { redirect_to @budget, notice: 'El presupuesto se creó correctamente' }\n format.json { render :show, status: :created, location: @budget }\n else\n format.html { render :new }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def create\n @clientsOffers = ClientsOffers.new(params[:clientsOffers])\n\n respond_to do |format|\n if @clientsOffers.save\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully created.' }\n format.json { render json: @clientsOffers, status: :created, location: @clientsOffers }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end",
"def new\n @client = Client.new\n # @client.contacts.build\n # @client.meetings.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n format.js\n end\n end",
"def create\n @client = Client.new(params[:client])\n @uuid = params[:uuid]\n respond_to do |format|\n if @client.save\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n respond_to do |format|\n # if @client.valid? \n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n # else\n # format.html { render :new }\n # format.json { render json: @client.errors, status: :unprocessable_entity }\n # end\n end\n end",
"def create\n client= Client.new\n client.cedula= params[:cedula]\n client.sector= params[:sector]\n client.nombre= params[:nombre]\n client.telefono= params[:telefono]\n client.pagina= params[:pagina]\n client.direccion= params[:direccion]\n if client.save\n render(json: client, status: 201 , location: client)\n else \n render(json: client.errors, status: 422)\n end\n end",
"def create\n @potential_client = PotentialClient.new(potential_client_params)\n\n respond_to do |format|\n if @potential_client.save\n format.html { redirect_to @potential_client, notice: 'Potential client was successfully created.' }\n format.json { render :show, status: :created, location: @potential_client }\n else\n format.html { render :new }\n format.json { render json: @potential_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @otg_client = OtgClient.new(otg_client_params)\n\n respond_to do |format|\n if @otg_client.save\n format.html { redirect_to @otg_client, notice: 'Otg client was successfully created.' }\n format.json { render :show, status: :created, location: @otg_client }\n else\n format.html { render :new }\n format.json { render json: @otg_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n client = Cliente.new\n\n client.nombre = params[:nombre]\n client.cedula = params[:cedula]\n client.pagina = params[:pagina]\n\n client.dirrecion = params[:dirrecion]\n client.telefono = params[:telefono]\n \n client.sector = params[:sector]\n \n\n if client.save\n \n\n render(json: client,status: 201 ,location: client)\n else\n\n render(json: client.errors,status: 422 )\n\n end\n end",
"def create\n @qa_client = QaClient.new(params[:qa_client])\n\n respond_to do |format|\n if @qa_client.save\n format.html { redirect_to @qa_client, notice: 'Qa client was successfully created.' }\n format.json { render json: @qa_client, status: :created, location: @qa_client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qa_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @labtech_client = LabtechClient.new(labtech_client_params)\n \n \n respond_to do |format|\n if @labtech_client.save\n \n \n \n format.html { redirect_to @labtech_client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @labtech_client }\n else\n format.html { render :new }\n format.json { render json: @labtech_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @authorized_client = AuthorizedClient.new(authorized_client_params)\n\n respond_to do |format|\n if @authorized_client.save\n format.html {redirect_to @authorized_client, notice: 'Authorized client was successfully created.'}\n format.json {render :show, status: :created, location: @authorized_client}\n else\n format.html {render :new}\n format.json {render json: @authorized_client.errors, status: :unprocessable_entity}\n end\n end\n end",
"def new\r\n @client = Client.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @client }\r\n\t format.js {}\r\n end\r\n end",
"def create\n client = Client.new(client_params)\n\n if !client.billing_plan\n render json: {error: \"you need to select a plan\"} \n else \n client.save\n render json: client, status: :created\n end\n end",
"def create(client)\n @client = Locomotive::Client.new(client)\n\n if @client.save\n redirect resource(@client), :message => {:notice => \"Client was successfully created\"}\n else\n render :new\n end\n end",
"def create\n @client = Client.new(params[:client])\n \n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => \"Client was successfully created. #{undo_link}\") }\n end\n respond_with(@client)\n end\n end",
"def create\n\n @client = Client.new(client_params)\n @client.business_owner_id = helpers.current_business_owner.id\n\n if @client.save\n flash[:notice] = \"#{@client.name} was added as a new client.\"\n redirect_to clients_path\n else\n render :new\n end\n end",
"def create\n @group_client = GroupClient.new(group_client_params)\n\n respond_to do |format|\n if @group_client.save\n format.html { redirect_to @group_client, flash: { success: \"Group client was successfully created.\" } }\n format.json { render action: 'show', status: :created, location: @group_client }\n else\n format.html { render action: 'new' }\n format.json { render json: @group_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client.update(client_params)\n render json: @client\n end",
"def create\n @my_studio_client = MyStudio::Client.new(params[:my_studio_client])\n\n respond_to do |format|\n if @my_studio_client.save\n format.html { redirect_to @my_studio_client, notice: 'Client was successfully created.' }\n format.json { render json: @my_studio_client, status: :created, location: @my_studio_client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Le client a bien été créé.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @client_doc = ClientDoc.new(client_doc_params)\n\n respond_to do |format|\n if @client_doc.save\n format.html { redirect_to @client_doc, notice: 'Client doc was successfully created.' }\n format.json { render :show, status: :created, location: @client_doc }\n else\n format.html { render :new }\n format.json { render json: @client_doc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = clients.new(params[:client])\n\n if @client.save\n flash[:notice] = 'Customer was successfully created.'\n redirect_to(user_company_clients_url(current_company))\n else\n render :action => \"new\"\n end\n end",
"def create\n @add_to_invoice_client = AddToInvoiceClient.new(add_to_invoice_client_params)\n\n respond_to do |format|\n if @add_to_invoice_client.save\n format.html { redirect_to @add_to_invoice_client, notice: 'Add to invoice client was successfully created.' }\n format.json { render :show, status: :created, location: @add_to_invoice_client }\n else\n format.html { render :new }\n format.json { render json: @add_to_invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_client\n if current_admin.present?\n @client = Client.new(params[:client])\n respond_to do |format|\n if @client.save\n flash[:notice] = \"Client has been successfully added!\"\n format.html { redirect_to root_url }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to new_admin_session_path and return\n end \n end",
"def create\n #create the object of client and assign the attributes in the request\n @client = Client.new(params[:client])\n \n #save the client\n if @client.save\n #if saved, return and redirect to client show page with success message\n return redirect_to client_path(@client), notice: \"client created successfuly\"\n else\n #if not saved, render the form with error messages\n return render action: :new\n end\n end",
"def show\n render json: @client\n end",
"def create\n @studio_client = StudioClient.new(studio_client_params)\n\n respond_to do |format|\n if @studio_client.save\n format.html { redirect_to edit_admin_studio_client_path(@studio_client), notice: 'Studio client was successfully created.' }\n format.json { render :show, status: :created, location: @studio_client }\n else\n format.html { render :new }\n format.json { render json: @studio_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dailyfeatured = Dailyfeatured.new(dailyfeatured_params)\n\n respond_to do |format|\n if @dailyfeatured.save\n format.html { redirect_to @dailyfeatured, notice: 'Dailyfeatured was successfully created.' }\n format.json { render :show, status: :created, location: @dailyfeatured }\n else\n format.html { render :new }\n format.json { render json: @dailyfeatured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clientes_servico = ClientesServico.new(clientes_servico_params)\n\n respond_to do |format|\n if @clientes_servico.save\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully created.' }\n format.json { render action: 'show', status: :created, location: @clientes_servico }\n else\n format.html { render action: 'new' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @clients = get_clients\n @client = Client.new\n\n respond_to do |format|\n format.js # new.js.erb\n end\n end",
"def create\n @featured_project = FeaturedProject.new(featured_project_params)\n\n respond_to do |format|\n if @featured_project.save\n format.json { render :show, status: :created, location: @featured_project }\n else\n format.json { render json: @featured_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def client_params\n params.require(:client).permit(:first_name, :last_name, :preferred_name, :is_veteran, :deceased, :inactive, :inactive_description, :dwelling, :current_camp_id,\n :previous_camp_id, :birth_date, :is_aftercare, :shoe_size, :boot_size, :number_meals, :phone, :joppa_apartment_number, :status, :gender,\n :last_interaction_date, :admin_notes, :number_tanks, :number_hoses, :household_id, :first_time_homeless, :date_became_homeless, :homeless_reason, :due_to_covid,\n :household_relationship_type, :client_picture, :race, :ethnicity)\n end",
"def create\n @client = Client.new(client_params)\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Client was successfully created.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n\n if @client.save\n redirect_to @client, notice: 'Client was successfully created.'\n else\n render :new\n end\n end",
"def create\n client_params[:specialDiscount].to_s.gsub!(',', '.')\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n\n format.html { redirect_to @client, notice: 'El Cliente fue Creado Exitosamente.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def client_params\n params.require(:client).permit(:id, :client_id, :name, :admin_comment, :area_important, :nav_id)\n end",
"def create\n @clientship = current_user.clientships.build(:client_id => params[:client_id], :fee => params[:fee])\n\n respond_to do |format|\n if @clientship.save\n format.html { redirect_to @clientship, notice: 'Clientship was successfully created.' }\n format.json { render json: @clientship, status: :created, location: @clientship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Client was successfully created.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @featured = Featured.new(featured_params)\n @featured.Project_id = session[:current_project_id]\n respond_to do |format|\n if @featured.save\n format.html { redirect_to home_index_url, notice: 'The project was successfully selected as best of the week.' }\n format.json { render :show, status: :created, location: @featured }\n else\n format.html { render :new }\n format.json { render json: @featured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @client = Client.new\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def create\n @paperclip_client = PaperclipClient.new(params[:paperclip_client])\n @client = @paperclip_client\n\n respond_to do |format|\n if @paperclip_client.save\n format.html { redirect_to(@paperclip_client, :notice => 'Paperclip client was successfully created.') }\n format.xml { render :xml => @paperclip_client, :status => :created, :location => @paperclip_client }\n else\n format.html { render 'clients/new' }\n format.xml { render :xml => @paperclip_client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def client_params\n params.require(:client).permit(:name, :pretty_name, \n :description, :organization_id, \n client_detectables_attributes: [:id, :detectable_id, :_destroy],\n det_group_clients_attributes: [:id, :det_group_id, :_destroy])\n end",
"def client_params\n params.require(:client).permit(:register_date, :budge, :insured, :cnpj, :itens, :current_bonus, :insured_type, :supervisor, :supervisor_email, :supervisor_phone, :supervisor_cellphone, :director, :director_email, :director_phone, :director_cellphone, :last_bonus, :validity, :insurer, :assistant, :commercial_supervisor, :city, :estate, :obs)\n end",
"def create\n @cliente = Cliente.new(params[:cliente])\n \n respond_to do |format|\n if @cliente.save\n format.html { redirect_to edit_cliente_path(@cliente), notice: 'Cliente was successfully created.' }\n format.json { render json: @cliente , status: :created, location: @cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @members_client = MembersClient.new(members_client_params)\n\n respond_to do |format|\n if @members_client.save\n format.html { redirect_to @members_client, notice: 'Members client was successfully created.' }\n format.json { render :show, status: :created, location: @members_client }\n else\n format.html { render :new }\n format.json { render json: @members_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client = Client.new(client_params)\n if @client.save\n redirect_to client_path(@client)\n else\n render ‘new’\n end\n end",
"def create\n @client = Client.new(params[:client])\n @states = State.find(:all,:order=>\"short_name\")\n @genders = Gender.find(:all)\n @email_priorities = EmailPriority.find(:all)\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Client was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def client_params\n params.require(:client).permit(:name, :slug, :avatar, :vision, :client_status, :new_name, :account_type, :toolbox)\n end"
] | [
"0.67577773",
"0.6596986",
"0.6583391",
"0.6533749",
"0.6523827",
"0.6325813",
"0.6287912",
"0.6286387",
"0.62818676",
"0.62335885",
"0.6210315",
"0.62056553",
"0.62049633",
"0.6194312",
"0.6185106",
"0.61788565",
"0.61700845",
"0.6154021",
"0.6149242",
"0.6149242",
"0.6149242",
"0.6148748",
"0.6143141",
"0.6113137",
"0.6113137",
"0.6113137",
"0.6102692",
"0.60985816",
"0.60902274",
"0.6089652",
"0.6073378",
"0.6055943",
"0.6042295",
"0.6032159",
"0.6019737",
"0.6009376",
"0.5984238",
"0.5960174",
"0.59506065",
"0.59408206",
"0.59378254",
"0.5936451",
"0.59233314",
"0.5905464",
"0.5898497",
"0.58909166",
"0.58818364",
"0.58702505",
"0.58592325",
"0.58592325",
"0.58592325",
"0.58592325",
"0.58512634",
"0.5848699",
"0.58396626",
"0.5836432",
"0.5830365",
"0.58129627",
"0.58091146",
"0.58005756",
"0.5798753",
"0.57916987",
"0.57912767",
"0.57853353",
"0.5783572",
"0.5778786",
"0.57643557",
"0.5749058",
"0.5743944",
"0.57427716",
"0.5740172",
"0.57307976",
"0.5726493",
"0.5716359",
"0.5713526",
"0.5710839",
"0.5708536",
"0.57013613",
"0.5683351",
"0.5682278",
"0.56609243",
"0.5658149",
"0.56570643",
"0.5656745",
"0.5645877",
"0.56435806",
"0.56373185",
"0.5633203",
"0.56312835",
"0.56300706",
"0.5624608",
"0.5623058",
"0.561747",
"0.56087047",
"0.55923045",
"0.55913717",
"0.5580343",
"0.55770963",
"0.5573815",
"0.5568634"
] | 0.7798717 | 0 |
PATCH/PUT /featured_clients/1 PATCH/PUT /featured_clients/1.json | def update
respond_to do |format|
if @featured_client.update(featured_client_params)
format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' }
format.json { render :show, status: :ok, location: @featured_client }
else
format.html { render :edit }
format.json { render json: @featured_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"published_dashboards\",\"enabled\":true},\n {\"name\":\"downloadable_reports\",\"enabled\":true},\n {\"name\":\"scheduled_emails\",\"enabled\":true}]\n }.to_json)\n puts response.body\n puts \"Client's features were updated.\" if response.success?\n end",
"def update\n @client.update(client_params)\n render json: @client\n end",
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def update\n authorize! :update, Client\n load_client\n build_client\n save_client or render :edit\n end",
"def update\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n @clients = get_clients\n #format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n #format.html { render action: \"index\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_client\n\t\t@client = Client.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @client.update_attributes(client_update_params)\n\t\t format.html { redirect_to(@client, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@client) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@client) }\n\t\t end\n\n \t end\n\tend",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Klijent je uspjesno izmjenjen.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'El cliente se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n if @client.update(client_params)\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n params[:client][:contact_ids] ||= []\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n authorize @client\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_back_or_default clients_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n authorize! :update, @client\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @client.update(client_params)\n head(:ok)\n else\n render json: @client.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n succeess_redirect_path = URI(request.referer).path.gsub 'edit', ''\n if @client.update(client_params)\n format.html { redirect_to succeess_redirect_path, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { redirect_to URI(request.referer).path }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:username] = current_user.username\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @client.update_attributes(client_params)\r\n format.html { redirect_to @client, notice: 'Client 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: @client.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: \"Client was successfully updated.\" }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to clients_url, notice: 'La información del cliente se actualizó correctamente.' }\n format.json { render :index, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n if @api_client.update_attributes(params[:api_client])\n format.html { redirect_to @api_client, notice: 'Api client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client record was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_client\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n respond_to do |format|\n if params[:client][:permalink].present?\n @client.update_attributes(:slug => params[:client][:permalink])\n end\n if @client.update_attributes(params[:client])\n format.html { redirect_to edit_admin_path(@client), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to new_admin_session_path and return\n end \n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to user_url(@client.id), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_user_url(@client.id)}\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n\n format.json { render :show, status: :ok, location: @client }\n\n else\n\n format.html { render :edit }\n\n format.json { render json: @client.errors, status: :unprocessable_entity }\n\n end\n end\n end",
"def update\n @client = current_user.clients.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to @client, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @live_client.update(live_client_params)\n format.html { redirect_to @live_client, notice: 'Live client was successfully updated.' }\n format.json { render :show, status: :ok, location: @live_client }\n else\n format.html { render :edit }\n format.json { render json: @live_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_client\n\t\tif(request.method == \"OPTIONS\")\n\t\t\trespond({status: 0})\n\t\telsif request.method == \"POST\"\n\t\t\trespond(update_user_client(params))\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @potential_client.update(potential_client_params)\n format.html { redirect_to @potential_client, notice: 'Potential client was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_client }\n else\n format.html { render :edit }\n format.json { render json: @potential_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n \tif params[:client][:logo].blank?\n \t\tparams[:client][:logo] = @client.logo\n \telse\n \t\tnew_file_name = upload_file(params[:client][:logo], \"/public/files/logo_files/\")\n\t \tFileUtils.rm Dir[\"#{Rails.root}/public/files/logo_files/\"+@client.logo.to_s]\n\t \tparams[:client][:logo] = new_file_name\n \tend\n\t \tparams[:client][:updated_by] = current_user.id\n @client.attributes = params[:client]\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n @groups = Group.all.map {|g| [g.name, g.id]}\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client a été mise à jour.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n if @my_studio_client.update_attributes(params[:my_studio_client])\n format.html { redirect_to @my_studio_client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(client_url, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @featured.update(featured_params)\n format.html { redirect_to @featured, notice: 'Featured was successfully updated.' }\n format.json { render :show, status: :ok, location: @featured }\n else\n format.html { render :edit }\n format.json { render json: @featured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @featured.update(featured_params)\n format.html { redirect_to @featured, notice: 'Featured was successfully updated.' }\n format.json { render :show, status: :ok, location: @featured }\n else\n format.html { render :edit }\n format.json { render json: @featured.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_resources(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/resources\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n \"resources\": [{\"name\":\"dashboard.tabs.total\", \"value\":1}]\n }.to_json)\n puts response.body\n puts \"Client's resources were updated.\" if response.success?\n end",
"def update\n @qa_client = QaClient.find(params[:id])\n\n respond_to do |format|\n if @qa_client.update_attributes(params[:qa_client])\n format.html { redirect_to @qa_client, notice: 'Qa client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qa_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invoice_client.update(invoice_client_params)\n format.html { redirect_to @invoice_client, notice: 'Invoice client was successfully updated.' }\n format.json { render :show, status: :ok, location: @invoice_client }\n else\n format.html { render :edit }\n format.json { render json: @invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n respond_to do |format|\n if @client.update_attributes(params[:client])\n \n flash[:notice] = 'Client was successfully updated.'\n format.html { redirect_to(@client) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n client_id = params[:contact].delete(:client_id)\n @contact = Contact.find(params[:id])\n @contact.client = Client.find(client_id.to_i)\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.js\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.js { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @otg_client.update(otg_client_params)\n format.html { redirect_to @otg_client, notice: 'Otg client was successfully updated.' }\n format.json { render :show, status: :ok, location: @otg_client }\n else\n format.html { render :edit }\n format.json { render json: @otg_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n flash[:notice] = 'Client was successfully updated.' if @client.update_attributes(params[:client])\n respond_with(@client)\n end",
"def update\n respond_to do |format|\n if @enabled_client.update(enabled_client_params)\n format.html { redirect_to @enabled_client, notice: 'Enabled client was successfully updated.' }\n format.json { render :show, status: :ok, location: @enabled_client }\n else\n format.html { render :edit }\n format.json { render json: @enabled_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @add_to_invoice_client.update(add_to_invoice_client_params)\n format.html { redirect_to @add_to_invoice_client, notice: 'Add to invoice client was successfully updated.' }\n format.json { render :show, status: :ok, location: @add_to_invoice_client }\n else\n format.html { render :edit }\n format.json { render json: @add_to_invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = clients.find(params[:id])\n\n if @client.update_attributes(params[:client])\n flash[:notice] = 'Client was successfully updated.'\n redirect_to(user_company_clients_url(current_company))\n else\n render :action => \"edit\"\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to(@client, :notice => 'Les informations du client ont été mises à jour.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n if @client_need.update_attributes(params[:client_need])\n format.html { redirect_to @client_need, notice: 'Client need was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_need.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @paperclip_client = PaperclipClient.find(params[:id])\n @client = @paperclip_client\n\n respond_to do |format|\n if @paperclip_client.update_attributes(params[:paperclip_client])\n format.html { redirect_to(@paperclip_client, :notice => 'Paperclip client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render 'clients/edit' }\n format.xml { render :xml => @paperclip_client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_client\n\t\t@client = Client.find(params[:id])\n\tend",
"def update\n if @client.update(client_params)\n redirect_to clients_path\n else\n render :edit\n end\n end",
"def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end",
"def update\n respond_to do |format|\n if @group_client.update(group_client_params)\n format.html { redirect_to @group_client, flash: { success: \"Group client was successfully updated.\" } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client_image.update(client_image_params)\n format.html { redirect_to client_client_images_path(params[:client_id]), notice: 'Client image was successfully updated.' }\n # format.json { render :show, status: :ok, location: @client_image }\n else\n format.html { redirect_to client_client_images_path(params[:client_id]), notice: 'Client image was successfully updated.' }\n format.json { render json: @client_image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client_doc.update(client_doc_params)\n format.html { redirect_to @client_doc, notice: 'Client doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_doc }\n else\n format.html { render :edit }\n format.json { render json: @client_doc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n \n respond_to do |format|\n if @client.update_attributes(params[:client])\n flash[:notice] = 'Client was successfully updated.'\n format.html { redirect_to client_url(@role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors.to_xml }\n end\n end\n end",
"def update\n if @client.update(client_params)\n redirect_to client_path(@client)\n else\n render :edit\n end\n end",
"def update\n\tif signed_in?\n\t\tif params[:client][:encrypted_password_confirmation].blank?\n\t\t\tparams[:client].delete(\"encrypted_password\")\n\t\t\tparams[:client].delete(\"encrypted_password_confirmation\")\n\t\tend\n\t\t@current_client = current_user.username\n\t\tif current_user.username == 'admin'\n\t\t\t@client = Client.find(params[:id])\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\telse\n\t\tredirect_to signin_path\n\tend\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n if @blocking_client.update_attributes(params[:blocking_client])\n format.html { redirect_to @blocking_client, notice: 'Blocking client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blocking_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n\n @client.redirect_urls << client_params[:add_redirect_url] if client_params[:add_redirect_url]\n \n @client.app_ids << BSON::ObjectId.new.to_s if client_params[:add_app_id]\n \n \n @client.versioned_update({\"redirect_urls\" => 1, \"app_ids\" => 1})\n\n if @client.op_success?\n render \"show\"\n else\n render \"edit\"\n end\n \n end",
"def update\n @oauth_client = OauthClient.find(params[:id])\n\n respond_to do |format|\n if @oauth_client.update(oauth_client_params)\n format.html { redirect_to oauth_clients_path, notice: 'OAuth client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oauth_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @company_client.update(company_client_params)\n format.html { redirect_to company_clients_path, notice: 'Клиент успешно отредактирован' }\n format.json { render :show, status: :ok, location: @company_client }\n else\n format.html { render :edit }\n format.json { render json: @company_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @featured_client = FeaturedClient.new(featured_client_params)\n\n respond_to do |format|\n if @featured_client.save\n format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' }\n format.json { render :show, status: :created, location: @featured_client }\n else\n format.html { render :new }\n format.json { render json: @featured_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n @states = State.find(:all,:order=>\"short_name\")\n @genders = Gender.find(:all)\n @email_priorities = EmailPriority.find(:all)\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @authorized_client.update(authorized_client_params)\n format.html {redirect_to @authorized_client, notice: 'Authorized client was successfully updated.'}\n format.json {render :show, status: :ok, location: @authorized_client}\n else\n format.html {render :edit}\n format.json {render json: @authorized_client.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\t\t\n if @client.update_attributes(params[:client])\n redirect_to @client, notice: 'Client was successfully updated!'\n else\n render action: \"edit\"\n end\n end",
"def update\n respond_to do |format|\n if @client_info.update(client_info_params)\n\n format.html { redirect_to @client_info, notice: 'Client info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @client_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n begin\n ActiveRecord::Base.transaction do\n @client.update!(client_params)\n @client.address.update!(address_params)\n end\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n rescue\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id, client)\n @client = Locomotive::Client.get(id)\n raise NotFound unless @client\n if @client.update_attributes(client)\n redirect resource(@client), :message => {:notice => \"Client was successfully updated\"}\n else\n display @client, :edit\n end\n end",
"def update\n\n #se não aguardar carregar os dados\n if client_params[:state] == '...'\n sweetalert_warning('Você precisa informar o CEP e aguardar os dados do endereço serem preenchidos.', 'Aviso!', useRejections: false)\n redirect_to edit_client_path(@client) and return\n end\n\n respond_to do |format|\n\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @client }\n sweetalert_success('Cliente atualizado com sucesso.', 'Sucesso!', useRejections: false)\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to admin_client_path(@client, search: params[:search], page: params[:page]),\n notice: 'клиент сохранен.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:update [ID] [options]\")\n\n if options.empty?\n raise(Heroku::Command::CommandFailed, \"Missing options\")\n end\n\n validate!(options[:url]) if options[:url]\n shell = options.delete(:shell)\n options[:redirect_uri] = options.delete(:url)\n\n client = request do\n api.request(\n :body => encode_json(options),\n :expects => 200,\n :headers => headers,\n :method => :patch,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if shell\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Updated client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end",
"def update\n respond_to do |format|\n if @featured_project.update(featured_project_params)\n format.json { render :show, status: :ok, location: @featured_project }\n else\n format.json { render json: @featured_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find params[:id]\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to client_path(@client), notice: 'Cliente fue Actualizado correctamente.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n flash[:success] = \"Cliente editado exitosamente\" if @client.update_attributes(params[:client])\n respond_with(@client)\n end",
"def update\n @user = User.find(params[:id])\n @client = Client.find(params[:id])\n if @client.update(client_params)\n # Save the item successfully\n redirect_to @client\n else\n render :action => \"edit\"\n end\n\n\n end",
"def update\n\n respond_to do |format|\n if @studio_client.update(studio_client_params)\n format.html { redirect_to edit_admin_studio_client_path(@studio_client), notice: 'Studio client was successfully updated.' }\n format.json { render :show, status: :ok, location: @studio_client }\n else\n Rails.logger.info(@studio_client.errors.inspect)\n format.html { render :edit }\n format.json { render json: @studio_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => \"Client was successfully updated. #{undo_link}\") }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end"
] | [
"0.7180061",
"0.71587324",
"0.67126924",
"0.6706564",
"0.6624684",
"0.66181684",
"0.66181684",
"0.657036",
"0.6560939",
"0.6560939",
"0.6537225",
"0.6521621",
"0.6474115",
"0.64677155",
"0.64466053",
"0.64425135",
"0.64348674",
"0.6433545",
"0.64225364",
"0.64199555",
"0.64164215",
"0.64164215",
"0.6408945",
"0.6405561",
"0.6400949",
"0.6400565",
"0.63983315",
"0.63983315",
"0.63983315",
"0.63983315",
"0.63983315",
"0.6384142",
"0.6374726",
"0.6353587",
"0.6352799",
"0.6352671",
"0.6337543",
"0.6322104",
"0.63215196",
"0.6297072",
"0.6288679",
"0.6277096",
"0.6276793",
"0.62558717",
"0.624599",
"0.62346333",
"0.62276816",
"0.62276816",
"0.62238455",
"0.6205565",
"0.61969304",
"0.6193482",
"0.6184176",
"0.61836636",
"0.6175032",
"0.6173061",
"0.6166312",
"0.61635494",
"0.61569697",
"0.61523604",
"0.613933",
"0.6137669",
"0.6122637",
"0.6111497",
"0.6105961",
"0.6100795",
"0.6092523",
"0.60869956",
"0.6086367",
"0.60802627",
"0.60635626",
"0.60629827",
"0.6059325",
"0.60590875",
"0.6056284",
"0.60562515",
"0.60532206",
"0.6052293",
"0.6051024",
"0.605077",
"0.60486656",
"0.6046169",
"0.6037306",
"0.6002813",
"0.59821206",
"0.5971862",
"0.59692216",
"0.59679735",
"0.59623766",
"0.595977",
"0.5937593",
"0.5929522",
"0.5928354",
"0.59281486",
"0.5927628",
"0.59179974",
"0.59178716",
"0.5904571",
"0.5903702",
"0.59026575"
] | 0.7571402 | 0 |
DELETE /featured_clients/1 DELETE /featured_clients/1.json | def destroy
@featured_client.destroy
respond_to do |format|
format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @client = Client.find(params[:id])\r\n @client.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to clients_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Данные по клиенту удалены.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n authorize! :update, @client\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\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",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client a été supprimer.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_client = ApiClient.find(params[:id])\n @api_client.destroy\n\n respond_to do |format|\n format.html { redirect_to api_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def delete(client_id)\n id = client_id.to_s\n Client.collection.filter(:id => id).delete\n AuthRequest.collection.filter(:client_id => id).delete\n AccessGrant.collection.filter(:client_id => id).delete\n AccessToken.collection.filter(:client_id => id).delete\n end",
"def destroy\n @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n \n if @client.deleted_at.blank?\n @client.destroy\n else\n @client.revive\n end\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n \n respond_to do |format|\n format.html { redirect_to clients_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @clients = get_clients\n @client = Client.new\n\n respond_to do |format|\n #format.html { redirect_to clients_url }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @otg_client.destroy\n respond_to do |format|\n format.html { redirect_to otg_clients_url, notice: 'Otg client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'El Cliente fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @client\n @client.destroy\n respond_to do |format|\n format.html { redirect_back_or_default clients_url, t('Record has been deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: \"Client was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_with(@client)\n end",
"def destroy\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente excluído com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @live_client.destroy\n respond_to do |format|\n format.html { redirect_to live_clients_url, notice: 'Live client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n clients_delete(@entity)\n @entity.destroy\n respond_to do |format|\n format.html { redirect_to clients_path }\n format.json { render json: {success: true} }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\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 @client = Client.find(params[:id])\n @client.destroy\n redirect_to clients_url\n end",
"def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = clients.find(params[:id])\n @client.destroy\n redirect_to(user_company_clients_url(current_company))\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy\n @client.showings.destroy_all\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @authorized_client.destroy\n respond_to do |format|\n format.html {redirect_to authorized_clients_url, notice: 'Authorized client was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @enabled_client.destroy\n respond_to do |format|\n format.html { redirect_to enabled_clients_url, notice: 'Enabled client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @potential_client.destroy\n respond_to do |format|\n format.html { redirect_to potential_clients_url, notice: 'Potential client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientsOffers = ClientsOffers.find(params[:id])\n @clientsOffers.destroy\n\n respond_to do |format|\n format.html { redirect_to clientsOffers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @group_client.destroy\n respond_to do |format|\n format.html { redirect_to group_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice_client.destroy\n respond_to do |format|\n format.html { redirect_to invoice_clients_url, notice: 'Invoice client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to admin_clients_url(search: params[:search], page: params[:page]),\n notice: 'Клиент удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @featured.destroy\n respond_to do |format|\n format.html { redirect_to featureds_url, notice: 'Featured was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @featured.destroy\n respond_to do |format|\n format.html { redirect_to featureds_url, notice: 'Featured was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n logger = Logger.new(STDOUT)\n if @client.dois.present?\n message = \"Can't delete client that has DOIs.\"\n status = 400\n logger.warn message\n render json: { errors: [{ status: status.to_s, title: message }] }.to_json, status: status\n elsif @client.update_attributes(is_active: nil, deleted_at: Time.zone.now)\n @client.send_delete_email unless Rails.env.test?\n head :no_content\n else\n logger.warn @client.errors.inspect\n render json: serialize_errors(@client.errors), status: :unprocessable_entity\n end\n end",
"def destroy\n @blocking_client = BlockingClient.find(params[:id])\n @blocking_client.destroy\n\n respond_to do |format|\n format.html { redirect_to blocking_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = current_user\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_path(@user) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n\tif signed_in?\n\t\tif current_user.username == 'admin'\n\t\t\t@client = Client.find(params[:id])\n\t\t\t@client.destroy\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\telse\n\t\tredirect_to signin_path\n\tend\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, Client\n load_client\n destroy_client\n\n redirect_to clients_url\n end",
"def destroy\n if @client.dois.present?\n message = \"Can't delete client that has DOIs.\"\n status = 400\n Rails.logger.warn message\n render json: {\n errors: [{ status: status.to_s, title: message }],\n }.to_json,\n status: status\n elsif @client.update(is_active: nil, deleted_at: Time.zone.now)\n unless Rails.env.test?\n @client.send_delete_email(responsible_id: current_user.uid)\n end\n head :no_content\n else\n # Rails.logger.error @client.errors.inspect\n render json: serialize_errors(@client.errors, uid: @client.uid),\n status: :unprocessable_entity\n end\n end",
"def destroy\n @add_to_invoice_client.destroy\n respond_to do |format|\n format.html { redirect_to add_to_invoice_clients_url, notice: 'Add to invoice client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(client_id)\n id = BSON::ObjectId(client_id.to_s)\n Client.collection.remove({ :_id=>id })\n AuthRequest.collection.remove({ :client_id=>id })\n AccessGrant.collection.remove({ :client_id=>id })\n AccessToken.collection.remove({ :client_id=>id })\n end",
"def destroy\n @studio_client.destroy\n respond_to do |format|\n format.html { redirect_to studio_clients_url, notice: 'Studio client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @featured_project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_doc.destroy\n respond_to do |format|\n format.html { redirect_to client_docs_url, notice: 'Client doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_client\n\t\t@client = Client.find(params[:id])\n\n\t\tif @client.destroy\n\t\t\tredirect_to \"/details\"\n\t\telse\n\t\t\treder :action => \"delete_client\"\n\t\tend\n\tend",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente foi excluido.' }\n format.json { head :no_content }\n sweetalert_success('Cliente excluido com sucesso.', 'Sucesso!', useRejections: false)\n end\n end",
"def destroy\n @oauth_client = OauthClient.find(params[:id])\n @oauth_client.destroy\n\n respond_to do |format|\n format.html { redirect_to oauth_clients_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @company_client.destroy\n respond_to do |format|\n format.html { redirect_to company_clients_url, notice: 'Клиент был успешно удален' }\n format.json { head :no_content }\n end\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def destroy\n @client.destroy\n redirect_to index_clients_path, notice: 'Client was successfully destroyed.'\n end",
"def destroy\n @client = Client.find(params[:id])\n\n project_id = @client.project_id\n\n # Destroy all the client's posts\n clients_posts = Post.where(:user_id => @client.id)\n clients_posts.each do |post|\n post.destroy\n end\n\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to project_url(:id => project_id, :page => 'options') }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n else\n redirect_to new_admin_session_path and return\n end \n end",
"def destroy\n orden@client.destroy\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @client.destroy\n redirect_to clients_url, notice: 'Client was successfully destroyed.'\n end",
"def destroy\n @client_asset = ClientAsset.find(params[:id])\n client_name = @client_asset.client_name\n @client_asset.deleted = true\n @client_asset.deleted_at = Time.now\n @client_asset.save\n #@client_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to client_assets_url, notice: \"#{client_name}'s asset was successfully deleted.\" }\n format.json { head :no_content }\n end\n end"
] | [
"0.75142395",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.744217",
"0.7420447",
"0.7420447",
"0.7416775",
"0.7321803",
"0.73160225",
"0.7283156",
"0.7262876",
"0.7257515",
"0.7226291",
"0.72083664",
"0.71967685",
"0.71831965",
"0.7175605",
"0.7167847",
"0.71629816",
"0.7150093",
"0.7143115",
"0.7134274",
"0.71249956",
"0.71247274",
"0.71247274",
"0.71247274",
"0.71247274",
"0.71247274",
"0.71247274",
"0.71247274",
"0.71234924",
"0.71225286",
"0.71208483",
"0.71191794",
"0.7118287",
"0.7117935",
"0.7114903",
"0.71142215",
"0.7110708",
"0.71053684",
"0.7099733",
"0.7096317",
"0.70849425",
"0.7076693",
"0.7072842",
"0.70724493",
"0.70724493",
"0.7018764",
"0.701638",
"0.70112014",
"0.6992112",
"0.6981462",
"0.6961145",
"0.693069",
"0.69164926",
"0.69145155",
"0.6913777",
"0.6913546",
"0.6881151",
"0.68717265",
"0.6867393",
"0.6867393",
"0.68630934",
"0.68447065",
"0.6842471",
"0.6833656",
"0.6827805",
"0.6824057",
"0.6819667",
"0.68190676",
"0.68170345",
"0.6802556",
"0.6798522",
"0.67829883",
"0.6779878",
"0.6779878",
"0.6779878",
"0.67797107",
"0.6776339",
"0.6770127",
"0.67644393",
"0.67600423",
"0.67574674",
"0.67539763",
"0.67539763",
"0.674283",
"0.6739325",
"0.6733673",
"0.67214197",
"0.6718136",
"0.6718",
"0.67123437",
"0.67115945"
] | 0.79933196 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_featured_client
@featured_client = FeaturedClient.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def call\n setup_context\n super\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.5330087",
"0.5311993",
"0.5297402",
"0.5296789",
"0.52957207",
"0.52596015",
"0.5245442",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5235431",
"0.5231888",
"0.5226663",
"0.52220625",
"0.5217086",
"0.52137345",
"0.5208314",
"0.5205469",
"0.5175606",
"0.5174914",
"0.5173361",
"0.51662856",
"0.5161792",
"0.51572216",
"0.5153063",
"0.5152982",
"0.5152632",
"0.51435786",
"0.5139829",
"0.51346594",
"0.511372",
"0.511372",
"0.51136476",
"0.51083213",
"0.5108011",
"0.5091935",
"0.5089297",
"0.5081576",
"0.50807106",
"0.50656676",
"0.50548106",
"0.50537366",
"0.505074",
"0.505074",
"0.5033361",
"0.5025158",
"0.5020441",
"0.5015611",
"0.50142473",
"0.5000281",
"0.50001067",
"0.49989453",
"0.4989465",
"0.4989465",
"0.4985425",
"0.49805096",
"0.49795893",
"0.49783278",
"0.49676263",
"0.49656346",
"0.49579078",
"0.4955427",
"0.49554235",
"0.49536413",
"0.49523768",
"0.49457142",
"0.49433607",
"0.4933641",
"0.49320185",
"0.49265638",
"0.49262375",
"0.49259067",
"0.4922456",
"0.49201223",
"0.49165115",
"0.49158815",
"0.49151883",
"0.49149552",
"0.4914386"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def featured_client_params
params.require(:featured_client).permit(:image, :website_name, :testimonial)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289145",
"0.62875307",
"0.6280997",
"0.62420976",
"0.62388235",
"0.6216686",
"0.62122375",
"0.6208949",
"0.619173",
"0.6176307",
"0.6173907",
"0.6170346",
"0.616111",
"0.6150513",
"0.6150023",
"0.61446756",
"0.6120429",
"0.6112975",
"0.6104845",
"0.6102966",
"0.6087884",
"0.6079323",
"0.60699135",
"0.60602236",
"0.60191786",
"0.60170597",
"0.60100305",
"0.6009527",
"0.60052776",
"0.60052776",
"0.600042",
"0.5999317",
"0.59933805",
"0.5991528",
"0.5991221",
"0.5990094",
"0.5979497",
"0.5966058",
"0.5958738",
"0.59579456",
"0.5957759",
"0.5956938",
"0.5951788",
"0.59511644",
"0.59423065",
"0.59373474",
"0.59361076",
"0.59361076",
"0.59331447",
"0.5928005",
"0.5924882",
"0.5924011",
"0.59169155",
"0.5908037",
"0.5907541",
"0.59061426",
"0.59056246",
"0.5897408",
"0.58960444",
"0.58951247",
"0.5893136",
"0.5892312",
"0.5890385",
"0.58853275",
"0.58801144",
"0.58784765",
"0.5872648",
"0.58682626",
"0.5867028",
"0.58661693",
"0.586578",
"0.58643955",
"0.5863193",
"0.58609086",
"0.5859997",
"0.5858935",
"0.5858632",
"0.5853379",
"0.5852741",
"0.584806",
"0.5847703"
] | 0.0 | -1 |
Convert value to bit array to_multi_bit( '0b101010', 6 ) => [1,0,1,0,1,0] to_multi_bit( '0b101010', 10 ) => [1,0,1,0,1,0,0,0,0,0] to_multi_bit( '0b101010', 3 ) => [1,0,1] to_multi_bit( '0b01010' ) => [1,0,1,0] minimum array size for val to_multi_bit( '' ) => [0] null string is equivalent to 0 | def to_multi_bit( val, array_size=-1 )
array_size = Integer(array_size) unless array_size.kind_of?(Integer)
if val == '' then
val = '0'
end
begin
val = Integer(val).to_s(2)
rescue => e
raise ParameterError, "#{__method__} contains invalid string for number"
end
arr = val.scan(/./).map{ |b| b.to_i(2) }
return arr if array_size < 0
return _fit_array_length( arr, array_size )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bit_array\n BitMapping.number_to_bit_array(number)\n end",
"def input_to_bitstring( value )\r\n value\r\n end",
"def number_to_bit_array(number, minimum_binary_places = 0)\n assert_non_negative(number)\n array = []\n while number > 0\n array << (number & 1)\n number >>= 1\n end\n array.reverse!\n zero_pad_count = minimum_binary_places - array.size\n zero_pad_count.times { array.unshift(0) }\n array\n end",
"def set_bits\n bits = []\n 0.upto(63) {|i| bits << i if set?(i)}\n bits\n end",
"def boolean_to_binary(array)\nend",
"def from_bits(bin_num)\n base10_value = 0\n @bit_vals.each_with_index do |val,i|\n base10_value += val if bin_num[i] == '1'\n end\n base10_value\n end",
"def bitarray(n) \n b=Array::new \n i=0 \n v=n\n while v > 0\n b[i] = (0x1 & v)\n v = v/2\n i = i + 1\n end\n return b\n end",
"def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend",
"def bits\n\t\t# Get a safe copy of the @bits array\n\t\tbts = @bits.clone\n\t\t##\n\t\t# If carrying and not [HACK catch the pattern tha breaks it by adding an extrax 1]\n\t\t##\n\t\tif @carrying && @bits[0,4] != [1, 0, 0, 0]\n\t\t\tbts\t\t= [1].concat @bits\n\t\tend\n\t\t# Return to the caller\n\t\tbts\n\tend",
"def translate_to_binary(array_of_hex)\n array_of_binary = []\n array_of_hex.each do |num|\n array_of_binary << sprintf(\"%b\", num).rjust(32, '0')\n end\n array_of_binary\n end",
"def to_bits(base10_num)\n bits = @bit_vals.map do |b|\n if base10_num >= b\n base10_num -= b\n '1'\n else\n '0'\n end\n end\n bits.join\n end",
"def binary_string_to_bit_array(string, minimum_binary_places = 0)\n number = binary_string_to_number(string)\n number_to_bit_array(number, minimum_binary_places)\n end",
"def to_set_bit_position_array\n BitMapping.number_to_set_bit_positions_array(number)\n end",
"def old_boolean_to_binary(arr)\n binary = \"\"\n\n arr.each do |boolean|\n if boolean\n binary += \"1\"\n else\n binary += \"0\"\n end\n end\n\n binary\nend",
"def encode integer_array\n integer_array = integer_array.clone\n bits = BitArray.new\n integer_array.each do |x|\n q = x/@M\n q.times {bits.push 1}\n bits.push 0\n r = x % @M\n (@b-1).downto(0){|i| bits.push r[i]}\n end\n bits\n end",
"def Bitwise(arr)\n output_num = ''\n arr[0].split(//).each_with_index {|char,idx| char == arr[1][idx] ? output_num << '0' : output_num << '1'}\n output_num.to_i\nend",
"def to_bin(number)\n number = Integer(number);\n if(number == 0)\n return 0;\n end\n ret_bin = \"\";\n ## Untill val is zero, convert it into binary format\n while(number != 0)\n ret_bin = String(number % 2) + ret_bin;\n number = number / 2;\n end\n return ret_bin;\n end",
"def encode_bits(bits)\n [bits.map { |b| b ? '1' : '0' }.join].pack('b*')\n end",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def boolean_to_binary(arr)\r\n\r\n binary = \"\"\r\n\r\n # iteration each method\r\n arr.each {|bool|\r\n if bool == true\r\n\r\n # bool true to binary 1\r\n binary << \"1\"\r\n else\r\n\r\n # bool false to binary 0\r\n binary << \"0\"\r\n end }\r\n\r\n binary\r\nend",
"def ALU1BIT(a,b,cin,binv,op1,op2) \n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\t#Send out an array pair of result, cout\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1]\nend",
"def shift_bits(buffer)\n buffer.slice!(0...1).unpack('b8').first.split('').map {|b| b == '1'}\n end",
"def bits(number)\n bits = []\n\n while number != 0\n bits << number % 2\n number = number / 2\n end\n\n bits.reverse.join\nend",
"def n_to_binary number\n bin_array = []\n until number == 0\n if number % 2 == 0\n bin_array << 0\n else \n bin_array << 1\n end\n number = number / 2\n end\n bin_array.join\nend",
"def bits()\n return(NetAddr.mask_to_bits(@netmask))\n end",
"def read_bit_array(num_bits)\n size = (num_bits + 7) / 8\n data = read_and_advance(size)\n bit_array = BinData::Array.new(type: :bit1, initial_length: size * 8)\n bit_array.read(data).to_ary\n end",
"def number_to_set_bit_positions_array(number)\n assert_non_negative(number)\n array = []\n position = 0\n while number > 0\n array << position if number & 1 == 1\n position += 1\n number >>= 1\n end\n array\n end",
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def setup\n @a = '0b100010011010101111001101'\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 shift_bits(buffer)\n buffer.slice!(0...1).unpack('b8').first.split('').map { |b| b == '1' }\n end",
"def binary_to_int(n)\n bitset = Array.new()\n while (n > 0) do\n x = largest_power_of_2(n)\n if (x != nil)\n bitset[x] = 1\n n -= BASE ** x\n end\n end\n bitset.map! { |x| \n if (x == nil) \n x = 0\n else\n x = 1\n end\n }\n return bitset\nend",
"def to_b(value)\n [0,false,nil].include?(value) ? false : true\n end",
"def b(value)\n (value & 0x0000ff00) >> 8\n end",
"def b(value)\n (value & 0x0000ff00) >> 8\n end",
"def _to_bit_string(i, min_width=0)\n hexed = i.to_s(16)\n padded = true if hexed.length % 2 == 1 # prepend 0\n bitstring = [(padded ? \"0#{hexed}\" : hexed)].pack(\"H*\").unpack(\"B*\").first\n bitstring = bitstring[4,bitstring.length - 4] if padded\n (\"0\" * [min_width - bitstring.length, 0].max) + bitstring\n end",
"def binary(digits)\n string(BINARY_DIGITS, digits)\n end",
"def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end",
"def convert_bits(data, from, to, padding=true)\n acc = 0\n bits = 0\n ret = []\n maxv = (1 << to) - 1\n max_acc = (1 << (from + to - 1)) - 1\n data.each do |v|\n return nil if v < 0 || (v >> from) != 0\n acc = ((acc << from) | v) & max_acc\n bits += from\n while bits >= to\n bits -= to\n ret << ((acc >> bits) & maxv)\n end\n end\n if padding\n ret << ((acc << (to - bits)) & maxv) unless bits == 0\n elsif bits >= from || ((acc << (to - bits)) & maxv) != 0\n return nil\n end\n ret\n end",
"def show_binstring()\n @values.values.map do |v|\n v ? \"1\" : \"0\"\n end.join\n end",
"def to_bin(num_string)\n digits = convert_to_base10(num_string)\n digits.map!{|char| to_bits(char)}\n digits.join\n end",
"def to_i\n bitmask\n end",
"def int_to_binary(value)\n nbytes = 0\n nbytes = 1 if value > 0xFF # 1 byte integer\n nbytes += 1 if value > 0xFFFF # 4 byte integer\n nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer\n nbytes = 3 if value < 0 # 8 byte integer, since signed\n\n bdata = Binary.type_bytes(\"1\", nbytes) # 1 is 0001, type indicator for integer\n buff = \"\"\n\n if(nbytes < 3) then\n fmt = \"N\"\n\n if(nbytes == 0) then\n fmt = \"C\"\n elsif(nbytes == 1)\n fmt = \"n\"\n end\n\n buff = [value].pack(fmt)\n else\n # 64 bit signed integer; we need the higher and the lower 32 bit of the value\n high_word = value >> 32\n low_word = value & 0xFFFFFFFF\n buff = [high_word,low_word].pack(\"NN\")\n end\n\n return bdata + buff\n end",
"def bits_to_numbers(bits)\n (0..8).select { |n| (bits & (1 << n)) != 0 }\n end",
"def split_bitstring(bitstring) \n arr = []\n mini = 0\n max = mini + 4 \n maxi = (bitstring.length) - 1\n while max <= maxi\n arr << bitstring[mini .. max]\n mini += 5\n max = mini + 4 \n end\n return arr\n end",
"def binary_multiple_of_4? s\n s =~ /^([01]*0)?0$/\nend",
"def stringy(num)\n binary = ''\n loop do\n binary << '1'\n break if binary.length == num\n binary << '0'\n break if binary.length == num\n end\n binary\nend",
"def to_binary_string(min_length = 0)\n BitMapping.number_to_binary_string(number, min_length)\n end",
"def to_bitwise_values(object, name)\n mapping = mapping_from_name(name)\n if object.is_a?(Array)\n object.map { |v| force_to_bitwise_value(v, mapping) }\n elsif object.is_a?(Hash)\n object.values.map { |v| force_to_bitwise_value(v, mapping) }\n else\n force_to_bitwise_value(object, mapping)\n end\n end",
"def binary_value\n\t\treturn self.value.unpack( 'm' ).first\n\tend",
"def to_a(bits_per_element)\n out_array = Array.new\n for ptr in 0.step(@fuse_data.length, bits_per_element) do\n out_element = 0\n @fuse_data[ptr..ptr+bits_per_element-1].each { |bit|\n out_element = out_element << 1\n out_element |= 1 if bit == 1\n }\n out_array.push out_element\n end\n out_array\n end",
"def masked_value_v1(value)\n # Int masks for one and zero chars\n ones_mask = @mask.chars.map { |c| c == \"1\" ? \"1\" : \"0\" }.join.to_i(2)\n zeros_mask = @mask.chars.map { |c| c == \"0\" ? \"1\" : \"0\" }.join.to_i(2)\n\n result = (ones_mask | value) & ~zeros_mask\n\n if DEBUG\n puts \" Mask: #{@mask}\" \n puts \" Ones Mask: #{padded_binary_string(ones_mask)}\" \n puts \" Zeros Mask: #{padded_binary_string(zeros_mask)}\" \n puts \"Initial value: #{padded_binary_string(value)} (decimal #{value})\"\n puts \" Masked value: #{padded_binary_string(result)} (decimal #{result})\"\n end\n\n result\n end",
"def toBinary(n)\n\ttop = Math.log2(n).to_int\n\tlist = []\n\twhile top >= 0\n\t\tn >= 2 ** top ? (list << 1 and n -= 2 ** top) : (list << 0)\n\t\ttop -= 1\n\tend\n\tlist.join\nend",
"def binary(digits: 4)\n bin = ''\n digits.times { bin += rand(2).to_s(2) }\n bin\n end",
"def to_i\n\t\tbits.map(&:to_s).join.to_i(2)\n\tend",
"def ALU1BIT_OF (a,b,cin,binv,op1,op2)\n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\tputs sUM_RESULT[0]\n\tovf = OF_CHECKING(a,b,sUM_RESULT[0])\n\t#Send out an array triple of result, cout, overflow\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1], ovf\nend",
"def value_to_binary_string(value)\n #value.pack(\"V\")\n raise NotImplementedError\n end",
"def to_binary(num)\n num_bin = ''\n current_power_of_2 = 1\n \n loop do\n num_bin.prepend ((num % (current_power_of_2 * 2)) / current_power_of_2).to_s\n \n break if num < current_power_of_2 * 2\n current_power_of_2 *= 2\n end\n \n num_bin.to_i\n end",
"def decimal_to_binary(num)\n binary_array = []\n until num == 0\n # prepend will add the new value to the front, instead of the end\n binary_array.prepend(num % 2)\n num /= 2\n end\n return binary_array\nend",
"def get_value\r\n @bitstring\r\n end",
"def test_010_lsb()\n TestVals.each do |sVal|\n iVal = sVal.to_i(2)\n bs = BitString.new(sVal)\n assert_equal(sVal[-1,1].to_i(2),\n bs.lsb,\n \"Test lsb(#{sVal}) => #{sVal[-1,1].to_i(2)}\")\n end\n end",
"def BitwiseTwo(strArr)\n result = strArr[0].to_i(2) & strArr[1].to_i(2)\n format(\"%0#{strArr[0].size}b\", result)\nend",
"def array_to_binary(val)\n saved_object_count = @written_object_count\n @written_object_count += 1\n\n bdata = Binary.type_bytes(\"a\", val.value.size) # a is 1010, type indicator for arrays\n\n val.value.each do |v|\n bdata += Binary.pack_it_with_size(@object_ref_size, v.to_binary(self));\n end\n\n @object_table[saved_object_count] = bdata\n return saved_object_count\n end",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def mask_to_bits(nm)\n\t\tmask = 32\n\t\tmask.times do\n if ( (nm & 1) == 1)\n break\n end\n\t\t\tnm = nm >> 1\n\t\t\tmask = mask - 1\n\t\tend\n\t\treturn(mask)\n\tend",
"def to_binary()\n return self.unpack('B*').join\n end",
"def bits_set\n (\"%b\" % self).count('1')\n #to_s(2).count('1') # alternative\n #count = 0 # alternative\n #byte = self.abs\n #count += byte & 1 and byte >>= 1 until byte == 0 # cf. http://snippets.dzone.com/posts/show/4233\n #count\n end",
"def to_i\n bitmask\n end",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def binary(num)\n result = []\n\n until num == 0\n result.unshift(num % 2)\n num /= 2\n end\n\n result.empty? ? \"0\" : result.join\nend",
"def handle_bit (num)\n num2str=''\n num2str+=NUM_MAP[num]\n return num2str\nend",
"def test_decode_bit_binary()\n input = [131, 77, 0, 0, 0, 4, 4, 195, 139, 30, 64]\n expected = Erlang::BitBinary.new(4, \"\\303\\213\\036@\")\n\n stream = Erlang::StreamEmulator.new(input)\n actual = Erlang::decode(stream)\n\n assert_equal(expected, actual)\n end",
"def pushBit bit1, bit2\n\t\t# Round inputs to 0/1 just in case\n\t\tbit1, bit2 = bit1.round.to_i, bit2.round.to_i\n\t\t##\n\t\t# Bit selection : [0, 0] = 0, [1, 0] or [0, 1] = [0, 1], [1, 1] = carry the 1\n\t\t##\n\t\t# when [1, 1]\n\t\tif bit1 == 1 && bit2 == 1\n\t\t\tif @carrying\n\t\t\t\t@bits\t= [1].concat @bits\n\t\t\telse\n\t\t\t\t@carrying \t= true\n\t\t\t\t@bits\t\t= [0].concat @bits\n\t\t\tend\n\t\t# when [0, 1] or [1, 0]\n\t\telsif bit1 == 1 || bit2 == 1\n\t\t\tif @carrying\n\t\t\t\t@bits\t= [0].concat @bits\n\t\t\telse\n\t\t\t\t@bits\t= [1].concat @bits\n\t\t\tend\n\t\t# when [0, 0]\n\t\telse\n\t\t\tif @carrying\n\t\t\t\t@bits\t= [1].concat @bits\n\t\t\t\t@carrying = false\n\t\t\telse\n\t\t\t\t@bits\t\t= [0].concat @bits\n\t\t\tend\n\t\tend\n\tend",
"def binary(array)\n @reactor.schedule { @driver.binary(array.to_a) }\n end",
"def binary_multiple_of_4?(str)\n str =~ /^[01]*1[01]*00$/\nend",
"def bit\n self\n end",
"def test_002_from_i()\n TestVals.each do |sVal|\n iVal = sVal.to_i(2)\n bs = BitString.new(0)\n bs.from_i(iVal)\n assert_equal(iVal,\n bs.to_i,\n \"Test BitString.from_i(#{sVal}) => #{iVal}\")\n end\n end",
"def string_to_binary(value)\n self.class.string_to_binary(value)\n end",
"def binary(integer)\n\nend",
"def binary(integer)\n\nend",
"def BitwiseOne(strArr)\n result = \"\"\n first = strArr[0]\n second = strArr[1]\n idx = 0\n\n while idx < strArr[0].length\n if first[idx] == \"0\" && second[idx] == \"0\"\n result << \"0\"\n else\n result << \"1\"\n end\n idx += 1\n end\n\n result\nend",
"def check_power(n)\n if n <= 1\n return [n, 1]\n end\n x = n\n b = 1\n c = 2\n while true\n found = false\n while c <= 8 * x.size\n res = NumberUtil::is_bth_power(x, c)\n if res\n x = res\n b *= c\n found = true\n break\n end\n if c >= 3\n c += 2\n else\n c += 1\n end\n end\n if found\n next\n else\n break\n end\n end\n return [x, b]\n end",
"def binary_multiple_of_4? s\n return false if s == \"\"#error if i didn't check for \"\"\n for i in 0..s.size-1 #cycle and check if it's binary\n return false unless s[i] == \"0\" || s[i] == \"1\"#1s and 0s only\n end\n s.to_i(2) % 4 == 0\nend",
"def dec2bin(n)\n case n\n when 0 then '0000'\n when 1 then '0001'\n when 2 then '0010'\n when 3 then '0011'\n when 4 then '0100'\n when 5 then '0101'\n when 6 then '0110'\n when 7 then '0111'\n when 8 then '1000'\n when 9 then '1001'\n when 10 then '1010'\n when 11 then '1011'\n when 12 then '1100'\n when 13 then '1101'\n else nil\n end\n end",
"def count_bits(n)\n n.to_s(2).count(\"1\")\nend",
"def set_value(new_val)\r\n @bitstring=self.input_to_bitstring(new_val)\r\n end",
"def serialize_value(value)\n [value.to_i].pack('N')\n end",
"def binary_array_to_number(arr)\n arr.join(\"\").to_i(2)\nend",
"def binary_array_to_number(arr)\n arr.join(\"\").to_i(2)\nend",
"def bit(y)\n bit?(y) ? ONE : ZERO\n end",
"def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend",
"def uint_once(min, max, default = nil)\n [default, (min..max), false,\n ->(a) { CoAP.vlb_decode(a[0]) },\n ->(v) { v == default ? [] : [CoAP.vlb_encode(v)] }\n ]\n end",
"def decimal_to_binary(decimal)\n binary_array = []\n num = decimal\n until num == 0\n binary_array.unshift(num % 2)\n num /= 2\n end\n return binary_array\nend",
"def count_bits(n)\r\n n.to_s(2).count \"1\"\r\nend",
"def count_bits(n)\n n.to_s(2).count \"1\"\nend",
"def bin(x)\n x.to_s(16).chars.to_a.map{|d| d.to_i(16).to_s(2).rjust(4, '0')}.join(' ')\nend",
"def bits\n self.class.bits.select { |bit, _| include? bit }.keys\n end",
"def count_bits(n)\n n.to_s(2).count('1')\nend",
"def count_bits(n)\n n.to_s(2).count('1')\nend",
"def encode_uint8(value)\n [value].pack(\"C\")\n end"
] | [
"0.71019197",
"0.64645636",
"0.6271918",
"0.6154316",
"0.6136181",
"0.61169845",
"0.60882556",
"0.6005125",
"0.59984744",
"0.5980631",
"0.59593886",
"0.5871188",
"0.58386976",
"0.5829",
"0.58206475",
"0.5820063",
"0.5797414",
"0.5794982",
"0.57928",
"0.56683254",
"0.56529534",
"0.56454474",
"0.5636628",
"0.56294316",
"0.55915666",
"0.5589879",
"0.5566919",
"0.55524087",
"0.5536534",
"0.55266786",
"0.55197275",
"0.55113155",
"0.550457",
"0.5503721",
"0.5503721",
"0.55029476",
"0.54493725",
"0.54461205",
"0.5440344",
"0.5439725",
"0.54006255",
"0.54004276",
"0.5378164",
"0.5377556",
"0.5366477",
"0.5365165",
"0.5364669",
"0.53471076",
"0.53404677",
"0.53402865",
"0.53039354",
"0.5292577",
"0.528578",
"0.526785",
"0.5254739",
"0.52527434",
"0.52509415",
"0.52307445",
"0.5227586",
"0.52271",
"0.52175105",
"0.52086097",
"0.5201127",
"0.52007616",
"0.52007616",
"0.5169294",
"0.5168512",
"0.51680696",
"0.51631665",
"0.5158288",
"0.5151631",
"0.5144827",
"0.514292",
"0.5140177",
"0.51395446",
"0.51280814",
"0.51276946",
"0.51242226",
"0.51232815",
"0.51232815",
"0.5113873",
"0.51036763",
"0.51030314",
"0.509882",
"0.50982106",
"0.509577",
"0.5092172",
"0.5091847",
"0.5091847",
"0.50834066",
"0.50818515",
"0.50813305",
"0.5080724",
"0.50729436",
"0.5070565",
"0.506986",
"0.50619125",
"0.50589937",
"0.50589937",
"0.50582725"
] | 0.7963539 | 0 |
class_exsits?("String") => ture class_exists?("djfakf20dak") => false | def class_exists?(classname)
str = classname.to_s
eval("defined?(#{str}) && #{str}.is_a?(Class)") == true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_exists? string\n\tc = Object.const_get string\n\treturn c.is_a? Class\nrescue NameError\n\treturn false\nend",
"def class_exists?(class_name)\n begin\n class_name.constantize\n true\n rescue NameError => ne\n false\n end\n end",
"def class_exists?(class_name)\n klass = Module.const_get(class_name)\n return klass.is_a?(Class)\nrescue NameError\n return false\nend",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def has_class?(sym)\n `var str=' '+this.__native__.className+' ',match=' '+sym.__value__+' '`\n `str.indexOf(match) > -1`\n end",
"def classible?\n %w[a b c d e].any? { |s| __send__(:\"class_#{s}?\") }\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n klass = Object.const_get(class_name)\n return klass.is_a?(Class)\n rescue NameError\n return false\n end",
"def has_class?(name)\n @class_syms ||= classes.map(&:to_sym)\n @class_syms.include?(name.to_sym)\n end",
"def has_class?(c)\n find_all do |q|\n n=q.get_attribute(\"class\").split(\" \")\n n.index(c.to_s)\n end\n end",
"def custom_class_present?(cls)\n custom_class.to_s.split.include?(cls)\n end",
"def class_variable_defined?(arg0)\n end",
"def class_variable_defined?(sym) end",
"def select_by_class_exists(class_name)\n return select_by_class(class_name).exist?\nend",
"def class_exist?(type, klass)\n !!(plugins_map(type) || {})[string2class(klass)]\n end",
"def matches?(klass); end",
"def isa? classname\n\t\t\tinit_classlist\n\t\t\t@cf.classlist.isa? classname\n\t\tend",
"def findExactClassMatch(name)\n fname = name.tr(':', '_')\n return ClassIndex.classExists?(fname)\n end",
"def can_get_class?(klass); true; end",
"def has_any? klass\n not find_all(\"class\", klass).empty?\n end",
"def system_class?(arg)\n return true ? arg == system_class : false\nend",
"def is_strclass?(); @type == GRT_STRCLASS; end",
"def string_class_name?(class_pair)\n class_pair.children[1].str_type?\n end",
"def div_by_class_exists(class_name)\n return div_by_class(class_name).exist?\nend",
"def has_classes?(klasses)\n klasses1 = klasses.kind_of?(Array) ? klasses : klasses.split\n klasses2 = classes.split\n for k in klasses1 do\n if not klasses2.find_index(k)\n return false\n end\n end\n return true\n end",
"def class_line?(line)\n line.include?('class') && !line.include?('func') && !line.include?('//') && !line.include?('protocol') && !line.include?('\"')\n end",
"def isClass _args\n \"isClass _args;\" \n end",
"def has_class?(class_names)\n class_names.strip.downcase.split(' ').compact.any? { |other_class|\n get_classes.any? { |e| e == other_class }\n }\n end",
"def has_class?(klass)\n return has_classes? [klass]\n end",
"def check_for_classes(catalog_response, config)\n expected = config[\"classes\"]\n actual = catalog_response[\"classes\"]\n all_found = expected.all? { |klass| actual.include?(klass) }\n abort \"Node '#{config['certname']}' missing classes.\\nExpected: #{expected}\\nActual: #{actual}\" unless all_found\nend",
"def test_class_exists\n refute_nil Calc::Q\n end",
"def class?(element_id, klass)\n find(element_id)[:class].split(' ').any? { |e| e == klass }\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 safe_class?\n true\n end",
"def exists\n self.class.exists(@name)\n end",
"def isa?(o_, class_) # -\t\t-\t-\t-\t-\t-\t-\t-\t-\t-\t- UNUSED, PREV USED HERE\n\t\tApplicationHelper.isa?(o_, class_)\n\tend",
"def has_klass?()\n return true unless self[:klass_id].empty?\n end",
"def autoload?(arg0)\n end",
"def class?\n @type == :class\n end",
"def class?\n @type == :class\n end",
"def class_name_match?(class_name, superclass_name, class_options)\n class_options.include?(class_name.to_s) || class_options.include?(superclass_name.to_s)\n end",
"def in_class_at?(start_time, end_time = nil)\n classes = in_what_class_at?(start_time, end_time)\n return false unless classes\n !classes.empty?\n end",
"def define_classes klasses\n klasses.each do |klassname|\n klass = klassname.gsub(/\\b('?[a-z])/) { $1.capitalize } #make uppercase\n #could check to see if not already define but at the minute not important\n #if (eval \"defined? #{klass}\") != \"constant\"\n eval \"class #{klass} < DynAttrClass \\n end\"\n #end\n end\nend",
"def type_registered?(klass_or_type)\n end",
"def defined?(name)\n catch (:exit) do\n\n case name\n when /^#{CN_PATTERN}$/o\n return \"ClassModule\" if findExactClassMatch(name)\n \n when /^(#{CN_PATTERN})(\\.|\\#|::)(.+)/o #/\n cname, type, mname = $1, $2, $3\n\n return nil unless findExactClassMatch(cname)\n \n cl = findClass(cname)\n\n if ClassModule === cl\n return \"Method\" if cl.findExactMethod(mname, type == \"::\")\n end\n end\n end\n \n nil\n end",
"def invalid_class_name?(model_class)\n model_class.name.constantize\n false\n rescue NameError\n true\n end",
"def ensure_class_exist(class_name)\n # Ensure Process class exists ---------------\n Object.const_get(class_name)\n rescue => e\n raise Lorj::PrcError.new, format('Lorj::Core: Unable to find class'\\\n \" '%s'\\n%s\", class_name, e.message)\n end",
"def match(klass); end",
"def balance_class?(string)\n unmatch = 0\n tester = [['[',']'],['{','}'],['(',')']]\n quotes = []\n string.each_char.with_index do |char, index|\n if char == \"'\" || char == \"\\\"\"\n unmatch += test_quote(char, quotes)\n elsif tester.each do |x,y|\n char == x ? unmatch += 1 : char == y ? unmatch -= 1 : nil\n end\n end\n break if unmatch < 0\n end\n unmatch\nend",
"def class_accepted? (fexp, include_classes, exclude_classes)\n\n return false if include_classes and (not include_classes.find do |klazz|\n fexp.is_a?(klazz)\n end)\n return false if exclude_classes and exclude_classes.find do |klazz|\n fexp.is_a?(klazz)\n end\n\n true\n end",
"def has_class(cls)\n `#{@el}.classList.contains(#{cls})`\n end",
"def string_to_class string\n chain = string.split \"::\"\n i=0\n res = chain.inject(Module) do |ans,obj|\n break if ans.nil?\n i+=1\n klass = ans.const_get(obj)\n # Make sure the current obj is a valid class\n # Or it's a module but not the last element,\n # as the last element should be a class\n klass.is_a?(Class) || (klass.is_a?(Module) and i != chain.length) ? klass : nil\n end\nrescue NameError\n nil\nend",
"def check_class_name\n\t\tspecial = \"!?<>',?[]}{=-)(*&|^%$#`~{}/\\\\:;\"\n\t\tregex = /[#{special.gsub(/./){|char| \"\\\\#{char}\"}}]/\n\t\tif class_name =~ regex\n\t\t\treturn \"The file name cannot contain special characters\"\n\t\telsif class_name.include?(\"\\n\")\n\t\t\treturn \"The file name cannot contain line breaks\"\n\t\telsif class_name.include?(\" \") || class_name.include?(\"\\t\")\n\t\t\treturn \"The file name cannot contain white spaces\"\n\t\telsif class_name == \"\"\n\t\t\treturn \"The file name cannot be empty\"\n\t\telse\n\t\t\treturn \"\"\n\t\tend\n\tend",
"def class_check(klass)\n # Cache Symbol for operand so I'm not converting it every time.\n name = (@operand_sym ||= @operand.to_sym)\n\n while klass\n case @operator\n when :equal\n return true if self.class.extract_class_name(klass) == name\n when :not_equal\n return true unless self.class.extract_class_name(klass) == name\n when :trueish # Necessarily true for classes.\n true\n else # Otherwise no test passes.\n false\n end\n klass = klass.superclass\n end\n false\n end",
"def ensure_klass_exists!\n klass\n end",
"def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end",
"def has_class?(name)\n a = []\n \n each do |e|\n if e.get(\"className\").split(\" \").index(name)\n a << e\n end\n end\n \n JS::Collection.new(a)\n end",
"def injectable_class(klazz)\n # Handle case when we get a PType instead of a class\n if klazz.is_a?(Types::PRubyType)\n klazz = Puppet::Pops::Types::ClassLoader.provide(klazz)\n end\n\n # data types can not be injected (check again, it is not safe to assume that given RubyType klazz arg was ok)\n return false unless type(klazz).is_a?(Types::PRubyType)\n if (klazz.respond_to?(:inject) && klazz.method(:inject).arity() == -4) || klazz.instance_method(:initialize).arity() == 0\n klazz\n else\n nil\n end\n end",
"def param_classname_present?(string)\n key = string.underscore.to_sym\n @config_params.key?(key)\n end",
"def BaseClass name\n name == \"string\" ? String : Object\nend",
"def is_supported_class?\n return false unless properties\n return false unless properties['player_class']\n unless CLASSES.include? properties['player_class'].downcase\n errors.add :character, \"class '#{properties['player_class']}' is not supported by Shadowcraft. Only rogues are supported.\"\n return false\n end\n true\n end",
"def get_class_by_name( name )\n raise \"get_class_by_name #{name}.#{name.class}\" unless name.is_a?(Symbol)\n c = classes[name]\n #puts \"MISS, no class #{name} #{name.class}\" unless c # \" #{classes}\"\n #puts \"CLAZZ, #{name} #{c.get_type.get_length}\" if c\n c\n end",
"def contains?(klass)\n\t\tmap { |obj| obj.class }.include? klass\n\tend",
"def klass_defined?(controller)\n present?(storage[controller][:klass])\n end",
"def centered?(class_str)\n (class_str.split(' ') & centered_classes).any?\n end",
"def classification?(c)\n not [\"malicious\", \"non-malicious\", \"suspicious\", \"unknown\"].index(c).nil?\n end",
"def validate!\n validations.each do |name, attributes|\n valid = instance_variable_get(name)\n case attributes[0]\n when :presence\n raise \"Class object didn't create.\" if valid !~ /^.{1}+/.freeze\n when :format\n raise \"Class object didn't create.\" if valid !~ attributes[1]\n when :type\n raise \"Class object didn't create.\" unless valid.is_a? attributes[1]\n end\n end\n end",
"def tagClass?()\r\n\t\treturn (@type == \"c\") || (@type == \"i\")\r\n\tend",
"def BaseClass(name)\n name == \"string\" ? String : Object\nend",
"def BaseClass(name)\n name == \"string\" ? String : Object\nend",
"def has_classes?\n c = @context.classes.find{|c| c.document_self}\n c ? true : false\n end",
"def is_one_of?(*classes)\n !!classes.find{|c| is_a?(c)}\n end",
"def class_get class_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\treturn p.class_get(class_name) \n\t\t\t\t\t\trescue NotExist;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\traise \"Class '#{class_name}' doesn't exist!\"\n\t\t\t\tend\n\t\t\tend",
"def need_define_class(p)\n if p.to_request && p.from_response\n cn = '{class}('\n return p.to_request.include?(cn) || p.from_response.include?(cn)\n end\n true\n end",
"def unique_class?(h, e)\n # first try \"whole text\" combination\n return true if unique_attr?(h, 'class', e)\n classes = e.value.split\n classes.each do |c|\n # is this a unique class?\n return true if h.css(\".#{c}\").one?\n end\n false\n end",
"def isa classname\n\t\t\tinit_classlist\n\t\t\tif !isa? classname\n\t\t\t\t@cf.classlist.add(classname,@hostname)\n\t\t\tend\n\t\tend",
"def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end",
"def findClassesThatMatch(name)\n fname = name.tr(':', '_')\n return ClassIndex.findClasses(fname)\n end",
"def klass_defined?(controller)\n present?(storage[controller][:klass])\n end",
"def klass_defined?(controller)\n present?(storage[controller][:klass])\n end",
"def can_handle?(name)\n case name\n \n when /^#{CN_PATTERN}$/o\n return findClassesThatMatch(name).size > 0\n \n when /^(#{CN_PATTERN})(\\.|\\#|::)(.+)/o\n cname, type, mname = $1, $2, $3\n return findClassesThatMatch(cname).size > 0 && \n methods_matching(cname, type, mname).size > 0\n \n else\n return MethodIndex.findMethods(name).size > 0\n end\n end",
"def is_constant?\n @classified.first.instance_of? Constant\n end",
"def should_be_final_class_line?(line)\n class_line?(line) && !line.include?('final') && !line.include?('open')\n end",
"def autoload?(p0) end",
"def autoload?(p0) end",
"def test_class_names_are_just_constants\n assert_equal true, MyString == ::String\n assert_equal true, MyString == \"HI\".class\n end",
"def matches_required_class(factory)\n begin\n !required_class || factory.provides_class <= required_class\n rescue NameError\n false\n end\n end",
"def is_fact?(sym_or_class_or_str = nil)\n return case sym_or_class_or_str\n when Symbol then\n is_fact?(sym_or_class_or_str.to_s)\n when String then\n begin\n is_fact?(const_get(sym_or_class_or_str.classify))\n rescue\n false\n end\n when Class then\n sym_or_class_or_str.respond_to?(\"is_fact?\") && \n sym_or_class_or_str.send(\"is_fact?\")\n when NilClass then true\n else false\n end\n end",
"def look_for_name_of_deceased(list_of_classes, current_index)\n if current_index + 1 < list_of_classes.count\n next_class = list_of_classes[current_index + 1]\n if next_class[1][0] == :name_component || next_class[1][1] <= 0.5\n ## we check if the next class is either a name_component, or had a low confidence\n next_class[1][0] = :already_considered\n return next_class[0]\n end\n end\n return nil\nend",
"def method_missing(name, *arguments)\n str_name = name.to_s\n\n if str_name =~ /\\w+\\?/ && Types::NAMES.include?(str_name.chop)\n klass_name = str_name.sub(/\\?/, '').capitalize\n self.class.class_name == klass_name\n else\n raise NoMethodError, \"undefined method: #{name}\"\n end\n end",
"def include?(sym)\n `c$Element.prototype.m$has_class_bool.call(#{@element},sym)`\n end",
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def get_class_from_production_environment(class_name, http)\n rest_api_endpoint = \"environments/production/classes/#{class_name}\"\n class_json = get_rest_api(rest_api_endpoint, http)\n\n # Verify that something was returned from the REST API\n if class_json.empty?\n puts \"Class #{class_name} not found in production environment.\"\n exit 1\n end\n\n # Verify that whatever was returned wasn't \"not-found\"\n class_hash = JSON.parse(class_json)\n if class_hash['kind'] == 'not-found'\n puts \"Class #{class_name} not found in production environment.\"\n exit 1\n end\n\n # If we got a valid object, return it\n class_hash\nend",
"def instance_of?(klass)\n klass == ::NilClass or super\n end",
"def exist?\n self.class.exist?(@path)\n end",
"def find_class_named name\n @classes_hash[name]\n end",
"def sc_kind_of?(type)\n if not (type.kind_of?(Class) or type.kind_of?(String))\n raise ArgumentInvalidTypeError.new \"type\", type, 'class < SCObject', String\n end\n \n if type.kind_of?(Class) and type.ancestors.member?(SCObject)\n type = type.represented_sc_class\n end\n \n type = type.downcase\n result = sc_all_classes.detect do |val| \n val.downcase == type\n end\n return (not result.nil?)\n end",
"def hidden?\n classes.include?('hidden')\n end"
] | [
"0.8096085",
"0.76872027",
"0.7647681",
"0.7635851",
"0.75350523",
"0.74830174",
"0.7474969",
"0.7474969",
"0.7474969",
"0.7412033",
"0.73887044",
"0.7370037",
"0.72096604",
"0.71148914",
"0.7091627",
"0.70484865",
"0.7038288",
"0.69804",
"0.69743073",
"0.6939178",
"0.6915956",
"0.68401116",
"0.6836201",
"0.68038714",
"0.672197",
"0.6647623",
"0.6489544",
"0.647736",
"0.64763945",
"0.6441544",
"0.64281774",
"0.63847154",
"0.6376192",
"0.6349685",
"0.6345763",
"0.62864125",
"0.6286024",
"0.6277815",
"0.6261924",
"0.6245454",
"0.6237204",
"0.6237204",
"0.6154197",
"0.6123536",
"0.6100084",
"0.6091523",
"0.6072696",
"0.6056957",
"0.6049935",
"0.6033264",
"0.6020294",
"0.601781",
"0.599386",
"0.59891003",
"0.59634113",
"0.59492433",
"0.59477806",
"0.5943665",
"0.5941395",
"0.5930758",
"0.59033024",
"0.59015447",
"0.589811",
"0.58805263",
"0.5874992",
"0.5873784",
"0.5872593",
"0.5866364",
"0.58585554",
"0.5855145",
"0.58535933",
"0.58535933",
"0.584106",
"0.5821286",
"0.5817584",
"0.58163166",
"0.57956254",
"0.5791331",
"0.5780232",
"0.57776135",
"0.5777331",
"0.5777331",
"0.57768196",
"0.57668597",
"0.5766688",
"0.57629097",
"0.57629097",
"0.5748897",
"0.57349116",
"0.5733363",
"0.5715588",
"0.5703369",
"0.5689303",
"0.5688553",
"0.5674001",
"0.56658393",
"0.5637817",
"0.5636665",
"0.56336415",
"0.5621867"
] | 0.8161565 | 0 |
Returns info for the specified venue. | def venue(id)
options = { :venue_id => id }
get('/venue_info', options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def venue(id)\n get(\"venues/#{id}\").venue\n end",
"def venue(vid, options = {})\n options.merge!({ :query => { :key => @api_key } })\n self.class.get(\"/venues/#{vid}\", options)\n end",
"def venue\n \t@events = Event.where(:venue => params[:venue])\n\n \trespond_to do |format|\n \t\tif @events.size>0\n \t\t\tformat.html { render json: {:message => \"Here are the details of #{@events.size} event(s) happening in #{params[:venue]}.\", :events => @events}}\n \t\telsif @events.size<=0\n \t\t\tformat.html { render json: {:message => \"Cannot find event - that venue does not exist. Please enter a valid venue.\"}}\n \t\tend\n \tend\n end",
"def venue_name\n venue.name if venue\n end",
"def show\r\n @venue = Venue.fetch(params[:id])\r\n render json: @venue\r\n end",
"def show\n @venue = Venue.find(params[:id])\n\n render json: @venue\n end",
"def venues(options = {})\n self.class.require_latitude_and_longitude(options)\n\n response = self.class.get(\"/venues.json\", :query => options, :basic_auth => @auth)[\"venues\"]\n response && response.flatten\n end",
"def show\n @venue = Venue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venue }\n end\n end",
"def show\n @venue = Venue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @venue }\n end\n end",
"def events_at_venue(venue)\n venue_events[venue.id]\n end",
"def venue\n\t\"Town Hall\"\nend",
"def venue_stats(id, options = {})\n get(\"venues/#{id}/stats\", options)\n end",
"def show\n venue = Venue.find(params[:id])\n\n redirect_to_venue_index(venue)\n end",
"def show\n @manage_venue = Venue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manage_venue }\n end\n end",
"def venue_show\n client = Foursquare2::Client.new(:client_id => '45M1USHSGHPODOQWPSYJGAW50GBCMIHCKVQF410CKBCSO024', :client_secret => '4GO20RGY0BTI3VAQSS04P35AJ4A0DIZWF2JWLRPBFP0SDNQK',:api_version => '20140201')\n #@restroom = Restroom.find(params[:id])\n @venue = Venue.find_by_venue_id(params[:venue_id])\n @review = Review.new\n #@pics = client.venue_photos(params[:venue_id], options = {:group => 'venue'})\n @review.venue_id = @venue.id\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def ig_venue\n Rails.cache.fetch cache_key('instagram:venue'), :compress => true do\n Instagram.location_search(nil, nil, :foursquare_v2_id => self.fs_venue_id).first\n end\n end",
"def venue_events(id)\n get(\"venues/#{id}/events\").events\n end",
"def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end",
"def get_recommended_venues\n uri = \"https://api.foursquare.com/v2/venues/explore?near=#{@location}&client_id=#{CLIENT_ID}&client_secret=#{CLIENT_SECRET}&v=#{Time.now.strftime(\"%Y%m%d\")}&categoryId=4d4b7105d754a06374d81259\"\n encoded = URI.parse(URI.encode(uri)) # to handle spaces in the location\n @api_response = HTTParty.get(encoded)\n @api_response['response']['groups'][0][\"items\"].each do |item|\n @recommended_venues << item[\"venue\"][\"name\"]\n end\n # puts encoded # uncomment this to see the uri that is being used in the HTTP get request\n @recommended_venues\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venue }\n end\n end",
"def show\n @paper_venue = PaperVenue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @paper_venue }\n end\n end",
"def show\n @place = Venue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @place }\n end\n end",
"def show\n @venue_config = VenueConfig.get!(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue_config }\n end\n end",
"def show\n @venue_product = VenueProduct.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venue_product }\n end\n end",
"def get_recommended_venues\n uri = \"https://api.foursquare.com/v2/venues/explore?near=#{@location}&client_id=#{CLIENT_ID}&client_secret=#{CLIENT_SECRET}&v=#{Time.now.strftime(\"%Y%m%d\")}&categoryId=4d4b7105d754a06374d81259&limit=10\"\n encoded = URI.parse(URI.encode(uri)) # to handle spaces in the location\n @api_response = HTTParty.get(encoded)\n @api_response['response']['groups'][0][\"items\"].each do |item|\n @recommended_venues << item[\"venue\"]\n end\n @recommended_venues\n # puts encoded # uncomment to see the uri that is being used in the HTTP get request\n end",
"def show\n\n @venue = Venue.find(params[:id])\n @concerts = Concert.where(:venue_id=>@venue.id)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def show\n @events = events_index(@venue.events)\n end",
"def search(venue, options={})\n get(:standard, {:method => \"venue.search\", :venue => venue}.merge(options))\n end",
"def show\n\n\n # respond_to do |format|\n # format.html # show.html.erb\n # format.json { render json: @venue }\n # end\n end",
"def venue_events venue_id\n response = get(\"/venues/#{venue_id}/events\")[\"response\"]\n @events = response[\"events\"]\n @events[\"items\"].map!{|item| Foursquared::Response::Event.new(self, item)}\n @events\n end",
"def search_venues options={}\n response = get(\"/venues/search\", options)[\"response\"]\n @venues = response[\"venues\"].collect{|venue| Foursquared::Response::Venue.new(self, venue)}\n end",
"def show\n @venue = Venue.from_param(params[:id])\n @page_title = @venue.page_title \n# render :layout => \"user\"\n end",
"def events(venue)\n get(:standard, {:method => \"venue.getEvents\", :venue => venue})\n end",
"def set_venue\n @venue = Venue.friendly.find(params[:id])\n end",
"def set_venue\n @venue = Venue.friendly.find(params[:id])\n end",
"def edit_venue\r\n @venue = Venue.find(params[:id])\r\n end",
"def new\n @venue = Venue.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @venue }\n end\n end",
"def full_name\n Venue.find(venue_id).name + \" - \" + roomName\n end",
"def create\n if params[\"foursq_id\"]\n @foursq_venue = foursquare.venues.find(params[\"foursq_id\"])\n @venue = Venue.new_from_4sq(@foursq_venue)\n else\n @venue = Venue.new(params[:venue])\n end\n\n respond_to do |format|\n if @venue.save\n format.html { redirect_to @venue, notice: 'Venue was successfully created.' }\n format.json { render json: @venue, status: :created, location: @venue }\n else\n format.html { render action: \"new\" }\n format.json { render json: @venue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def venue_search(ll, options = {})\n get('venues/search', { :ll => ll }.merge(options)).venues\n end",
"def new\n @offer = Offer.new\n if can? :manage, @offer\n @venue_names = current_user.venues.pluck(:venue_name)\n #@venue_names = current_user.venues.select('venues.id, venue_name')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @offer }\n end\n else\n redirect_to offers_path\n end\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n\n end",
"def search_by_venue(venueID)\n all.select do |event| \n event.venue == venueID\n end\n end",
"def show\n @venue = Venue.find(params[:id])\n @events = @venue.events.starting_today\n separate_events_by_date\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def show\n @venue_role = VenueRole.find(params[:id])\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def set_venue\n @venue = Venue.find(params[:id])\n end",
"def new\n @venue = Venue.new\n @venue.build_location\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venue }\n end\n end",
"def show\n\n @client = Yelp::Client.new\n\n @request = Location.new(\n :term => @event.topPrefs,\n :zipcode => @event.zip,\n :limit => \"3\"\n #:category_filter => @yelp_search.category_filter,\n #:radius_filter => @yelp_search.radius_filter,\n )\n\n @response = @client.search(@request)\n @businesses = @response.to_h[\"businesses\"]\n end",
"def get_address(event)\n this_uri = \"http://data.pollstar.com/api/pollstar.asmx/VenueEvents?venueID=#{event.VenueID}&startDate=#{Time.now.strftime(\"%m/%d/%Y\")}&dayCount=0&page=0&pageSize=0#{ps_key}\"\n\n doc = Nokogiri::XML(Net::HTTP.get(URI(this_uri)))\n venue = doc.xpath(\"//VenueInfo\")\n address = Address.new(event.id) \n address.address1 = venue.attribute('Address1')\n address.address2 = venue.attribute('Address2')\n address.zip = venue.attribute('Zip')\n\n return address\n end",
"def venue_hours venue_id\n response = get(\"/venues/#{venue_id}/hours\")[\"response\"][\"hours\"]\n end",
"def show\n @venue = Venue.find(params[:id])\n\t\tremove_old_attendees\n\t\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n format.json { render :json => @venue }\n end\n end",
"def info(event)\n get(:standard, {:method => \"event.getInfo\", :event => event})\n end",
"def index\n @venues = Venue.all\n end",
"def show\n if session[:user_id] == nil\n redirect_to \"/login\"\n else\n @venue = Venue.find(params[:id])\n @splash_ads = @venue.splash_ads.all\n @advertisements = @venue.advertisements.all\n @schedules = @venue.schedules.all\n @display = @venue.display if @venue.display != nil\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n end\n end\n end",
"def details\n get(\"v1/event/#{@id}\")\n end",
"def show\n @audio_clip = AudioClip.find(params[:id])\n \n # @client = Foursquare2::Client.new(:client_id => 'MLGORRLYKVWVSEMAKWHQURQVIEAZEJ5PSESSRER3VK4XBHRL', :client_secret => 'JT11S30HAAOSMQYEA2CU3QQXB1DEPK5ESQTIM0CUFM1UB2NB')\n # @audio_clip.fsvenue = @client.search_venues(:ll => '36.142064,-86.816086')\n unless @audio_clip.latitude.blank? || @audio_clip.longitude.blank?\n @fsquare_response = open(\"https://api.foursquare.com/v2/venues/search?ll=#{@audio_clip.latitude},#{@audio_clip.longitude}&llAcc=100&limit=1&oauth_token=FNUK2E0Z5BI33J0BRQBR3FZWBBYEUSY4LAX1WE1NPAQDDIHT&v=20130203\").read\n @result = ActiveSupport::JSON.decode(@fsquare_response)\n @venue = @result[\"response\"][\"venues\"][0][\"name\"]\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @audio_clip }\n \n # format.json { render :json => @audio_clip.to_json(:include => [:facebook_id])}\n end\n end",
"def set_venue\n @venue = Venue.find(params[:venue_id])\n end",
"def set_venue\n @venue = Venue.find(params[:venue_id])\n end",
"def explore_venues options={}\n response = get(\"/venues/explore\", options)[\"response\"]\n response[\"groups\"].each do |group|\n response[\"items\"].each do |item|\n item[\"venue\"] = Foursquared::Response::Venue.new(self, item[\"venue\"])\n item[\"tips\"].map!{|tip| Foursquared::Response::List.new(self, tip)}\n end\n end\n response\n end",
"def set_venue\n @venue = Venue.friendly.find(params[:id]).decorate\n end",
"def show\n @page_title = @venue.name\n @venue_events = @venue.events.where('date >= ?', DateTime.now).order('date').limit(5).includes(:festival)\n end",
"def full(vin)\n find(vin).to_json\n end",
"def new\n @venue = Venue.new\n end",
"def index\n \tif\n params[:search].present?\n client = Foursquare2::Client.new(:client_id => '45M1USHSGHPODOQWPSYJGAW50GBCMIHCKVQF410CKBCSO024', :client_secret => '4GO20RGY0BTI3VAQSS04P35AJ4A0DIZWF2JWLRPBFP0SDNQK', :api_version => '20140201')\n \n #results = client.search_venues(:ll => '40.0462925,-82.91250359', :query => params[:search])\n results = client.search_venues(:near => params[:location], :query => params[:search])\n\t\n @venues = results.venues\n\n @venues.each do |venue|\n Venue.where({\n name: venue.name,\n address: venue.location.address,\n venue_id: venue.id,\n city: venue.location.city,\n state: venue.location.state,\n lat: venue.location.lat,\n long: venue.location.lng,\n }).first_or_create\n end\n\n else\n\tclient = Foursquare2::Client.new(:client_id => '45M1USHSGHPODOQWPSYJGAW50GBCMIHCKVQF410CKBCSO024', :client_secret => '4GO20RGY0BTI3VAQSS04P35AJ4A0DIZWF2JWLRPBFP0SDNQK',:api_version => '20140201')\n \n results = client.search_venues(:ll => '40.0462925,-82.91250359', :query => params[:search])\n @venues = results.venues\n\n\nend\n\n\n #else\n # @restrooms = Restroom.all\n # end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @restrooms }\n end\n end",
"def id\n\t\t\t\treturn self.venue['id'].to_i\n\t\t\tend",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def new\n @venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def show\n\n @venue = Venue.find(params[:id])\n render :json => @venue, \n :methods => [:average_rating,:user_count],\n :include => [:venue_photos,:parties]\n end",
"def my_venues\n @venues = \n if admin_session?\n User.find_by_uuid(params[:for_user]).try(:owned_venues)\n else\n current_user.owned_venues\n end\n @venues ||= []\n respond_to do |format|\n format.json {\n @venues = [Venue.new(:name => 'TBD')] + @venues\n @venues += [Venue.new(:name => VenuesHelper::ADD_NEW_VENUE_PROMPT)] if params[:add_new]\n render :json => @venues.map {|v| {:value => v.uuid, :text => v.name}}\n }\n format.html\n end\n end",
"def show\n @title = \"Profile\"\n @user = User.find(params[:id])\n @venues = @user.venues\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n end\n end",
"def getVenueOrResolve\n begin\n venue = client.venue(venueId)\n\n if primary_id_changed?(venue)\n self.status = 'alternate resolution'\n self.resolved_details = '(merged)'\n save\n\n return true\n end\n\n if is_closed?(venue)\n self.status = 'alternate resolution'\n self.resolved_details = '(closed)'\n self.save\n return true\n end\n\n return venue\n rescue Foursquare2::APIError => e\n if e.message =~ /has been deleted/ or e.message =~ /is invalid for venue id/\n self.status = 'alternate resolution'\n self.resolved_details = '(deleted)'\n self.save\n return true\n else\n raise e\n end\n end\n end",
"def locate!\n if foursquare_venue_id\n locate_via_foursquare!\n else\n locate_via_coords!\n end\n end",
"def show\n @room = Room.find(params[:id])\n\n # @user = User.find(current_user)\n\n # if @user.venues.all.include? @venue\n # @owns_venue = true\n # end\n\n if @venue.id == @room.venue_id\n @booking = Booking.new\n @uploadable = @room\n @assets = @uploadable.assets\n @room = Room.find(params[:id])\n respond_to do |format|\n format.html\n format.json { render json: @room}\n end\n else\n redirect_to error_path\n end\n end",
"def venue_times\n\n end",
"def venue_likes venue_id\n response = get(\"/venues/#{venue_id}/similar\")[\"response\"][\"similarVenues\"]\n response[\"items\"].map!{|item| Foursquared::Response::Venue.new(self, item)}\n response\n end",
"def venue_location\n major_geo = self.state || self.country\n [self.city, major_geo].compact.join(\", \")\n end",
"def venue_tips(id, options = {})\n get(\"venues/#{id}/tips\", options).tips\n end",
"def new\n @manage_venue = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manage_venue }\n end\n end",
"def new\n @place = Venue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end",
"def show\n @venue_review = VenueReview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue_review }\n end\n end",
"def venue_likes(id)\n get(\"venues/#{id}/likes\").likes\n end",
"def new\n @venue = Venue.new\n @venue.user_id = current_user.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def show\n @venue = Venue.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render :json => @venue.to_json(:except=>[:display, :user_id, :modified_user_id]), :callback=>params[:callback] }\n end\n end",
"def event_get_location_details\n @loc = Apis::HereApi.new(\"\").get_location_details(params[:locationid])\n render json: @loc\n end",
"def is_at_facility\n self.venues\n end",
"def new\n @event = Event.new\n #@venues = Venue.all\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end",
"def propose_venue_edit venue_id, options={}\n response = post(\"/venues/#{venue_id}\", options)\n end"
] | [
"0.7556617",
"0.72925836",
"0.71240777",
"0.6950226",
"0.69235957",
"0.6780076",
"0.6749551",
"0.6677567",
"0.66518515",
"0.6548156",
"0.64478546",
"0.6389568",
"0.63407123",
"0.63203627",
"0.63155055",
"0.6270055",
"0.62002933",
"0.6194573",
"0.616607",
"0.61569226",
"0.61444414",
"0.61082983",
"0.60768706",
"0.60666513",
"0.60255635",
"0.60190034",
"0.6014551",
"0.5995302",
"0.5993458",
"0.59926015",
"0.59874016",
"0.5958941",
"0.59476876",
"0.590946",
"0.590946",
"0.5872337",
"0.5868287",
"0.5866908",
"0.58521277",
"0.5842597",
"0.5817673",
"0.580565",
"0.580565",
"0.580565",
"0.580565",
"0.5790576",
"0.57889163",
"0.57877934",
"0.5785185",
"0.57795995",
"0.57795995",
"0.57795995",
"0.57795995",
"0.5776965",
"0.5776965",
"0.5776965",
"0.5776965",
"0.5776965",
"0.57698023",
"0.5740598",
"0.5738624",
"0.57300925",
"0.57267433",
"0.5708066",
"0.57043046",
"0.57030153",
"0.5697803",
"0.5671046",
"0.5669506",
"0.5669506",
"0.5666424",
"0.5658276",
"0.56527054",
"0.5631378",
"0.56273425",
"0.5623087",
"0.5614406",
"0.5599577",
"0.5599577",
"0.5599577",
"0.559383",
"0.5587319",
"0.5581941",
"0.55773664",
"0.55461675",
"0.5543013",
"0.55381",
"0.5502448",
"0.5482799",
"0.5482059",
"0.5477775",
"0.5453866",
"0.5448908",
"0.54398376",
"0.5438759",
"0.5436779",
"0.54354215",
"0.54305255",
"0.5429842",
"0.5418747"
] | 0.79124004 | 0 |
GET /communities/1 GET /communities/1.json | def show
@community = Community.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @community }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n respond_with @communities\n end",
"def index\n # @user = User.find(params[:user_id])\n # @communities = @user.communities\n @communities = Community.all\n end",
"def index\n @communities = Community.search(params[:search], params[:page])\n respond_with(@communities)\n end",
"def index\n @communities = Community.all\n\n render json: @communities.to_json(include: {posts: {include: :replies} })\n end",
"def profile_communities\n messages = MessageQuery.new(current_user).communities(\n params[:limit], params[:offset]\n )\n\n render json: {\n messages: messages.as_json(\n methods: %i[\n avatar_url image_urls video_urls like_by_user legendary_by_user user\n text_with_links post_url expire_at has_expired\n ]\n )\n }, status: 200\n end",
"def index\n @community_communities = Community::Community.all\n end",
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def show\n render json: @community\n end",
"def show\n @community = Community.find(params[:id])\n @rcommunities = Community.relatedCommunities(params[:id])\n @posts = Post.getCommunityPosts(params)\n respond_with(@community)\n end",
"def index\n @communities = current_user.communities.all\n\n @page_title = \"Communities\"\n @page_subtitle = \"Uniting People and Companies\"\n @page_description = \"\"\n end",
"def index\n @communities = Community.paginate(page: params[:page])\n respond_to do |format|\n # format.html # index.html.erb\n format.xml { render xml: @communities }\n end\n end",
"def index\n @communications = Communication.paginate(:page => params[:page], :per_page => 2)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @communications }\n end\n end",
"def community; Community.get(self.community_id); end",
"def my\n @membercommunities = current_user.communities.where(:community_users=>{:is_communitymember=>true})\n\n @owncommunities = current_user.communities.where(:community_users=>{:is_communityadmin=>true})\n end",
"def index\n @memberships = @community.memberships\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end",
"def index\n if params[:search]\n @communities = Community.search(params[:search])\n expires_in 5.minutes, public: true\n else\n @communities = Community.all.order('name ASC').page params[:page]\n end\n end",
"def getConversations\n @conversations = Conversation.all.select(\"name\").map(&:name)\n\n respond_to do |format|\n format.json {render :json => {:conversations => @conversations}}\n end\n end",
"def show\n @communication = Communication.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @communication }\n end\n end",
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def commune\n Commune.find_by_id self.commune_id\n end",
"def update\n @community = current_user.own_communities.find(params[:id])\n flash[:notice] = 'Community was successfully updated.' if @community.update_attributes(update_params)\n respond_with(@community)\n end",
"def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def show\n @community = Community.find(params[:id])\n if request.path != community_path(@community)\n redirect_to @community, status: :moved_permanently\n end\n end",
"def new\n @community = Community.new\n respond_with(@community)\n end",
"def index\n @conversations = Conversation.all\n\n render json: @conversations\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @conversation = current_user.conversations.find(params[:conversation_id])\n render json: @conversation.as_json()\n end",
"def index\n if @current_role_user.is_student? or @current_role_user.is_teacher?\n @communities = Community.check_access_to_community(@current_user_object.id)\n @communities = Kaminari.paginate_array(@communities).page(params[:page]).per(10)\n else\n @communities = Community.all.page(params[:page]).per(10)\n end\n end",
"def index\n @community_topics = CommunityTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @community_topics }\n end\n end",
"def set_community_community\n @community_community = Community::Community.find(params[:id])\n end",
"def create\n @community = Community.new(community_params)\n\n if @community.save\n render :show, status: :created, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_district_communities_url }\n format.json { head :no_content }\n end\n end",
"def index\n @connections = Connection.all(:include => :user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @connections }\n end\n end",
"def update\n if @community.update(community_params)\n render :show, status: :ok, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def index\n @community_sections = CommunitySection.all\n end",
"def show\n @networking = Networking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @networking }\n end\n end",
"def index\n @network_invitations = current_organization.network_invitations\n @networks = current_organization.networks.paginate(:page => params[:page], :order => \"name\")\n end",
"def community_for_route\n case params[:action]\n when \"show\"\n Event.find_by(id: params[:id]).try(:community)\n when \"index\"\n current_user.community\n end\n end",
"def index\n @communicates = Communicate.all\n @communicate = Communicate.new\n end",
"def show\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community_topic }\n end\n end",
"def show\n @network_connection = NetworkConnection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @network_connection }\n end\n end",
"def getAllCategories(community_id, params)\n url_base = URI_BASE + \"/api/v1/communities/#{community_id}/categories\"\n makeGetCall(url_base, nil, params)\n end",
"def communalities(m=nil)\n if m!=@m or @clean\n iterate(m)\n raise \"Can't calculate comunality\" if @communalities.nil?\n end\n @communalities\n end",
"def show\n @social_network = SocialNetwork.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @social_network }\n end\n end",
"def index\n\n respond_to do |format|\n format.html { @boards = Board.where network_id: current_user.network_id }\n format.json { @boards = Board.where network_id: current_user.network_id }\n \n end\n end",
"def show\n @community\n @community_news = @community.community_newses.build(community: @community, creator: @current_user_object) # для подключения community_news/form\n @discipline_section = @community.community_disciplines.first.discipline.discipline_sections.build(community: @community, discipline: @community.community_disciplines.first.discipline)\n @community_news_index = @community.community_newses.reverse\n @community_news_index = Kaminari.paginate_array(@community_news_index).page(params[:page]).per(5)\n @check = Community.check_access_to_edit_community(@current_user_object.id, @community.id) # проверяем доступ к редактированию сообщества\n end",
"def set_community\n @community = Community.where(id: params[:community_id]).first\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def conversation\n current_user_id = current_user.id\n other_user_id = params[:id]\n @messages = Message.get_conversation(current_user_id, other_user_id)\n render json: @messages\n end",
"def member_collections\n Collection.where(community_id: id)\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @internship }\n end\n end",
"def getCity\n @city_id=ReceiverAddress.where(id: params[:address_id]).first.city_id\n @city=City.where(id: @city_id).first\n respond_to do |format|\n format.html\n format.json {render json: @city}\n end\n end",
"def index\n @networkings = Networking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @networkings }\n end\n end",
"def destroy\n # @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @community = Community.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_all_conversations\n response = RestClient::Request.execute method: :get,\n url: URL,\n user: USERNAME,\n password: PASSWORD,\n headers: {params: {pageSize: OBJECTS_PER_PAGE, page:ARGV[1]}},\n :content_type => :json,\n :accept => :json\n JSON(response)['conversations'][396..-1]\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def show\n @committees_voivodeship = CommitteesVoivodeship.find(params[:id])\n #@committees = Committee.all\n #@voivodeships = Voivodeship.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @committees_voivodeship }\n end\n #redirect_to :list_commi\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @community }\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render action: 'show', status: :created, location: @community }\n else\n format.html { render action: 'new' }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n history_ids = CommunityMemberHistory.select('community_id, max(id) as max_id').group('community_id').collect{|cmh| cmh.max_id}\n @histories_hash = Hash[*(CommunityMemberHistory.where(id: history_ids).all.collect{|cmh| [cmh.community_id, cmh]}.flatten)]\n @communities = Community.where(permission_id: @user_permission_ids)\n end",
"def show\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n format.html \n format.json { render :json => @internship }\n end\n end",
"def community; end",
"def show\n @new_comm = NewComm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @new_comm }\n end\n end",
"def create\n @community = Community.new(community_params)\n community_hash = @community.get_from_vk\n existing = Community.includes([:community_histories]).find_by_vk_id(community_hash[:id])\n if !existing.nil?\n @community = existing\n @community.update_history(community_hash)\n else\n @community.set_from_vk(community_hash)\n end\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully added.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end",
"def show_cities\n\n @cities = City.where(\"country_id = ?\", params[:country_id])\n\n render json: @cities\n \n end",
"def show\n @condolence = Condolence.find(params[:id])\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @condolence }\n end\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @collaborations = Collaboration.where(:project_id => params[:project_id])\n respond_with @collaborations\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def community\n render_template\n end",
"def set_community\n #community = Community.find(params[:id])\n @community = Community.includes(community_disciplines: {discipline: {discipline_sections: :marks}}, community_users: :user).find(params[:id])\n #@community = Community.includes(community_disciplines: {discipline: {discipline_sections: {marks: :student}}}, ).find(params[:id])\n end",
"def fetch\n conversation_users = paginate ConversationUser.where(conversation_id: params[:conversation_id])\n\n render json: conversation_users.to_json(:include => :user)\n end",
"def create\n @community_community = Community::Community.new(community_community_params)\n\n respond_to do |format|\n if @community_community.save\n format.html { redirect_to @community_community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community_community }\n else\n format.html { render :new }\n format.json { render json: @community_community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @topics = Topic.getCommunityTopic(params)\n respond_with(@topics)\n end",
"def show\n if current_user.blank?\n @neighborhood = Neighborhood.find(params[:id])\n else\n @neighborhood = Neighborhood.find(params[:id])\n @move= Move.find(params[:move_id])\n @community= Community.new\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end"
] | [
"0.75319916",
"0.743811",
"0.73624486",
"0.7266786",
"0.7266786",
"0.7210947",
"0.7142459",
"0.70275843",
"0.7001811",
"0.6939018",
"0.68679535",
"0.6789699",
"0.6706936",
"0.67003244",
"0.66298616",
"0.6583088",
"0.6502852",
"0.63781494",
"0.6237151",
"0.6207699",
"0.607654",
"0.6073056",
"0.6061523",
"0.5981023",
"0.5962262",
"0.59253556",
"0.5853453",
"0.5853453",
"0.58493197",
"0.58439904",
"0.5812376",
"0.5810859",
"0.57584846",
"0.574738",
"0.57411593",
"0.57342964",
"0.5732205",
"0.5732205",
"0.5732205",
"0.5732205",
"0.5732205",
"0.5732205",
"0.5732205",
"0.5732205",
"0.57193744",
"0.5692814",
"0.5684621",
"0.5681496",
"0.5666479",
"0.5655724",
"0.56369877",
"0.5635441",
"0.56316966",
"0.5627749",
"0.56245196",
"0.5616699",
"0.56102866",
"0.5596251",
"0.55942315",
"0.5575343",
"0.5565814",
"0.5564287",
"0.5554048",
"0.5552893",
"0.5552613",
"0.5546624",
"0.553294",
"0.553294",
"0.553294",
"0.553294",
"0.5524982",
"0.55144775",
"0.5503135",
"0.5500845",
"0.54936594",
"0.54900914",
"0.54849845",
"0.54775023",
"0.54707",
"0.5468292",
"0.54676163",
"0.5464762",
"0.5461714",
"0.5456897",
"0.54544026",
"0.543902",
"0.5437737",
"0.5435721",
"0.54286665",
"0.5428162",
"0.54261595",
"0.5420709",
"0.54190814",
"0.54190814",
"0.5416366",
"0.54155594",
"0.5414016",
"0.54039526",
"0.53970176",
"0.53879714"
] | 0.6814191 | 11 |
GET /communities/new GET /communities/new.json | def new
@community = Community.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @community }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @community = Community.new\n respond_with(@community)\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @community }\n end\n end",
"def create\n @community = Community.new(community_params)\n\n if @community.save\n render :show, status: :created, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render action: 'show', status: :created, location: @community }\n else\n format.html { render action: 'new' }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @new_comm = NewComm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_comm }\n end\n end",
"def new\n\t@community= Community.new\nend",
"def new\n @communication = Communication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @communication }\n end\n end",
"def create\n @community_community = Community::Community.new(community_community_params)\n\n respond_to do |format|\n if @community_community.save\n format.html { redirect_to @community_community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community_community }\n else\n format.html { render :new }\n format.json { render json: @community_community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t@community= Community.new(params[:community])\n\t if @community.save\n\trender ('create')\n else \n\trender ('new')\n end\nend",
"def new\n @social_network = SocialNetwork.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @social_network }\n end\n end",
"def new\n @colaboration = Colaboration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def new\n @network = Network.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @network }\n end\n end",
"def create\n @community = Community.new(community_params)\n #raise community_params.inspect\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Сообщество успешно создано' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user = People.new\n @comunities = Comunity.find(:all, :order => :name)\n end",
"def new\n @committees_voivodeship = CommitteesVoivodeship.new\n\t@committees = Committee.all.map do |commi|\n\t\t[commi.id]\n\tend\n\t@voivodeships = Voivodeship.all.map do |voi|\n\t\t[voi.id]\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @committees_voivodeship }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @internship = Internship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internship }\n end\n end",
"def new\n @community_topic = CommunityTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community_topic }\n end\n end",
"def new\n @protocol = Protocol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @protocol }\n end\n end",
"def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to community_memberships_path(@community), notice: 'Community membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n flash[:notice] = 'Community was successfully created.' if @community.save\n respond_with @community\n end",
"def new\n @cities = City.order 'name'\n @college = College.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @college }\n end\n end",
"def new\n @title = \"New Networks\"\n @network = Network.new\n @computers = Computer.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @network }\n end\n end",
"def new\n @city = City.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @city }\n end\n end",
"def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end",
"def new\n @intern = Intern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to community_home_url(:subdomain => @community.subdomain), notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @membership }\n end\n end",
"def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\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",
"def new\n @network_connection = NetworkConnection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @network_connection }\n end\n end",
"def new\n @membership = Membership.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @membership }\n end\n end",
"def new\n @project = Project.new(user_id: current_user.id)\n find_people_list\n fetch_clients\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 @relation = Relation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relation }\n end\n end",
"def new\n @conn = current_user.conns.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conn }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood }\n end\n end",
"def new\n @conversation = Conversation.new\n logger.debug \"In new!\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conversation }\n end\n end",
"def new\n @projecct = Projecct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projecct }\n end\n end",
"def new\n @competitor = Competitor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competitor }\n end\n end",
"def create\n @new_comm = NewComm.new(params[:new_comm])\n\n respond_to do |format|\n if @new_comm.save\n format.html { redirect_to @new_comm, notice: 'New comm was successfully created.' }\n format.json { render json: @new_comm, status: :created, location: @new_comm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @new_comm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @laboratory = Laboratory.new\n @municipalities = Municipality.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @laboratory }\n end\n end",
"def new\n @comp = Comp.new\n\t@games = Game.find_all_by_comp_id(nil)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comp }\n end\n end",
"def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end",
"def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end",
"def new\n @projeto = Projeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projeto }\n end\n end",
"def new\n @collaborator = Collaborator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def new\n @new_city_notification = NewCityNotification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_city_notification }\n end\n end",
"def new\n @message = Message.new(:relation_id => params[:relation_id], :user_id => params[:user_id], :sent => false)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end",
"def create\n @community = Community.new(community_params)\n community_hash = @community.get_from_vk\n existing = Community.includes([:community_histories]).find_by_vk_id(community_hash[:id])\n if !existing.nil?\n @community = existing\n @community.update_history(community_hash)\n else\n @community.set_from_vk(community_hash)\n end\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully added.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @competent = Competent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competent }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end",
"def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end",
"def new\n @partner = Partner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n end\n end",
"def new\n @organism = Organism.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organism }\n end\n end",
"def create\n @community = Community.new(params[:community])\n\n @community.creator = current_user\n \n if @community.save\n @communityuser = current_user.community_users.create(:community => @community,\n :is_communityadmin=> true,\n :is_communitymember=> false\n )\n flash[:notice] = 'Community was successfully created.'\n redirect_to(@community)\n else\n render :action => \"new\"\n end\n\n end",
"def new\n @commitment = Commitment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commitment }\n end\n end",
"def new\n if @network\n @membership = Membership.new(:user_id => current_user.id, :network_id => @network.id)\n else\n @membership = Membership.new(:user_id => current_user.id)\n end\n end",
"def new\n @internships_user = InternshipsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @internships_user }\n end\n end",
"def new\n @mission = Mission.new(:convocationjours => [Convocationjour.new])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mission }\n end\n end",
"def new\n @commemt = Commemt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commemt }\n end\n end",
"def new\n @comment = @network.comments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comment }\n end\n end",
"def new\n @sitecity = Sitecity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitecity }\n end\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n end",
"def new\n @participation = Participation.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participation }\n end\n end",
"def new\n @commodity = Commodity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commodity }\n end\n end",
"def new\n @commodity = Commodity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commodity }\n end\n end",
"def new\n @conversation = Conversation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conversation }\n end\n end",
"def new\n @conversation = Conversation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conversation }\n end\n end",
"def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html { render layout: nil } # new.html.erb\n format.json { render json: @contrato }\n end\n end",
"def new\n @breadcrumb = 'create'\n @entity = Entity.new\n @towns = towns_dropdown\n @provinces = provinces_dropdown\n @zipcodes = zipcodes_dropdown\n @regions = Region.order(:name)\n @countries = Country.order(:name)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end",
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n if(params[:messages])\n @messages = params[:messages]\n end\n @receiver = Receiver.new\n @receivers = Receiver.order('created_at DESC').limit 10\n @cities = City.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @receiver }\n end\n end",
"def new\n @relation = Relation.new\n @personnages = Personnage.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relation }\n end\n end",
"def new\n @comp_info = CompInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comp_info }\n end\n end",
"def new\n @competency = Competency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency }\n end\n end",
"def new\n @mentorship = Mentorship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mentorship }\n end\n end",
"def new\n @work_merge_list = WorkMergeList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @work_merge_list }\n end\n end",
"def new\n @confession = Confession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @confession }\n end\n end",
"def new\n @confession = Confession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @confession }\n end\n end",
"def new\n @neighborhood_topic = NeighborhoodTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neighborhood_topic }\n end\n end",
"def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\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 @person = people_type.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 @partner_project = PartnerProject.new\n @partners = Partner.all\n @projects = Project.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner_project }\n end\n end",
"def new\n @cond = Orbituarysite.find(params[:id]) \n @condolence = @cond.condolences.new\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @condolence }\n end\n end",
"def new\n @recent_activity = RecentActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recent_activity }\n end\n end",
"def new\n @comming_soon = CommingSoon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comming_soon }\n end\n end",
"def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end",
"def new\n @colleague = Colleague.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colleague }\n end\n end",
"def new\n @colleague = Colleague.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colleague }\n end\n end",
"def new\n @contact_partner = ContactPartner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_partner }\n end\n end",
"def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end",
"def new\n @competition = Competition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competition }\n end\n end"
] | [
"0.7959961",
"0.71575254",
"0.7025313",
"0.7009266",
"0.6981981",
"0.695217",
"0.6947142",
"0.68749774",
"0.68749774",
"0.6841163",
"0.6815259",
"0.67953557",
"0.6756949",
"0.6732288",
"0.6707693",
"0.66622007",
"0.6636089",
"0.66074175",
"0.6576715",
"0.65577555",
"0.65519",
"0.65519",
"0.64946127",
"0.6492686",
"0.64803386",
"0.647797",
"0.647308",
"0.6465244",
"0.6460512",
"0.6452273",
"0.6441166",
"0.64247864",
"0.6410522",
"0.640803",
"0.6407396",
"0.6401358",
"0.6390071",
"0.63895255",
"0.6388822",
"0.63728243",
"0.6364428",
"0.6364428",
"0.6352308",
"0.63417405",
"0.63412505",
"0.63362336",
"0.63192505",
"0.63164514",
"0.63140935",
"0.6303992",
"0.62967885",
"0.62860876",
"0.62765604",
"0.6275685",
"0.62646705",
"0.6257714",
"0.62541574",
"0.6248131",
"0.6248131",
"0.62430847",
"0.6242874",
"0.6235631",
"0.6222138",
"0.62141424",
"0.6210656",
"0.620496",
"0.61964935",
"0.6177498",
"0.617103",
"0.6170835",
"0.6170835",
"0.61678356",
"0.6167119",
"0.6167119",
"0.6156943",
"0.6156943",
"0.61388373",
"0.61360496",
"0.61359096",
"0.61328566",
"0.6125922",
"0.61235493",
"0.6109736",
"0.6107269",
"0.60975945",
"0.6090441",
"0.6090441",
"0.60839796",
"0.60827035",
"0.6075499",
"0.6074527",
"0.6071922",
"0.6071321",
"0.6070565",
"0.6065478",
"0.6064523",
"0.6064523",
"0.60643035",
"0.6057829",
"0.6057829"
] | 0.7494975 | 1 |
POST /communities POST /communities.json | def create
@community = Community.new(params[:community])
respond_to do |format|
if @community.save
format.html { redirect_to @community, notice: 'Community was successfully created.' }
format.json { render json: @community, status: :created, location: @community }
else
format.html { render action: "new" }
format.json { render json: @community.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n if @community.save\n render :show, status: :created, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render action: 'show', status: :created, location: @community }\n else\n format.html { render action: 'new' }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def create\n @community_community = Community::Community.new(community_community_params)\n\n respond_to do |format|\n if @community_community.save\n format.html { redirect_to @community_community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community_community }\n else\n format.html { render :new }\n format.json { render json: @community_community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end",
"def index\n @communities = Community.all\n\n render json: @communities.to_json(include: {posts: {include: :replies} })\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to community_home_url(:subdomain => @community.subdomain), notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n end",
"def create\n @community = Community.new(community_params)\n #raise community_params.inspect\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Сообщество успешно создано' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n flash[:notice] = 'Community was successfully created.' if @community.save\n respond_with @community\n end",
"def profile_communities\n messages = MessageQuery.new(current_user).communities(\n params[:limit], params[:offset]\n )\n\n render json: {\n messages: messages.as_json(\n methods: %i[\n avatar_url image_urls video_urls like_by_user legendary_by_user user\n text_with_links post_url expire_at has_expired\n ]\n )\n }, status: 200\n end",
"def community_params\n params.require(:community).permit(:name, :num_of_members)\n end",
"def index\n # @user = User.find(params[:user_id])\n # @communities = @user.communities\n @communities = Community.all\n end",
"def community_community_params\n params.require(:community).permit(:title, :participants, :coordinates, :center, :geometry_type, :agree, :color, :icon, :link, :feature_id)\n end",
"def index\n @communities = Community.all\n respond_with @communities\n end",
"def create\n @membership = Membership.new(membership_params)\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to community_memberships_path(@community), notice: 'Community membership was successfully created.' }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = Community.search(params[:search], params[:page])\n respond_with(@communities)\n end",
"def create\n @community = Community.new(params[:community])\n\n @community.creator = current_user\n \n if @community.save\n @communityuser = current_user.community_users.create(:community => @community,\n :is_communityadmin=> true,\n :is_communitymember=> false\n )\n flash[:notice] = 'Community was successfully created.'\n redirect_to(@community)\n else\n render :action => \"new\"\n end\n\n end",
"def community_params\n params.require(:community).permit(:name, :about, :link, :rss, :tag_list, :category_list)\n end",
"def community_params\n params.require(:community).permit(:name, :location, :scope, :verified)\n end",
"def community_params\n params.require(:community).permit(:name)\n end",
"def community_params\n params.require(:community).permit(:name, :owner_id, :description)\n end",
"def create\n @community = Community.new(community_params)\n community_hash = @community.get_from_vk\n existing = Community.includes([:community_histories]).find_by_vk_id(community_hash[:id])\n if !existing.nil?\n @community = existing\n @community.update_history(community_hash)\n else\n @community.set_from_vk(community_hash)\n end\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully added.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end",
"def community_params\n params.require(:community).permit(:name, :detail)\n end",
"def create\n\t@community= Community.new(params[:community])\n\t if @community.save\n\trender ('create')\n else \n\trender ('new')\n end\nend",
"def community_params\n params.require(:community).permit(:community_name, :community_visibility, :archive, community_disciplines_attributes: [:discipline_id, :community_id, :id, :_destroy],\n community_users_attributes: [:link_type, :user_id, :community_id, :id, :_destroy])\n end",
"def community_params\n params.require(:community).permit(:user_id, :name, :description, :approved, :parent_community_id, :image, :url_name)\n end",
"def community_params\n params.require(:community).permit(:name,\n :subdomain,\n :owner_id,\n :photo,\n :remote_photo_url,\n :is_active,\n { :user_ids => [] },\n digital_addresses_attributes: [:id, :name, :address_type, :url],\n address_attributes: [:id, :street_line_1, :street_line_2, :city, :state, :zip])\n end",
"def create\n @topic = current_user.communities.find(params[:community_id]).topics.new(create_params)\n Topic.checkParams(params, current_user) && @topic.save\n respond_with(@topic)\n end",
"def create\n @community_post = CommunityPost.new(community_post_params)\n\n respond_to do |format|\n if @community_post.save\n format.html { redirect_to @community_post, notice: 'Community post was successfully created.' }\n format.json { render :show, status: :created, location: @community_post }\n else\n format.html { render :new }\n format.json { render json: @community_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @community_communities = Community::Community.all\n end",
"def community_params\n params.require(:community).permit(:member_count, :title, :subtitle, :banner, :official)\n end",
"def index\n @communities = current_user.communities.all\n\n @page_title = \"Communities\"\n @page_subtitle = \"Uniting People and Companies\"\n @page_description = \"\"\n end",
"def index\n @communities = Community.paginate(page: params[:page])\n respond_to do |format|\n # format.html # index.html.erb\n format.xml { render xml: @communities }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end",
"def create\n # @community = Community.new(community_params)\n @community = Community.create name: params[:community][:name], owner_id: current_user.id, image: params[:community][:image]\n\n respond_to do |format|\n if @community.save\n # format.html { redirect_to community_url(@community), notice: 'Community was successfully created.' }\n format.js { render js: \"window.location.href='\" + community_path(@community) + \"'\" }\n format.json { render :show, status: :created, location: @community }\n else\n # format.html { render :new }\n # format.js { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @community = current_user.own_communities.find(params[:id])\n flash[:notice] = 'Community was successfully updated.' if @community.update_attributes(update_params)\n respond_with(@community)\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 community_params\n params.require(:community).permit([:screen_name, :monitor_members, :disabled])\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @communications = Communication.paginate(:page => params[:page], :per_page => 2)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @communications }\n end\n end",
"def index\n @memberships = @community.memberships\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def create\n @community_question = CommunityQuestion.new(community_question_params)\n\n respond_to do |format|\n if @community_question.save\n format.html { redirect_to @community_question, notice: 'Community question was successfully created.' }\n format.json { render :show, status: :created, location: @community_question }\n else\n format.html { render :new }\n format.json { render json: @community_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tuser = User.find(params[:user_id])\n net_cat = NetworkCategory.find(params[:net_cat])\n network = Network.new(name: params[:network_name], desc: params[:desc],\n network_type: params[:network_type])\n network.user = user\n network.network_category = net_cat\n @status = network.save!\n respond_to do |format|\n format.json\n end\n end",
"def create\n @communication = Communication.new(params[:communication])\n\n respond_to do |format|\n if @communication.save\n format.html { redirect_to communications_path, notice: 'Communication was successfully created.' }\n format.json { render json: @communication, status: :created, location: @communication }\n else\n format.html { render action: \"new\" }\n format.json { render json: @communication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community_topic = CommunityTopic.new(params[:community_topic])\n\n respond_to do |format|\n if @community_topic.save\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully created.' }\n format.json { render json: [@community, @community_topic], status: :created, location: @community_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community_section = CommunitySection.new(community_section_params)\n\n respond_to do |format|\n if @community_section.save\n format.html { redirect_to @community_section, notice: 'Community section was successfully created.' }\n format.json { render :show, status: :created, location: @community_section }\n else\n format.html { render :new }\n format.json { render json: @community_section.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n # @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def community_post_params\n params.require(:community_post).permit(:user_id, :community_id, :type, :content)\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Сообщество успешно удалено' }\n format.json { head :no_content }\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 new\n @community = Community.new\n respond_with(@community)\n end",
"def create\r\n @comunne = Comunne.new(comunne_params)\r\n\r\n respond_to do |format|\r\n if @comunne.save\r\n format.html { redirect_to @comunne, notice: 'Comunne was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @comunne }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @comunne.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n\n reviews = []\n params[:scores].keys.each{ |name|\n score = params[:scores][name]\n peer_review = PeerReview.new(name:name, score:score, miniproject_id:params[:project][:id])\n peer_review.save\n reviews << peer_review\n }\n\n render json: reviews\n\n end",
"def create\n @communication = Communication.new(communication_params)\n\n respond_to do |format|\n if @communication.save\n format.html { redirect_to @communication, notice: 'Záznam komunikácie bol úspešne vytvorený.' }\n format.json { render :show, status: :created, location: @communication }\n else\n format.html { render :new }\n format.json { render json: @communication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(create_params)\n @community[:owner_id] = current_user.id\n Community.createActionAvailableTime(current_user) > 30.seconds and @community.save\n respond_with(@community)\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_district_communities_url }\n format.json { head :no_content }\n end\n end",
"def create\n @graphium_city = Graphium::City.new(graphium_city_params)\n\n respond_to do |format|\n if @graphium_city.save\n format.html { redirect_to @graphium_city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @graphium_city }\n else\n format.html { render :new }\n format.json { render json: @graphium_city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community_user = CommunityUser.new(create_params)\n @community_user.user_id = current_user.id\n flash[:notice] = 'Community user was successfully created.' if @community_user.save\n respond_with(@community_user)\n end",
"def update\n if @community.update(community_params)\n render :show, status: :ok, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def create\n @network = Network.new(network_params)\n\n respond_to do |format|\n if @network.save\n format.html { redirect_to @network, notice: 'Network was successfully created.' }\n format.json { render :show, status: :created, location: @network }\n format.js {\n @networks = Network.all\n render :create\n }\n else\n format.html { render :new }\n format.json { render json: @network.errors, status: :unprocessable_entity }\n format.js {\n @networks = Network.all\n render :create\n }\n end\n end\n end",
"def create\n @commision = Commision.new(commision_params)\n\n respond_to do |format|\n if @commision.save\n format.html { redirect_to commisions_path, notice: 'Commision was successfully created.' }\n format.json { render :show, status: :created, location: @commision }\n else\n format.html { render :new }\n format.json { render json: @commision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @laboratory = Laboratory.new(params[:laboratory])\n @municipalities = Municipality.all\n respond_to do |format|\n if @laboratory.save\n format.html { redirect_to @laboratory, notice: 'Laboratory was successfully created.' }\n format.json { render json: @laboratory, status: :created, location: @laboratory }\n else\n format.html { render action: \"new\" }\n format.json { render json: @laboratory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @social_networking = Admin::SocialNetworking.new(social_networking_params)\n\n if @social_networking.save\n render json: @social_networking, status: :created\n else\n render json: @social_networking.errors, status: :unprocessable_entity\n end\n end",
"def community_params\n params.require(:community).permit(:name, :image, :at_the_beginning, :domain)\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def create\n @community_service = CommunityService.new(community_service_params)\n\n create_one_user_events\n\n respond_to do |format|\n if @community_service.save\n format.html { redirect_to @community_service, notice: 'Community service was successfully created.' }\n format.json { render :show, status: :created, location: @community_service }\n else\n format.html { render :new }\n format.json { render json: @community_service.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @social_network = SocialNetwork.new(params[:social_network])\n\n respond_to do |format|\n if @social_network.save\n format.html { redirect_to @social_network, notice: 'Social network was successfully created.' }\n format.json { render json: @social_network, status: :created, location: @social_network }\n else\n format.html { render action: \"new\" }\n format.json { render json: @social_network.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n render json: @community\n end",
"def update\n respond_to do |format|\n if @community.update(params[:community].permit(:name, :about, :link, :rss, :tag_list, :category_list))\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n participants = make_participants\n @existing_chat_thread = current_user.chat_threads.where(\"participants = ?\", participants.to_yaml)\n if @existing_chat_thread.present?\n render json: @existing_chat_thread.first, serializer: Rest::ChatThreadSerializer\n return\n end\n @chat_thread = current_user.chat_threads.build({participants: participants})\n ActiveRecord::Base.transaction do\n @chat_thread.save!\n participants.each do |participant|\n ChatStatus.create(chat_thread_id: @chat_thread.id, user_id: participant)\n end\n end\n render json: @chat_thread, status: :created, serializer: Rest::ChatThreadSerializer\n rescue => e\n render json: @chat_thread.errors.full_messages, status: :unprocessable_entity\n end",
"def create\n @network = current_user.networks.new(network_params)\n\n respond_to do |format|\n if @network.save\n format.html { redirect_to @network, notice: t(:nertwork_created_ok) }\n format.json { render action: 'show', status: :created, location: @network }\n else\n format.html { render action: 'new' }\n format.json { render json: @network.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @community = Community.find(params[:id])\n @rcommunities = Community.relatedCommunities(params[:id])\n @posts = Post.getCommunityPosts(params)\n respond_with(@community)\n end",
"def create\n @user = current_user\n @internship = @user.internships.build(params[:internship])\n #@internship = Internship.new(params[:internship])\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to @internship, notice: 'Internship was successfully created.' }\n format.json { render json: @internship, status: :created, location: @internship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def my\n @membercommunities = current_user.communities.where(:community_users=>{:is_communitymember=>true})\n\n @owncommunities = current_user.communities.where(:community_users=>{:is_communityadmin=>true})\n end",
"def dog_community_params\n # params.fetch(:dog_community, {})\n params.require(:dog_community).permit(:dog_id, :dog_park_id)\n end",
"def park_community_params\n # params.fetch(:park_community, {})\n params.require(:park_community).permit()\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def create_from_candidates\n authorize @competition.competitors.new\n\n heat = params[:heat].to_i\n competitors = params[:competitors]\n begin\n LaneAssignment.transaction do\n competitors.each do |_, competitor|\n reg = Registrant.find_by!(bib_number: competitor[:bib_number])\n lane_assignment = LaneAssignment.new(registrant_id: reg.id, lane: competitor[:lane].to_i, heat: heat, competition: @competition)\n lane_assignment.allow_competitor_auto_creation = true\n lane_assignment.save!\n end\n end\n flash[:notice] = \"Created Lane Assignments & Competitors\"\n rescue StandardError => e\n flash[:alert] = \"Error creating lane assignments/competitors #{e}\"\n end\n redirect_to competition_competitors_path(@competition)\n end",
"def index\n @communicates = Communicate.all\n @communicate = Communicate.new\n end",
"def update\n @community = Community.find(params[:id])\n\n respond_to do |format|\n if @community.update_attributes(params[:community])\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @new_comm = NewComm.new(params[:new_comm])\n\n respond_to do |format|\n if @new_comm.save\n format.html { redirect_to @new_comm, notice: 'New comm was successfully created.' }\n format.json { render json: @new_comm, status: :created, location: @new_comm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @new_comm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to community_url(@community), notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @committees_voivodeship = CommitteesVoivodeship.new\n\t@committees = Committee.all.map do |commi|\n\t\t[commi.id]\n\tend\n\t@voivodeships = Voivodeship.all.map do |voi|\n\t\t[voi.id]\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @committees_voivodeship }\n end\n end",
"def create\n\n @post = Post.new(post_params)\n\n @post.user = current_user\n @post.community = @community\n if @post.save\n flash[:success] = \"Post was created succesfully\"\n redirect_to @community\n else\n render 'new'\n end\n\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.70707315",
"0.66136265",
"0.6542512",
"0.6542512",
"0.65264356",
"0.6512408",
"0.6478941",
"0.64413625",
"0.642376",
"0.6319061",
"0.6268977",
"0.62562805",
"0.62562805",
"0.6253957",
"0.6224876",
"0.61537445",
"0.6138845",
"0.6112662",
"0.6100711",
"0.6098621",
"0.6066858",
"0.6021744",
"0.60022664",
"0.598996",
"0.59717023",
"0.5957461",
"0.5890849",
"0.588703",
"0.5865174",
"0.58644116",
"0.58559066",
"0.583782",
"0.58246",
"0.5785719",
"0.57828325",
"0.5782244",
"0.578129",
"0.5710137",
"0.5707873",
"0.5703454",
"0.5647919",
"0.56399053",
"0.5622833",
"0.5509579",
"0.55039704",
"0.5495767",
"0.549553",
"0.54881805",
"0.54863447",
"0.54858136",
"0.54858136",
"0.54858136",
"0.54858136",
"0.5483125",
"0.54667884",
"0.54663134",
"0.5463525",
"0.54611826",
"0.5451804",
"0.5443314",
"0.54374343",
"0.54164076",
"0.5409373",
"0.53946346",
"0.53897125",
"0.5362407",
"0.53599644",
"0.53588396",
"0.5331306",
"0.53203404",
"0.5312117",
"0.5285757",
"0.5278152",
"0.5265141",
"0.5254537",
"0.52543414",
"0.5236595",
"0.5233165",
"0.5229678",
"0.52236396",
"0.52058566",
"0.5201512",
"0.5198263",
"0.51960987",
"0.51899123",
"0.51850945",
"0.5166576",
"0.51645255",
"0.51644397",
"0.5160523",
"0.5160523",
"0.51460093",
"0.513653",
"0.5114218",
"0.5108295",
"0.5105192",
"0.5104344",
"0.51029813",
"0.5101938",
"0.5101938"
] | 0.6584072 | 2 |
PUT /communities/1 PUT /communities/1.json | def update
@community = Community.find(params[:id])
respond_to do |format|
if @community.update_attributes(params[:community])
format.html { redirect_to @community, notice: 'Community was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @community.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @community = current_user.own_communities.find(params[:id])\n flash[:notice] = 'Community was successfully updated.' if @community.update_attributes(update_params)\n respond_with(@community)\n end",
"def update\n if @community.update(community_params)\n render :show, status: :ok, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @community.update(params[:community].permit(:name, :about, :link, :rss, :tag_list, :category_list))\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @community = Community.find(params[:id])\n\n respond_to do |format|\n if @community.update_attributes(params[:community])\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to community_url(@community), notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Community was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n flash[:notice] = 'Community was successfully updated.' if @community.update(community_params)\n respond_with @community\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to @community, notice: 'Сообщество успешно обновлено' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community.update(community_params)\n format.html { redirect_to community_home_url(:subdomain => @community.subdomain), notice: 'Community was successfully updated.' }\n format.json { render :show, status: :ok, location: @community }\n else\n format.html { render :edit }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def update\n @community = Community.where(street: params[:subscriber][:community]).first\n @subscriber.community = @community\n respond_to do |format|\n if @subscriber.update_attributes(:community => @community)\n format.html { redirect_to \"/subscribers/new?lon=#{params[:lon]}&lat=#{params[:lat]}\", notice: \"您当前绑定社区为: #{@community.street}.\" }\n format.json { render :show, status: :ok, location: @subscriber }\n else\n format.html { render :edit }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n end",
"def update\n @community = Community.find(params[:id])\n\n\n if @community.update_attributes(params[:community])\n flash[:notice] = 'Community was successfully updated.'\n redirect_to(@community)\n \n else\n render :action => \"edit\" \n end\n \n end",
"def set_community\n @community = Community.where(id: params[:community_id]).first\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def set_community_community\n @community_community = Community::Community.find(params[:id])\n end",
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def community_params\n params.require(:community).permit(:name, :owner_id, :description)\n end",
"def create\n @community = Community.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, location: @community }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @community_service.update(community_service_params)\n format.html { redirect_to @community_service, notice: 'Community service was successfully updated.' }\n format.json { render :show, status: :ok, location: @community_service }\n else\n format.html { render :edit }\n format.json { render json: @community_service.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def create\n @community = Community.new(community_params)\n community_hash = @community.get_from_vk\n existing = Community.includes([:community_histories]).find_by_vk_id(community_hash[:id])\n if !existing.nil?\n @community = existing\n @community.update_history(community_hash)\n else\n @community.set_from_vk(community_hash)\n end\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully added.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_community\n @community = Community.friendly.find(params[:community_id])\n end",
"def community_params\n params.require(:community).permit(:name)\n end",
"def create\n @community = Community.new(community_params)\n\n if @community.save\n render :show, status: :created, location: @community\n else\n render json: @community.errors, status: :unprocessable_entity\n end\n end",
"def index\n # @user = User.find(params[:user_id])\n # @communities = @user.communities\n @communities = Community.all\n end",
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @communities = Community.all\n end",
"def index\n @communities = Community.all\n end",
"def community_params\n params.require(:community).permit(:name, :num_of_members)\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render action: 'show', status: :created, location: @community }\n else\n format.html { render action: 'new' }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def community_params\n params.require(:community).permit(:name, :detail)\n end",
"def set_community_update\n @community_update = Community::Update.find(params[:id])\n end",
"def community_community_params\n params.require(:community).permit(:title, :participants, :coordinates, :center, :geometry_type, :agree, :color, :icon, :link, :feature_id)\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def create\n @community_community = Community::Community.new(community_community_params)\n\n respond_to do |format|\n if @community_community.save\n format.html { redirect_to @community_community, notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community_community }\n else\n format.html { render :new }\n format.json { render json: @community_community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @community = Community.find(params[:id]) \n if @community.update_attributes(params[:community])\n render ('update')\n else \nrender ('edit')\n end\nend",
"def update\n respond_to do |format|\n if @community_section.update(community_section_params)\n format.html { redirect_to @community_section, notice: 'Community section was successfully updated.' }\n format.json { render :show, status: :ok, location: @community_section }\n else\n format.html { render :edit }\n format.json { render json: @community_section.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = Community.all\n respond_with @communities\n end",
"def update\n respond_to do |format|\n if @membership.update(membership_params)\n format.html { redirect_to community_memberships_path(@community), notice: 'Community membership was successfully updated.' }\n format.json { render :show, status: :ok, location: @membership }\n else\n format.html { render :edit }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def community_params\n params.require(:community).permit(:name, :location, :scope, :verified)\n end",
"def community_params\n params.require(:community).permit(:user_id, :name, :description, :approved, :parent_community_id, :image, :url_name)\n end",
"def community_params\n params.require(:community).permit(:name, :about, :link, :rss, :tag_list, :category_list)\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_district_communities_url }\n format.json { head :no_content }\n end\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def community_params\n params.require(:community).permit(:community_name, :community_visibility, :archive, community_disciplines_attributes: [:discipline_id, :community_id, :id, :_destroy],\n community_users_attributes: [:link_type, :user_id, :community_id, :id, :_destroy])\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @community = Community.new(community_params)\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to community_home_url(:subdomain => @community.subdomain), notice: 'Community was successfully created.' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @community = Community.find(params[:id])\nend",
"def community_update_params\n params.require(:community_update).permit(:content, :trail_id)\n end",
"def destroy\n # @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @community = Community.new(community_params)\n flash[:notice] = 'Community was successfully created.' if @community.save\n respond_with @community\n end",
"def community_params\n params.require(:community).permit(:member_count, :title, :subtitle, :banner, :official)\n end",
"def create\n @community = Community.new(community_params)\n #raise community_params.inspect\n respond_to do |format|\n if @community.save\n format.html { redirect_to @community, notice: 'Сообщество успешно создано' }\n format.json { render :show, status: :created, location: @community }\n else\n format.html { render :new }\n format.json { render json: @community.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n if @community_topic.update_attributes(params[:community_topic])\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_park_community\n @park_community = ParkCommunity.find(params[:id])\n end",
"def set_community_service\n @community_service = CommunityService.find(params[:id])\n end",
"def set_community\n #community = Community.find(params[:id])\n @community = Community.includes(community_disciplines: {discipline: {discipline_sections: :marks}}, community_users: :user).find(params[:id])\n #@community = Community.includes(community_disciplines: {discipline: {discipline_sections: {marks: :student}}}, ).find(params[:id])\n end",
"def set_community_section\n @community_section = CommunitySection.find(params[:id])\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Сообщество успешно удалено' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @community_post.update(community_post_params)\n format.html { redirect_to @community_post, notice: 'Community post was successfully updated.' }\n format.json { render :show, status: :ok, location: @community_post }\n else\n format.html { render :edit }\n format.json { render json: @community_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t@community= Community.new(params[:community])\n\t if @community.save\n\trender ('create')\n else \n\trender ('new')\n end\nend",
"def update\n respond_to do |format|\n if @community_question.update(community_question_params)\n format.html { redirect_to @community_question, notice: 'Community question was successfully updated.' }\n format.json { render :show, status: :ok, location: @community_question }\n else\n format.html { render :edit }\n format.json { render json: @community_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n \n redirect_to(my_communities_url, :notice => 'Community was successfully deleted.')\n \n end",
"def index\n @community_communities = Community::Community.all\n end",
"def update\n @communication = Communication.find(params[:id])\n\n respond_to do |format|\n if @communication.update_attributes(params[:communication])\n format.html { redirect_to communications_path, notice: 'Communication was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @communication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def community_params\n params.require(:community).permit(:name,\n :subdomain,\n :owner_id,\n :photo,\n :remote_photo_url,\n :is_active,\n { :user_ids => [] },\n digital_addresses_attributes: [:id, :name, :address_type, :url],\n address_attributes: [:id, :street_line_1, :street_line_2, :city, :state, :zip])\n end",
"def update\r\n respond_to do |format|\r\n if @comunne.update(comunne_params)\r\n format.html { redirect_to @comunne, notice: 'Comunne 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: @comunne.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def index\n @communities = @district.communities.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @communities }\n end\n end",
"def update\n if @social_networking.update(social_networking_params)\n render json: @social_networking, status: :ok\n else\n render json: @social_networking.errors, status: :unprocessable_entity\n end\n end",
"def create\n @community = Community.new(params[:community])\n\n @community.creator = current_user\n \n if @community.save\n @communityuser = current_user.community_users.create(:community => @community,\n :is_communityadmin=> true,\n :is_communitymember=> false\n )\n flash[:notice] = 'Community was successfully created.'\n redirect_to(@community)\n else\n render :action => \"new\"\n end\n\n end",
"def update\n respond_to do |format|\n if @internship_committee.update(internship_committee_params)\n format.html { redirect_to @internship_committee, notice: 'Internship committee was successfully updated.' }\n format.json { render :show, status: :ok, location: @internship_committee }\n else\n format.html { render :edit }\n format.json { render json: @internship_committee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @communities = Community.all\n\n render json: @communities.to_json(include: {posts: {include: :replies} })\n end",
"def new\n @community = Community.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community }\n end\n end",
"def show\n render json: @community\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @internship = Internship.find(params[:id])\n\n respond_to do |format|\n if @internship.update_attributes(params[:internship])\n format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @internship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_replace_community_list_with_http_info(tier_0_id, community_list_id, community_list, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier0GatewaysRoutingCommunityListsApi.create_or_replace_community_list ...'\n end\n # verify the required parameter 'tier_0_id' is set\n if @api_client.config.client_side_validation && tier_0_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_0_id' when calling PolicyNetworkingConnectivityTier0GatewaysRoutingCommunityListsApi.create_or_replace_community_list\"\n end\n # verify the required parameter 'community_list_id' is set\n if @api_client.config.client_side_validation && community_list_id.nil?\n fail ArgumentError, \"Missing the required parameter 'community_list_id' when calling PolicyNetworkingConnectivityTier0GatewaysRoutingCommunityListsApi.create_or_replace_community_list\"\n end\n # verify the required parameter 'community_list' is set\n if @api_client.config.client_side_validation && community_list.nil?\n fail ArgumentError, \"Missing the required parameter 'community_list' when calling PolicyNetworkingConnectivityTier0GatewaysRoutingCommunityListsApi.create_or_replace_community_list\"\n end\n # resource path\n local_var_path = '/infra/tier-0s/{tier-0-id}/community-lists/{community-list-id}'.sub('{' + 'tier-0-id' + '}', tier_0_id.to_s).sub('{' + 'community-list-id' + '}', community_list_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(community_list)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'CommunityList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier0GatewaysRoutingCommunityListsApi#create_or_replace_community_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @community = Community.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community }\n end\n end",
"def update\n if @city.update(city_params)\n render json: @city\n # 'city was successfully updated.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def set_dog_community\n @dog_community = DogCommunity.find(params[:id])\n end",
"def set_community\n @community = Community.find(params[:id])\n if !(@user_permission_ids.include? @community.permission_id)\n insufficient_permissions\n end\n end",
"def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.70225936",
"0.67517334",
"0.67264223",
"0.6724205",
"0.6630993",
"0.65974313",
"0.65974313",
"0.65297955",
"0.6431997",
"0.6372459",
"0.6371188",
"0.6314842",
"0.6314842",
"0.62161005",
"0.6210379",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6131868",
"0.6031552",
"0.6000155",
"0.5985095",
"0.5981667",
"0.594382",
"0.5934644",
"0.59261376",
"0.59236693",
"0.59137124",
"0.590027",
"0.58855027",
"0.5885363",
"0.5865916",
"0.58651096",
"0.58543926",
"0.58543926",
"0.5854145",
"0.5850751",
"0.5843357",
"0.5843357",
"0.5842359",
"0.5820476",
"0.58158517",
"0.57861704",
"0.57664406",
"0.575042",
"0.5722424",
"0.57201403",
"0.57196057",
"0.57183975",
"0.5708562",
"0.5674554",
"0.5670437",
"0.56584984",
"0.56411505",
"0.5623145",
"0.5623145",
"0.5623145",
"0.5623145",
"0.56158376",
"0.5598164",
"0.5594809",
"0.558529",
"0.5580565",
"0.5570775",
"0.5526702",
"0.55184513",
"0.5506132",
"0.54900724",
"0.5485086",
"0.5458208",
"0.5458152",
"0.54299074",
"0.5421487",
"0.5406575",
"0.54025215",
"0.53931254",
"0.53779083",
"0.5377568",
"0.5368529",
"0.5361739",
"0.53611946",
"0.53430367",
"0.5332011",
"0.5300857",
"0.5299312",
"0.52982837",
"0.5298173",
"0.52945167",
"0.52945167",
"0.5279406",
"0.52764934",
"0.52760583",
"0.5257002",
"0.5241553",
"0.5238171"
] | 0.67545354 | 1 |
DELETE /communities/1 DELETE /communities/1.json | def destroy
@community = Community.find(params[:id])
@community.destroy
respond_to do |format|
format.html { redirect_to communities_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_district_communities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Сообщество успешно удалено' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url, notice: 'Community was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n \n redirect_to(my_communities_url, :notice => 'Community was successfully deleted.')\n \n end",
"def destroy\n @communication = Communication.find(params[:id])\n @communication.destroy\n\n respond_to do |format|\n format.html { redirect_to communications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n end",
"def destroy\n @community_community.destroy\n respond_to do |format|\n format.js\n format.json { head :no_content }\n end\n end",
"def delete\n if @community.update_attributes(published: false)\n # Yeah, I really don't care if this fails. It's just convenience:\n @community.collection.update_attributes(published: false) rescue nil\n begin\n @community.remove_member(current_user)\n rescue EOL::Exceptions::ObjectNotFound => e\n flash[:error] = I18n.t(:could_not_find_user)\n end\n EOL::GlobalStatistics.decrement('communities')\n log_action(:delete)\n # TODO - it might make sense (?) to remove this community from any collection_items that once pointed to it...\n # that would remove it from watchlists and the like, though, and I don't know if that's wise (since then they\n # wouldn't see the delete log item).\n flash[:notice] = I18n.t(:community_destroyed)\n else\n flash[:error] = I18n.t(:community_not_destroyed_error)\n end\n redirect_to(community_newsfeed_path(@community), status: :moved_permanently)\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to @community, notice: 'Community membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community_service.destroy\n respond_to do |format|\n format.html { redirect_to community_services_url, notice: 'Community service was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community.destroy\n flash[:notice] = 'Community was successfully destroyed.'\n respond_with @community\n end",
"def delete \n\t\t@community = Community.find(params[:id])\n\t\trescue ActiveRecord::RecordNotFound\n\tend",
"def destroy\n @community_section.destroy\n respond_to do |format|\n format.html { redirect_to community_sections_url, notice: 'Community section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @comunne.destroy\r\n respond_to do |format|\r\n format.html { redirect_to comunnes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @colaboration = Colaboration.find(params[:id])\n @colaboration.destroy\n\n respond_to do |format|\n format.html { redirect_to colaborations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collaboration.destroy\n respond_to do |format|\n format.html { redirect_to collaborations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_networking.destroy\n\n render json: @social_networking, status: :ok\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_url }\n format.json { head :no_content }\n end\n end",
"def destroy \n\t\tCommunity.find(params[:id]).destroy\n\t\trescue ActiveRecord::RecordNotFound\n\t\tredirect_to(:action => 'list')\n\n\tend",
"def destroy\n @graphium_city.destroy\n respond_to do |format|\n format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @communicate.destroy\n respond_to do |format|\n format.html { redirect_to communicates_url, notice: 'Communicate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community_post.destroy\n respond_to do |format|\n format.html { redirect_to community_posts_url, notice: 'Community post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @network_connection = NetworkConnection.find(params[:id])\n @network_connection.destroy\n\n respond_to do |format|\n format.html { redirect_to network_connections_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @community_topic = CommunityTopic.find(params[:id])\n @community_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to community_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship_committee.destroy\n respond_to do |format|\n format.html { redirect_to internship_committees_url, notice: 'Internship committee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comitemember.destroy\n respond_to do |format|\n format.html { redirect_to comitemembers_url, notice: 'Comitemember was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comite.destroy\n respond_to do |format|\n format.html { redirect_to comites_url, notice: 'Comite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_network = SocialNetwork.find(params[:id])\n @social_network.destroy\n\n respond_to do |format|\n format.html { redirect_to social_networks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @committees_voivodeship = CommitteesVoivodeship.find(params[:id])\n @committees_voivodeship.destroy\n\n respond_to do |format|\n format.html { redirect_to committees_voivodeships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @communication_post.destroy\n respond_to do |format|\n format.html { redirect_to root_path(communication: true) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collaboration.destroy\n respond_to do |format|\n format.html { redirect_to collaborations_url, notice: 'Collaboration was successfully destroyed.' }\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 destroy\n @comunity.destroy\n respond_to do |format|\n format.html { redirect_to comunities_url, notice: 'Comunity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @communication.destroy\n respond_to do |format|\n flash[:notice] = 'Záznam komunikácie bol úspešne zmazaný.'\n #format.html { redirect_to communications_url, notice: 'Záznam komunikácie bol úspešne zmazaný.' }\n format.html { redirect_back(fallback_location: communications_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conn = current_user.conns.find(params[:id])\n @conn.destroy\n\n respond_to do |format|\n format.html { redirect_to conns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @commision.destroy\n respond_to do |format|\n format.html { redirect_to commisions_url, notice: 'Commision was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @society_member_ship.destroy\n respond_to do |format|\n format.html { redirect_to society_member_ships_url, notice: 'Society member ship was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n\n respond_to do |format|\n format.html { redirect_to networks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n respond_to do |format|\n format.html { redirect_to networks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n respond_to do |format|\n format.html { redirect_to networks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n respond_to do |format|\n format.html { redirect_to networks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #TODO use deleteflag\n @community_user = CommunityUser.available_object(params[:id], current_user.id)\n @community_user.destroy\n respond_with(@community_user)\n end",
"def destroy\r\n\r\n @connection_request = ConnectionRequest.find(params[:id])\r\n @connection_request.destroy\r\n\r\n render json: {:status => :success, :data => @connection_request}\r\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",
"def destroy\n @community_health_station = CommunityHealthStation.find(params[:id])\n @community_health_station.destroy\n\n respond_to do |format|\n format.html { redirect_to community_health_stations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @localisation = Localisation.find(params[:id])\n @localisation.destroy\n\n respond_to do |format|\n format.html { redirect_to localisations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community_question.destroy\n respond_to do |format|\n format.html { redirect_to community_questions_url, notice: 'Community question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @discipleship.destroy\n respond_to do |format|\n format.html { redirect_to discipleships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @voivodeship = Voivodeship.find(params[:id])\n @voivodeship.destroy\n\n respond_to do |format|\n format.html { redirect_to voivodeships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member_commision.destroy\n respond_to do |format|\n format.html { redirect_to member_commisions_url, notice: 'Member commision was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network_action.destroy\n respond_to do |format|\n format.html { redirect_to network_actions_url, notice: 'Network action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_network.destroy\n respond_to do |format|\n format.html { redirect_to admin_social_networks_url, notice: 'Social network was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_contract = SocialContract.find(params[:id])\n @social_contract.destroy\n\n respond_to do |format|\n format.html { redirect_to social_contracts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @new_comm = NewComm.find(params[:id])\n @new_comm.destroy\n\n respond_to do |format|\n format.html { redirect_to new_comms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @internship = Internship.find(params[:id])\n @internship.destroy\n\n respond_to do |format|\n format.html { redirect_to(internships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @intern = Intern.find(params[:id])\n @intern.destroy\n\n respond_to do |format|\n format.html { redirect_to interns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to country_state_cities_url, :notice => t('controller_message.deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_site_url(@membership.site) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conversation = Conversation.find(params[:id])\n @conversation.destroy\n\n respond_to do |format|\n format.html { redirect_to conversations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chatline = Chatline.find(params[:id])\n @chatline.destroy\n\n respond_to do |format|\n format.html { redirect_to chatlines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commanet.destroy\n respond_to do |format|\n format.html { redirect_to commanets_url, notice: 'Commanet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @sitecity = Sitecity.find_by_url(params[:id])\n @sitecity.destroy\n\n respond_to do |format|\n format.html { redirect_to sitecities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mission_membership.destroy\n respond_to do |format|\n format.html { redirect_to mission_memberships_url, notice: 'Mission membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commtent1 = Commtent1.find(params[:id])\n @commtent1.destroy\n\n respond_to do |format|\n format.html { redirect_to commtent1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_phone_connection = MessagePhoneConnection.find(params[:id])\n @message_phone_connection.destroy\n\n respond_to do |format|\n format.html { redirect_to message_phone_connections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n respond_to do |format|\n format.html {\n flash[:notice] = 'Network was successfully destroyed.'\n index\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @convite.destroy\n respond_to do |format|\n format.html { redirect_to convites_url, notice: 'Convite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @networking.destroy\n respond_to do |format|\n format.html { redirect_to networkings_url, notice: 'Networking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @monitorship = Monitorship.find(params[:id])\n @monitorship.destroy\n\n respond_to do |format|\n format.html { redirect_to monitorships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @voivodship_committee = VoivodshipCommittee.find(params[:id])\n @voivodship_committee.destroy\n\n respond_to do |format|\n format.html { redirect_to voivodship_committees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @campaign_commitee.destroy\n respond_to do |format|\n format.html { redirect_to campaign_commitees_url, notice: 'Campaign commitee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @colaborador.destroy\n respond_to do |format|\n format.html { redirect_to colaboradors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to connections_url, notice: \"Connection was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @colaboradore\n @colaboradore.destroy\n respond_to do |format|\n format.html { redirect_to colaboradores_url, notice: 'Colaborador eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n logger.debug 'destroy_some interesting information'\n @comdty = Comdty.find(params[:id])\n @comdty.destroy\n\n respond_to do |format|\n format.html { redirect_to(comdties_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @network.destroy\n respond_to do |format|\n format.html { redirect_to networks_url, notice: 'Network was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community_farm.destroy\n respond_to do |format|\n format.html { redirect_to community_farms_url, notice: 'Community farm was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @commemt = Commemt.find(params[:id])\n @commemt.destroy\n\n respond_to do |format|\n format.html { redirect_to commemts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @community = @commentable.community\n \n @comment.destroy\n\n redirect_to([@community,@commentable], :notice => 'Comment was successfully deleted.')\n end"
] | [
"0.77494264",
"0.7628726",
"0.758887",
"0.7582639",
"0.75190085",
"0.75190085",
"0.75190085",
"0.75190085",
"0.7345361",
"0.7032567",
"0.6991609",
"0.6987676",
"0.6948728",
"0.69379205",
"0.69283324",
"0.6902466",
"0.6833026",
"0.68261915",
"0.6721534",
"0.67208093",
"0.66859394",
"0.6685231",
"0.66849786",
"0.66849786",
"0.66849786",
"0.6680042",
"0.66653764",
"0.66237456",
"0.66183996",
"0.6611705",
"0.6603603",
"0.6578998",
"0.6575302",
"0.6571472",
"0.65661925",
"0.654761",
"0.6524218",
"0.6517575",
"0.65153444",
"0.65099794",
"0.6506117",
"0.64983",
"0.6497986",
"0.6492771",
"0.6478606",
"0.6478606",
"0.6471057",
"0.64619845",
"0.6448754",
"0.64473563",
"0.6439156",
"0.6439156",
"0.6439156",
"0.6437183",
"0.64228266",
"0.6421356",
"0.6417741",
"0.64164835",
"0.6412534",
"0.640345",
"0.6390148",
"0.63848555",
"0.638154",
"0.6380585",
"0.6380518",
"0.63775647",
"0.63718736",
"0.6366902",
"0.6355353",
"0.63540417",
"0.63510984",
"0.63486546",
"0.6347754",
"0.63359314",
"0.63268185",
"0.63135684",
"0.6310071",
"0.6306023",
"0.63057595",
"0.6303315",
"0.6297975",
"0.6296957",
"0.6285987",
"0.6274243",
"0.6274197",
"0.62738645",
"0.6268303",
"0.6267343",
"0.62633675",
"0.6261408",
"0.6255593",
"0.62555295",
"0.62451243",
"0.6243584",
"0.6243584",
"0.6243343",
"0.6242117",
"0.6239034",
"0.6238808",
"0.62377334"
] | 0.77372575 | 1 |
Load appium.txt (toml format) into system ENV the basedir of this file + appium.txt is what's used | def load_appium_txt opts
raise 'opts must be a hash' unless opts.kind_of? Hash
opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v }
opts = {} if opts.nil?
file = opts.fetch :file, nil
raise 'Must pass file' unless file
verbose = opts.fetch :verbose, false
# Check for env vars in .txt
parent_dir = File.dirname file
toml = File.expand_path File.join parent_dir, 'appium.txt'
puts "appium.txt path: #{toml}" if verbose
# @private
def update data, *args
args.each do |name|
var = data[name]
ENV[name] = var if var
end
end
toml_exists = File.exists? toml
puts "Exists? #{toml_exists}" if verbose
data = nil
if toml_exists
require 'toml'
puts "Loading #{toml}" if verbose
# bash requires A="OK"
# toml requires A = "OK"
#
# A="OK" => A = "OK"
data = File.read toml
data = data.split("\n").map do |line|
line.sub /([^\s])\=/, "\\1 = "
end.join "\n"
data = TOML::Parser.new(data).parsed
ap data unless data.empty? if verbose
update data, 'APP_PATH', 'APP_APK', 'APP_PACKAGE',
'APP_ACTIVITY', 'APP_WAIT_ACTIVITY',
'DEVICE'
# ensure app path is resolved correctly from the context of the .txt file
ENV['APP_PATH'] = Appium::Driver.absolute_app_path ENV['APP_PATH']
end
# return list of require files as an array
# nil if require doesn't exist
if data && data['require']
r = data['require']
r = r.kind_of?(Array) ? r : [ r ]
# ensure files are absolute
r.map! do |file|
file = file.include?(File::Separator) ? file :
File.join(parent_dir, file)
file = File.expand_path file
File.exists?(file) ? file : nil
end
r.compact! # remove nils
files = []
# now expand dirs
r.each do |item|
unless File.directory? item
# save file
files << item
next # only look inside folders
end
Dir.glob(File.join(item, '**/*.rb')) do |file|
# do not add folders to the file list
files << File.expand_path(file) unless File.directory? file
end
end
files
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 root_dir\n __FILE__.match(%r{.*(appium-test-runner)}).to_s\n end",
"def run_android test_file=nil\n wait_for_valid_device\n cmd = 'bundle exec ruby ./appium/run.rb android'\n cmd += %Q( \"#{ test_file }\") if test_file\n bash cmd\nend",
"def import_env_file(path)\n return unless File.file?(path)\n File.readlines(path).each do |line|\n next if line.start_with?('#') || line.strip.empty?\n line_to_env(line)\n end\nend",
"def app_config_file(filename)\n File.read(File.dirname(__FILE__)+\"/../../app/config/\" + filename).split(\"\\n\")\nend",
"def config_file\n File.join(install_directory,'installer','rails_installer.yml')\n end",
"def file_text\n text = \"[caps]\\n\"\n text << \"platformName = \\\"#{platform_name}\\\"\\n\"\n text << \"deviceName = \\\"#{device_name}\\\"\\n\"\n text << \"platformVersion = \\\"#{platform_version}\\\"\\n\" unless platform_version.nil?\n text << \"app = \\\"#{app}\\\"\\n\"\n text << \"newCommandTimeout = #{new_command_timeout}\\n\"\n text << \"udid = \\\"#{udid}\\\"\\n\" unless udid.nil?\n Logger.debug \"appium.text == #{text}\"\n text\n end",
"def load_monkfile\n file = find_in_project(\"Monkfile\")\n\n if file\n load file\n @project = File.dirname(file)\n Dir.chdir @project\n end\n end",
"def config_file\n File.expand_path('../hubble/config.yml', __FILE__)\n end",
"def config_file\n File.join(@path, %w[ application config application.php ])\n end",
"def config_file\n FilePath.new(@directory, 'tc-config.xml')\n end",
"def env_file\n dir['env.rb']\n end",
"def setup_app_files\n cp HANAMI_TEMPLATES.join('config/hanami-vite.json'), config.config_path\n inject_line_after root.join('config/environment.rb'), 'environment :development do', ' middleware.use(ViteRuby::DevServerProxy, ssl_verify_none: true) if ViteRuby.run_proxy?'\n inject_line_after_last root.join('apps/web/application.rb'), 'include Web::Assets::Helpers', ' include ViteHanami::TagHelpers'\n inject_line_after root.join('apps/web/application.rb'), 'configure :development do', <<-CSP\n # Allow @vite/client to hot reload changes in development\n security.content_security_policy(\n security.content_security_policy\n .sub('script-src', \"script-src 'unsafe-eval'\")\n .sub('connect-src', \"connect-src ws://\\#{ ViteRuby.config.host_with_port }\")\n )\n CSP\n append root.join('Rakefile'), <<~RAKE\n require 'vite_hanami'\n ViteRuby.install_tasks\n RAKE\n end",
"def load_launcher_data launcher_data_file=\"bin/LAUNCHER_TYPE\"\n launcher_data = nil\n\n begin\n File.open launcher_data_file do |f|\n launcher_data = YAML.load(f.read)\n end\n rescue Errno::ENOENT\n end\n\n return launcher_data\nend",
"def loadIOSConfigFile(org_id)\n file = \"generic.yaml\" # points to bFAN Sports config\n path = \"./fastlane/\"\n\n if File.exist?(\"FastlaneEnv\")\n path = \"\"\n end\n\n # Is there is a config for the target ?\n if File.file?(\"#{path}./FastlaneEnv/#{org_id}.yaml\")\n file = \"#{org_id}.yaml\"\n end\n\n conf = YAML.safe_load(File.read(\"#{path}./FastlaneEnv/#{file}\"))\n\n UI.important(\"Config used: fastlane/FastlaneEnv/#{file}\")\n\n return conf\nend",
"def configure_data\n [:bitcask, :eleveldb, :merge_index].each {|k| env[k] ||= {} }\n env[:bitcask][:data_root] ||= (data + 'bitcask').expand_path.to_s\n env[:eleveldb][:data_root] ||= (data + 'leveldb').expand_path.to_s\n env[:merge_index][:data_root] ||= (data + 'merge_index').expand_path.to_s\n env[:riak_core][:slide_private_dir] ||= (data + 'slide-data').expand_path.to_s\n env[:riak_core][:ring_state_dir] ||= (data + 'ring').expand_path.to_s\n\n TS_NODE_DIRECTORIES.each do |dir|\n env[:riak_core][:\"platform_#{dir}_dir\"] ||= send(dir).to_s\n end\n end",
"def config_file\n File.join AppRoot, ConfigFile\n end",
"def app_file_path\n File.join(tmp_dir, \"example_app_#{$example_app_counter}.rb\")\n end",
"def load_environment_file(name, fail_on_missing = false)\n unless File.exists?(name)\n abort(\"Unable to read environment: #{name}\") if fail_on_missing\n return nil\n end\n\n load_env = EC2Launcher::DSL::Environment.new\n load_env.load(File.read(name))\n load_env\n end",
"def intent_fixture_file_path(intent_name)\n File.join(intents_fixture_dir, \"#{intent_name}.txt\")\nend",
"def setup_autoinst(autoinst)\n raise \"ERROR: #{autoinst} not found\" unless autoinst.file?\n content = File.read(autoinst)\n autoinst_vars(autoinst.sub_ext(\".vars\")).each { |k, v| content.gsub!(\"{{#{k}}}\", v) }\n content.gsub!(\"/dev/vd\", \"/dev/sd\") if provider == :virtualbox\n File.open(autoinst_path, \"w\") { |f| f.puts content }\n end",
"def app\n @app ||= Rack::Builder.parse_file(File.join(OpenRecipeApp.root,\"config.ru\"))[0]\n end",
"def default_app_variables_path\n Hanami.root.join(\"apps\", Concierge.app.to_s, \"config\", \"environment_variables.yml\").to_s\n end",
"def initialize(app_file)\n @config_file = File.expand_path(File.join(File.dirname(app_file), \"../app.yml\"))\n if !File.exist? @config_file\n @shoes.alert(\"Unable to locate configuration file.\\nFile '#{@config_file}' not found.\")\n @shoes.exit\n end\n\n @config = YAML.load(File.new(@config_file))\n setup\n run\n end",
"def config_filepath(name)\n File.expand_path(\"../fixtures/configs/#{name}.yaml\", __dir__)\nend",
"def root_dir\n ManageIQ::Providers::Lenovo::Engine.root.join(\"content/ansible_runner\")\n end",
"def add_file file\n @config.merge!(YAML::load_file \"#{@@env_dir}/#{file}\")\n end",
"def roby_app_fixture_path\n File.expand_path(\n File.join(\"..\", \"..\", \"..\", \"test\", \"app\", \"fixtures\"),\n __dir__\n )\n end",
"def load_env_from_file(path)\n File.readlines(path).each do |line|\n values = line.split(\"=\")\n key = values[0]\n value = values[1, values.length - 1 ].map {|v| v.strip() }.join('=')\n ENV[key] = value\n end\n end",
"def app_template_fixture(name)\n File.expand_path(\"fixtures/#{name}\",File.dirname(__FILE__))\n end",
"def read_app_config(path_to_file)\n app_config = {}\n File.open(path_to_file).readlines.each do |line|\n line.strip!\n unless line.start_with? '#' or line.empty?\n splitted = line.split(':')\n next unless splitted.size == 3\n app_config.merge! \"#{splitted[1]}\" => {host: splitted[0], command: splitted[2]}\n end\n end\n app_config\n end",
"def initialize\n @path = File.join(File.expand_path('.'), FILE_NAME)\n unless File.exist?(@path)\n @path = (ENV['ASPELLBEE_CONFIG_PATH'] || File.join(File.expand_path('~'), FILE_NAME))\n end\n @data = load_config_file\n end",
"def config_file\n @config_file ||= File.join( home_dir, TyrantManager.config_file_basename )\n end",
"def load_enviroment(file = nil)\n file ||= \".\"\n\n if File.directory?(file) && File.exists?(File.expand_path(\"#{file}/config/environment.rb\"))\n require 'rails'\n require File.expand_path(\"#{file}/config/environment.rb\")\n if defined?(::Rails) && ::Rails.respond_to?(:application)\n # Rails 3\n ::Rails.application.eager_load!\n elsif defined?(::Rails::Initializer)\n # Rails 2.3\n $rails_rake_task = false\n ::Rails::Initializer.run :load_application_classes\n end\n elsif File.file?(file)\n require File.expand_path(file)\n end\n end",
"def fake_config_path_relative_to_project(file_name)\n File.join(\"spec/support/upsteem/deploy/fake_config\", file_name)\n end",
"def load_config(path)\n # Set the impfile and initial root path settings...\n if File.file?(path.chomp('.rb') + '.rb')\n # Received a path to a configuration file.\n Imp::Config[:root_path] = File.expand_path(File.dirname(path))\n Imp::Config[:impfile] = File.expand_path(path.chomp('.rb') + '.rb')\n else\n # Received a directory in which the app is located, expect an imp.rb\n # configuration file to be present.\n Imp::Config[:root_path] = File.expand_path(path)\n Imp::Config[:impfile] = File.expand_path(File.join(path, 'imp.rb'))\n end\n\n unless File.file?(Imp::Config[:impfile])\n raise ApplicationLoadError, \"Couldn't load app at #{path}\"\n end\n\n # TODO: This is decidedly ugly.\n Imp::Command._subclasses = Set.new\n\n load Imp::Config[:impfile]\n end",
"def load_config_file\n \tproject_name = ENV['PROJECT_NAME']\n \tconfig_file_path = \"#{@configs_folder_path}#{project_name}.yaml\"\n\tif !File.exists?(config_file_path)\n log_message(\"No '#{project_name}.yaml' file found in configs directory.\")\n exit\n end\n @config = YAML.load_file(config_file_path)\n end",
"def build_environment(autoinst)\n environment = {\n \"AYTESTS_FILES_DIR\" => files_dir.to_s,\n \"AYTESTS_PROVIDER\" => provider.to_s,\n \"AYTESTS_WEBSERVER_PORT\" => WEBSERVER_PORT,\n \"AYTESTS_MAC_ADDRESS\" => MAC_ADDRESS\n }\n linuxrc_file = autoinst.sub_ext(\".linuxrc\")\n environment[\"AYTESTS_LINUXRC\"] = File.read(linuxrc_file).chomp if linuxrc_file.exist?\n environment\n end",
"def android_app_dir\n File.join(File.dirname(__FILE__), '..', 'android', 'iscratcher-app')\nend",
"def parse envfile\n path = Pathname.new envfile\n update case path.extname\n when '.pl', '.perl' then parse_perl path\n when '.js', '.json' then parse_json path\n when '.yml', '.yaml' then parse_yaml path\n else parse_xaicron path\n end\n end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end",
"def get_appium_instance\n ENV['APP_URL'].nil? ? 'http://127.0.0.1:4723/wd/hub' : ENV['APP_URL']\n end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file(\"config.ru\").first\nend",
"def exec_env_filepath\n filename.to_s\n end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def load_config_configuration\n file_name = @config_manager['run.config_file', default: nil]\n return if file_name.nil?\n\n FileUtils.cd(FRAMEWORK_ROOT) { @config_manager.load_configuration('config', \"Configuration/Builds/#{file_name}\") }\n end",
"def read_data(file)\n if ENV['RACK_ENV'] == 'test'\n local = File.expand_path(\"../test/data/#{file}\", __FILE__)\n else\n local = File.expand_path(\"../data/#{file}\", __FILE__)\n\n if USE_GOOGLE_DRIVE\n remote = google_session.file_by_title(file.to_s)\n remote.download_to_file(local)\n end\n end\n\n YAML.load_file(local)\nend",
"def app\n path = File.expand_path('../config.ru', File.dirname(__FILE__))\n @app ||= Rack::Builder.parse_file(path).first\n end",
"def load(path, app)\n Dir.chdir(Hardwired::Paths.root || '.') do\n Dir.glob(path) do |file|\n $stderr.puts \"loading config file '#{file}'\" if app.logging?\n document = IO.read(file)\n @@config = RecursiveOpenStruct.new(config_for_env(YAML.load(document),app.environment) || {})\n return @@config \n end\n \n end\n end",
"def load_local_configfile\n Dir.glob('**/project.yml') do |filename|\n project = Project.new(config: @config, filename: filename)\n @projects[project.name] = project if project.valid?\n end\n end",
"def initialize(file_name:, build_configuration:, app_name:, device: nil)\n app_name = file_name if app_name.nil?\n\n @app_name = \"#{app_name}\" << '.app'\n @tmp_dir = Dir.mktmpdir(app_name)\n @build_configuration = build_configuration\n\n if device.nil?\n @app_dir = \"#{@tmp_dir}\" << \"/#{@build_configuration}-iphonesimulator/\"\n else\n @app_dir = \"#{@tmp_dir}\" << \"/#{@build_configuration}-iphoneos/\"\n end\n\n @app_path = \"#{@app_dir}\" << \"#{@app_name}\"\n end",
"def config_file\n File.join(root, 'config.yml')\n end",
"def path_for(config); File.expand_path(File.join('../fixtures', config), __FILE__) ;end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\n end",
"def read_config\n config = open(ENV['HOME']+'/.slacky')\n config.readline.chomp\nend",
"def load_yaml(base=ENV['PWD'], env=\"active\")\n env = \"dev\" if env == \"active\" and not File.exist? \"#{base}/opt/active\"\n @data = ::YAML.load_file(\"#{base}/opt/#{env}/config.yaml\")\n end",
"def app_path(path)\n File.expand_path(path, Dir.pwd)\n end",
"def load_app\n require File.expand_path(File.join('config', 'application.rb'))\n @app ||= Rails.application\n end",
"def config_read\n f = File.expand_path(CONFIG_FILE)\n return unless File.readable? f\n\n hash = loadYML(f)\n @used_dirs = hash['DIRS']\n @visited_files = hash['FILES']\n @bookmarks = hash['BOOKMARKS']\n @used_dirs.concat get_env_paths\nend",
"def config_dev_path\n File.join test_app_path, 'config', 'deploy', 'dev.rb'\n end",
"def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend",
"def load_config(file_path)\n config = OpenStruct.new\n\tfile_path.gsub!(\"/\", \"\\\\\") if Selenium::WebDriver::Platform.windows?\n YAML.load_file(file_path).each do |k,v|\n config.send(\"#{k}=\", v)\n end\n\n config.browser ||= \"firefox\"\n config.username ||= config.user\n\n return config\n end",
"def default_global_config_file\n File.join(File.expand_path(ENV[\"HOME\"]), \".kitchen\", \"config.yml\")\n end",
"def read_rc_file\n \n file = File.join( ENV['HOME'], '.app47rc') \n if File.exists? file \n config_options = YAML.load_file( file) \n @options.merge!( config_options)\n end\n\n end",
"def maillist_dev_file\n Origen.app.root.to_s + '/config/maillist_dev.txt'\n end",
"def config_file\n \"#{confdir}/config.yml\"\n end",
"def data_root\n File.expand_path(\"spec/data\", Dir.pwd)\n end",
"def env\n\t\t@rootDir = Dir.new( @rootDir )\n\n\t\t# config file exist\n\t\tif Dir.exist?( @configDir )\n\t\t\t@configDir = Dir.new( @configDir )\n\t\telse\n\t\t\t@configDir = Dir.mkdir( @configDir )\n\t\tend\n\n\t\t@configFile = File.join( @configDir, @configFile )\n\n\t\t# parse config file\n\t\t@configFile = File.new( @configFile ) unless !File.exist?( @configFile )\n\n\t\t@configFile = JSON.parse( @configFile )\n\n\t\tif @configFile['webroot'] == nil\n\t\t\t@configFile['webroot'] = @@webroot\n\t\tend\n\n\t\tif @configFile['port'] == nil\n\t\t\t@configFile['port'] = @@port\n\t\tend\n\tend",
"def gen_app_config_file\n filename = 'config/init/app_config.rb'\n bakname = 'config/init/app_config.rb~'\n File.delete(bakname) if File.exist?(bakname)\n File.rename(filename, bakname) if File.exist?(filename)\n File.open(filename, \"w\") do |file|\n file.puts(app_config_content)\n end\n end",
"def load(file_name, default_env = T.unsafe(nil)); end",
"def setup\n preference_file = \"#{defaults[:root_dir]}/config.yml\"\n preferences = {}\n if File.exists? preference_file\n require 'yaml'\n File.open(preference_file) { |file| preferences = YAML.load(file) }\n end\n base_file_variations(absolute_paths(defaults.merge(preferences)))\n end",
"def loadConfig(configFile)\n #For Shoes compatability change to a known directory\n Dir.chdir(ENV['HOME'])\n config = {}\n #do this to set parameters that might be missing from the yaml file\n config[:raw_conf_folder_loc] = \"1\"\n config[:drv_conf_folder_loc] = \"2\"\n if File.exist?(configFile)\n config.update(open(configFile) {|f| YAML.load(f) })\n end\n return config\nend",
"def application_mode_file_path locale = locale\n File.join(Translate::Storage.root_dir, \"config\", \"locales\", \"#{locale}.yml\")\n end",
"def load(name)\n config_file \"#{name}\"\n end",
"def load_integ_environment_vars\n env_file = File.join(__dir__, 'config/local_env_integ.yml')\n env_key_vals = YAML.load_file(env_file)\n %w[\n SqsQueueIntegTests_QueueUrl\n SqsQueueIntegTests_QueueRegion\n SqsQueueIntegTests_AccessId\n SqsQueueIntegTests_SecretKey\n ].each { |var| ENV[var] = env_key_vals.fetch(var) }\nend",
"def test_config_system_properties_file(module_set)\n FilePath.new(classes_directory_for_eclipse(module_set['common'].subtree('tests.base')), \"test-system-properties.properties\")\n end",
"def load()\n\n checkFileExists()\n loadConfigs()\n checkConfigs() \n end",
"def load_overrides\n if ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != ''\n if File.readable?(ENV['PARAMS_FILE'])\n project_root = self.instance_variable_get(\"@project_root\")\n packaging_root = self.instance_variable_get(\"@packaging_root\")\n self.config_from_yaml(ENV['PARAMS_FILE'])\n self.instance_variable_set(\"@project_root\", project_root) if project_root\n self.instance_variable_set(\"@packaging_root\", packaging_root) if packaging_root\n else\n fail \"PARAMS_FILE was set, but not to the path to a readable file.\"\n end\n end\n end",
"def load\n Dotenv.load(\n root.join(\".env.local\"),\n root.join(\".env.#{Rails.env}\"),\n root.join(\".env\")\n )\n end",
"def load(name)\n yml_file(\"#{name}/#{environment}\") ||\n yml_file_with_key(\"#{name}\", environment) ||\n yml_file(\"#{name}/default\") ||\n yml_file_with_key(\"#{name}\", 'default') ||\n raise(NotFound.new(name, environment))\n end",
"def app_require(file)\n require File.expand_path(file)\nend",
"def load_from_file filename\n fnm = File.exist?(filename) ? filename : File.join(@wd,filename)\n load_configuration(fnm)\n end",
"def run_android(test_file = nil)\n wait_for_valid_device\n cmd = 'bundle exec ruby ./lib/run.rb android'\n cmd = %(#{cmd} \"#{test_file}\") if test_file\n bash cmd\nend",
"def load\n config = YAML.load_file @config_path\n @path = config['steam']\n end",
"def setup_path\n # The Java Buildpack for WLS creates the complete domain structure and other linkages during staging.\n # The directory used for staging is at /tmp/staged/app\n # But the actual DEA execution occurs at /home/vcap/app. This discrepancy can result in broken paths and non-startup of the server.\n # So create linkage from /tmp/staged/app to actual environment of /home/vcap/app when things run in real execution\n # Also, this script needs to be invoked before starting the server as it will create the links and also tweak the server args\n # (to listen on correct port, use user supplied jvm args)\n\n File.open(@application.root.to_s + '/' + SETUP_ENV_SCRIPT, 'w') do |f|\n\n f.puts '#!/bin/sh '\n f.puts '# There are 4 things handled by this script '\n f.puts ' '\n f.puts '# 1. Create links to mimic staging env and update scripts with jvm options '\n f.puts '# The Java Buildpack for WLS creates complete domain structure and other linkages during staging at '\n f.puts '# /tmp/staged/app location '\n f.puts '# But the actual DEA execution occurs at /home/vcap/app. '\n f.puts '# This discrepancy can result in broken paths and non-startup of the server. '\n f.puts '# So create linkage from /tmp/staged/app to actual environment of /home/vcap/app when things run in real execution '\n f.puts '# Create paths that match the staging env, as otherwise scripts will break!! '\n f.puts ' '\n f.puts 'if [ ! -d \\\"/tmp/staged\\\" ]; then '\n f.puts ' /bin/mkdir /tmp/staged '\n f.puts 'fi; '\n f.puts 'if [ ! -d \\\"/tmp/staged/app\\\" ]; then '\n f.puts ' /bin/ln -s `pwd` /tmp/staged/app '\n f.puts 'fi; '\n f.puts ' '\n f.puts ' '\n end\n end",
"def load_config(global)\n config_file_path = File.join(Dir.home, CONFIG_FILE_NAME)\n\n if File.exists?(config_file_path)\n require 'yaml'\n file_settings = YAML.load_file(config_file_path)\n global[:config].merge!(file_settings)\n end\n\nend",
"def setup\n File.expand_path(File.dirname(__FILE__) + '/data/')\n end",
"def intents_fixture_dir\n File.join(fixture_path, 'intents')\nend",
"def load_launcher_data launcher_data_file=\"bin/LAUNCHER_TYPE\"\n launcher_data = nil\n\n begin\n File.open launcher_data_file do |f|\n launcher_data = YAML.load(f.read)\n end\n rescue Errno::ENOENT\n end\n\n return {'launcher_main' => 'org.jruby.Main'}\nend",
"def android_build_root()\n \"#{build_root}/android\"\n end",
"def app_file\n @app_file ||= Chef::Resource::RemoteFile.new(\n ::File.join(deploy_dir, app_name), run_context\n )\n @app_file.mode('0755')\n @app_file.source(asset_url.to_s)\n @app_file\n end",
"def load_app_config\n user_configs = read_yaml_file(USER_CONFIGS)\n environment_configs = Maybe(ENV).or_else({})\n\n # Order: user, env\n config_order = [user_configs, environment_configs]\n\n configs = config_order.inject { |a, b| a.merge(b) }\n OpenStruct.new(configs.symbolize_keys)\n end",
"def load_irbrc(path)\n return if (path == ENV['HOME']) || (path == '/')\n\n load_irbrc(File.dirname path)\n irbrc = File.join(path, '.irbrc')\n load irbrc if File.exists?(irbrc)\nend",
"def go_bundles\n FileUtils.cd(TXMP_SUPPORT_PATH + \"/bundles\")\nend",
"def configuration_file\n gitpusshuten_root + '/config.rb'\n end",
"def test_config_filename\n File.join File.dirname(__FILE__), 'config.yml'\nend",
"def appDataPath\n \"#{SIMULATORS_ROOT}/#{@guid}/#{DEVICE_APP_DATA_RELATIVE_PATH}\"\n end",
"def load_from_filesystem(options)\n return if options[:skip_metadata]\n\n # Load localised data\n ignore_validation = options[:ignore_language_directory_validation]\n Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|\n language = File.basename(lang_folder)\n (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|\n path = File.join(lang_folder, \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= {}\n options[key][language] ||= File.read(path)\n end\n end\n\n # Load non localised data\n (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key|\n path = File.join(options[:metadata_path], \"#{key}.txt\")\n next unless File.exist?(path)\n\n UI.message(\"Loading '#{path}'...\")\n options[key] ||= File.read(path)\n end\n\n # Load trade representative contact information\n options[:trade_representative_contact_information] ||= {}\n TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:trade_representative_contact_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:trade_representative_contact_information][option_name] ||= File.read(path)\n end\n\n # Load review information\n options[:app_review_information] ||= {}\n REVIEW_INFORMATION_VALUES.values.each do |option_name|\n path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, \"#{option_name}.txt\")\n next unless File.exist?(path)\n next if options[:app_review_information][option_name].to_s.length > 0\n\n UI.message(\"Loading '#{path}'...\")\n options[:app_review_information][option_name] ||= File.read(path)\n end\n end"
] | [
"0.5981987",
"0.5774271",
"0.56039727",
"0.55971855",
"0.55521613",
"0.54813564",
"0.543904",
"0.541871",
"0.54058915",
"0.5370258",
"0.5336662",
"0.5312171",
"0.5307017",
"0.5273903",
"0.527349",
"0.5264785",
"0.5259214",
"0.5235099",
"0.5223799",
"0.52233565",
"0.519876",
"0.5196877",
"0.51611173",
"0.51579475",
"0.515366",
"0.51453936",
"0.5136753",
"0.51355577",
"0.51109993",
"0.5110647",
"0.51022774",
"0.50997406",
"0.5090595",
"0.50740093",
"0.5070343",
"0.5061258",
"0.5039813",
"0.5035079",
"0.5030829",
"0.502894",
"0.50184506",
"0.50171876",
"0.50098735",
"0.500507",
"0.49890035",
"0.49890035",
"0.49862704",
"0.49803427",
"0.49789304",
"0.4972758",
"0.4970034",
"0.4964515",
"0.49622795",
"0.49577254",
"0.49549565",
"0.4948782",
"0.49463272",
"0.4943174",
"0.49429014",
"0.4940956",
"0.4936481",
"0.49364412",
"0.4927088",
"0.49225307",
"0.49179623",
"0.491659",
"0.49130338",
"0.4910659",
"0.4907423",
"0.49050376",
"0.49039042",
"0.48959696",
"0.48919326",
"0.48907053",
"0.48893553",
"0.48854324",
"0.48825088",
"0.48729712",
"0.48724717",
"0.48714083",
"0.48694122",
"0.486034",
"0.4858513",
"0.48569354",
"0.48504865",
"0.4846043",
"0.4841384",
"0.4838897",
"0.48371077",
"0.48333305",
"0.48194095",
"0.4815992",
"0.48156953",
"0.48155993",
"0.48083195",
"0.4808263",
"0.48075747",
"0.48054424",
"0.48039398",
"0.47912696"
] | 0.81331265 | 0 |
Returns the server's version string | def server_version
status['value']['build']['version']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_server_version\n server_info[:server_version]\n end",
"def version\n @version ||= exec('SHOW server_version')[0]['server_version'].split[0]\n end",
"def server_version\n request(auth: false, expects: 200)['version']\n rescue => ex\n error { \"Server version exception\" }\n error { ex }\n nil\n end",
"def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend",
"def server_version\n call! :server_version\n end",
"def server_version\n ServerVersion.new(server_info[\"version\"])\n end",
"def server_version\n check_connection\n @protocol.server_version\n end",
"def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end",
"def version\n build_string\n end",
"def server_version; end",
"def version\n @version_helper.to_s\n end",
"def version\n @version_helper.to_s\n end",
"def ver\n if v = version\n str = +\"#{program_name} #{[v].join('.')}\"\n str << \" (#{v})\" if v = release\n str\n end\n end",
"def server_version\n db.server_version(@opts[:server])\n end",
"def server_version\n server_info.present? ? @server_info[:parseServerVersion] : nil\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n [@major_version, @minor_version].join('.')\n end",
"def server_version(server=nil)\n @server_version ||= (synchronize(server){|conn| conn.info[:id]})\n end",
"def get_version(version)\n \"V#{version.gsub('-','_')}\"\n end",
"def get_version\n request('getVersion')\n end",
"def get_version\n\t\tself.dev_stage.blank? ? dev_stage_string = \"\" : dev_stage_string = self.dev_stage + \" \"\n\t\treturn dev_stage_string + self.maj_version.to_s + \".\" + self.min_version.to_s\n\tend",
"def to_s\n @version\n end",
"def to_s\n @version\n end",
"def version\n case @version\n when Module\n \"#{@version::Major}.#{@version::Minor}.#{@version::Release}\"\n when Proc # not sure about this\n @version.call\n when NilClass\n 'unknown'\n else\n @version\n end\n end",
"def version\n VERSION\n end",
"def server_version(_server=nil)\n @server_version ||= super()\n end",
"def version\n self.class.get(\"/get/version\")\n end",
"def version\n VERSION\n end",
"def version\n send_command(:getinfo, 'version')\n reply = read_reply.split('=').last\n read_reply # skip \"250 OK\"\n reply\n end",
"def to_s\n @version\n end",
"def server_version(server=nil)\n return @server_version if @server_version\n ds = dataset\n ds = ds.server(server) if server\n @server_version = swallow_database_error{ds.with_sql(\"SELECT CAST(current_setting('server_version_num') AS integer) AS v\").single_value} || 0\n end",
"def info_string\n \"Rodsec v#{VERSION}\"\n end",
"def version\n fetch('vehicle.version')\n end",
"def version\n name.split('_')[1]\n end",
"def major_minor\n # TODO: It would be cool to try <major>.<minor + 1> if possible.\n ver = version_data['serverVersion']\n [ver['major'], ver['minor']]\n .map(&:to_i)\n .map(&:to_s)\n .join('.')\n end",
"def http_version\n \"%d.%d\" % [self[:http_major], self[:http_minor]]\n end",
"def version\n cmd(COMMANDS[:version], 2)\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def version\n api_execute('/version', :get).body\n end",
"def version\n v = KJess::Request::Version.new\n r = send_recv( v )\n return r.version if Response::Version === r\n raise KJess::Error, \"Unexpected Response from VERSION command\"\n end",
"def version\n @version\n end",
"def version\n\t\t\tbegin\n\t\t\t\tv = \"#{GVB.major_version}.#{GVB.minor_version}.#{GVB.patch_version}\"\n\t\t\trescue\n\t\t\t\tv = File.read(\".gvb_version\") if File.exists?(\".gvb_version\")\n\t\t\tend\n\t\t\t# If we got a version then use it to construct a link to the github tag of the same\n\t\t\tif v\n\t\t\t\tl = link_to v, \"https://github.com/machiavellian/machiavelli/releases/tag/v#{v}\", target: \"blank\" if v\n\t\t\t\treturn \"version #{l} \".html_safe\n\t\t\tend\n\t\tend",
"def to_s\n self.version.to_s\n end",
"def version\n execute_string(\"-version\")\n end",
"def version\n\t\tmodule_info['Version'].split(/,/).map { |ver|\n\t\t\tver.gsub(/\\$Rev.s.on:\\s+|\\s+\\$$/, '')\n\t\t}.join(',')\n\tend",
"def to_s\n version = get_version_string\n version << \"-#{get_pre_string}\" unless @pre == nil\n version << \"+#{get_build_string}\" unless @build == nil\n version\n end",
"def to_version_string(version)\n version = version.to_s\n if version.match(/\\./)\n version\n else\n from_version_code(version).to_s\n end\n end",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n @gemspec.version || @version_helper.to_s\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def get_version\n\t\tend",
"def package_version\n @semver.to_s '%M.%m.%p%s'\n end",
"def v string\n Gem::Version.create string\n end",
"def v string\n Gem::Version.create string\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def version_number\n @version\n end",
"def API_version(options={})\n return \"#{@major}.#{@minor}\"\n end",
"def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end",
"def version_const\n \"Version_\" + @__version.upcase.gsub(\".\", \"_\")\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end",
"def version\n h = call(CMD_VERSION)\n return h[:result]\n end",
"def client_meta_version(version)\n regexp = /^([0-9]+\\.[0-9]+\\.[0-9]+)(\\.?[a-z0-9.-]+)?$/\n match = version.match(regexp)\n return \"#{match[1]}p\" if (match[2])\n\n version\n end",
"def version\n @sock.cmd(\"String\" => \"version\", \"Match\" => /(SUCCESS:.*\\n|ERROR:.*\\n|END.*\\n)/)\n end",
"def version\n (version_from_class.to_f / 10).to_s\n end",
"def client_version\n ClientVersion\n end",
"def version_number\n \"#{self.major}.#{self.minor}\"\n end",
"def server\n @server.to_s\n end",
"def version\n path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__\n dir = File.dirname(path)\n if File.exist?(dir+'/version.stamp')\n version = File.read(dir+'/version.stamp')\n else\n version = \"Unknown version\"\n end\n version\n end",
"def version\n super.to_s\n end",
"def version\n super.to_s\n end",
"def version\n values = {}\n ring.servers.each do |server|\n values[server.name.to_s] = server.alive? ? server.request(:version) : nil\n end\n values\n end",
"def get_version()\n\t\tend",
"def version\n ret = @client.call('Bugzilla.version')\n handle_faults(ret)\n ret['version']\n end",
"def rubygems_version_string\n VERSION.gsub(/[-\\+]/,'.')\n end",
"def version\n p\n version = File.read(HOSTER_PATH+\"/hoster.version\")\n puts PROGNAME + \" version \" + version\nend",
"def version_tag\n version_composition.join(\".\")\n end",
"def version\n return last_version if versionable?\n version_number\n end",
"def current_version\n version_number rev\n end",
"def version\n self.class.name + ' ' + VERSION\n end",
"def to_s\n \"<Version #{number}>\"\n end",
"def appcache_version_string\n RailsAppcache.config.version\n end"
] | [
"0.81980455",
"0.818916",
"0.79347074",
"0.7893697",
"0.77782583",
"0.7761562",
"0.77331555",
"0.77269936",
"0.7645589",
"0.752514",
"0.7523649",
"0.7523649",
"0.7495116",
"0.7490963",
"0.7465442",
"0.73399574",
"0.7339925",
"0.7339925",
"0.7330919",
"0.7274454",
"0.72268337",
"0.7209724",
"0.71657854",
"0.7139696",
"0.7139696",
"0.7108887",
"0.71069777",
"0.7103767",
"0.7099849",
"0.7079013",
"0.70783186",
"0.70465046",
"0.70331293",
"0.7031734",
"0.6990673",
"0.69875485",
"0.6984241",
"0.69794095",
"0.69559133",
"0.69034696",
"0.6900373",
"0.6889841",
"0.6886001",
"0.68751174",
"0.6864219",
"0.68598086",
"0.68452984",
"0.68392664",
"0.68377995",
"0.68347996",
"0.68347996",
"0.68347996",
"0.6827242",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6823335",
"0.6812359",
"0.6795891",
"0.6786795",
"0.6786795",
"0.6776113",
"0.6776113",
"0.6776113",
"0.6776113",
"0.6776113",
"0.6776113",
"0.6776113",
"0.6774316",
"0.67707455",
"0.67691535",
"0.6760977",
"0.6749765",
"0.67474246",
"0.67455584",
"0.67434615",
"0.6735776",
"0.6731278",
"0.67310894",
"0.67229885",
"0.6721875",
"0.67105615",
"0.67070186",
"0.67070186",
"0.67009115",
"0.6692811",
"0.6686949",
"0.66794777",
"0.66674405",
"0.6655",
"0.6648803",
"0.66412246",
"0.66374457",
"0.66315085",
"0.6621211"
] | 0.75308967 | 9 |
Get the server url for sauce or local based on env vars. | def server_url
return @custom_url if @custom_url
if !@sauce_username.nil? && !@sauce_access_key.nil?
"http://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:80/wd/hub"
else
"http://127.0.0.1:#{@port}/wd/hub"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_url\n if Rails.env.production?\n # Place your production URL in the quotes below\n \"http://www.ezonline.com/\"\n else\n # Our dev & test URL\n \"http://ezonline-dev.com:3000\"\n end\n end",
"def host\n return @@nfg_urls['sandbox']['host'] if @use_sandbox\n @@nfg_urls['production']['host']\n end",
"def server_url\n \"#{ROCCI_SERVER_CONFIG.common.protocol || 'http'}://\" \\\n \"#{ROCCI_SERVER_CONFIG.common.hostname || 'localhost'}:\" \\\n \"#{ROCCI_SERVER_CONFIG.common.port.to_s || '3000'}\"\n end",
"def casein_config_hostname\n if ENV['RAILS_ENV'] == 'production'\n 'http://www.caseincms.com'\n else\n 'http://localhost:3000'\n end\n end",
"def url\n options[:test] ? options[:test_url] : options[:production_url]\n end",
"def url\n options[:test] ? options[:test_url] : options[:production_url]\n end",
"def server_url\n \"http://#{server_host}:#{server_port}\"\n end",
"def baseURL\n Rails.env.development? ? GeventAnalysis::Application::CONSTS[:dev_host] : GeventAnalysis::Application::CONSTS[:app_host]\n end",
"def app_url\n ENV['APP_URL']\nend",
"def url\n return @@nfg_urls['sandbox']['url'] if @use_sandbox\n @@nfg_urls['production']['url']\n end",
"def server_url\n url\n end",
"def casein_config_hostname\n if ENV['RAILS_ENV'] == 'production'\n 'http://www.caseincms.com'\n else\n 'http://0.0.0.0:3000'\n end\n end",
"def site_url\n if development_environment?\n request.protocol + request.host + ':' + request.port.to_s\n else\n request.protocol + 'rehttp.me'\n end\n end",
"def url\n env[:url]\n end",
"def base_url\n if ENV['BASE_URL']\n ENV['BASE_URL']\n else\n 'https://beam.pro/'\n end\n end",
"def server_url\n params[:server_url] || session[:server_url]\n end",
"def server_url\n @uri\n end",
"def ci_base_url\n # Assume we're in dev if we don't have this url\n return ENV[\"FASTLANE_CI_BASE_URL\"] || \"http://localhost:8080\"\n end",
"def prod_server\n PROD_SERVER\n end",
"def get_ordercup_path\n if Rails.env.production?\n @ordercup_path = \"https://ship.ordercup.com/connect-to-ordercup\"\n elsif Rails.env.staging?\n @ordercup_path = \"https://ship.ordercup4.com/connect-to-ordercup\"\n else\n @ordercup_path = \"http://localhost:3000/connect-to-ordercup\"\n end \n end",
"def get_url(is_local = true)\n is_local ? (return '../../../www/public/') : (return 'https://whimsy.apache.org/public/')\n end",
"def auth_server(environment)\n auth_server_url = ENV['ADSAPI_AUTH_URL']\n if auth_server_url.nil?\n environment = environment.upcase.to_sym\n auth_server_url = auth_server_config[environment]\n end\n if auth_server_url.nil?\n # If we don't have an entry for this environment, we just return the\n # default server (the same one being used for the default environment)\n auth_server_url = auth_server_config[default_environment()]\n end\n return auth_server_url\n end",
"def default_url_prefix\n case @environment\n when \"development\" then \"https://#{domain}.dev.montagehot.club\"\n when \"production\" then \"https://#{domain}.mntge.com\"\n when \"test\" then @test_url\n end\n end",
"def webserver_url\n \"http://#{webserver_host}:#{webserver_port}\"\n end",
"def url\n return @url if @url\n\n case environment\n when :production\n PRODUCTION_API_ENDPOINT\n when :sandbox\n SANDBOX_API_ENDPOINT\n end\n end",
"def myservices_environment_details_host\n ENV['ENV_DETAILS'].nil? ? 'esu2v871:9080' : ENV['ENV_DETAILS']\n end",
"def getserverurl\r\n return getvalue(@@SERVER_URL)\r\n end",
"def sslhost\n if ENV['RAILS_ENV'] == 'production'\n \"https://m41.herokuapp.com\"\n else\n \"\"\n end\n end",
"def url\n raise \"The 'URL' environment variable was not specified on the cucumber command line.\" if ENV['URL'].nil?\n ENV['URL']\n end",
"def repo_url\n ENV[\"FASTLANE_CI_REPO_URL\"]\n end",
"def repo_url\n ENV[\"FASTLANE_CI_REPO_URL\"]\n end",
"def iadmin_url\n @test_mode ? @test_url : @production_url\n end",
"def get_server_url\n if params && params[:version] && params[:type]\n app_version = Core::Version.find_by(name: params[:version], app_type: params[:type])\n current_version = params[:version].split('.').map{|s|s.to_i}\n latest_version = Core::Version.where(app_type: params[:type]).last.name.split('.').map{|s|s.to_i}\n if app_version.nil? && (current_version <=> latest_version) >= 0\n # this version is the develop version, doesn't exist in our data set\n render :json => {message: Settings.client_heroku_dev_server}, :status => 200\n else\n # otherwise get the production url\n render :json => {message: Settings.client_heroku_server}, :status => 200\n end\n else\n # otherwise get the production url\n render :json => {message: Settings.client_heroku_server}, :status => 200\n end\n end",
"def main_site_host\n case Rails.env\n when 'development'\n # '192.168.1.140' # to test in ie\n # 'ngoaidmap.dev'\n 'iom.dev'\n when 'test'\n 'example.com'\n when 'staging'\n Settings.main_site_host\n when 'production'\n Settings.main_site_host\n end\n end",
"def host_url_from_rack_env env\n port = ((env[\"SERVER_PORT\"] == 80) && \"\") || \":#{env['SERVER_PORT']}\"\n host = (env[\"HTTP_HOST\"]) || (env[\"SERVER_NAME\"] + port)\n \"#{scheme(env)}://#{host}\"\n end",
"def full_url(env)\n \"#{ SSL_SCHEME }://#{ host }:#{ port }#{ ::Rack::Request.new(env).fullpath }\"\n end",
"def beef_host\n public_host || local_host\n end",
"def host_for_test\n if @controller.nil?\n ::AppConfig.host.sub('http://', '')\n else\n @controller.send(:default_url_options, nil)[:host]\n end\n end",
"def mock_host\n mock_host = (ENV['MOCK_HOST'].nil?) ? 'esu2v871' : ENV['MOCK_HOST']\n end",
"def server\n uri = \"#{options[:use_ssl] ? \"https\" : \"http\"}://#{Blupee.config.api_server}\"\n end",
"def application_url\n tenant = use_shared_configservers ? @tenant_name : \"default\"\n application = use_shared_configservers ? @application_name : \"default\"\n \"https://#{vespa.nodeproxies.first[1].addr_configserver[0]}:#{19071}/application/v2/tenant/#{tenant}/application/#{application}/environment/prod/region/default/instance/default/\"\n end",
"def determine_url\n ENV[\"DATABASE_URL\"] || database_url_from_database_yml\n end",
"def environment_name(url = nil)\n url ||= self.url\n uri = URI(url)\n\n if (uri.host == 'localhost')\n if uri.port.nil?\n uri.host;\n else\n \"#{uri.host}:#{uri.port}\"\n end\n else\n name = case uri.host\n when /(?:origin-)?www\\d?(?:\\.pos)?(?:\\.siteb)?\\.([^\\.]+)(?:\\.fds)?\\.com/,\n /(?:m|m2qa1|mdev1|mockmacys|local)\\.([^\\.]+)(?:\\.fds)?\\.com/, # mobile env\n /([^\\.]+)\\.\\w+\\.\\w+\\.griddynamics\\.net/, # partial env\n /([^\\.]+)\\.stage2\\.cistages\\.fds/, # stage 2 env\n /([^\\-]+)-staging.bloomingdales\\.com/, #BCOM Heroku Staging Env\n /([^\\.]+).bloomingdales\\.com/, #BCOM Heroku Production Env\n /([^\\.]+)\\.cistages\\.fds/,\n /([^\\.]+)\\.macysbackstage\\.com/,\n /([^\\.]+)\\.herokuapp\\.com/,\n /([^\\.]+)\\.c4d\\.devops\\.fds\\.com/,\n /sstportal/\n Regexp.last_match.captures.first\n else\n raise URI::InvalidURIError, \"URI was not recognized: '#{url}'.\"\n end\n name\n end\n end",
"def test_server\n TEST_SERVER\n end",
"def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end",
"def local_host\n get('beef.http.host') || '0.0.0.0'\n end",
"def hostname\n Rails.env.development? ? h.root_url(port: 3000).chomp!('/') : h.root_url.chomp!('/')\n end",
"def get_server_path\n @host=request.host.to_s\n @port=request.port.to_s\n @serverURL=\"http://#{@host}\"\n @serverURL = @serverURL + \":#{@port}\" unless @port == \"80\"\n end",
"def server_url\n 'dkdeploy.dev'\n end",
"def webserver_host\n AgileProxy.config.webserver_host\n end",
"def host\n ENV['CA_HOST'] || DEFAULT_HOST\n end",
"def dev_url(path = \"/\")\n uri = URI.join(\"http://#{Radiant::Config['dev.host'] || 'dev'}.#{self.base_domain}\", path)\n uri.to_s\n end",
"def site_url(full: true)\n full ? root_url : \"#{request.host}:#{request.port}/\"\n end",
"def set_base_url\n $base_url = (ENV['base_url'].nil? || ENV['base_url'].empty?) ? CONFIG['default_base_url'] : ENV['base_url']\nend",
"def get_url\n URI.parse(\"#{@server}#{URL}\")\n end",
"def localhost_url path = nil\n \"http://localhost:4270/#{path}\"\n end",
"def base_url\n case mode&.to_sym\n when :production\n ::Deepblue::DoiMintingService.production_base_url\n when :testing\n ::Deepblue::DoiMintingService.test_base_url\n when :test\n ::Deepblue::DoiMintingService.test_base_url\n else\n raise Error.new\"Unrecognized mode #{mode}\"\n end\n # mode&.to_sym == :production ? ::Deepblue::DoiMintingService.production_base_url\n # : ::Deepblue::DoiMintingService.test_base_url\n end",
"def server_host\n AgileProxy.config.server_host\n end",
"def browser_url\r\n \"http://#{external_app_server_host}:#{external_app_server_port}\"\r\n end",
"def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end",
"def hostname\n Rails.env.development? ? 'http://localhost:3000' : 'http://coderalert.com'\n end",
"def host\n @host || HOST_PRODUCTION\n end",
"def base_url\n # Using the X-Forwarded headers in the UI can leave the app vulnerable\n # https://www.acunetix.com/blog/articles/automated-detection-of-host-header-attacks/\n # Either use the explicitly configured base url or an empty string,\n # rather than request.base_url, which uses the X-Forwarded headers.\n env[\"pactbroker.base_url\"] || \"\"\n end",
"def getServerUrl\n puts \"******* getServerUrl \" + \"*\" * 21\n reqUrl = request.original_url\n puts \" ** reqUrl \" + reqUrl\n gon.currentServerUrl = reqUrl\n end",
"def default_url_options\n { host: ScihistDigicoll::Env.lookup!(:app_url_base) }\n end",
"def fullurl\n if Rails.env == 'development'\n 'http://localhost:3000' + object.url.to_s\n else\n 'http://signlab-rails.herokuapp.com' + object.url.to_s\n end\n end",
"def host_url\n Rails.application.routes.default_url_options[:host] || Spree::Store.current.url\n end",
"def base_url\n self.mode == 'production' ? Ebay::Search::Api::PRODUCTION_URL : Ebay::Search::Api::SANDBOX_URL\n end",
"def url\n url = \"#{config.url[config.env]}/#{@path}\"\n url = \"#{url}?#{@params.to_param}\" unless @params.empty?\n url\n end",
"def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end",
"def selenium_host\n ENV.fetch('SELENIUM_HOST', '192.168.56.102')\nend",
"def brine_root_url\n if ENV['BRINE_ROOT_URL']\n ENV['BRINE_ROOT_URL']\n elsif ENV['ROOT_URL']\n deprecation_message('1.0', 'ROOT_URL is deprecated, replace with BRINE_ROOT_URL') if ENV['ROOT_URL']\n ENV['ROOT_URL']\n end\nend",
"def solr_url\n if ENV['SOLR_URL'] || ENV['WEBSOLR_URL']\n URI.parse(ENV['SOLR_URL'] || ENV['WEBSOLR_URL'])\n end\n end",
"def url\n 'https://' + request.host\n end",
"def wsfe_url\n raise 'Environment not sent to either :test or :production' unless Afip::URLS.keys.include? environment\n Afip::URLS[Afip.environment][:wsfe]\n end",
"def default_url_options\n { host: ENV['HOST'] || 'localhost:3000' }\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def pull_request_host\n\t\tpull_request_where == 'jackrabbit' ? ALF_CFG['host'] : ALF_CFG[\"cedar_host\"]\n\tend",
"def gardener_url\n (ENV['SUT_SCHEME'] || 'https') + \"://\" + gardener_fqhn()\n end",
"def url\n @url ||= \"http://#{host}:#{port}\"\n end",
"def host_url\n proto = request.env['SERVER_PROTOCOL'].downcase.index(\"https\").nil? ? \"http\" : \"https\"\n return \"#{proto}://#{request.env['HTTP_HOST']}\"\n end",
"def root_path_location\n dmptool_url = 'https://dmptool.org/' if Rails.env.production?\n dmptool_url = 'https://dmptool-dev.cdlib.org/' if dashboard_url.include?('-dev.cdlib.org')\n dmptool_url = 'https://dmptool-stg.cdlib.org/' unless dmptool_url.present?\n dmptool_url\n end",
"def get_repo_url\n repo_url = ENV['MXNET_GLUON_REPO'] || DEFAULT_REPO\n repo_url += '/' if repo_url[-1] != '/'\n repo_url\n end",
"def host; config[:host]; end",
"def __cluster_url\n if '_local_' == arguments[:network_host]\n \"http://localhost:#{arguments[:port]}\"\n else\n \"http://#{arguments[:network_host]}:#{arguments[:port]}\"\n end\n end",
"def console_url\n URI::HTTPS.build(:host => hostname, :port => port)\n end",
"def site_url\n SITE_URL\n end",
"def site_url\n get_url(:site)\n end",
"def default_url_options\n { host: ENV[\"HOST\"] || \"localhost:3000\" }\n end",
"def default_url_options\n { host: ENV[\"HOST\"] || \"localhost:3000\" }\n end",
"def default_url_options\n { host: ENV[\"HOST\"] || \"localhost:3000\" }\n end",
"def default_url_options\n { host: ENV[\"HOST\"] || \"localhost:3000\" }\n end",
"def gateway_url\n if sandbox?\n GATEWAY_SANDBOX_URL\n else\n GATEWAY_URL\n end\n end",
"def default_url_options\n {\n host: ScihistDigicoll::Env.lookup(:app_url_base)\n }\n end",
"def base_web_url(artefact)\n if [\"production\", \"test\"].include?(ENV[\"RACK_ENV\"])\n public_web_url\n else\n Plek.current.find(artefact.rendering_app || artefact.owning_app)\n end\n end",
"def surl(service)\n service_url = @env == :stable ? API_URL : SANDBOX_API_URL\n service_url = service_url + \"/\" + service\n service_url.gsub!('www', 'usercontent') if service.to_s == 'image'\n service_url\n end",
"def url\n config.source_host_url\n end",
"def url\n @url || Gandi::TEST_URL\n end",
"def desired_hostname\n if path.start_with?('/foo/en')\n Rails.env.staging? ? 'foo-staging.infopark.com' : 'www.foo.com'\n else\n # Default hostname\n Rails.env.staging? ? 'website-staging.infopark.com' : 'www.website.com'\n end\n end",
"def api_endpoint\n case current_user.environment\n when 'int', 'integration'\n 'http://newapi.int.brandwatch.com'\n when 'rel', 'release', 'stage'\n 'http://newapi.rel.brandwatch.com'\n else\n 'http://newapi.brandwatch.com'\n end\n end"
] | [
"0.7494612",
"0.7353119",
"0.7247557",
"0.71140593",
"0.7103848",
"0.7103848",
"0.7079462",
"0.7078015",
"0.70766836",
"0.7011295",
"0.70039564",
"0.69781536",
"0.6976606",
"0.6950521",
"0.6943098",
"0.6860118",
"0.68076366",
"0.6805368",
"0.6766746",
"0.6763752",
"0.67558944",
"0.67557734",
"0.67414767",
"0.67252356",
"0.6686264",
"0.6675498",
"0.66525966",
"0.66518605",
"0.6644073",
"0.6640798",
"0.6640798",
"0.66386443",
"0.6633209",
"0.6602409",
"0.6588477",
"0.657456",
"0.6565086",
"0.6563014",
"0.6553521",
"0.653219",
"0.6505976",
"0.6491652",
"0.6480509",
"0.64703715",
"0.645774",
"0.6452444",
"0.6427334",
"0.64259595",
"0.64222664",
"0.64209974",
"0.6401782",
"0.63928545",
"0.63908815",
"0.6387752",
"0.63866115",
"0.6362633",
"0.635371",
"0.6336862",
"0.6328631",
"0.6295546",
"0.62927073",
"0.6291834",
"0.6283445",
"0.6256412",
"0.62452084",
"0.6228894",
"0.6180671",
"0.6173689",
"0.6166986",
"0.6165618",
"0.61609596",
"0.61587244",
"0.61427516",
"0.6142042",
"0.61262774",
"0.6120455",
"0.61175764",
"0.6117492",
"0.6114549",
"0.60942984",
"0.6093258",
"0.6090631",
"0.6077162",
"0.607682",
"0.60762197",
"0.6074789",
"0.60742825",
"0.60675335",
"0.6064423",
"0.6064423",
"0.6064423",
"0.6064423",
"0.60509384",
"0.6043241",
"0.6038314",
"0.60222465",
"0.6019649",
"0.6010133",
"0.60092413",
"0.59975815"
] | 0.7927469 | 0 |
Takes a png screenshot and saves to the target path. Example: screenshot '/tmp/hi.png' | def screenshot png_save_path
@driver.save_screenshot png_save_path
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_screenshot(png_path)\n extension = File.extname(png_path).downcase\n if extension != '.png'\n ::Appium::Logger.warn 'name used for saved screenshot does not match file type. ' \\\n 'It should end with .png extension'\n end\n File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }\n end",
"def screenshot(driver,sess_time,shot_num,descr)\n filename = \"shot-#{shot_num}-#{driver.current_url.sub(\"http://\",\"\").sub(\"admin:123@\",\"\").gsub(\"/\",\"-\")}-(#{descr})-#{sess_time}.png\"\n # driver.save_screenshot (\"shot-#{shot_num}-#{driver.current_url.sub(\"https://format-staging.com/\",\"\").gsub(\"/\",\"-\")}-(#{descr})-#{sess_time}.png\")\n driver.save_screenshot(filename)\n # puts (\" 📸 Shot #{shot_num} (#{driver.current_url})\")\n puts (\" 📸 #{filename}\")\n return 1\nend",
"def save_screenshot\n browser.screenshot.save(\"#{report_dir}/shot#{timestamp}.png\")\n end",
"def save_shot(screenshot)\n\t\t@browser.screenshot.save(screenshot)\n\tend",
"def save_screenshot(filename)\n file = File.join(\n @screen_dir,\n sanitize(filename.end_with?('.png') ? filename : \"#{filename}.png\")\n )\n\n dir = File.dirname(file)\n\n mkdir(dir) unless Dir.exist?(dir)\n\n driver.save_screenshot(file)\n end",
"def save_screenshot\n @suite.p \"-- CAPTURE SCREENSHOT ::\"\n begin\n screenshot_flag = true\n filename = (ENV['REPORTS_DIR'] + \"/\" + self.class.name + '.png')\n @suite.capture_screenshot(filename)\n @suite.p \"-- SCREENSHOT CAPTURED TO: {#{filename}}\"\n screenshot_flag = false\n rescue => e\n if screenshot_flag\n @suite.p \"FAILED TO CAPTURE SCREENSHOT: \"\n @suite.p e.inspect\n @suite.p e.backtrace\n end\n end\n end",
"def take_screenshot(_scenario)\n screenshot_dir = \"#{FigNewton.screenshot_directory}/#{$date_and_time}\"\n FileUtils.mkdir screenshot_dir unless File.directory? screenshot_dir\n encoded_img = @browser.driver.screenshot_as(:base64)\n embed(\"data:image/png;base64,#{encoded_img}\", 'image/png')\nend",
"def screenshot(filename)\n platform.screenshot(filename)\n end",
"def save_screenshot(path, options = {})\n appium_driver.screenshot path if @appium_driver\n end",
"def screenshoot(url, filename)\n unless File.exists?(\"#{IMG_DIR}/#{filename}.png\")\n system \"python webkit2png.py -t #{IMG_TIMEOUT} -o #{IMG_DIR}/#{filename}.png #{url} \"\n else \n puts \"Already screenshoted: #{IMG_DIR}/#{filename}.png\"\n end\nend",
"def saos\n save_and_open_screenshot\n end",
"def save_screenshot(path, options = {})\n browser.screenshot path\n end",
"def make_screenshot\n Logbook.step('Taking a screenshot of a result page')\n @browser.save_screenshot(\"screenshots/screenshot - #{Time.now.strftime('%Y-%m-%d %H-%M-%S')}.png\")\n end",
"def screenshot _value\n send_cmd(\"screenshot #{_value}\")\n end",
"def add_screenshot(scenario)\n nome = scenario.name.tr(' ', '_').downcase!\n captura = page.save_screenshot(\"log/screenshots/#{nome}.png\")\n attach(captura, 'image/png')\nend",
"def save_screenshot(file_name)\n source_image = File.basename(file_name)\n source_image.slice!(/\\.attempt_\\d+/)\n source_image.slice!(/^\\d\\d_/)\n\n FileUtils.cp(File.expand_path(source_image, TEST_IMAGES_DIR), file_name)\n end",
"def store_screenshot(path)\n screenshot = screenshots.first\n if (screenshot)\n begin \n variant = screenshot.variant(resize_to_limit: [425, nil], resize_to_fill: [425, 250, { crop: :low }]).processed\n path = variant.blob.service.send(:path_for, variant.key)\n FileUtils.cp(path, \"/Users/jan.prill/Documents/workspace/msp/inviadorepo/web/js/gridsome/inviado/src/assets/images/inviado/#{id}.png\")\n rescue\n p \"There is a problem on #{variant}\"\n end\n end\n end",
"def screenshot(filename=nil)\n fn = filename || @ticket || SecureRandom.uuid.to_s\n f = \"screenshots/#{fn}.png\"\n @session.save_screenshot(f)\n puts \"Saved #{f}:\"\n return f\n end",
"def save_screenshot(scenario)\n path = SCREENSHOTS_DIR\n\n # prepare dir\n FileUtils.mkdir(path) unless File.directory?(path)\n\n # prepare scenario name\n if scenario.instance_of?(Cucumber::Ast::OutlineTable::ExampleRow)\n scenario_name = scenario.scenario_outline.name.gsub(/[^\\w\\-]/, ' ')\n scenario_name << \"-Example#{scenario.name.gsub(/\\s*\\|\\s*/, '-')}\".chop\n else\n scenario_name = scenario.name.gsub(/[^\\w\\-]/, ' ')\n end\n\n # prepare filename\n filename = \"#{path}/#{scenario_name}.png\"\n\n # save screenshot\n Testing.browser.driver.save_screenshot(filename)\n\n # embed into HTML output\n embed(filename, 'image/png')\n end",
"def saveScreenShot(filepath)\n @browser.screenshot.save(filepath)\n end",
"def save(path)\n @driver.save_screenshot(path)\n end",
"def screenshot path = '~/Desktop'\n capture_screen self, path\n end",
"def screenshot\n @browser.save_screenshot(\"screenshot.png\")\n end",
"def take_screenshot(scenario)\r\n scenario_name = \"#{scenario.name}_step\"\r\n sshot_name = \"log/screens/\" + scenario_name +\".png\"\r\n @browser.screenshot.save(sshot_name) rescue nil\r\n embed(sshot_name, 'image/png') rescue nil\r\nend",
"def png\n @driver.screenshot_as(:png)\n end",
"def screen_capture(fileName)\n return $marathon.saveScreenShot(fileName)\nend",
"def screen_capture(fileName)\n return $marathon.saveScreenShot(fileName)\nend",
"def take_screenshot(scenario)\r\n screen_name = \"log/screens/\" +scenario.name+\".png\"\r\n page.save_screenshot(screen_name) rescue nil\r\n embed(screen_name, 'image/png') rescue nil\r\nend",
"def save_image(class_name, test_case_method_name)\r\n if (WatirBrowser.ie?)\r\n #see if CC_BUILD_ARTIFACTS is set, used by cruise control server\r\n build_artifacts_folder = ENV['CC_BUILD_ARTIFACTS']\r\n if (not build_artifacts_folder.nil?)\r\n build_artifacts_folder = build_artifacts_folder.gsub(\"/\", \"\\\\\")\r\n end\r\n #if not set, see if TORNADO_TEST_IMAGE is set\r\n #developer can set this if they want to capture the images on their own machine\r\n if (build_artifacts_folder.nil?)\r\n build_artifacts_folder = ENV['TORNADO_TEST_IMAGE']\r\n end\r\n \r\n# build_artifacts_folder = \"c:\\\\railsproject\"\r\n unless (build_artifacts_folder.nil?)\r\n\r\n file_name = build_artifacts_folder+ \"\\\\\" + class_name + \"-\" + test_case_method_name.to_s + \".png\"\r\n \r\n if (File.exists?(file_name)) \r\n FileUtils.rm(file_name)\r\n end\r\n \r\n begin\r\n\r\n width, height, bitmap = Win32::Screenshot.desktop\r\n img = Magick::Image.from_blob(bitmap)[0]\r\n img.write(file_name)\r\n rescue Magick::ImageMagickError => e\r\n puts(\"cannot capture screen. Exception is \" + e.message)\r\n end\r\n \r\n # @screen_capture = Watir::ScreenCapture\r\n # @screen_capture.screen_capture(file_name, false, false) \r\n end\r\n end\r\n end",
"def take_screenshot(to_file = nil, opts = {})\r\n # puts \"calling new take screenshot: #{$screenshot_supported}\"\r\n # unless $screenshot_supported\r\n # puts \" [WARN] Screenhost not supported, check whether win32screenshot gem is installed\" \r\n # return\r\n # end\r\n\r\n if to_file\r\n screenshot_image_filepath = to_file\r\n else\r\n screenshot_image_filename = \"screenshot_\" + Time.now.strftime(\"%m%d%H%M%S\") + \".jpg\"\r\n the_dump_dir = opts[:to_dir] || default_dump_dir\r\n FileUtils.mkdir_p(the_dump_dir) unless File.exists?(the_dump_dir)\r\n screenshot_image_filepath = File.join(the_dump_dir, screenshot_image_filename)\r\n screenshot_image_filepath.gsub!(\"/\", \"\\\\\") if is_windows?\r\n\r\n FileUtils.rm_f(screenshot_image_filepath) if File.exist?(screenshot_image_filepath)\r\n end\r\n\r\n begin \r\n if is_firefox? then\r\n Win32::Screenshot::Take.of(:window, :title => /mozilla\\sfirefox/i).write(screenshot_image_filepath)\t\t\t\t\t\r\n\t\t elsif ie\r\n Win32::Screenshot::Take.of(:window, :title => /internet\\sexplorer/i).write(screenshot_image_filepath)\t\t\t\t\t\r\n else\r\n Win32::Screenshot::Take.of(:foreground).write(screenshot_image_filepath)\r\n end\r\n notify_screenshot_location(screenshot_image_filepath)\r\n\t\t\t\trescue ::DL::DLTypeError => de\r\n\t\t\t\t\tputs \"No screenshot libray found: #{de}\"\r\n rescue => e\r\n puts \"error on taking screenshot: #{e}\"\r\n end\r\n \r\n\r\n end",
"def screenshot(name=\"screenshot\")\n page.driver.render(\"public/#{name}.jpg\",full: true)\n end",
"def saveScreenshot(filename=nil, hidePatientDetails=false)\n if filename.nil?\n filename = @fileNameTextField.getText\n else\n # Enter the filename in the text field\n @fileNameTextField.enterText(filename)\n end\n\n \tLog.TestLog(\"Saving screenshot to '#{filename}.png'\")\n \tcheckHideDetails if hidePatientDetails\n \tclickSave\n end",
"def screenshot_large\n screenshot()\n end",
"def take_screenshot\n $browser.screenshot.save \"#{$image_folder}#{$testcase}_#{@var2}.png\"\n @var2+=1\n end",
"def create_image_from_screenshot\n type = @desktop_image.split(/\\./).last\n `screencapture -t#{type} -x #@desktop_image`\n end",
"def take_screenshot(file_name=nil)\n # make sure screenshots folder exists\n FileUtils.mkdir_p './screenshots'\n\n # if file name given, use time stamp\n if file_name.nil?\n file_name = Time.now.strftime(\"%Y-%m-%d_%H-%M-%S.png\")\n end\n\n sleep(1)\n $browser.screenshot.save \"./screenshots/#{file_name}\"\n log(\"screenshot taken: ./screenshots/#{file_name}\")\n sleep(1)\n\n # add to report\n embed(\"./screenshots/#{file_name}\", \"image/png\", \"SCREENSHOT\")\nend",
"def screenshot(filename=Time.now\\\n .strftime(\"Screenshot from %Y-%m-%d %d-%m-%y\"))\n\n XDo::Keyboard.simulate('{print}');\n sleep 4;\n XDo::Keyboard.simulate(\"{down}\")\n sleep 4;\n XDo::Keyboard.alt_s\n sleep 5;\n XDo::Keyboard.type filename\n sleep 3\n XDo::Keyboard.alt_s\n sleep 1\n\n end",
"def saveScreen(fileInfo)\n screenShotPath = \"#{fileInfo}.png\"\n screenHTMLPath = \"#{fileInfo}.html\"\n saveScreenShot(screenShotPath)\n saveScreenHTML(screenHTMLPath)\n end",
"def screenshot_and_save_page\n Capybara::Screenshot.screenshot_and_save_page\nend",
"def screenshot rect = CGRect.new(CGPoint.new(0, 0), CGSize.new(-1, -1)),\n path = '~/Desktop'\n require 'accessibility/screen_shooter'\n ScreenShooter.shoot rect.to_rect, path\n end",
"def take_screenshot(options)\n verify_ffmpeg_exists\n verify_source_exists\n \n ffmpeg_options = {\n :i => @source,\n :s => '320x240',\n :vframes => 1,\n :ss => options[:at],\n :an => '',\n }.merge(options.has_key?(:options) ? options[:options] : {})\n \n output = run_ffmpeg( ffmpeg_options, options[:to], true )\n raise \"unable to take screenshot:\\n\\n#{output}\" unless File.exists?(options[:to])\n end",
"def screenshot_small\n screenshot(:small)\n end",
"def save_screenshot_embed(screenshot, id)\n if driver\n driver.save_screenshot(screenshot)\n embed(screenshot, 'image/png', \"Screenshot #{id}\")\n end\nend",
"def snagScreenshot\n thing = waitForObject(@symbolicName)\n image = grabWidget(thing)\n format = \"PNG\"\n ssName = thing.name + \".\" + format\n ssLoc = Log.testLogLocation\n image.save(ssLoc + ssName, format)\n Log.AppendLog(\"Taking screenshot of: \" + @name + \" symbolicName: \" + @symbolicName + \" and saving to Location: \" + ssLoc)\n return ssName\n end",
"def cmd_screenshot( *args )\n\t\tpath = Rex::Text.rand_text_alpha(8) + \".jpeg\"\n\t\tquality = 50\n\t\tview = true\n\t\t\n\t\tscreenshot_opts = Rex::Parser::Arguments.new(\n\t\t\t\"-h\" => [ false, \"Help Banner.\" ],\n\t\t\t\"-q\" => [ true, \"The JPEG image quality (Default: '#{quality}')\" ],\n\t\t\t\"-p\" => [ true, \"The JPEG image path (Default: '#{path}')\" ],\n\t\t\t\"-v\" => [ true, \"Automatically view the JPEG image (Default: '#{view}')\" ]\n\t\t)\n\t\t\n\t\tscreenshot_opts.parse( args ) { | opt, idx, val |\n\t\t\tcase opt\n\t\t\t\twhen \"-h\"\n\t\t\t\t\tprint_line( \"Usage: screenshot [options]\\n\" )\n\t\t\t\t\tprint_line( \"Grab a screenshot of the current interactive desktop.\" )\n\t\t\t\t\tprint_line( screenshot_opts.usage )\n\t\t\t\t\treturn\n\t\t\t\twhen \"-q\"\n\t\t\t\t\tquality = val.to_i\n\t\t\t\twhen \"-p\"\n\t\t\t\t\tpath = val\n\t\t\t\twhen \"-v\"\n\t\t\t\t\tview = false if ( val =~ /^(f|n|0)/i )\n\t\t\tend\n\t\t}\n\t\t\n\t\tdata = client.ui.screenshot( quality )\n\t\t\n\t\tif( data )\n\t\t\t::File.open( path, 'wb' ) do |fd|\n\t\t\t\tfd.write( data )\n\t\t\tend\n\t\t\n\t\t\tpath = ::File.expand_path( path )\n\t\t\t\n\t\t\tprint_line( \"Screenshot saved to: #{path}\" )\n\t\t\t\n\t\t\tRex::Compat.open_file( path ) if view\n\t\tend\n\t\t\n\t\treturn true\n\tend",
"def screenshot\n dname = Document.name.get[0][0..-5]\n a = File.open(\"/tmp/skim-#{dname}-tmp\",\"a\")\n page = Document.get[0].current_page.get.index.get\n\n curfile = File.last_added(\"#{Home_path}/Desktop/Screen*.png\")\n a << \"#{curfile},#{page}\\n\"\n growl(\"One picture added to wiki notes cache\")\nend",
"def to_png(path, options = {})\n return raise Exceptions::InvalidFileFormatError unless valid_output_format?(path, 'png')\n screenshot(path, 'png', options)\n end",
"def add_image_from_rspec(argument, example, url_path)\n blob = caller.find{|i| i[ example.file_path.gsub(/:\\d*|^\\./,\"\") ]}\n file_with_line = blob.split(\":\")[0,2].join(\":\")\n\n filename = [example.description, argument, file_with_line, SecureRandom.hex(6) ].join(\" \").gsub(/\\W+/,\"_\") + \".jpg\"\n full_name = File.join(Poltergeist::ScreenshotOverview.target_directory, filename )\n FileUtils.mkdir_p Poltergeist::ScreenshotOverview.target_directory\n describe = example.metadata[:example_group][:description_args]\n @files << Screenshot.new({\n :url => url_path,\n :argument => argument,\n :local_image => filename,\n :full_path => full_name,\n :group_description => describe,\n :example_description => example.description,\n :file_with_line => file_with_line\n })\n full_name\n end",
"def screenshot(filename=nil)\n # TODO: This should call document.screenshot instead, but that\n # requires a generic ScreenShotReply interface in OperaDriver.\n filename.nil? ? OperaWatir::Screenshot.new(self) : OperaWatir::Screenshot.new(self).save(filename)\n end",
"def capture\n unless Platform.darwin?\n puts \"Capture command is only supported on OS X for the time being.\"\n return\n end\n\n image_path = \"#{ENV['HOME']}/.imgurr.temp.png\"\n Platform.capture('-W', image_path)\n\n # User might have canceled or it takes some time to write to disk.\n # Check up to 3 times with 1 sec delay\n 3.times do\n if File.exist?(image_path)\n puts \"Uploading screenshot...\"\n upload(image_path)\n File.delete(image_path)\n break\n end\n sleep(1)\n end\n end",
"def screenshot(page)\n return\tif page[\"url\"].to_s.strip.length == 0\n\n host = Addressable::URI.parse(page[\"url\"]).host\n foldr = GIT_REPO_PATH + host\n\n foldr.mkpath if !File.exists?( foldr )\n image_filename = Digest::MD5.hexdigest( page[\"url\"] + page[\"selector\"] )+\".png\"\n image_path = (foldr + image_filename).expand_path\n\n cmd = Shellwords.join(['xvfb-run', '-a', CONFIG[\"slimerjs_cmd\"],\n '--ssl-protocol=any',\n SCREENSHOTJS_PATH, page[\"url\"], image_path, page[\"selector\"]])\n puts \"screenshot cmd: #{cmd}\"\n puts %x{#{cmd}}\n\n # update git repo & push to remote repo\n Dir.chdir(GIT_REPO_PATH)\n commit_message = \"#{page[\"title\"]} - #{page[\"url\"]} \\n #{Time.now.to_s}\"\n %x{git add . && git commit -a -m #{Shellwords.escape(commit_message)} && git push 2>&1}\nend",
"def screenshot(name)\n begin\n @screenshots[name] = @browser.screenshot.base64\n rescue StandardError => ex\n @logger.warn(\"Unable to take screenshot '#{name}' due to an error \"\\\n \"(#{ex.class}: #{ex})\")\n end\n end",
"def window_capture(fileName, windowName)\n return $marathon.saveScreenShot(fileName)\nend",
"def window_capture(fileName, windowName)\n return $marathon.saveScreenShot(fileName)\nend",
"def realizarCapturaDePantalla\n self.getBrowser().screenshot.save(\"#{GEDORUTASCREENSHOT}GEDO_#{DateTime.now.strftime(\"%Y-%b-%d_%H%M%S\")}.png\")\n end",
"def create_screenshot_path\n @ocr_screenshots_path =\n File.join(Dir.tmpdir, 'screen_element', 'ocr_screenshots')\n FileUtils.rm_r @ocr_screenshots_path if Dir.exist?(@ocr_screenshots_path)\n FileUtils.mkdir_p @ocr_screenshots_path\n end",
"def default_screenshot(message)\n [\"./screenshot.jpg\", message]\n end",
"def screenshot(project_id, screenshot_id, req_params = {})\n params = { query: [project_id, screenshot_id], req: req_params }\n\n data = endpoint(name: 'Screenshots', params: params).do_get\n\n resource 'Screenshot', data\n end",
"def generate_png\n command = \"python #{Rails.root}/lib/webkit2png --transparent -F -o #{id} -D #{Rails.root}/tmp #{url} \"\n system command\n return \"#{Rails.root}/tmp/#{id}-full.png\"\n end",
"def take_failed_screenshot\n return unless failed? && supports_screenshot? && Capybara::Session.instance_created?\n\n take_screenshot\n metadata[:failure_screenshot_path] = relative_image_path if Minitest::Runnable.method_defined?(:metadata)\n end",
"def save_evidence_execution\n evidence_dir = \"evidence/#{Time.now.strftime('%F')}/#{ENV['CUCUMBER_MOBILE_EXECUTION']}\"\n FileUtils::mkdir_p evidence_dir unless Dir.exist? evidence_dir\n screenshot_embed({:prefix=>evidence_dir, :name=>\"#{timestamp}_evidence.png\"})\nend",
"def png_file(path, *args)\n File.open(path, 'wb') do |f|\n png(f, *args)\n end\n end",
"def run\n super\n\n uri = _get_entity_attribute \"name\"\n filename = \"screenshot_#{rand(100000000000000)}.png\"\n full_path = \"#{Dir.pwd}/public/screenshots/#{filename}\"\n\n begin\n @task_log.log \"Saving to... #{full_path}\"\n\n f = Screencap::Fetcher.new(uri)\n screenshot = f.fetch(\n :output => full_path, # don't forget the extension!\n # optional:\n #:div => '.header', # selector for a specific element to take screenshot of\n #:width => 1024,\n #:height => 768,\n #:top => 0, :left => 0, :width => 100, :height => 100 # dimensions for a specific area\n )\n\n @task_log.good \"Saved to #{full_path}\"\n _create_entity \"Screenshot\", :name => \"#{uri}_screenshot\", :uri => \"#{$intrigue_server_uri}/screenshots/#{filename}\"\n\n rescue Screencap::Error => e\n @task_log.error \"Unable to capture screenshot: #{e}\"\n end\n\n end",
"def to_file(name: 'screen.png')\n if name === 'ascii'\n system \"clear\" #clear the terminal screen\n Magick::Image::from_blob(to_svg).first.inspect_bitstream(width, height)\n else\n Magick::Image::from_blob(to_svg).first.write(name)\n end\n end",
"def take_screenshot(scenario)\n if scenario.failed?\n scenario_name = \"#{(convert_turkish_characters scenario.name)}\"\n scenario_name= scenario_name.split(\" \").join('-').delete(',')\n puts scenario_name\n time = Time.now.strftime(\"%H.%M-%m.%d.%Y\")\n time=time.to_s\n page.save_screenshot(File.absolute_path(\"features/screenshots/FAIL-#{time}-count-#{$screenshot_counter}-#{scenario_name[0..50]}.png\"))\n end\nend",
"def png(base_filename)\n check_that_dot_is_installed\n mk_tmp_dir\n abs_path = \"#{TMP_DIR}/#{base_filename}.png\"\n write_png(abs_path)\n system \"open #{abs_path}\"\n end",
"def snap(descriptor = \"\")\n name = clean_url(page.current_url)\n\n # Descriptor\n name = name + (descriptor.empty? ? \"\" : \"-state-#{descriptor}\")\n p \"#snap\", \"name\", name unless name.empty?\n\n set_window_size\n\n # Ensure @folder exists\n FileUtils.mkdir_p(@folder) unless File.exists?(@folder)\n Capybara.current_session.driver.browser.save_screenshot(\"#{@folder}/#{name}.png\")\n end",
"def set_default_screenshot(screen)\n return unless screen\n \n self.thumb_url = screen.screenshot.url(:thumb)\n self.preview_url = screen.screenshot.url(:original)\n self.screenshot_url = screen.screenshot.url\n self.save\n end",
"def screenshot\n Screenshot.new self\n end",
"def take_screenshot_from_tab(options = {})\n screenshoter = File.join Chromeshot.root, 'bin', 'save-screenshot.js'\n system 'nodejs', screenshoter, \"--tab=#{options[:tab]}\", \"--output=#{options[:output]}\", \"--debugPort=#{self.debug_port}\", \"--script=#{options[:script]}\"\n system 'convert', options[:output], '-trim', '-strip', '-quality', '90', options[:output]\n end",
"def take_screenshot(index, action)\n #-------------------------------------------------------------------------------------------------------------\n # save body au format text to fichier\n #-------------------------------------------------------------------------------------------------------------\n begin\n source_file = Flow.new(@home, index.to_s, action, Date.today, nil, \".txt\")\n source_file.write(@browser.body)\n\n rescue Exception => e\n @@logger.an_event.debug \"browser save body #{source_file.basename} : #{e.message}\"\n\n else\n @@logger.an_event.debug \"browser save body #{source_file.basename}\"\n\n end\n\n #-------------------------------------------------------------------------------------------------------------\n # prise d'un screenshot au format image\n #-------------------------------------------------------------------------------------------------------------\n [source_file.absolute_path, @browser.take_screenshot(Flow.new(@home, index.to_s, action, Date.today, nil, \".png\"))]\n\n end",
"def save_png(filename)\n save_svg(filename)\n Dir.cd_to(filename) do |basename|\n system(\"convert \\\"#{basename}.svg\\\" \\\"#{basename}.png\\\"\") || system(\"rsvg-convert \\\"#{basename}.svg\\\" -o \\\"#{basename}.png\\\"\")\n end\n end",
"def test_step_screenshot(source, step_name, file)\n test = source.test\n suite_name, test_name = _test_details(test)\n\n @manager.allure_add_attachment(suite_name, test_name, file, step: step_name, title: File.basename(file))\n end",
"def save(path='result.jpg')\n @canvas.write(path)\n end",
"def XOtakeScreenShot()\n\t\tbegin\n\t\t\tif(@brTypeSym== :chrome)\n\t\t\t\twidth = @wwBrws.execute_script(\"return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);\")\n\t\t\t\theight = @wwBrws.execute_script(\"return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);\")\n#\n# Add some pixels on top of the calculated dimensions for good\n# measure to make the scroll bars disappear\n#\n\t\t\t\t@wwBrws.window.resize_to(width+100, height+100)\n\t\t\tend\n\n\t\t\timgName= $gcfd.report_path+@wwBrws.url.tr(\" =%?*/\\\\:&~\",'_')[0..100]+Time.now.to_i.to_s+'.png'\n\t\t\t@wwBrws.screenshot.save imgName\n\t\t\t@screenList << imgName\n\t\t\t$alog.lwrite(('Image saved in '+imgName), 'DEBG')\n\t\t\tres= OK\n\t\trescue\n\t\t\t$alog.lwrite('Problems taking screenshots: '+$!.to_s, 'ERR_') \t\t\t\t#\n\t\t\tres= CRITICAL\n\t\tend\n\t\treturn res\n\tend",
"def generate_png\n img = IMGKit.new(url).to_png\n file = File.new(\"#{id}-full.png\", \"w\", :encoding => 'ascii-8bit')\n file.write(img)\n return file.path\n end",
"def capture_screenshot\n screenshot_file = ScreenshotClient.capture(live_url, format: 'JPG')\n\n screenshot = WorkshopProjectScreenshot.new\n screenshot.file.attach(\n io: screenshot_file,\n filename: 'screenshot.jpg'\n )\n\n self.screenshot = screenshot\n end",
"def prepare_screenshot(screenshot_name = \"screenshot.png\", is_remove_previous = true, is_crop = true)\n logc(\"method: #{__method__}, params: #{screenshot_name}, #{is_remove_previous}, #{is_crop}\")\n\n remove_screenshot_file if is_remove_previous\n\n $screenshot_file_path = take_screenshot_faster(File.join(@report_path, screenshot_name))\n\n crop_image($screenshot_file_path) if is_crop\n\n logc(\"screenshot saved: #{$screenshot_file_path}\")\n return $screenshot_file_path\nend",
"def test_screenshot(source, file)\n test = source.test\n suite_name, test_name = _test_details(test)\n\n @manager.allure_add_attachment(suite_name, test_name, file: file)\n end",
"def screenshot(width, height, quality)\n url = player_url+'/application/screenshot?'\n url += \"width=#{width}\"\n url += \"&height=#{height}\"\n url += \"&quality=#{quality}\"\n url += \"&#{plex_token}\" if plex_token\n\n ping url\n end",
"def png(*args)\n PNG.write(@source, *args)\n end",
"def component_capture(fileName, windowName, componentName)\n return $marathon.saveScreenShot(fileName)\nend",
"def component_capture(fileName, windowName, componentName)\n return $marathon.saveScreenShot(fileName)\nend",
"def makeScreenShot(urlArray)\n urlArray.each do |item|\n puts \"Item: \"+item\n cmd = \"webkit2png -W 1366 -D \"+@outputDirectory+\" -F \"+item\n\n Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|\n puts \"stdout is:\" + stdout.read\n puts \"stderr is:\" + stderr.read\n end\n\n puts green('Done...')\n sleep(@screenShotSleepTime)\n end\n end",
"def tirar_foto(nome_pasta, ordem)\n shot = \"logs/shots/a_registrar/#{nome_pasta}/#{ordem}.png\"\n page.save_screenshot(shot)\n end",
"def create_screenshot(screenshot)\n @sceenshot = Sprite.new(@viewport).set_bitmap(screenshot)\n @sceenshot.set_origin(@viewport.rect.x, @viewport.rect.y)\n @sceenshot.zoom = Graphics.width / screenshot.width.to_f\n end",
"def captureScreen(filename=nil, hidePatientDetails=false)\n screenCaptureBtn = Element.new(\"Capture Screen Button\", \":Form.captureScreenButton_QPushButton\")\n screenCaptureBtn.click\n snooze 1\n ScreenCapturePopup.new.saveScreenshot(filename, hidePatientDetails)\n end",
"def capture(url, filename)\n page_class = Class.new { include PageMagic }\n session = PageMagic.session(browser: :headless_chrome, url: url)\n session.visit(page_class, url: url)\n session.browser.save_screenshot(filename)\n filename\n end",
"def to_jpeg(path, options = {})\n return raise Exceptions::InvalidFileFormatError unless valid_output_format?(path, 'jpeg')\n screenshot(path, 'jpeg', options)\n end",
"def save\r\n # Draw a frame.\r\n frame = Draw.new\r\n frame.stroke(\"black\")\r\n frame.stroke_width(2)\r\n frame.fill_opacity(0)\r\n frame.rectangle(0, 0, @image.columns-1, @image.rows-1)\r\n frame.draw(@image)\r\n \r\n @image.write(name + '.png')\r\n end",
"def screenshot(thumbnail = nil)\n url = nil\n begin \n url = Url.find(params[:id])\n rescue\n url = nil\n end\n if (!url.nil? &&\n !url.screenshot.nil? &&\n (url.group_id.nil? ||\n current_user.has_role?(:admin) ||\n !current_user.groups.map{|g| g.is_a?(Group) ? g.id : g}.index(url.group_id).nil?))\n send_file(url.screenshot.public_filename(thumbnail).to_s,\n :disposition => 'inline',\n :type => url.screenshot.content_type,\n :size => url.screenshot.size, \n :x_sendfile => true)\n else\n redirect_back_or_default('/')\n end\n end",
"def failed(*args)\n begin\n CucumberCounters.error_counter += 1\n file_name = format('tmp/capybara/error_%03d.png',\n CucumberCounters.error_counter)\n Capybara.page.save_screenshot(file_name, full: true)\n Rails.logger.info(\"[Cucumber] Saved screenshot of error for #{ @scenario_name } to #{ file_name }\")\n rescue\n Rails.logger.info('[Cucumber] Cannot make screenshot of failure')\n end\n binding.pry if ENV['DEBUGGER']\n orig_failed(*args)\n end",
"def create_screenshots(project_id, params = {})\n c_r Lokalise::Resources::Screenshot, :create, project_id, params, :screenshots\n end",
"def screencapture(out_folder:, out_file: nil)\n path = \"/plugin_inspect\"\n conn = multipart_connection\n payload = {\n mysubmit: \"Screenshot\",\n passwd: @dev_password,\n archive: Faraday::UploadIO.new(File::NULL, 'application/octet-stream')\n }\n response = conn.post path, payload\n\n path = /<img src=\"([^\"]*)\">/.match(response.body)\n return false unless path\n path = path[1]\n unless out_file\n out_time = /time=([^\"]*)\">/.match(response.body)\n out_ext = /dev.([^\"]*)\\?/.match(response.body)\n out_file = \"dev_#{out_time[1]}.#{out_ext[1]}\" if out_time and out_ext\n out_file = \"dev.jpg\" unless out_file\n end\n\n conn = simple_connection\n\n response = conn.get path\n\n File.open(File.join(out_folder, out_file), \"wb\") do |io|\n io.write(response.body)\n end\n @logger.info \"Screen captured to #{File.join(out_folder, out_file)}\"\n return response.success?\n end",
"def create_screenshot_graphic\n @screenshot_loaded = false\n @screenshot = Sprite.new(@viewport)\n @screenshot.opacity = 0\n end",
"def save_tile(image, dest_path, x, y, width, height, quality)\n image = if image.is_a? Magick::Image\n image\n else\n Magick::Image::read(image).first\n end\n\n quality = quality * 100 if quality < 1\n\n tile = image.crop(x, y, width, height, true)\n tile.write(dest_path)\n end",
"def allure_screenshot\n RSpec.configure do |config|\n config.include AllureRSpec::Adaptor\n config.after(:each) do |example|\n rescue_standard_error do\n if example.exception && @browser\n rescue_standard_error do\n example.attach_file(\n 'screenshot', File.new(\n @browser.save_screenshot(\n file: 'tmp/allure_' + build_path + \"/#{UUID.new.generate}.png\"\n )\n )\n )\n end\n end\n end\n end\n end\n end",
"def draw_and_save_image\n\t\tcolor = @avatar[:color]\n\t\tpng = ChunkyPNG::Image.new(250, 250, ChunkyPNG::Color::WHITE)\n\t\tcolor = ChunkyPNG::Color.rgba(color[:r], color[:g], color[:b], color[:alpha])\n\t\t@colorable_grid.each do |points|\n\t\t\tp1 = points[0]\n\t\t\tp2 = points[1]\n\t\t\tpng.rect(p1[0], p1[1], p2[0], p2[1] , color, color)\n\t\tend\n\t\tpng.save(File.join(Dir.pwd, \"/#{@term}.png\"), :interlace => true)\n\tend",
"def screenshot\n bridge.element_screenshot @id\n end",
"def write_out(path = nil)\n return img unless path\n FileUtils.mkdir_p File.dirname(path)\n img.write(path)\n path\n rescue Errno::ENOENT\n puts_and_exit(\"Path not found '#{path}'\")\n end"
] | [
"0.7713248",
"0.73897016",
"0.7361552",
"0.7261436",
"0.72201663",
"0.71657145",
"0.71561575",
"0.7147954",
"0.7093388",
"0.7071087",
"0.7060184",
"0.7058387",
"0.70374185",
"0.70342076",
"0.7021363",
"0.69934297",
"0.69775933",
"0.69728357",
"0.6949938",
"0.69415283",
"0.6916968",
"0.68982786",
"0.68832767",
"0.68749493",
"0.6871197",
"0.68632275",
"0.6847745",
"0.68095076",
"0.6807864",
"0.6768278",
"0.67349076",
"0.67109054",
"0.66808563",
"0.66308016",
"0.66195136",
"0.66059804",
"0.65994984",
"0.6594423",
"0.65888184",
"0.6584992",
"0.65331453",
"0.65304637",
"0.6497206",
"0.6494038",
"0.64487445",
"0.6432974",
"0.64002633",
"0.6381995",
"0.63262707",
"0.6318499",
"0.62937",
"0.6272596",
"0.62676007",
"0.6253421",
"0.62482804",
"0.61841214",
"0.6145088",
"0.6133063",
"0.61244625",
"0.6096164",
"0.60896367",
"0.6080184",
"0.6058398",
"0.6054187",
"0.6042284",
"0.6037225",
"0.6030058",
"0.60123867",
"0.599368",
"0.59858924",
"0.59848106",
"0.59523743",
"0.5934988",
"0.59027004",
"0.589864",
"0.58878773",
"0.58873403",
"0.58864754",
"0.58652174",
"0.58481514",
"0.58221316",
"0.57988816",
"0.5783719",
"0.57816756",
"0.5768825",
"0.5756114",
"0.5755265",
"0.5728345",
"0.5705417",
"0.5702844",
"0.56916595",
"0.5684617",
"0.56838477",
"0.56754625",
"0.5645867",
"0.5628885",
"0.5612157",
"0.5611315",
"0.5605633",
"0.55996984"
] | 0.8234669 | 0 |
Creates a new global driver and quits the old one if it exists. | def start_driver
@client = @client || Selenium::WebDriver::Remote::Http::Default.new
@client.timeout = 999999
begin
@driver = Selenium::WebDriver.for :remote, http_client: @client, desired_capabilities: capabilities, url: server_url
# Load touch methods. Required for Selendroid.
@driver.extend Selenium::WebDriver::DriverExtensions::HasTouchScreen
# export session
if @export_session
begin
File.open('/tmp/appium_lib_session', 'w') do |f|
f.puts @driver.session_id
end
rescue
end
end
rescue Errno::ECONNREFUSED
raise 'ERROR: Unable to connect to Appium. Is the server running?'
end
# Set timeout to a large number so that Appium doesn't quit
# when no commands are entered after 60 seconds.
# broken on selendroid: https://github.com/appium/appium/issues/513
mobile :setCommandTimeout, timeout: 9999 unless @device == 'Selendroid'
# Set implicit wait by default unless we're using Pry.
@driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry
@driver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_driver\n @new_driver ||= run_context.chef_provisioning.driver_for(new_resource.driver)\n end",
"def create_driver name\n\t\tdriver = Driver.new name\n\t\t@drivers[driver.name] = driver\n\t\tdriver\t\t\n\tend",
"def reset_driver\n\t\t\t@driver.quit if @driver\n\t\t\t@driver = nil\n\t\tend",
"def driver(label = nil, options = nil)\n # Resolve unique options\n label, options = resolve_options(label, options)\n\n # Create a key for the label and options. This should always\n # return the same key for the same label and options.\n key = options['unobtainium_instance_id']\n if key.nil?\n key = identifier('driver', label, options)\n end\n\n # Only create a driver with this exact configuration once. Unfortunately\n # We'll have to bind the destructor to whatever configuration exists at\n # this point in time, so we have to create a proc here - whether the Driver\n # gets created or not.\n at_end = config.fetch(\"at_end\", \"quit\")\n dtor = proc do |the_driver|\n # :nocov:\n if the_driver.nil?\n return\n end\n\n # We'll rescue Exception here because we really want all destructors\n # to run.\n # rubocop:disable Lint/RescueException\n begin\n meth = at_end.to_sym\n the_driver.send(meth)\n rescue Exception => err\n puts \"Exception in destructor: [#{err.class}] #{err}\"\n end\n # rubocop:enable Lint/RescueException\n # :nocov:\n end\n return ::Unobtainium::Runtime.instance.store_with_if(key, dtor) do\n ::Unobtainium::Driver.create(label, options)\n end\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 quit_driver()\n @driver.shutdown\n end",
"def setup_local(driver)\n if driver == 'chrome'\n @browser = Watir::Browser.new :chrome\n elsif driver == 'firefox'\n @browser = Watir::Browser.new :firefox, marionette: true\n end\nend",
"def new_driver(suite, platform)\n ddata = data.driver_data_for(suite.name, platform.name)\n Driver.for_plugin(ddata[:name], ddata)\n end",
"def reset_driver\n @driver.reset\n end",
"def driver\n start_app_if_needed\n @driver\n end",
"def create_driver()\n startdrivernow(true)\n driver = @driver\n @asset_maps = YAML.load_file(\"features/test_data_mapping/environment.yml\")\n\n if DEVICE_TYPE != 'Android'\n if APP_TYPE == 'Phone'\n sleep 1\n driver.manage.window.resize_to(480, 800)\n sleep 1\n else\n driver.manage.window.maximize\n end\n asset_mapping = @asset_maps.find { |item| item[:Environment] == \"system\" }\n fail \"Could not find asset mapping for system\" if not asset_mapping\n\n asset_url = asset_mapping[:url]\n\n driver.navigate.to asset_url\n\n # This is required otherwise ie does no pick up the events\n driver.switch_to.active_element if DEVICE_TYPE == 'IE'\n end\nend",
"def new_browser\n if ENV[\"LOCAL_OR_HEROKU\"] then\n Watir::Browser.new :firefox\n else\n options = Selenium::WebDriver::Chrome::Options.new\n # make a directory for chrome if it doesn't already exist\n chrome_dir = File.join Dir.pwd, %w(tmp chrome)\n FileUtils.mkdir_p chrome_dir\n user_data_dir = \"--user-data-dir=#{chrome_dir}\"\n # add the option for user-data-dir\n options.add_argument user_data_dir\n\n # let Selenium know where to look for chrome if we have a hint from\n # heroku. chromedriver-helper & chrome seem to work out of the box on osx,\n # but not on heroku.\n if chrome_bin = ENV[\"GOOGLE_CHROME_BIN\"]\n options.add_argument \"no-sandbox\"\n options.binary = chrome_bin\n # give a hint to here too\n Selenium::WebDriver::Chrome.driver_path = \\\n \"/app/vendor/bundle/bin/chromedriver\"\n end\n\n # headless!\n # keyboard entry wont work until chromedriver 2.31 is released\n options.add_argument \"window-size=1200x600\"\n options.add_argument \"headless\"\n options.add_argument \"disable-gpu\"\n\n # make the browser\n Watir::Browser.new :chrome, options: options\n end\n end",
"def close_driver\n\t$driver.close\nend",
"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 create_driver(_conf = APPLICATION_DEFAULT_CONFIG, _tag = 'test')\n _undefined\n end",
"def start_driver\n @driver.start_driver\n end",
"def close_driver\n $driver.quit\nend",
"def close\n driver.close\n end",
"def register_driver\n @driver = yield\n setup_exit_handler\n end",
"def create(_, _)\n driver = ::Unobtainium::Nokogiri::Driver.new\n return driver\n end",
"def driver\n\t\t\t_load_driver unless @driver\n\t\t\t@driver\n\t\tend",
"def disconnect!\n @driver.close\n ensure\n close\n end",
"def close\n driver.close # FIXME?\n end",
"def quit_driver\n driver.quitDriver\n end",
"def define_driver(name, &block)\n drivers[name] = block\n end",
"def update\n if correct_binary?\n msg = required_version != EMPTY_VERSION ? 'The required webdriver version' : 'A working webdriver version'\n Webdrivers.logger.debug \"#{msg} is already on the system\"\n return driver_path\n end\n\n remove\n System.download(download_url, driver_path)\n end",
"def setup\n # caps = Selenium::WebDriver::Remote::Capabilities.new\n # caps[:browserName] = :chrome\n #@driver = Selenium::WebDriver.for (\n # :remote,\n # :url=> 'http://localhost:4444/wd/hub',\n # :desired_capabilities=> caps )\n #ENV['base_url'] = 'http://codap.concord.org/~eireland/CodapClasses'\n @@driver = Selenium::WebDriver.for :chrome\n # ENV['base_url'] = 'http://localhost:4020/dg'\n ENV['base_url'] = 'http://codap.concord.org/releases/latest/'\n # setupHelper(@driver.session_id)\nrescue Exception => e\n puts e.message\n puts \"Could not start driver #{@@driver}\"\n exit 1\nend",
"def driver_name\n return @driver_name.dup if @driver_name\n return nil\n end",
"def set_driver_is_available\n driver.update(is_available: false) if !is_complete?\n end",
"def setup_exit_handler\n main = Process.pid\n at_exit do\n @driver.driver_quit if Process.pid == main\n end\n end",
"def quit\r\n @@driver.quit\r\n end",
"def configure_browser()\r\n if test_config.browser == \"ie\"\r\n Capybara.register_driver :selenium do |app|\r\n Capybara::Selenium::Driver.new(app, :browser=>:internet_explorer)\r\n end\r\n else\r\n Capybara.register_driver :selenium do |app|\r\n if !(test_config.browserPath.nil? || test_config.browserPath.empty?)\r\n require 'selenium/webdriver'\r\n Selenium::WebDriver::Firefox::Binary.path = test_config.browserPath\r\n end\r\n Capybara::Selenium::Driver.new(app, :browser => :firefox)\r\n end\r\n end\r\n end",
"def register_chrome_driver\n Capybara.register_driver :chrome do |app|\n if ENV['SELENIUM_GRID'] == 'false'\n Capybara::Selenium::Driver.new(app,\n browser: :chrome,\n desired_capabilities: chrome_capabilities)\n else\n Capybara::Selenium::Driver.new(app, browser: :remote,\n url: hub_url,\n desired_capabilities: chrome_capabilities)\n end\n end\n end",
"def initialize_browser\n client = Selenium::WebDriver::Remote::Http::Default.new\n case ENV['browser']\n when 'firefox'\n puts \"\\n>Initializing Firefox browser\"\n full_path = File.dirname(File.dirname(__FILE__)) + '/config/geckodriver0.13'\n @browser = Selenium::WebDriver.for :firefox, http_client: client, driver_path: full_path\n when 'chrome'\n puts \"\\n>Initializing Chrome browser\"\n full_path = File.dirname(File.dirname(__FILE__)) + '/config/chromedriver2.27'\n @browser = Selenium::WebDriver.for :chrome, http_client: client, driver_path: full_path\n when 'safari'\n puts \"\\n>Initializing Safari browser\"\n @browser = Selenium::WebDriver.for :safari, http_client: client\n else\n @browser = Selenium::WebDriver.for :firefox, http_client: client\n end\n\n @browser.manage.timeouts.page_load = 10\n return @browser\nend",
"def assign_driver(cls, args, block)\n _cls = cls\n if not _cls.kind_of? Class\n _cls = cls.class\n end\n \n driver = nil\n name = nil\n \n self.class::DRIVERS.each_pair do |_name, _driver|\n begin\n _module = Module::get_module(_name.to_s)\n rescue NameError\n next\n end\n \n if _cls <= _module\n driver = _driver\n name = _name\n break\n end\n end\n \n ###\n \n require \"unified-queues/single/driver/\" << driver\n \n path = name.to_s.split(\"::\")\n classname = path.shift << 'Driver::' << path.join('::')\n _module = Module::get_module(\"UnifiedQueues::Single::Driver::\" << classname)\n \n args = [cls] + args\n @driver = _module::new(*args, &block)\n return @driver\n end",
"def start_new_browser_session(options={})\n start_args = [@browser_string, @browser_url, @extension_js]\n\n if driver = options.delete(:driver)\n expected_browser_string = \"*webdriver\"\n unless @browser_string == expected_browser_string\n raise ArgumentError, \"can't use :driver unless the browser string is #{expected_browser_string.inspect} (got #{@browser_string.inspect})\"\n end\n\n sid = driver.capabilities['webdriver.remote.sessionid']\n sid or raise ArgumentError, \"This driver can not be wrapped in the RC API.\"\n\n start_args << \"webdriver.remote.sessionid=#{sid}\"\n end\n\n start_args << options.collect {|key,value| \"#{key.to_s}=#{value.to_s}\"}.sort.join(\";\")\n\n @session_id = string_command \"getNewBrowserSession\", start_args\n # Consistent timeout on the remote control and driver side.\n # Intuitive and this is what you want 90% of the time\n self.remote_control_timeout_in_seconds = @default_timeout_in_seconds\n self.highlight_located_element = true if highlight_located_element_by_default\n end",
"def assign_driver(cls, args, block)\n _cls = cls\n if not _cls.kind_of? Class\n _cls = cls.class\n end\n\n driver = nil\n name = nil\n \n self.class::DRIVERS.each_pair do |_name, _driver|\n begin\n _module = Module::get_module(_name.to_s)\n rescue NameError\n next\n end\n \n if _cls <= _module\n driver = _driver\n name = _name\n break\n end\n end\n \n ###\n \n require \"unified-queues/multi/driver/\" << driver\n \n path = name.to_s.split(\"::\")\n classname = path.shift << 'Driver::' << path.join('::')\n _module = Module::get_module(\"UnifiedQueues::Multi::Driver::\" << classname)\n \n args = [cls] + args\n @driver = _module::new(*args, &block)\n return @driver\n end",
"def driver\n @driver ||= self.class.default_driver\n end",
"def create_driver(name)\n path = File.expand_path(DIR + '/' + WSDL_PATHS[name])\n wsdl = SOAP::WSDLDriverFactory.new(path)\n driver = wsdl.create_rpc_driver\n # /s+(1000|0|9c9|fcc)\\s+/ => \"\"\n driver.wiredump_dev = STDOUT if @debug\n \n driver\n end",
"def driver=(driver)\n # TODO throw some exception as modyfing driver is not supported\n raise NotImplementedError, \"You cannot modify driver of already created storage!\"\n end",
"def setup_grid(driver)\n if driver == 'chrome'\n capabilities = Selenium::WebDriver::Remote::Capabilities.new\n @browser = Watir::Browser.new(\n :remote,\n url: gridUrl,\n desired_capabilities: capabilities\n )\n end\nend",
"def driver_name=(name)\n @driver_name = name\n @driver_name.freeze\n end",
"def teardown\r\n # Do nothing\r\n @driver.close\r\n end",
"def driver_start_with(caps, server_url)\n @driver ||= driver_start(caps, server_url)\n end",
"def quit\n driver.quit\n end",
"def register_firefox_driver\n Capybara.register_driver :firefox do |app|\n if ENV['SELENIUM_GRID'] == 'false'\n options = Selenium::WebDriver::Firefox::Options.new\n Capybara::Selenium::Driver.new(app, browser: :firefox,\n options: options,\n desired_capabilities: firefox_capabilities)\n else\n Capybara::Selenium::Driver.new(app, browser: :remote,\n url: hub_url,\n desired_capabilities: firefox_capabilities)\n end\n end\n end",
"def new_session\n\n # Register PhantomJS (aka poltergeist) as the driver to use\n Capybara.register_driver :poltergeist do |app|\n Capybara::Poltergeist::Driver.new(app)\n end\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/4.0 (compatible; MSIE 6.1; Windows XP)\" }\n\n # Return the driver's session\n @session\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\n @driver = driver\n end",
"def setup\n if ENV['BROWSER'] == 'firefox'\n $driver = Selenium::WebDriver.for :firefox\n elsif ENV['BROWSER'] == 'chrome'\n $driver = Selenium::WebDriver.for :chrome\n else\n puts 'The only valid browser options are [firefox | chrome]'\n end\nend",
"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 get_local_browser(scenario)\n client = Selenium::WebDriver::Remote::Http::Default.new\n client.read_timeout = TIMEOUT\n browser = Watir::Browser.new DRIVER.to_sym, :http_client => client\n return browser\nend",
"def free_driver(driver)\n @@semaphore.synchronize do\n @@pool.each do |entry|\n if entry[:driver] == driver\n entry[:taken] = false\n end\n end\n end\n nil\n end",
"def quit\n\t\t@driver.quit\n\tend",
"def setup\r\n @browsers.each_with_index do |browser, index|\r\n sleep 0.15\r\n @providers[index] ||= browser[:object].new_browser((browser[:browser_type] || @browser_type))\r\n end\r\n end",
"def turn_off_engine\n fail 'No Driver Error' if driver.nil?\n\n @engine_on = false\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 test_db\n 'ruby-driver'.freeze\n end",
"def teardown\n @driver.close\n @driver.quit\n end",
"def init_browser\n Capybara.default_driver = ENV['CAPYBARA_BROWSER'].to_sym\n # script driver\n Capybara.javascript_driver = case ENV['CAPYBARA_BROWSER']\n when /poltergeist/\n :poltergeist\n when /headless_chrome/\n :headless_chrome\n when /headless_firefox/\n :headless_firefox\n end\nend",
"def test_new\n # clone\n browser = Browser.new :name => browsers(:first).name,\n :path => browsers(:first).path,\n :selenium_name => browsers(:first).selenium_name\n # Non-unique name should fail a save\n assert !browser.save\n browser.name = \"Test\"\n\n # working save\n assert browser.save\n\n assert browser == Browser.find(browser.id)\n\n assert browser.created_on = \"2008-10-02 17:23:43\"\n\n # test update\n assert browser.update\n\n assert browser.destroy\n end",
"def create_jdbcdriver(doc, jdbc_driver_id, lib_id, fileset_id, lib_dir)\n # We assume a consistent server.xml. If the datasource did not exist, then this must be a pure \"push app\" use case. If it is a \"push server.xml\"\n # case, then failure to find the datasource indicates server.xml is not consistent.\n # TODO: surprisingly, the following will find the driver even if it is imbedded in another datasource.\n # We could probably use XPATH /server/jdbcDriver to limit the search to global.\n drivers = doc.elements.to_a(\"//jdbcDriver[@id='#{jdbc_driver_id}']\")\n # if we find an existing jdbc driver, then one of two things has occurred\n # 1) case of pushing server.xml, but datasource not found (user error)\n # 2) case of pushing a web app and multiple instances of a given resource type (db2) were bound. The JDBC driver was already created when\n # we created the datasource for a previously processed instance. All instances of a resource type share the same JDBCDriver and library.\n if drivers.empty?\n # Not found, create it. The JDBC Driver is created as a global element and not nested underneath the datasource.\n # puts \"jdbcDriver #{jdbc_driver_id} not found, creating it\"\n # create the jdbcDriver\n driver = REXML::Element.new('jdbcDriver', doc.root)\n driver.add_attribute('id', jdbc_driver_id)\n driver.add_attribute('libraryRef', lib_id)\n modify_jdbc_driver([driver])\n # create the shared library. It should not exist.\n ClientJarUtils.create_global_library(doc, lib_id, fileset_id, lib_dir, @client_jars_string)\n end\n end",
"def teardown\r\n @driver.quit\r\n @driver = nil\r\n end",
"def setupSeleniumEnv\n\t\t#Clear selenium db\n\t\tsystem(\"RAILS_ENV=selenium rake db:reset\")\n\t\t#Starts server from selenium env\n\t\t@pid = spawn(\"RAILS_ENV=selenium rails s\")\n\tend",
"def start_driver(caps)\n driver = Appium::Driver.new(caps, true)\n # Tests expect methods defined on the minispec object\n Appium.promote_appium_methods ::Minitest::Spec, driver\n driver.start_driver\nend",
"def x\n driver_quit\n exit # exit pry\n end",
"def create_bridge(**opts)\n # for a new session request\n capabilities = opts.delete(:capabilities)\n bridge_opts = { http_client: opts.delete(:http_client), url: opts.delete(:url) }\n\n # for attaching to an existing session\n session_id = opts.delete(:existing_session_id)\n automation_name = opts.delete(:automation_name)\n platform_name = opts.delete(:platform_name)\n\n raise ::Appium::Core::Error::ArgumentError, \"Unable to create a driver with parameters: #{opts}\" unless opts.empty?\n\n bridge = ::Appium::Core::Base::Bridge.new(**bridge_opts)\n\n if session_id.nil?\n bridge.create_session(capabilities)\n else\n # attach to the existing session id\n bridge.attach_to(session_id, platform_name, automation_name)\n end\n\n bridge\n end",
"def stop_app\n if @driver\n driver_quit\n @driver = nil\n end\n end",
"def handle_driver_command input_params\n\t\tunless input_params[1].nil?\n\t\t\tdriver_name = input_params[1]\n\t\t\tself.create_driver driver_name\t\t\t\n\t\telse \n\t\t\traise ArgumentError, \"Driver command requires a driver name\" \n\t\tend\n\tend",
"def teardown\n $driver.quit\nend",
"def stop\n driver.stop\n end",
"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 teardown\n invalidate_google_session\n @driver.quit\n end",
"def open_conn(global = true, set_wait = true, host = DBHOST, user = DBUSER, pass = DBPASS, name = DBNAME)\n LOGGER.debug \"Opening db connection\"\n conn = nil\n\n #use global connection\n if global \n LOGGER.debug \"Using global database connection\"\n \n # global connection is already defined\n if is_global_db_connected?\n LOGGER.debug \"Global connection is set, just giving it back\"\n conn = $global_db_conn\n \n # global connection is not defined or not set\n else\n \n # open new global connection \n LOGGER.debug \"Global connection isn't defined or isn't set; attempting to reconnect...\"\n begin\n $global_db_conn = Mysql::new(host, user, pass, name)\n conn = $global_db_conn\n \n if set_wait && defined?(DBWAIT)\n LOGGER.debug \"Settign wait time for db connection to #{DBWAIT}\"\n sql = \"SET SESSION WAIT_TIMEOUT = #{DBWAIT};\" \n dbres = conn.query(sql)\n end\n\n rescue Mysql::Error => err\n LOGGER.error \"Error making db connection: #{$1}\"\n raise err\n end\n end\n \n # don't use global connection\n else\n LOGGER.debug \"Not using global connection, creating anew...\"\n # open new global connection \n\n begin\n conn = Mysql::new(host, user, pass, name)\n \n if set_wait && defined?(DBWAIT)\n LOGGER.debug \"Settign wait time for db connection to #{DBWAIT}\"\n sql = \"SET SESSION WAIT_TIMEOUT = #{DBWAIT};\" \n dbres = conn.query(sql)\n end\n rescue Mysql::Error => err\n LOGGER.error \"Error making db connection: #{$1}\"\n raise err\n end\n end\n \n conn\nend",
"def initialize( config, logger )\n @config = config\n @logger = logger\n\n @logger.debug \"Requested browser config: #{@config.get :global, :browser }\"\n\n type=@config.get :global, :browser, :type\n browser=@config.get :global, :browser, :browser\n port=@config.get :global, :browser, :port\n url=@config.get_default false, :global, :browser, :url\n extra_capabilities=@config.get_default false, :global, :browser, :extras\n if ! extra_capabilities\n extra_capabilities = Hash.new\n end\n\n if browser =~ %r{^\\s*ie\\s*$} or browser =~ %r{^\\s*internet\\s*_?\\s*explorer\\s*$}\n browser = 'internet explorer'\n end\n\n @logger.debug \"Launching some browser; #{type}, #{port}, #{browser}\"\n\n if type == 'remote'\n @logger.info \"Launching remote browser #{browser} on port #{port}\"\n capabilities = Selenium::WebDriver::Remote::Capabilities.new(\n :browser_name => browser,\n :javascript_enabled=>true,\n :css_selectors_enabled=>true,\n :takes_screenshot=>true,\n )\n # Load in any other stuff the user asked for\n @logger.debug \"Requested extra capabilities: #{extra_capabilities.inspect}\"\n extra_capabilities.each do |key, value|\n @logger.debug \"Adding capability #{key} with value #{value}\"\n capabilities[key] = value\n end\n\n if url\n @logger.debug \"Launching with custom url #{url}\"\n else\n url = \"http://127.0.0.1:#{port}/wd/hub\"\n end\n\n client = Selenium::WebDriver::Remote::Http::Default.new\n client.timeout = config.get_default( 600, :global, :browser, :timeout )\n\n @browser = Watir::Browser.new(:remote, :url => url, :desired_capabilities => capabilities, :http_client => client)\n else\n @logger.info \"Launching local browser #{browser}\"\n @browser = Watir::Browser.new browser\n end\n end",
"def driver\n # DATPages::Driver.instance\n @driver ||= DATPages::DriverConnection.initialize_driver\n end",
"def new_session\n\n # Register PhantomJS (aka poltergeist) as the driver to use\n Capybara.register_driver :poltergeist do |app|\n Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)\n end\n\n # Use XPath 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' => \"Mozilla/5.0 (Macintosh; Intel Mac OS X)\" }\n\n # Return the driver's session\n @session\n end",
"def teardown\n @driver.quit()\n end",
"def generator(driver)\n unless @generators.key?(driver)\n \n generator_class = @@generator_classes[driver] \n \n unless generator_class \n begin\n require \"topo/provision/#{driver}/generator\"\n generator_class = @@generator_classes[driver]\n rescue LoadError => e\n STDERR.puts e.message\n STDERR.puts(\"#{driver} driver cannot be loaded - using default generator instead\")\n generator_class = @@generator_classes[\"default\"] \n end\n end\n \n @generators[driver] = Object::const_get(generator_class).new(@topology)\n end\n \n @generators[driver]\n end",
"def start_driver\n begin\n every(interval) do\n send_command\n end\n\n super\n rescue Exception => e\n Logger.error \"Error starting Crazyflie driver!\"\n Logger.error e.message\n Logger.error e.backtrace.inspect\n end\n end",
"def init_browser(application_source)\n Selenium::WebDriver::Chrome.driver_path = application_source.driverPath\n options = Selenium::WebDriver::Chrome::Options.new\n options.add_argument('--headless')\n options.add_argument('--disable-gpu')\n # TODO Use factory method\n @driver = Selenium::WebDriver.for :chrome, options: options\n # TODO Move to strategy classes\n @driver.manage.timeouts.implicit_wait = application_source.implicitWaitTimeOut\n #@driver.manage.window.maximize\n end",
"def new_db(options = {})\n cached = find_cached(options)\n return cached if cached && !options[:force_new]\n @cache[options] = ConnectionMaker.new(options).connection\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 define_driver\n { 'name' => 'solusvm',\n 'privileged' => 'true'\n }\n end",
"def current_driver \n @current_driver ||= Driver.find(session[:driver_id]) if session[:driver_id]\n\n end",
"def clear\n @driver.clear\n end",
"def create\n Feature.bgp_enable if platform == :nexus\n router_bgp\n wait_for_process_initialized\n end",
"def teardown\n @driver.quit \n end",
"def set_driver\n return if params[:id] == 'submit_query'\n @driver = Driver.find(params[:id])\n end",
"def initialize(driver)\r\n @@driver = driver\r\n end",
"def teardown\n @driver.quit\n end",
"def teardown\n # Do nothing\n @driver.quit()\n end",
"def return_driver\r\n\t\treturn @driver\r\n\tend",
"def set_driver\n id = params[:driver_id] || params[:id]\n @driver = Driver.find_by(id: id)\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 driver; end",
"def spawn\r\n raise \"No type given (#{@opts.keys.join(\",\")}).\" if !@opts[:type]\r\n \r\n fpaths = [\r\n \"drivers/#{@opts[:type]}/knjdb_#{@opts[:type]}.rb\",\r\n \"libknjdb_#{@opts[:type]}.rb\"\r\n ]\r\n fpaths.each do |fpath|\r\n rpath = \"#{File.dirname(__FILE__)}/#{fpath}\"\r\n \r\n if (!@opts.key?(:require) or @opts[:require]) and File.exists?(rpath)\r\n require rpath\r\n break\r\n end\r\n end\r\n \r\n return Kernel.const_get(\"KnjDB_#{@opts[:type]}\").new(self)\r\n end",
"def refresh\n $driver.refresh\n end",
"def register_selenium_remote_driver(browser)\n Capybara.register_driver \"selenium_remote_#{browser}\".to_sym do |app|\n Capybara::Selenium::Driver.new(app, browser: :remote, url: \"http://#{ENV['SELENIUM_SERVER']}:4444/wd/hub\", desired_capabilities: browser)\n end\n end",
"def restart\n page.driver.browser.restart\n end"
] | [
"0.61282456",
"0.609435",
"0.596046",
"0.59585905",
"0.5870247",
"0.5737365",
"0.57364815",
"0.5728515",
"0.57254726",
"0.56848717",
"0.5647045",
"0.55671555",
"0.55487204",
"0.5531377",
"0.5495244",
"0.5397843",
"0.53778654",
"0.53486824",
"0.53267455",
"0.5323303",
"0.5294777",
"0.5280804",
"0.52804446",
"0.5259212",
"0.51831037",
"0.5181312",
"0.51677436",
"0.51502657",
"0.5128213",
"0.5120138",
"0.51067555",
"0.5102668",
"0.5086333",
"0.508149",
"0.5067471",
"0.5034358",
"0.50157815",
"0.500724",
"0.49705124",
"0.49693468",
"0.49519023",
"0.49173257",
"0.49127766",
"0.49103773",
"0.4908764",
"0.48989958",
"0.48949495",
"0.4888777",
"0.48865467",
"0.48812345",
"0.48754904",
"0.48704693",
"0.48653632",
"0.48573667",
"0.48550516",
"0.4835427",
"0.4832253",
"0.47830445",
"0.4782836",
"0.4775895",
"0.47713503",
"0.47692177",
"0.47631466",
"0.47585714",
"0.4757201",
"0.47570133",
"0.47503212",
"0.4736222",
"0.47241816",
"0.47234213",
"0.47177213",
"0.47086468",
"0.47066408",
"0.47057334",
"0.46755546",
"0.4655949",
"0.4651931",
"0.46499792",
"0.46482527",
"0.46479377",
"0.4643812",
"0.46390703",
"0.46350858",
"0.46322912",
"0.4631329",
"0.46302915",
"0.4626739",
"0.46205452",
"0.46090323",
"0.45953372",
"0.45899907",
"0.45890737",
"0.4580556",
"0.45798615",
"0.45731634",
"0.45711592",
"0.45635748",
"0.45521843",
"0.45413762",
"0.4535216"
] | 0.45938253 | 90 |
Set implicit wait and default_wait to zero. | def no_wait
@last_waits = [@default_wait, 0]
@default_wait = 0
@driver.manage.timeouts.implicit_wait = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_wait\n @default_wait\n end",
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unless e.message.include?('The operation requested is not yet implemented')\n raise ::Appium::Core::Error::ServerError, e.message\n end\n\n ::Appium::Logger.debug(e.message)\n {}\n end",
"def set_wait timeout=nil\n if timeout.nil?\n # puts \"timeout = @default_wait = @last_wait\"\n # puts \"timeout = @default_wait = #{@last_waits}\"\n timeout = @default_wait = @last_waits.first\n else\n @default_wait = timeout\n # puts \"last waits before: #{@last_waits}\"\n @last_waits = [@last_waits.last, @default_wait]\n # puts \"last waits after: #{@last_waits}\"\n end\n\n @driver.manage.timeouts.implicit_wait = timeout\n end",
"def implicit_wait=(seconds); end",
"def implicit_wait; end",
"def wait\n sleep 0.0001\n end",
"def wait\n 0\n end",
"def wait\n sleep WAIT_TIME unless @skip_wait\n end",
"def reset_wait\n @wait = @t + rand(@t_rand)\n end",
"def wait_timeout\n @wait_timeout ||= options[:wait_timeout] || DEFAULT_WAIT_TIMEOUT\n end",
"def abs_wait_short\n wait(15)\n end",
"def wait!\n sleep(@sleep)\n end",
"def wait(arg0)\n end",
"def skip_wait\n @skip_wait = true\n end",
"def wait\n @running.reset\n @waiting.set\n @running.wait\n end",
"def skip_wait=(setting)\n @skip_wait = setting\n end",
"def wait(what = T.unsafe(nil)); end",
"def wait; end",
"def wait; end",
"def wait; end",
"def sleep_for\n @sleep_for ||= 5\n end",
"def wait(seconds)\n @waiting = seconds * 1000\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def set_max_wait_time\n q = 'Set the MAX WAIT TIME after executing the RESTART command ' \\\n '(>= 180 secs): '\n until @max_wait && @max_wait.to_i > 179\n @max_wait = Utils.qna(q.cyan, true)\n end\n end",
"def wait\n true\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def wait\n @wait.synchronize do\n sleep 1 while @count >= THREAD_MAX\n @count += 1\n end\n end",
"def reset_wait_time_span\n @iteration = 0\n true\n end",
"def wait\n\tend",
"def wait\n loop do sleep 1 end\n end",
"def wait_for_launching\n sleep @delay\n end",
"def after_wait(&block)\n @after_wait_block = block\n end",
"def brute_wait(delay)\n sleep(delay)\n end",
"def init_window\n super\n # Make sure it's only done when called inside initialize\n return unless @waiter.nil?\n @wait_input = false\n @blocking = false\n @waiter = 0\n end",
"def wait_async\n @wait_async = true\n end",
"def wait_until(index)\n\t\t@wait = index\n\tend",
"def set_wait_time\n @wait_time = WaitTime.find(params[:id])\n end",
"def set_wait_time\n @wait_time = WaitTime.find(params[:id])\n end",
"def wait timeout = nil\n @mutex.synchronize {\n if @cnt != 0\n if timeout\n @cond_var.wait @mutex, timeout\n else\n @cond_var.wait @mutex\n end\n end\n }\n end",
"def wait_for_less_busy_worker(val = T.unsafe(nil)); end",
"def ev_do_calculate_rw_wait(wait); end",
"def set_default_status\n\t self.status = 0 \n\tend",
"def wait(frames)\n return if @wait > 0\n @wait = frames\n end",
"def wait(timeout=10)\n Selenium::WebDriver::Wait.new(:timeout => timeout)\n end",
"def wait_until_not_full; end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def set_defaults\n self.not_to_exceed ||= false\n self.emergency ||= false\n end",
"def waiting; end",
"def waiting; end",
"def do_wait(waited)\n wait = get_config(:docker_wait)\n return unless wait.is_a?(Integer) || wait.is_a?(Float)\n return if waited >= wait\n sleep(wait - waited)\n end",
"def sleep\n sleep_after(0)\n end",
"def default_delay\n @@default_delay ||= 0\n end",
"def wait(timeout = nil)\n @latch.wait(timeout)\n end",
"def wait\n continue = false\n trap \"SIGINT\" do\n puts \"Continuing...\"\n continue = true\n end\n puts \"Waiting. Press ^C to continue test...\"\n wait_until(3600) { continue }\n trap \"SIGINT\", \"DEFAULT\"\n end",
"def pre_sleep; end",
"def wait(seconds) \r\n\t\texec(\"Wait\", seconds.to_s)\r\n\tend",
"def actor_wait_phase \n @wait_pic.update\n if Input.trigger?(Input::B)\n #reset actor direction to original direction\n @active_battler.set_direction(@wait_pic.initial_dir)\n exit_wait_phase\n actor_menu_open\n \n elsif Input.trigger?(Input::C)\n @active_battler.set_wait\n check_batevent_trigger\n deactivate_battler\n exit_wait_phase \n next_actor if !@ATB_Active\n end\n end",
"def hard_test\n wait(10) # let some capacitor get up some charge.\n \n 5.times do\n wait(5)\n cmd(\"CFS CFS_WHE_OBS_START\")\n wait(5) \n cmd(\"CFS CFS_WHE_HTR_ON\")\n wait(5)\n cmd(\"CFS CFS_WHE_LOUVER_CLOSE\")\n wait(5)\n \n end\nend",
"def wait\n @notifier.wait if @notifier\n end",
"def wait\n @notifier.wait if @notifier\n end",
"def wait\n # Here we use a loop-sleep combination instead of using\n # ThreadPoolExecutor's `wait_for_termination`. See issue #21 for more\n # information.\n loop do\n break if @executor.shutdown?\n sleep 0.1\n end\n end",
"def sleep_for=(seconds)\n seconds ||= 0\n if Integer === seconds && seconds >= 0\n @sleep_for = seconds\n else\n raise ArgumentError, \"argument must be nil or an integer >= 0\"\n end\n end",
"def default_delay=(v)\n @@default_delay = v\n end",
"def wait_for timeout = 0, &condition\n if condition\n SeleniumAdapter.wait_for(timeout, &condition)\n return nil\n else\n @wait_for = timeout\n return self\n end\n end",
"def update_for_wait\n update_basic\n end",
"def waitTillLimitReset\n timeTillReset = CLIENT.rate_limit.resets_in + 5\n @logger.info(\"API limit reached while fetching... Sleeping for #{timeTillReset} seconds 😴 brb\")\n sleep(timeTillReset)\nend",
"def set_waitness\n @waitness = Waitness.find(params[:id])\n end",
"def set_wait_order\n @wait_order = WaitOrder.find(params[:id])\n end",
"def set_wait_flags(*flags)\n a = (flags.include?(:a) || flags.include?(:a)) ? '1' : 'X'\n b = (flags.include?(:b) || flags.include?(:b)) ? '1' : 'X'\n c = (flags.include?(:c) || flags.include?(:c)) ? '1' : 'X'\n d = (flags.include?(:d) || flags.include?(:d)) ? '1' : 'X'\n self.wait_flags = d + c + b + a\n self\n end",
"def set\n return true if set?\n @mutex.synchronize do\n @set = true\n @waiters.each {|waiter| waiter.run if waiter.status == 'sleep'}\n end\n return true\n end",
"def pause wait_time\r\n command 'pause', wait_time\r\n end",
"def force_wait(frames)\n frames.times do\n Graphics.update\n Input.update\n end\n end",
"def wait_until(options = {}, &block)\n eventually(options, &block)\n end",
"def wait\n #$_api_queue.clear\n wait_for(/>/)\nend",
"def wait(seconds)\n sleep(seconds)\n\n self\n end",
"def sleep_if_set\n config[:sleep].to_i.times do\n print '.'\n sleep 1\n end\n end",
"def wait\r\n Ragweed::Wrap32::wait_for_single_object @h\r\n end",
"def click_wait(locator, sec, _arg = nil)\n click_on(locator)\n wait(sec)\n end",
"def wait timeout: 3, &block\n wait = Selenium::WebDriver::Wait.new timeout: timeout\n wait.until(&block)\nend",
"def wait\n\t\t\t\t@available.wait\n\t\t\tend",
"def set_initial_status\n \tself.status = \"waiting\"\n end",
"def set_defaults\n self.condition_estimation_type_id ||= 1\n self.condition_threshold ||= 2.5\n end",
"def wait_done\n sleep 0.01 until done?\n end",
"def wake_up()\n # Do nothing by default\n end",
"def set_defaults\n self.status = STARTED\n end",
"def wait!\n now = Time.now.utc.to_i\n duration = (reset.to_i - now) + 1\n\n sleep duration if duration >= 0\n\n yield if block_given?\n\n duration\n end",
"def check_defaults\n raise AvailableAttemptsNotInitialized unless self.class.available_attempts\n raise WaitTimeNotInitialized unless self.class.wait_time\n end",
"def wait_connection=(_arg0); end",
"def wait_while_present\n container.wait_while_present\n end",
"def wait_for_seconds\n\t\tsleep(1 * rand + 1)\n\tend",
"def set_timeout(timeout, element_timeout)\n @log.info('Setting the selenium timeout to: ' + timeout.to_s + ' element timeout: '+element_timeout.to_s)\n @driver.manage.timeouts.implicit_wait = timeout\n Capybara.default_wait_time = element_timeout\n end",
"def wait(on=nil)\n []\n end",
"def trim(force=false, wait: true)\n super(force)\n Thread.pass until @trim_requested == 0 if wait\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def waitForElement=(value)\n\t\t\t@waitForElement = value\n\t\tend",
"def waitForElement=(value)\n\t\t\t@waitForElement = value\n\t\tend",
"def wait_for(wait_max: 3, step: 0.001, &block)\n stop_at = wait_max.seconds.from_now\n\n sleep step while !block.call && (@time = Time.now) < stop_at\n\n fail \"Timeout of #{wait_max} seconds exceeded!\" unless @time < stop_at\nend",
"def wait\n waitUntilStarted\n\n @resultsSemaphore.wait\n end"
] | [
"0.76416105",
"0.7500537",
"0.721602",
"0.65911514",
"0.65868926",
"0.6399924",
"0.6341235",
"0.63308007",
"0.6221979",
"0.6141044",
"0.60687554",
"0.60397017",
"0.60141146",
"0.5988994",
"0.5857542",
"0.5737748",
"0.5725504",
"0.5707285",
"0.5707285",
"0.5707285",
"0.56800336",
"0.56691337",
"0.56596994",
"0.5610205",
"0.5606721",
"0.5588754",
"0.5588045",
"0.55802375",
"0.5572142",
"0.5542457",
"0.5496814",
"0.5451819",
"0.54320115",
"0.54205483",
"0.54082066",
"0.5387698",
"0.53282475",
"0.5325145",
"0.5325145",
"0.5301583",
"0.52868104",
"0.52761173",
"0.5274298",
"0.52573925",
"0.52401435",
"0.5216012",
"0.5210175",
"0.5210175",
"0.52035457",
"0.52035457",
"0.519982",
"0.5186728",
"0.5169688",
"0.5138505",
"0.5135443",
"0.5132782",
"0.5121939",
"0.5115356",
"0.5103241",
"0.51007783",
"0.51007783",
"0.51006603",
"0.509362",
"0.50910604",
"0.50848",
"0.508074",
"0.50756323",
"0.5073556",
"0.5070105",
"0.50692284",
"0.5026345",
"0.50160235",
"0.5004317",
"0.49987945",
"0.49972633",
"0.4985876",
"0.4984698",
"0.4975132",
"0.49666914",
"0.49646285",
"0.49610096",
"0.4952067",
"0.49360466",
"0.49329996",
"0.49324852",
"0.4931146",
"0.49295416",
"0.49221817",
"0.49217573",
"0.49211228",
"0.4918898",
"0.49069345",
"0.4906143",
"0.48960137",
"0.48936945",
"0.48936945",
"0.48925465",
"0.48925465",
"0.48922864",
"0.48916468"
] | 0.7951602 | 0 |
Set implicit wait and default_wait to timeout, defaults to 30. if set_wait is called without a param then the second to last wait will be used. ```ruby` set_wait 2 set_wait 3 set_wait 2 ```` | def set_wait timeout=nil
if timeout.nil?
# puts "timeout = @default_wait = @last_wait"
# puts "timeout = @default_wait = #{@last_waits}"
timeout = @default_wait = @last_waits.first
else
@default_wait = timeout
# puts "last waits before: #{@last_waits}"
@last_waits = [@last_waits.last, @default_wait]
# puts "last waits after: #{@last_waits}"
end
@driver.manage.timeouts.implicit_wait = timeout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unless e.message.include?('The operation requested is not yet implemented')\n raise ::Appium::Core::Error::ServerError, e.message\n end\n\n ::Appium::Logger.debug(e.message)\n {}\n end",
"def default_wait\n @default_wait\n end",
"def wait_timeout\n @wait_timeout ||= options[:wait_timeout] || DEFAULT_WAIT_TIMEOUT\n end",
"def implicit_wait=(seconds); end",
"def set_max_wait_time\n q = 'Set the MAX WAIT TIME after executing the RESTART command ' \\\n '(>= 180 secs): '\n until @max_wait && @max_wait.to_i > 179\n @max_wait = Utils.qna(q.cyan, true)\n end\n end",
"def wait timeout: 3, &block\n wait = Selenium::WebDriver::Wait.new timeout: timeout\n wait.until(&block)\nend",
"def state_wait(set, state, timeout=1200)\n # do a special wait, if waiting for operational (for dns)\n if state == \"operational\"\n set.each { |server| obj_behavior(server, :wait_for_operational_with_dns, timeout) }\n else\n set.each { |server| obj_behavior(server, :wait_for_state, state, timeout) }\n end\n end",
"def wait_for(wait_max: 3, step: 0.001, &block)\n stop_at = wait_max.seconds.from_now\n\n sleep step while !block.call && (@time = Time.now) < stop_at\n\n fail \"Timeout of #{wait_max} seconds exceeded!\" unless @time < stop_at\nend",
"def no_wait\n @last_waits = [@default_wait, 0]\n @default_wait = 0\n @driver.manage.timeouts.implicit_wait = 0\n end",
"def wait(timeout=10)\n Selenium::WebDriver::Wait.new(:timeout => timeout)\n end",
"def set_wait_time\n @wait_time = WaitTime.find(params[:id])\n end",
"def set_wait_time\n @wait_time = WaitTime.find(params[:id])\n end",
"def do_wait(waited)\n wait = get_config(:docker_wait)\n return unless wait.is_a?(Integer) || wait.is_a?(Float)\n return if waited >= wait\n sleep(wait - waited)\n end",
"def set_timeout(timeout)\n @log.info('Setting the selenium timeout to: ' + timeout.to_s)\n @driver.manage.timeouts.implicit_wait = timeout\n end",
"def abs_wait_short\n wait(15)\n end",
"def wait(seconds)\n @waiting = seconds * 1000\n end",
"def wait\n sleep WAIT_TIME unless @skip_wait\n end",
"def wait(seconds) \r\n\t\texec(\"Wait\", seconds.to_s)\r\n\tend",
"def reset_wait\n @wait = @t + rand(@t_rand)\n end",
"def wait\n sleep 0.0001\n end",
"def pause wait_time\r\n command 'pause', wait_time\r\n end",
"def wait!\n sleep(@sleep)\n end",
"def brute_wait(delay)\n sleep(delay)\n end",
"def set_timeout(timeout, element_timeout)\n @log.info('Setting the selenium timeout to: ' + timeout.to_s + ' element timeout: '+element_timeout.to_s)\n @driver.manage.timeouts.implicit_wait = timeout\n Capybara.default_wait_time = element_timeout\n end",
"def set_wait_flags(*flags)\n a = (flags.include?(:a) || flags.include?(:a)) ? '1' : 'X'\n b = (flags.include?(:b) || flags.include?(:b)) ? '1' : 'X'\n c = (flags.include?(:c) || flags.include?(:c)) ? '1' : 'X'\n d = (flags.include?(:d) || flags.include?(:d)) ? '1' : 'X'\n self.wait_flags = d + c + b + a\n self\n end",
"def wait timeout = nil\n @mutex.synchronize {\n if @cnt != 0\n if timeout\n @cond_var.wait @mutex, timeout\n else\n @cond_var.wait @mutex\n end\n end\n }\n end",
"def implicit_wait; end",
"def wait(sec = 5)\n Logbook.message(\"Waiting #{sec} sec >>\" + \"\\n\")\n sec.instance_of?(Integer) ? sleep(sec) : Logbook.message(\"Waiting time is not integer: [#{sec}]\" + \"\\n\")\n end",
"def wait(frames)\n return if @wait > 0\n @wait = frames\n end",
"def wait(arg0)\n end",
"def skip_wait=(setting)\n @skip_wait = setting\n end",
"def wait_until timeout=10, &block\n wait = Selenium::WebDriver::Wait.new(:timeout => timeout)\n wait.until &block\nend",
"def wait_for timeout = 0, &condition\n if condition\n SeleniumAdapter.wait_for(timeout, &condition)\n return nil\n else\n @wait_for = timeout\n return self\n end\n end",
"def after_wait(&block)\n @after_wait_block = block\n end",
"def timeouts_set=(_arg0); end",
"def click_wait(locator, sec, _arg = nil)\n click_on(locator)\n wait(sec)\n end",
"def wait(timeout = nil)\n @latch.wait(timeout)\n end",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def set_timeout timeout\r\n command 'setTimeout', timeout\r\n end",
"def state_wait(set, state)\n # do a special wait, if waiting for operational (for dns)\n if state == \"operational\"\n set.each { |server| server.wait_for_operational_with_dns }\n else\n set.each { |server| server.wait_for_state(state) }\n end\n end",
"def wait_time(value)\n define_singleton_method(:wait_time_value) { value }\n private_class_method :wait_time_value\n end",
"def wait_for(seq,timeout=1)\n begin\n ::Timeout.timeout(timeout) do\n wait(seq)\n end\n rescue ::Timeout::Error\n end\n end",
"def wait_until(index)\n\t\t@wait = index\n\tend",
"def wait(duration, variable)\n for i in 0...duration\n @wait_time += 1 if variable\n @wait_time_thirst if variable == false \n break if i >= duration / 2\n end\n end",
"def wait\n loop do sleep 1 end\n end",
"def wait_until(options = {}, &block)\n eventually(options, &block)\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def wait(per = nil)\n @target += per || @period\n error = @target - Time.now\n sleep error if error > 0\n true\n end",
"def ev_do_calculate_rw_wait(wait); end",
"def wait_true max_wait=30, interval=0.5, &block\n max_wait = 1 if max_wait <= 0\n result = nil\n timeout max_wait do\n until (result = begin; block.call; rescue; end)\n sleep interval\n end\n end\n result\n end",
"def wait_for(timeout = DEFAULT_TIMEOUT)\n Selenium::WebDriver::Wait.new(:timeout => timeout).until {yield}\nend",
"def wait_until_with_buffer(args, &block)\n original_timeout = args[:timeout] || ENV['WAIT_TIMEOUT'].to_i\n args_buffered = args.dup\n\n args_buffered[:timeout] = 60\n\n start_time = Time.now\n Frank::Cucumber::WaitHelper.wait_until(args_buffered) { block.call() }\n end_time = Time.now\n\n delta = end_time - start_time\n puts(\"wait_until exceeded timeout #{original_timeout}. Took #{delta}. #{caller[0]}\") if delta > original_timeout\nend",
"def wait(timeout = nil)\n return true if set?\n\n @mutex.synchronize { @waiters << Thread.current }\n return true if set? # if event was set while waiting for mutex\n\n if timeout.nil?\n slept = sleep\n else\n slept = sleep(timeout)\n end\n rescue\n # let it fail\n ensure\n @mutex.synchronize { @waiters.delete(Thread.current) }\n return set?\n end",
"def sleep_for\n @sleep_for ||= 5\n end",
"def wait\n @wait.synchronize do\n sleep 1 while @count >= THREAD_MAX\n @count += 1\n end\n end",
"def send_and_wait(type, *args); end",
"def set_waitness\n @waitness = Waitness.find(params[:id])\n end",
"def wait_until(timeout=self.class.default_timeout, cycle=1, fatigue=1.2, &block)\n waited = 0\n until block.call\n debug \"#{self} is waiting for resource (%5.2f/%2ds +%5.2f)...\"% [waited, timeout, cycle]\n sleep cycle\n waited += cycle\n cycle *= fatigue\n if waited > timeout\n raise WaitTimeoutError, \"Waiting for aws resources timed out after #{waited} seconds!\"\n end\n end\n end",
"def wait\n @running.reset\n @waiting.set\n @running.wait\n end",
"def wait_until times: 5, delay: 1, &condition\n times.times do\n return if condition.call\n sleep delay\n end\n raise \"Condition not met. Waited #{times} times with #{delay} sec delay\"\n end",
"def wait(timeout = 0)\n Window.wait(@title, @text, timeout)\n end",
"def wait_for(seconds = timeout)\n Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }\n end",
"def normalize_timeout(timeout)\r\n if timeout == nil\r\n timeout = Capybara.default_wait_time\r\n end\r\n\r\n if timeout < 1\r\n timeout = 1\r\n end\r\n\r\n return timeout\r\n end",
"def with_driver_timeout(timeout)\n\t\t\tcurrent = @driver_timeout\n\t\t\tdriver.manage.timeouts.implicit_wait = timeout\n\t\t\tyield\n\t\tensure\n\t\t\t@driver_timeout = current\n\t\t\tdriver.manage.timeouts.implicit_wait = current\n\t\tend",
"def timeouts_set; end",
"def wait(duration)\n info \"Request from Experiment Script: Wait for #{duration}s....\"\n warn \"Calling 'wait' or 'sleep' will block entire EC event loop. Please try 'after' or 'every'\"\n sleep duration\n end",
"def wait_until(wait_time = Capybara.default_max_wait_time)\n Timeout.timeout(wait_time) do\n loop until yield\n end\n end",
"def wait_until(wait_time = Capybara.default_max_wait_time)\n Timeout.timeout(wait_time) do\n loop until yield\n end\n end",
"def wait(what = T.unsafe(nil)); end",
"def eventually(wait_time = Capybara.default_max_wait_time, &block)\n Checkpoint.wait_for wait_time, &block\n end",
"def set_timeout(value)\n if value.nil?\n @timeout = 2\n else\n return skip_resource 'timeout is not numeric' unless value.to_s =~ /^\\d+$/\n @timeout = value\n end\n end",
"def wait\n 0\n end",
"def wait(duration, value)\n for i in 0...duration\n @wait_time += 1 if value == false\n @wait_time2 += 1 if value\n break if i >= duration / 2\n end\n end",
"def wait(duration, value)\n for i in 0...duration\n @wait_time += 1 if value == false\n @wait_time2 += 1 if value\n break if i >= duration / 2\n end\n end",
"def set_waitlist\n @waitlist = Waitlist.find(params[:id])\n end",
"def wait(time = 60)\n resp = connection.post(\"/containers/#{id}/wait\", nil, read_timeout: time)\n Docker::Util.parse_json(resp)\n end",
"def wait(time, increment = 1, elapsed_time = 0, &block)\n begin\n yield\n rescue Exception => e\n if elapsed_time >= time\n raise e\n else\n sleep increment\n wait(time, increment, elapsed_time + increment, &block)\n end\n end\nend",
"def wait_for(seconds)\n Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }\nend",
"def wait_any(timeout = -1)\n DRMAA.wait(ANY_JOB, timeout)\n end",
"def skip_wait\n @skip_wait = true\n end",
"def wait(time = 60)\n resp = connection.post(\"/containers/#{id}/wait\", nil, :read_timeout => time)\n Docker::Util.parse_json(resp)\n end",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def pick_timeout!\n @timeout = (ENV['TIMEOUT'] || DEFAULT_TIME_LIMIT).to_i\n $stdout.puts \"TIMEOUT=#{@timeout}\"\n $stdout.flush\n end",
"def wait(frames)\n frames.times do\n wait_internal\n end\n end",
"def wait(time)\n if time.kind_of?(ExperimentProperty)\n duration = time.value\n else\n duration = time\n end\n info \"Request from Experiment Script: Wait for #{duration}s....\"\n Kernel.sleep duration\n end",
"def set_lock_timeout(timeout)\n @lock_timeout = timeout\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def wait_for_condition script, timeout\r\n command 'waitForCondition', script, timeout\r\n end",
"def wait; end",
"def wait; end",
"def wait; end",
"def wait(timeout, &block)\n end_time = @end_time || (current_time + timeout)\n loop do\n yield(block)\n @remaining_time = end_time - current_time\n break if @remaining_time.negative?\n end\n end",
"def wait\n\tend",
"def wait_for_jobs(jobs)\n jobs.each(&:wait)\n end",
"def wait(timeout = nil)\n event.wait(timeout) if timeout != 0 && incomplete?\n self\n end",
"def wait!\n now = Time.now.utc.to_i\n duration = (reset.to_i - now) + 1\n\n sleep duration if duration >= 0\n\n yield if block_given?\n\n duration\n end",
"def test_time_out\n get_method = proc { create_op MockOperation.new(status: :NOTDONE, name: NAME) }\n mock_client = MockLroClient.new get_method: get_method\n op = create_op MockOperation.new(status: :NOTDONE, name: NAME), client: mock_client\n\n sleep_counts = [10, 20, 40, 80]\n sleep_mock = Minitest::Mock.new\n sleep_counts.each do |sleep_count|\n sleep_mock.expect :sleep, nil, [sleep_count]\n end\n sleep_proc = ->(count) { sleep_mock.sleep count }\n\n Kernel.stub :sleep, sleep_proc do\n time_now = Time.now\n incrementing_time = lambda do\n delay = sleep_counts.shift || 160\n time_now += delay\n end\n Time.stub :now, incrementing_time do\n retry_config = { initial_delay: 10, multiplier: 2, max_delay: (5 * 60), timeout: 400 }\n op.wait_until_done! retry_policy: retry_config\n refute op.done?\n end\n end\n\n sleep_mock.verify\n end",
"def wait(timeout=60)\n countdown = timeout.to_f\n\n while countdown > 0\n if @zmq_thread and @zmq_thread.alive?\n sleep 0.1\n countdown = countdown - 0.1\n else\n break\n end\n end\n\n super()\n end"
] | [
"0.7200762",
"0.6679357",
"0.65788174",
"0.6443681",
"0.6226858",
"0.596722",
"0.59339607",
"0.58681065",
"0.5848157",
"0.5846182",
"0.58411944",
"0.58411944",
"0.58140564",
"0.5790305",
"0.57674325",
"0.57514125",
"0.57201034",
"0.5716633",
"0.56703126",
"0.5669643",
"0.560765",
"0.56066203",
"0.55677146",
"0.55675995",
"0.5563107",
"0.55415636",
"0.55283546",
"0.552373",
"0.5503527",
"0.5499676",
"0.5491762",
"0.5481426",
"0.547819",
"0.54749",
"0.54464847",
"0.5444415",
"0.5393835",
"0.53878504",
"0.53878504",
"0.5382702",
"0.53710735",
"0.5354443",
"0.53336674",
"0.53278303",
"0.53137374",
"0.52783096",
"0.52596825",
"0.52596825",
"0.52242017",
"0.52166414",
"0.5209517",
"0.51961994",
"0.5191122",
"0.5187647",
"0.51807165",
"0.5132711",
"0.5130975",
"0.5123968",
"0.5108815",
"0.5106938",
"0.5105778",
"0.51013505",
"0.5084699",
"0.507069",
"0.50667423",
"0.5066697",
"0.5065286",
"0.50625074",
"0.50625074",
"0.5046045",
"0.503985",
"0.50366455",
"0.50340354",
"0.5013885",
"0.5013885",
"0.5012922",
"0.5004764",
"0.49990445",
"0.49981248",
"0.49882007",
"0.49848828",
"0.49846333",
"0.49790746",
"0.49790746",
"0.49790746",
"0.4978969",
"0.4975581",
"0.4972192",
"0.49705392",
"0.49705392",
"0.4964455",
"0.4964455",
"0.4964455",
"0.4958019",
"0.49421915",
"0.49399215",
"0.49313208",
"0.49302775",
"0.4925183",
"0.492385"
] | 0.8285323 | 0 |
Returns the default client side wait. This value is independent of what the server is using | def default_wait
@default_wait
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_timeout\n @wait_timeout ||= options[:wait_timeout] || DEFAULT_WAIT_TIMEOUT\n end",
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unless e.message.include?('The operation requested is not yet implemented')\n raise ::Appium::Core::Error::ServerError, e.message\n end\n\n ::Appium::Logger.debug(e.message)\n {}\n end",
"def wait\n 0\n end",
"def balloon_wait\n return (@battler.nil? ? BALLOON_WAIT : @battler.balloon_wait)\n end",
"def get_waiting\n raise NotImplementedError\n end",
"def default_timeout\n @default_timeout ||= 20000\n end",
"def abs_wait_short\n wait(15)\n end",
"def max_wait_time\n @data[\"max_wait_time\"]\n end",
"def default_timeout\n 3\n end",
"def default_timeout\n @default_timeout ||= 30\n end",
"def wait_connection=(_arg0); end",
"def event_wait_delay seconds\n ScriptActionHandler::HandlerResult::waitDelay seconds\n end",
"def implicit_wait; end",
"def default_value_noninteractive\n default_value\n end",
"def implicit_wait=(seconds); end",
"def max_select_wait_time; end",
"def wait(seconds)\n @waiting = seconds * 1000\n end",
"def wait\n status = (\"\\x00\"*SIZEOFINT).to_ptr\n r = CALLS[\"libc!wait:=I\"].call(status).first\n raise SystemCallError.new(\"wait\", DL.last_error) if r== -1\n return status.to_s(SIZEOFINT).unpack('i_').first\n end",
"def default_value()\n defval = cpptype.default_value;\n if name == \"accept-mode\" and parent.name == \"transfer\" then defval = \"1\"; end\n return defval\n end",
"def set_wait timeout=nil\n if timeout.nil?\n # puts \"timeout = @default_wait = @last_wait\"\n # puts \"timeout = @default_wait = #{@last_waits}\"\n timeout = @default_wait = @last_waits.first\n else\n @default_wait = timeout\n # puts \"last waits before: #{@last_waits}\"\n @last_waits = [@last_waits.last, @default_wait]\n # puts \"last waits after: #{@last_waits}\"\n end\n\n @driver.manage.timeouts.implicit_wait = timeout\n end",
"def num_waiting\n @num_waiting\n end",
"def wait!\n sleep(@sleep)\n end",
"def wait\n @future.value\n end",
"def wait(arg0)\n end",
"def wait\n sleep 0.0001\n end",
"def wait_time\n self.measurement.wait_time\n end",
"def wait\n sleep WAIT_TIME unless @skip_wait\n end",
"def server_ready_timeout\n Zartan::Config.new['server_ready_timeout'].to_i\n end",
"def wait_async\n @wait_async = true\n end",
"def wait\n true\n end",
"def default_delay\n @@default_delay ||= 0\n end",
"def wait(timeout: nil)\n if connected?\n client.wait(timeout: timeout)\n else\n wait_connection_attempt_result(timeout: timeout)\n end\n end",
"def wait_connection; end",
"def wait_connection; end",
"def wait_for_less_busy_worker(val = T.unsafe(nil)); end",
"def waiting?\n @status[:description] == :wait\n end",
"def wait(what = T.unsafe(nil)); end",
"def sleep_value\n 20\n end",
"def sleep_for\n @sleep_for ||= 5\n end",
"def default_timeout\n @default_time ||= @doc.at('/document/results/@defaultTimeout').value.to_i\n end",
"def default_task_heartbeat_timeout; Float::INFINITY; end",
"def balloon_wait\r\r\n return 20\r\r\n end",
"def num_waiting\n end",
"def num_waiting\n end",
"def default_delay\n 0.seconds\n end",
"def wait_true max_wait=30, interval=0.5, &block\n max_wait = 1 if max_wait <= 0\n result = nil\n timeout max_wait do\n until (result = begin; block.call; rescue; end)\n sleep interval\n end\n end\n result\n end",
"def no_wait\n @last_waits = [@default_wait, 0]\n @default_wait = 0\n @driver.manage.timeouts.implicit_wait = 0\n end",
"def wait\n if defined? @result\n return @result\n else\n @waiters << Eventlet.current\n Eventlet.sleep\n end\n end",
"def default_timeout\n 900\n end",
"def wait\n\tend",
"def default_timeout\n self.class.mocked_default_timeout\n end",
"def wait_time(value)\n define_singleton_method(:wait_time_value) { value }\n private_class_method :wait_time_value\n end",
"def lock_timeout\n self.class.lock_timeout || default_lock_timeout\n end",
"def wait(sec = 5)\n Logbook.message(\"Waiting #{sec} sec >>\" + \"\\n\")\n sec.instance_of?(Integer) ? sleep(sec) : Logbook.message(\"Waiting time is not integer: [#{sec}]\" + \"\\n\")\n end",
"def default_timeout\n 60\n end",
"def get_standalone_worker_spec_timeout\n if timeout = ENV['STANDALONE_WORKER_SPEC_TIMEOUT']\n puts \"STANDALONE_WORKER_SPEC_TIMEOUT=#{timeout}\"\n timeout.to_i\n else\n 10\n end\nend",
"def wait_until_not_full; end",
"def wait\r\n Ragweed::Wrap32::wait_for_single_object @h\r\n end",
"def default_timeout_class; end",
"def heartbeat_timeout; Float::INFINITY; end",
"def sync_wait\n if IO.select([sync_read], nil, nil, 20).nil?\n # timeout reading from the sync pipe.\n send_side_channel_error(\"Error syncing processes in run lock test (timeout)\")\n exit!(1)\n else\n sync_read.getc\n end\n end",
"def connection_status_crypt_wait_response; end",
"def wait_text\n case self.days_delay\n when -1, nil then 'after an unknown wait'\n when 0 then 'within one business day'\n when 1..9 then 'after a short wait'\n when 10..22 then 'after a moderate wait'\n when 23..34 then 'after a long wait'\n else 'after a very long wait'\n end\n end",
"def wait(interval)\n\t\tif( interval and interval == -1 )\n\t\t\twhile(not self.done)\n\t\t\t\t::IO.select(nil, nil, nil, 0.1)\n\t\t\tend\n\t\telse\n\t\t\tbegin\n\t\t\t\tTimeout.timeout(interval) {\n\t\t\t\t\twhile(not self.done)\n\t\t\t\t\t\t::IO.select(nil, nil, nil, 0.1)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue Timeout::Error\n\t\t\t\tself.response = nil\n\t\t\tend\n\t\tend\n\t\treturn self.response\n\tend",
"def wait(timeout=10)\n Selenium::WebDriver::Wait.new(:timeout => timeout)\n end",
"def num_waiting\n @waiting\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def driver_timeout=(value)\n Watir.default_timeout = value\n end",
"def wait; end",
"def wait; end",
"def wait; end",
"def wait(path, rev=current_revision, timeout=-1)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::WAIT), true, timeout)\n end",
"def set_max_wait_time\n q = 'Set the MAX WAIT TIME after executing the RESTART command ' \\\n '(>= 180 secs): '\n until @max_wait && @max_wait.to_i > 179\n @max_wait = Utils.qna(q.cyan, true)\n end\n end",
"def default_value\n return @default_value\n end",
"def wait(on=nil)\n []\n end",
"def num_waiting\n @num_waiting.value\n end",
"def wait_for timeout = 0, &condition\n if condition\n SeleniumAdapter.wait_for(timeout, &condition)\n return nil\n else\n @wait_for = timeout\n return self\n end\n end",
"def waiting; end",
"def waiting; end",
"def get_delay\n return @retry_timeout unless @retry_timeout.nil?\n\n if !response.nil? && !response.headers['Retry-After'].nil?\n return response.headers['Retry-After'].to_i\n end\n\n return AsyncOperationStatus::DEFAULT_DELAY\n end",
"def send_and_wait(type, *args); end",
"def wait\n loop do sleep 1 end\n end",
"def wait_until_ready\n # this method may be left unimplemented if that is applicable\n end",
"def waiting?\n @waiting\n end",
"def ev_do_calculate_rw_wait(wait); end",
"def lock_timeout\n @lock_timeout ||= self.class.lock_timeout || 0\n end",
"def calculate_sleep\n if @timeouts.empty?\n @sleep_for = DefaultSleepFor\n else\n diff = @timeouts.first.value.timeout_at.to_f - Time.now.to_f\n\n if diff < 0.0\n @sleep_for = 0\n else\n @sleep_for = diff\n end\n end\n end",
"def wait_for_elements\n self.class.options[:wait_for_elements]\n end",
"def auto_blocked_status\n 'auto_blocked'\n end",
"def poll\n options['poll'] || 10\n end",
"def wait_for_startup\n TCPSocket.wait_for_service_with_timeout(:host => http_ip,\n :port => http_port,\n :timeout => 10)\n end",
"def default_delay=(v)\n @@default_delay = v\n end",
"def wait(seconds) \r\n\t\texec(\"Wait\", seconds.to_s)\r\n\tend",
"def wait_before_new_request\n return unless @last_request # this is the first request\n diff = Time.now - @last_request\n if diff < SECONDS_BEFORE_NEW_REQUEST\n sleep(SECONDS_BEFORE_NEW_REQUEST - diff)\n end\n end",
"def encounter_balloon_wait\n TH::Encounter_Alert::Balloon_Wait\n end",
"def waiting?\n @waiting\n end",
"def wait_for_seconds\n\t\tsleep(1 * rand + 1)\n\tend",
"def wait\n\t\t\t\t@available.wait\n\t\t\tend",
"def default\r\n @opts[:default]\r\n end",
"def default_value\n config[:default]\n end"
] | [
"0.6918232",
"0.60194534",
"0.59551215",
"0.588512",
"0.5776252",
"0.57113725",
"0.5703889",
"0.56906146",
"0.56605303",
"0.56548905",
"0.5632716",
"0.5559097",
"0.54802066",
"0.5451355",
"0.54511195",
"0.5442161",
"0.5430147",
"0.5423666",
"0.540995",
"0.5396949",
"0.53838134",
"0.5355152",
"0.5348608",
"0.53484386",
"0.53484",
"0.53445137",
"0.5333474",
"0.532643",
"0.53183776",
"0.53131574",
"0.53035676",
"0.5295322",
"0.5287853",
"0.5287853",
"0.5281392",
"0.52785814",
"0.5277126",
"0.52617455",
"0.5254496",
"0.5228575",
"0.5216255",
"0.52126306",
"0.52111065",
"0.52111065",
"0.51959795",
"0.5185639",
"0.51784664",
"0.5171339",
"0.51462305",
"0.5141119",
"0.51383007",
"0.51345384",
"0.5129593",
"0.51230013",
"0.51224965",
"0.5121793",
"0.51208085",
"0.51114947",
"0.5101802",
"0.50921893",
"0.5091175",
"0.50825554",
"0.5081047",
"0.50716376",
"0.5051215",
"0.50508255",
"0.50499505",
"0.50499505",
"0.5042296",
"0.5042296",
"0.5042296",
"0.5041654",
"0.5033814",
"0.50326663",
"0.5031412",
"0.5029484",
"0.50256056",
"0.50218827",
"0.50218827",
"0.5020541",
"0.501607",
"0.50084776",
"0.5002291",
"0.49940434",
"0.4993806",
"0.4988921",
"0.4967733",
"0.49579552",
"0.4950963",
"0.49480748",
"0.49450937",
"0.49432313",
"0.49398813",
"0.49323025",
"0.49301705",
"0.4919119",
"0.4917916",
"0.49155232",
"0.4907267",
"0.49045745"
] | 0.7904518 | 0 |
Helper method for mobile gestures driver.execute_script 'mobile: swipe', endX: 100, endY: 100, duration: 0.01 becomes mobile :swipe, endX: 100, endY: 100, duration: 0.01 | def mobile method, *args
raise 'Method must not be nil' if method.nil?
raise 'Method must have .to_s' unless method.respond_to? :to_s
@driver.execute_script "mobile: #{method.to_s}", *args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swipe(opts)\n start_x = opts.fetch :start_x, 0\n start_y = opts.fetch :start_y, 0\n end_x = opts.fetch :end_x, 0\n end_y = opts.fetch :end_y, 0\n duration = opts.fetch :duration, 2\n\n \n action = Appium::TouchAction.new.press(x: start_x, y: start_y).move_to(x: end_x, y: end_y).release \n action.perform\nend",
"def swipe(direction, duration=700)\n # @option opts [int] :start_x Where to start swiping, on the x axis. Default 0.\n # @option opts [int] :start_y Where to start swiping, on the y axis. Default 0.\n # @option opts [int] :end_x Where to end swiping, on the x axis. Default 0.\n # @option opts [int] :end_y Where to end swiping, on the y axis. Default 0.\n # @option opts [int] :duration How long the actual swipe takes to complete in milliseconds.\n screen_resolution = $driver.window_size\n up = {\n start_x: screen_resolution.width/2,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width/2,\n end_y: 0001,\n duration: duration\n }\n down = {\n start_x: screen_resolution.width/2,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width/2,\n end_y: screen_resolution.height - 10,\n duration: duration\n }\n left = {\n start_x: screen_resolution.width - 10,\n start_y: screen_resolution.height/2,\n end_x: 0200,\n end_y: screen_resolution.height/2,\n duration: duration\n }\n right = {\n start_x: 0200,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width - 10,\n end_y: screen_resolution.height/2,\n duration: duration\n }\n\n case direction.to_s.downcase\n when 'up'\n $driver.swipe(up)\n when 'down'\n $driver.swipe(down)\n when 'left'\n $driver.swipe(left)\n when 'right'\n $driver.swipe(right)\n else\n raise \"#{direction} is not a valid option\"\n end\n\n end",
"def swipe_element_to_rigth(xpath)\r\n\r\n #get 'mobile element' form xpath\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n ym = (y1 + y2) >> 1\r\n adb_exec(\"shell input swipe #{x1} #{ym} 10000 #{ym}\")\r\n #puts \"EXEC SHELL => shell input swipe #{x1} #{ym} 10000 #{ym}\"\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"swipe_element_to_rigth => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def swipe_element_to_left(xpath)\r\n\r\n #get 'mobile element' form xpath\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n ym = (y1 + y2) >> 1\r\n adb_exec(\"shell input swipe 10000 #{ym} #{x2} #{ym}\")\r\n #puts \"EXEC SHELL => shell input swipe #{x1} #{ym} 10000 #{ym}\"\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"swipe_element_to_rigth => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def scroll_to_down(drag_to = nil)\r\n\r\n #get 'mobile element' form xpath\r\n xpath = \"(//node[./node/node])[last()]\"\r\n drag = drag_to.nil? ? 100 : drag_to.to_s.to_i\r\n\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n if (x1 + y1 + x2 + y2) == 0\r\n screen_size = get_screen_size\r\n xm = screen_size[:width] >> 1\r\n ym = screen_size[:height] >> 1\r\n yf = ym - drag\r\n else\r\n xm = (x1 + x2) >> 1\r\n ym = (y1 + y2) >> 1\r\n yf = y1 - drag\r\n end\r\n\r\n adb_exec(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n #puts(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"scroll_to_down => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def scroll_down\r\n $driver.swipe(start_y: 0.9, end_y: 0.5, start_x: 0.9, end_x: 0.9, duration: 800)\r\n end",
"def swipe direction, obj = nil, wait = 0.2\n move_mouse_to obj, wait: 0 if obj\n Mouse.swipe direction\n sleep wait\n end",
"def drag_element_to(xpath_element_origin, x_fate, y_fate, duration = nil)\r\n\r\n result = false\r\n mobile_element_source = get_mobile_element xpath_element_origin\r\n\r\n duration_time = duration.nil? ? 500 : duration\r\n xm1 = nil\r\n ym1 = nil\r\n xm2 = x_fate\r\n ym2 = y_fate\r\n\r\n if mobile_element_source.nil? or mobile_element_source.to_s.empty?\r\n raise \"Element sourse Not Found. XPATH => ''#{xpath_element_origin}''\"\r\n end\r\n\r\n begin\r\n\r\n fb_1 = get_bounds_from_element(mobile_element_source) do |x1, y1, x2, y2|\r\n xm1 = (x1 + x2) >> 1\r\n ym1 = (y1 + y2) >> 1\r\n #puts(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n adb_exec(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n end\r\n\r\n result = !fb_1.nil?\r\n\r\n unless result\r\n raise \"drag_element_to => Fail => no fue posible hacer scroll down => '#{xpath_element_origin}'.\"\r\n end\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"drag_element_to_element => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def drag_element_to_element(xpath_element_origin, xpath_element_fate, duration = nil)\r\n\r\n result = false\r\n mobile_element_source = get_mobile_element xpath_element_origin\r\n mobile_element_fate = get_mobile_element xpath_element_fate\r\n duration_time = duration.nil? ? 1000 : (duration.to_i * 1000)\r\n xm1 = nil\r\n ym1 = nil\r\n xm2 = nil\r\n ym2 = nil\r\n\r\n if mobile_element_source.nil? or mobile_element_source.to_s.empty?\r\n raise \"Element sourse Not Found. XPATH => ''#{xpath_element_origin}''\"\r\n end\r\n\r\n if mobile_element_fate.nil? or mobile_element_fate.to_s.empty?\r\n raise \"Element fate Not Found. XPATH => ''#{xpath_element_fate}''\"\r\n end\r\n\r\n begin\r\n\r\n fb_1 = get_bounds_from_element(mobile_element_source) do |x1, y1, x2, y2|\r\n xm1 = (x1 + x2) >> 1\r\n ym1 = (y1 + y2) >> 1\r\n end\r\n\r\n fb_2 = get_bounds_from_element(mobile_element_fate) do |x1, y1, x2, y2|\r\n xm2 = (x1 + x2) >> 1\r\n ym2 = (y1 + y2) >> 1\r\n end\r\n\r\n if !fb_1.nil? and !fb_2.nil?\r\n result = true\r\n end\r\n\r\n puts(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n adb_exec(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"drag_element_to_element => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def scroll_to_up(drag_to = nil)\r\n\r\n #get 'mobile element' form xpath\r\n xpath = \"(//node[./node/node])[1]\"\r\n drag = drag_to.nil? ? 100 : drag_to.to_s.to_i\r\n\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n xm = (x1 + x2) >> 1\r\n ym = (y1 + y2) >> 1\r\n yf = ym + drag\r\n adb_exec(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n #puts(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"scroll_to_down => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def swipe_left_element(element_to_swipe)\n $home_page.user_swipe_left_element(element_to_swipe)\nend",
"def scroll_left (x1,x2,y1,y2)\r\n #driver.swipe(start_x: 1000, end_x: 100, start_y: y, end_y: y, duration: 1000)\r\n #driver.swipe(start_x: x1, end_x: x2, start_y: y1, end_y: y2, duration: 1000)\r\n scroll_in_any_direction(x1,x2,y1,y2)\r\n end",
"def swipe_right_and_wait_to_animate(wait_time, element_to_animate)\n\t\tif ENV['PLATFORM'] == 'android'\n\t\t\tperformAction('swipe', 'right')\n\t\t\twait_to_animate(wait_time, element_to_animate)\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'iPhone'\n\t\t\t\t#TODO Suhas Pls add Iphone swipe test\n\t\t\tend\n\t\tend\n\tend",
"def launch_UPgame_4\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::hooksheroes_mobile_html@netent', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::hooksheroes_mobile_html@netent'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n wait_for_element_exists \"webView css:'.interface-toggleSwitch_loadAnimation'\", :timeout => 10\n\n touch (\"webView css:'.interface-toggleSwitch_loadAnimation'\")\n sleep 3\n touch \"webView css:'.interface-homeButton_baseButton'\"\n sleep 0.5\n\n\n end",
"def swipe_left_and_wait_to_animate(wait_time, element_to_animate)\n\t\tif ENV['PLATFORM'] == 'android'\n\t\t\tperformAction('swipe', 'left')\n\t\t\twait_to_animate(wait_time, element_to_animate)\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'iPhone'\n\t\t\t\t#TODO Suhas Pls add Iphone swipe test\n\n\t\t\tend\n\t\tend\n\tend",
"def click_dropdown(element_data_set, data_set)\n if ENV['PLATFORM_NAME'] =='android'\n dropdown = \"xpath://android.widget.ScrollView[1]\"\n required_xpath = \"xpath://*[@text='#{data_set}']\"\n elsif ENV['PLATFORM_NAME'] =='ios'\n dropdown = \"xpath://XCUIElementTypeWindow[1]/XCUIElementTypeOther[2]//XCUIElementTypeScrollView[1]\"\n required_xpath = \"predicate:label contains[c] '#{data_set}'\"\n end\n\n begin @driver.hide_keyboard\n rescue => e\n end\n \n sleep(3)\n $home_page.user_click(element_data_set)\n Timeout::timeout(DEFAULT_TIMEOUT) {swipe_up_element_until(required_xpath, dropdown)}\n sleep(3)\n $home_page.user_click(required_xpath)\nend",
"def swipe_down_element_until(expected_element, element_to_swipe)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_down_element(element_to_swipe)\n end\n return true\nend",
"def swipe_down_until(expected_element)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_down\n end\nend",
"def swipe_up_element_until(expected_element, element_to_swipe)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_up_element(element_to_swipe)\n end\n return true \nend",
"def swipes_to_template_on_the_screen(template_path, direction = \"down\", max_swipes = 5)\n logc(\"method: #{__method__}, params: #{template_path}, #{direction}, #{max_swipes}\")\n direction_list = [\"up\", \"down\", \"left\", \"right\"]\n assert_true_custom(direction_list.include?(direction),\n \"Wrong param 'direction'. Should be one of #{direction_list}, but found '#{direction}'\")\n\n #wait for swipes numbers reached OR expectation reached\n res_of_finding = nil\n res_image_path = nil\n occurrences = nil\n is_expectation_reached = false\n attempt_counter = 1\n while true\n logc(\"Attempt: '#{attempt_counter}'\")\n res_of_finding, res_image_path = get_templates_on_the_screen(template_path, 0.85)\n occurrences = res_of_finding[\"point_clouds\"].to_i\n is_expectation_reached = occurrences > 0\n\n if is_expectation_reached || (attempt_counter > max_swipes)\n break\n else\n swipe(direction)\n attempt_counter += 1\n end\n end\n\n assert_true_custom(is_expectation_reached,\n \"During #{attempt_counter} swipes, found '#{occurrences}' occurrences templates '#{File.basename(template_path)}' on the screen.\" +\n \" Check report folder '#{@report_path}' to details.\")\n # remove_file_if_exist(res_image_path) if is_expectation_reached\nend",
"def handle_swipe(sender)\n @egg.add_code(sender.direction)\n end",
"def gesture!\n unless @ws.nil?\n data = JSON \"enableGestures\" => true\n options[:enable_gesture] = ws.send data\n end\n end",
"def move( mobile )\n\t\tif @closed && !mobile.affected?(\"pass door\")\n\t\t\tmobile.output \"The #{name} is closed.\"\n\t\t\treturn false\n elsif mobile.affected?(\"pass door\") && @passproof\n mobile.output \"You can't pass through the #{self.name}.\"\n return false\n\t\telse\n portal = @direction.nil?\n sneaking = mobile.affected?(\"sneak\")\n leave_string = \"\"\n if portal\n leave_string = \"0<N> steps into 1<n>.\"\n mobile.output(\"You step into 0<n>.\", [self]) unless sneaking\n else\n leave_string = \"0<N> leaves #{@direction.name}.\"\n end\n (mobile.room.occupants - [mobile]).each_output(leave_string, [mobile, self]) unless sneaking\n old_room = mobile.room\n mobile.move_to_room( @destination )\n if old_room\n old_room.occupants.select { |t| t.position != :sleeping && t.responds_to_event(:observe_mobile_use_exit) }.each do |t|\n Game.instance.fire_event( t, :observe_mobile_use_exit, {mobile: mobile, exit: self } )\n end\n end\n arrive_string = \"\"\n if portal\n arrive_string = \"0<N> has arrived through 1<n>.\"\n else\n arrive_string = \"0<N> has arrived.\"\n end\n (mobile.room.occupants - [mobile]).each_output arrive_string, [mobile, self] unless sneaking\n\t\tend\n return true\n\tend",
"def swipe_up_until(expected_element)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_up\n end\nend",
"def type_via_applescript(str, opts = {})\n opts[:speed] = 50 unless !opts[:speed].nil?\n opts[:speed] = opts[:speed] / 1000.0\n\n full_str = \"\"\n str.split(\"\").each do |a|\n a.gsub!(/\"/, '\\\"')\n full_str += \"delay #{opts[:speed]}\\n\" if !full_str.empty?\n full_str += \"keystroke \\\"#{a}\\\"\\n\"\n end\n cmd = %Q'\n tell application \"System Events\"\n set frontApp to name of first item of (processes whose frontmost is true)\n tell application frontApp\n #{full_str}\n end\n end tell\n '\n execute_applescript cmd\n\n str\n end",
"def scroll_page(to)\n if to == 'end'\n $driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')\n elsif to == 'top'\n $driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')\n else\n raise \"Exception : Invalid Direction (only scroll \\\"top\\\" or \\\"end\\\")\"\n end\nend",
"def scroll_page(to)\n if to==\"end\"\n $driver.execute_script(\"window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));\")\n elsif to==\"top\"\n $driver.execute_script(\"window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);\") \n else\n raise \"Exception : Invalid Direction (only scroll \\\"top\\\" or \\\"end\\\")\"\n end\nend",
"def scroll_to text\n args = 'scroll',\n # textContains(text)\n [ [3, text] ],\n # descriptionContains(text)\n [ [7, text] ]\n\n mobile :find, args\n end",
"def tap_element(xpath)\r\n\r\n #get 'mobile element' form xpath\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n xm = (x1 + x2) >> 1\r\n ym = (y1 + y2) >> 1\r\n adb_exec(\"shell input tap #{xm} #{ym}\")\r\n #puts \"ADB => shell input tap #{xm} #{ym}\"\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"tap_element => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend",
"def touch_moved(touch); end",
"def select_menu_item(value)\n #checking for reach end of list( get_source is current screen id)\n current_screen = get_source\n previous_screen = \"\"\n\n until (exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}) || (current_screen == previous_screen) do\n Appium::TouchAction.new.swipe(start_x:0.5,start_y: 0.8,end_x:0.5,end_y:0.2,duration:500).perform\n previous_screen = current_screen\n current_screen = get_source\n end\n #add more information in case of errors\n if exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}\n find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\").click\n else\n fail(\"Element #{value} was not found in menu\")\n end\nend",
"def tap_element element\n tapAction = Appium::TouchAction.new\n tapAction.tap(element: element).perform\n puts \"TAP is Working \\\\o/\"\n end",
"def scroll_and_touch(element, options = {})\n scroll_until_i_see(element, options)\n touch(element)\n end",
"def scroll_to_exact text\n args = 'scroll',\n # text(text)\n [ [1, text] ],\n # description(text)\n [ [5, text] ]\n\n mobile :find, args\n end",
"def swipe(track_data)\r\n @PARAM_HASH['SWIPE'] = track_data\r\n # Regex matchers \r\n # track1_and_track2 = /(%B)\\d{0,19}\\^([\\w\\s]*)\\/([\\w\\s]*)([\\s]*)\\^\\d{7}\\w*\\?;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n # track2 = /;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n end",
"def swipe(track_data)\r\n @PARAM_HASH['SWIPE'] = track_data\r\n # Regex matchers \r\n # track1_and_track2 = /(%B)\\d{0,19}\\^([\\w\\s]*)\\/([\\w\\s]*)([\\s]*)\\^\\d{7}\\w*\\?;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n # track2 = /;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n end",
"def move_slider(slider, position)\n append_to_script \"move_slider \\\"#{slider}\\\" , \\\"#{position}\\\"\"\n end",
"def perform\n $driver.multi_touch @actions\n end",
"def light_swipe_trait_until_exists(dir, element_destination, timeout_duration: 50)\r\n until_element_exists(element_destination,\r\n :action => lambda{light_swipe_element(trait, dir)}, :timeout=>timeout_duration)\r\n end",
"def resize_to_mobile\n page.driver.browser.manage.window.resize_to(360, 591)\n end",
"def scroll_to(top, left)\n tap { @page.execute(\"window.scrollTo(#{top}, #{left})\") }\n end",
"def launch_UPgame_2\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::70145@nyx', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::70145@nyx'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n wait_for_element_exists \"* marked:'NO'\", :timeout => 5\n end",
"def perform_slide(move)\n raise IllegalMoveError.new unless slides.include? move\n\n perform_move(move)\n end",
"def move_task(initial, target)\n initial_x = initial.wd.location['x']\n initial_y = initial.wd.location['y']\n\n target_x = target.wd.location['x']\n target_y = target.wd.location['y']\n\n total_x = target_x - initial_x + 5\n total_y = target_y - initial_y + 5\n\n initial.when_present.drag_and_drop_by(total_x, total_y)\n sleep 1 #Allow for motion to happen\n end",
"def click_mobile_menu_from_categories\n # This is required instead of click_mobile_menu because categories screen is not part of the dialog class\n if category_menu_scroller.displayed?\n mobile_menu.click\n wait = Selenium::WebDriver::Wait.new(timeout: 60)\n wait.until { category_menu_scroller == false }\n end\n end",
"def moves\n # overridden in slideable/stepable modules\n end",
"def move \n self.send(@orientation.current.to_sym)\n end",
"def make_move(move)\n if DIRECTIONS.include? move\n key = {'up' => :up, 'down' => :down, 'left' => :left, 'right'=> :right}[move]\n @driver.action.send_keys(key).perform\n sleep(0.02)\n else\n puts \"ERROR: Invalid move.\"\n end\n end",
"def scroll_up\r\n $driver.execute_script(\"window.scrollTo(0, -document.body.scrollHeight)\")\r\nend",
"def scroll_down\r\n $driver.execute_script(\"window.scrollTo(0, document.body.scrollHeight)\")\r\nend",
"def zoom(percentage = 200, auto_perform = true)\n fail ArgumentError(\"Can't zoom to smaller then screen size.\") if percentage < 100\n\n p = 100 / Float(percentage)\n i = 1 - p\n\n top = TouchAction.new\n top.swipe start_x: i, start_y: i, end_x: 1, end_y: 1, duration: 1\n\n bottom = TouchAction.new\n bottom.swipe start_x: p, start_y: p, end_x: 1, end_y: 1, duration: 1\n\n zoom = MultiTouch.new\n zoom.add top\n zoom.add bottom\n return zoom unless auto_perform\n zoom.perform\n end",
"def U\r\n move_method(4) \r\nend",
"def scroll_down(amount)\n $driver.execute_script(\"window.scrollBy(0,#{amount});\")\n end",
"def zoom_in_out(in_out)\n if get_os==\"windows\"\n key=\"control\"\n elsif get_os==\"mac\"\n key=\"command\"\n end\n\n $driver.action.key_down(:\"#{key}\").send_keys(:\"#{in_out}\").key_up(:\"#{key}\").perform\nend",
"def D\r\n move_method(5) \r\nend",
"def move(direction)\n \n end",
"def mobile_modifier()\n if browser.device.mobile?\n return '-mobile'\n else\n return ''\n end\n end",
"def move_incremental(acc, dec, ve, dist)\n Process.spawn \"screen -S usbserial -X stuff 'AC#{acc} DE#{dec} VE#{ve} DI#{dist} GO\\n'\"\n puts \"screen -S usbserial -X stuff 'AC#{acc} DE#{dec} VE#{ve} DI#{dist} GO\\n'\"\n end",
"def custom_keyboard(count)\n for i in 0..5\n if ENV['PLATFORM_NAME'] == 'android' or ENV['PLATFORM_NAME'] == 'ios'\n $driver.find_element(:accessibility_id,\"Numpad_Button_#{count[i]}\").click\n sleep (1)\n else\n $driver.xpath(\"predicate:type == 'XCUIElementTypeOther' AND (label == #{count[i]}])\").click\n sleep (1)\n end\n end\nend",
"def click_mobile_menu\n if close_search_bar.displayed?\n close_search_bar.click\n end\n # categoryMenuScroller is required because category screen is not part of the dialogs yet\n count = @browser.find_elements(:class, 'dialog-overlay-settings').count + @browser.find_elements(:class, 'dialog').count\n mobile_menu.click\n wait = Selenium::WebDriver::Wait.new(timeout: 60)\n wait.until { (@browser.find_elements(:class, 'dialog-overlay-settings').count + @browser.find_elements(:class, 'dialog').count) != count }\n sleep(1)\n end",
"def navigate\n unless current_page?\n preview_screen = go_to(InstagramPreviewScreen)\n sleep(WAIT_SCREENLOAD)\n #wait_for_elements_exist(preview_screen.share, :timeout => MAX_TIMEOUT)\n #touch preview_screen.share\n touch query(\"* id:'shareButton'\")\n sleep(WAIT_SCREENLOAD)\n \n end\n await\n end",
"def fake_drop(from,to)\n to = to.gsub(/#/,\"\")\n from = from.gsub(/#/,\"\")\n script = <<-EOF\n var drop = Droppables.drops.find( function (e) { if (e.element.id == '#{to.gsub(/#/,\"\")}') return true; });\n if (drop) {\n drop.onDrop($('#{from}'));\n }\n EOF\n page.execute_script(script)\nend",
"def robot_move\n state_execute do |robot|\n robot.move\n end\n end",
"def W\r\n move_method(3) \r\nend",
"def advance(duration)\n page.execute_script \"window.clock.tick(#{ duration * 1000 });\"\n end",
"def scroll_until_i_see(button, direction = :up)\n #wait_poll(until_exists: \"* {text CONTAINS[c] '#{escape_quotes(text)}'}\", timeout: 10) do\n wait_poll(until_exists: \"webView css:'#mockImage'\", timeout: 10) do\n pan(\"* id:'viewpager'\", direction)\n end\n end",
"def next_slide\n switch_to_current_frame\n body = $driver.find_element(:tag_name => \"body\")\n $driver.mouse.move_to(body, 3*body.size.width/4, body.size.height/4)\n $driver.mouse.down\n $driver.mouse.move_by(-body.size.width/2, 0)\n $driver.mouse.up\n sleep(1)\n switch_to_current_frame\n end",
"def moveUpAndDown(dis)\n vector = getCurrentDirection\n vector.length = dis\n moveTransformation = Geom::Transformation.translation(vector)\n @@componentInstance.transform! moveTransformation\n updateAvatarLocation\n updateTransformation\n updateViewPort\n\n \n\n end",
"def moveArrowInputRangeToRight(how,element, numberOfArrowMove)\n findElement(how,element).send_keys :tab\n sleep 1\n for i in 1..numberOfArrowMove\n findElement(how, element).send_keys :arrow_right\n sleep 1\n end\n end",
"def tom_likes_walker\n Swipe.create!({\n swiped_yes: true,\n swiper_id: 23,\n swipee_id: 24\n })\nend",
"def drag_and_drop locator, movements_string\r\n command 'dragAndDrop', locator, movements_string\r\n end",
"def execute script\n native.execute_script script\n end",
"def scroll_action(x, duration)\n width = (x * 2)\n move = SKAction.moveByX(-width, y: 0, duration: duration * width)\n reset = SKAction.moveByX(width, y: 0, duration: 0)\n\n SKAction.repeatActionForever(SKAction.sequence([move, reset]))\n end",
"def scroll_action(x, duration)\n width = (x * 2)\n move = SKAction.moveByX(-width, y: 0, duration: duration * width)\n reset = SKAction.moveByX(width, y: 0, duration: 0)\n\n SKAction.repeatActionForever(SKAction.sequence([move, reset]))\n end",
"def scroll_to(element, device: T.unsafe(nil)); end",
"def scroll_down_for_element_exists(xpath, intentos = nil, scroll_size = nil)\r\n\r\n result = false\r\n no_scrols = intentos.nil? ? 10 : intentos\r\n\r\n for i in 0..no_scrols\r\n\r\n if mobile_element_exists xpath\r\n result = true\r\n break\r\n end\r\n\r\n scroll_to_down scroll_size\r\n\r\n end\r\n\r\n return result\r\n\r\nend",
"def launch_UPgame_5\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::superflipmobile@playngo', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::superflipmobile@playngo'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n wait_for_element_exists \"all webView css:'#moneyBalanceWrapper'\", :timeout => 40\n sleep 3\n if element_exists \"all webView css:'#moneyBalanceWrapper'\"\n puts ' Super Flip game launched successfully'\n else\n fail ' Super Flip not launched'\n end\n sleep 8\n end",
"def process_page_with_mobile(page)\n page.app = app?\n page.mobile = app? || mobile?\n process_page_without_mobile(page)\n end",
"def move_piece(from, to)\n from = @browser.image(:id, /img_chessboard.*#{from}/)\n to = @browser.image(:id, /img_chessboard.*#{to}/)\n\n\n attempt = -> () do\n begin \n #Selenium race condition requires error handling\n return nil if (!from.exists? || !to.exists?) && (from.visible? && to.visible?)\n\n from.drag_and_drop_on(to)\n return 1\n rescue Selenium::WebDriver::Error::ObsoleteElementError, \n Watir::Exception::UnknownObjectException, \n Selenium::WebDriver::Error::MoveTargetOutOfBoundsError, \n Selenium::WebDriver::Error::UnknownError\n return nil\n end\n end\n\n count = 5\n while attempt.call == nil && count != 0\n count -= 1 #try again\n end\n end",
"def launch_UPgame_3\n sleep 0.5\n scroll_to_collection_view_item_with_mark('casino-app-unibet-picks-7-579350::eyeofthekrakenmobile@playngo', {:scroll_position => :right})\n sleep 1\n touch \"* marked:'casino-app-unibet-picks-7-579350::eyeofthekrakenmobile@playngo'\"\n sleep 1\n touch \"* marked:'Play for Fun'\"\n # rotate :right\n wait_for_element_exists \"all webView css:'#moneyBalanceWrapper'\", :timeout => 40\n sleep 3\n if element_exists \"all webView css:'#moneyBalanceWrapper'\"\n puts ' Eye of The Kraken game launched successfully'\n else\n fail ' Eye of The Kraken not launched'\n end\n end",
"def click_button(id)\n case @browser\n when :iPad\n @driver.execute_script \"$('##{id} button').click();\"\n else\n $test.driver.find_element(:css, \"##{id} button\").click\n end\n end",
"def hover_and_move_slow(how, what, move_x, move_y)\n $debug and print \"In hover_and_move_slow: #{how}, #{what}, #{move_x}, #{move_y}\\n\"\n distance = [ 40, ((move_x + move_y)/4).abs].max\n e=$driver.find_element(how, what)\n $driver.action.click_and_hold(e).perform\n\n x = e.location.x\n y = e.location.y\n\n goal_x = x + move_x\n goal_y = y + move_y\n\n while( (goal_x - x).abs > 5 or (goal_y - y).abs > 5 )\n diff_x = goal_x - x\n diff_y = goal_y - y\n\n while( diff_x.abs > distance )\n diff_x = diff_x / 2;\n end\n\n while( diff_y.abs > distance )\n diff_y = diff_y / 2;\n end\n\n $debug and print \"In hover_and_move_slow: moving x #{diff_x} and y #{diff_y}, given current x #{x} and y #{y} with goals x #{goal_x} and y #{goal_y}\\n\"\n\n $driver.action.move_by(diff_x, diff_y).perform\n\n #$debug and sleep 2\n\n e=$driver.find_element(how, what)\n x = e.location.x\n y = e.location.y\n end\n\n $debug and print \"In hover_and_move_slow: exited main loop, current x #{x} and y #{y} with goals x #{goal_x} and y #{goal_y}\\n\"\n\n $driver.action.release.perform\n end",
"def drag_drop(start_x, start_y, end_x, end_y)\n @java_obj.dragDrop(\n org.sikuli.script::Location.new(start_x, start_y).offset(x(), y()),\n org.sikuli.script::Location.new(end_x, end_y).offset(x(), y()),\n 0\n )\n end",
"def walk_right_for(ms)\n behavior = MovementBehavior.create { move_right }\n behavior.at_end { stop_totally }\n behavior.completed_after(ms)\n record_behavior(behavior)\n end",
"def move_type_custom\n # Interrupt if not stopping\n if jumping? or moving?\n return\n end\n # Loop until finally arriving at move command list\n while @move_route_index < @move_route.list.size\n # Acquiring move command\n command = @move_route.list[@move_route_index]\n # If command code is 0 (last part of list)\n if command.code == 0\n # If [repeat action] option is ON\n if @move_route.repeat\n # First return to the move route index\n @move_route_index = 0\n end\n # If [repeat action] option is OFF\n unless @move_route.repeat\n # If move route is forcing\n if @move_route_forcing and not @move_route.repeat\n # Release forced move route\n @move_route_forcing = false\n # Restore original move route\n @move_route = @original_move_route\n @move_route_index = @original_move_route_index\n @original_move_route = nil\n end\n # Clear stop count\n @stop_count = 0\n end\n return\n end\n # During move command (from move down to jump)\n if command.code <= 14\n # Branch by command code\n case command.code\n when 1 # Move down\n move_down\n when 2 # Move left\n move_left\n when 3 # Move right\n move_right\n when 4 # Move up\n move_up\n when 5 # Move lower left\n move_lower_left\n when 6 # Move lower right\n move_lower_right\n when 7 # Move upper left\n move_upper_left\n when 8 # Move upper right\n move_upper_right\n when 9 # Move at random\n move_random\n when 10 # Move toward player\n move_toward_player\n when 11 # Move away from player\n move_away_from_player\n when 12 # 1 step forward\n move_forward\n when 13 # 1 step backward\n move_backward\n when 14 # Jump\n jump(command.parameters[0], command.parameters[1])\n end\n # If movement failure occurs when [Ignore if can't move] option is OFF\n if not @move_route.skippable and not moving? and not jumping?\n return\n end\n @move_route_index += 1\n return\n end\n # If waiting\n if command.code == 15\n # Set wait count\n @wait_count = command.parameters[0] * 2 - 1\n @move_route_index += 1\n return\n end\n # If direction change command\n if command.code >= 16 and command.code <= 26\n # Branch by command code\n case command.code\n when 16 # Turn down\n turn_down\n when 17 # Turn left\n turn_left\n when 18 # Turn right\n turn_right\n when 19 # Turn up\n turn_up\n when 20 # Turn 90° right\n turn_right_90\n when 21 # Turn 90° left\n turn_left_90\n when 22 # Turn 180°\n turn_180\n when 23 # Turn 90° right or left\n turn_right_or_left_90\n when 24 # Turn at Random\n turn_random\n when 25 # Turn toward player\n turn_toward_player\n when 26 # Turn away from player\n turn_away_from_player\n end\n @move_route_index += 1\n return\n end\n # If other command\n if command.code >= 27\n # Branch by command code\n case command.code\n when 27 # Switch ON\n $game_switches[command.parameters[0]] = true\n $game_map.need_refresh = true\n when 28 # Switch OFF\n $game_switches[command.parameters[0]] = false\n $game_map.need_refresh = true\n when 29 # Change speed\n @move_speed = command.parameters[0]\n when 30 # Change freq\n @move_frequency = command.parameters[0]\n when 31 # Move animation ON\n @walk_anime = true\n when 32 # Move animation OFF\n @walk_anime = false\n when 33 # Stop animation ON\n @step_anime = true\n when 34 # Stop animation OFF\n @step_anime = false\n when 35 # Direction fix ON\n @direction_fix = true\n when 36 # Direction fix OFF\n @direction_fix = false\n when 37 # Through ON\n @through = true\n when 38 # Through OFF\n @through = false\n when 39 # Always on top ON\n @always_on_top = true\n when 40 # Always on top OFF\n @always_on_top = false\n when 41 # Change Graphic\n @tile_id = 0\n @character_name = command.parameters[0]\n @character_hue = command.parameters[1]\n if @original_direction != command.parameters[2]\n @direction = command.parameters[2]\n @original_direction = @direction\n @prelock_direction = 0\n end\n if @original_pattern != command.parameters[3]\n @pattern = command.parameters[3]\n @original_pattern = @pattern\n end\n when 42 # Change Opacity\n @opacity = command.parameters[0]\n when 43 # Change Blending\n @blend_type = command.parameters[0]\n when 44 # Play SE\n $game_system.se_play(command.parameters[0])\n when 45 # Script\n result = eval(command.parameters[0])\n end\n @move_route_index += 1\n end\n end\n end",
"def right_click_list(list, item_index)\n append_to_script \"right_click_list \\\"#{list}\\\" , \\\"#{item_index}\\\"\"\n end",
"def drag_and_drop_by(source, right_by, down_by, device: T.unsafe(nil)); end",
"def redirect_for_mobile\n if request.mobile?\n pa = params.dup\n pa[:controller] = \"/mobile\"\n pa[:action] = \"index\"\n redirect_to pa\n end\n end",
"def set_screen_postion(start_pos, reset = false)\n position = reset ? [$game_player.x,$game_player.y] : start_pos \n pos = set_screen_move_postion(position)\n set_screen(pos[0], $game_map.display_x, true)\n set_screen(pos[1], $game_map.display_y, false)\n end",
"def press element\n element.perform :press\n end",
"def move_absolute(acc, dec, ve, pos) \n Process.spawn \"screen -S usbserial -X stuff 'AC#{acc} DE#{dec} VE#{ve} DA#{pos} GO\\n'\"\n puts \"screen -S usbserial -X stuff 'AC#{acc} DE#{dec} VE#{ve} DA#{pos} GO\\n'\"\n end",
"def drag_and_drop_js(source, target)\n jquery = Rails.root.join('spec/js_helpers/jquery-3.3.1.min.js').read\n dnd = Rails.root.join('spec/js_helpers/drag_and_drop_helper.js').read\n\n Capybara.current_session.driver.browser.execute_script(jquery)\n Capybara.current_session.driver.browser.execute_script(dnd)\n Capybara.current_session.driver.browser.execute_script(\"$('#{source}').simulateDragDrop({ dropTarget: '#{target}'});\")\n end",
"def scroll_up_for_element_exists(xpath, intentos = nil, scroll_size = nil)\r\n\r\n result = false\r\n no_scrols = intentos.nil? ? 10 : intentos\r\n\r\n for i in 0..no_scrols\r\n\r\n if mobile_element_exists xpath\r\n result = true\r\n break\r\n end\r\n\r\n scroll_to_up scroll_size\r\n\r\n end\r\n\r\n return result\r\n\r\nend",
"def dim\n execute_applescript(%Q`\n tell application \"Mousepose\"\n stop effect\n end\n `)\n end",
"def test_gesture\r\n @point_poller.kill\r\n @current_gesture.name = \"match gesture\"\r\n @current_gesture.action = \"none\"\r\n @current_gesture.convert_points_to_gesture\r\n @recording = false\r\n @matching = false\r\n @current_gesture.test_gesture(@gestures)\r\n end",
"def move_to_element(element)\n driver.execute_script('arguments[0].scrollIntoView(true)', element)\n end",
"def move\n \n end",
"def move\n \n end",
"def run_script\n %[timeout $((PBS_WALLTIME-300)) \"#{script}\"]\n end",
"def scroll_speed() 6 end"
] | [
"0.7361401",
"0.7070836",
"0.65706843",
"0.6538832",
"0.63910407",
"0.63701206",
"0.6151815",
"0.6132001",
"0.6125521",
"0.6123976",
"0.58873904",
"0.58606666",
"0.57438546",
"0.54728895",
"0.5465492",
"0.5428572",
"0.5262703",
"0.52456886",
"0.5206053",
"0.5147923",
"0.5138546",
"0.5133129",
"0.50768185",
"0.5061511",
"0.5040456",
"0.49782744",
"0.4961272",
"0.48514652",
"0.48444977",
"0.48024246",
"0.47956514",
"0.47901222",
"0.4788592",
"0.47824267",
"0.47014567",
"0.47014567",
"0.46713367",
"0.46218717",
"0.46020034",
"0.45988065",
"0.45912427",
"0.45831332",
"0.45309308",
"0.45290545",
"0.45255956",
"0.4513324",
"0.4511831",
"0.45050874",
"0.45027024",
"0.44955516",
"0.44843486",
"0.44839475",
"0.44828826",
"0.4471142",
"0.44544324",
"0.44496465",
"0.44456437",
"0.44396916",
"0.4436212",
"0.44305477",
"0.44221768",
"0.44078168",
"0.44022727",
"0.43933895",
"0.43915886",
"0.43904534",
"0.4364268",
"0.43582553",
"0.43573305",
"0.43558806",
"0.43453902",
"0.4345205",
"0.43433458",
"0.43433458",
"0.43417695",
"0.43265045",
"0.43155706",
"0.43106303",
"0.42797843",
"0.42692375",
"0.4266488",
"0.4262286",
"0.42593277",
"0.42225334",
"0.4221176",
"0.42165375",
"0.42147803",
"0.4213334",
"0.4211224",
"0.4205349",
"0.42047137",
"0.42021158",
"0.41967258",
"0.4196374",
"0.41959035",
"0.4194192",
"0.4192498",
"0.4192498",
"0.41921282",
"0.41907588"
] | 0.65246856 | 4 |
Quit the driver and Pry. quit and exit are reserved by Pry. | def x
driver_quit
exit # exit pry
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quit!\n quit\n exit!\n end",
"def quit_driver()\n @driver.shutdown\n end",
"def quit\r\n @@driver.quit\r\n end",
"def quit\n\t\t@driver.quit\n\tend",
"def quit\n exit(1)\n end",
"def quit\n @ui.close\n @player.close\n @logger.close\n exit\n end",
"def quit\n @ui.close\n @player.close\n @logger.close\n exit\n end",
"def quit()\n @webdriver.quit()\n cleanUp();\n end",
"def quit\n send_cmd \"quit\"\n nil\n end",
"def quit\n driver.quit\n end",
"def exit\n\t\tquit\n\tend",
"def quit_driver\n driver.quitDriver\n end",
"def quit\n send_command(:quit)\n read_response # \"Bye!\"\n disconnect\n end",
"def command_quit\n command_save\n exit(0)\n end",
"def quit; end",
"def quit; end",
"def quit; @quit = 1 end",
"def exit\n send_cmd \"exit\"\n nil\n end",
"def quit\n end",
"def exit_program\n exit\n end",
"def quit\n Rubygame.quit()\n exit\n end",
"def exit_program\n exit\n end",
"def quit\n Gamework::App.quit\n end",
"def quit\n system('clear')\n exit\n end",
"def close_driver\n $driver.quit\nend",
"def quit()\n @ole.Quit()\n end",
"def quit\n puts 'The library is now closed for renovations'\n end",
"def quit\n pid = fork{ exec 'killall', 'afplay' }\n exit\n end",
"def quit()\n $webdriver.quit()\n cleanUp();\n $webdriver = nil;\n TestAttributes.put(\"reuseFixture\", null);\n end",
"def quit(reason = \"You told me to\")\n @t.puts \"QUIT :#{reason}\"\n exit\n end",
"def setup_exit_handler\n main = Process.pid\n at_exit do\n @driver.driver_quit if Process.pid == main\n end\n end",
"def quit\r\n raise Shells::NotRunning unless running?\r\n raise Shells::ShellBase::QuitNow\r\n end",
"def quit\n puts \"\"\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"Thank you for using UPTIME!\"\n puts \"\"\n puts \"Have a fantastic day!\"\n puts \"\"\n puts \"\"\n exit\n end",
"def exit() end",
"def quit\n send_line('QUIT')\n reply = read_reply\n close\n reply\n end",
"def exit!() end",
"def exit_program\n abort('Exiting...')\n end",
"def exit(*args)\n # Restore the console at exit.\n VTConsole.map_console(1)\n _exit(*args)\n end",
"def disconnect_and_quit\n $db.close\n puts \"Closing DB. Bye!\"\n exit\nend",
"def exit\n @main_loop = false\n end",
"def exit\n Rushmate::Exit\n end",
"def close\n puts \"Goodbye comeback soon!\"\n exit\nend",
"def cmd_exit(*args)\n\t\tshell.stop\n\tend",
"def exit_prg \n puts \"Your brain must hurt from learning all of that information!\"\n exit \n end",
"def quit\n abort (\"Thanks for checking it out!\") \nend",
"def quit\n @browser.close\n end",
"def cmd_quit(param)\n send_response \"221 Bye\"\n close_datasocket\n close_connection_after_writing\n end",
"def exit\n @window.pause = true\n @window.close\n end",
"def quitCmd\n\tputs \"Cient sent a quit command\"\nend",
"def teardown\n $driver.quit\nend",
"def exit_now\n\t\tputs \"Goodbye!\"\n\tend",
"def quit?\n exit if options[:quit]\n end",
"def forced_exit?; @quit > 1 end",
"def quit!\n @done = true\n @quit = true\n\n # If quit! is called from other than a command, we need to interrupt the\n # breakpoint listener thread\n unless @debug_thread\n @breakpoint_tracker.debug_channel.send nil\n @breakpoint_listener.join\n end\n end",
"def quit _signal = :SIGINT\n @networks.each do |network|\n network.transmit :QUIT, 'Got SIGINT?'\n network.disconnect\n end\n\n EventMachine.stop\n end",
"def quit\n @open = false\n 'The library is now closed for renovations.'\n end",
"def quit!\n @quit = true\n\n # If quit! is called from other than a command, we need to interrupt the\n # breakpoint listener thread\n unless @debug_thread\n @breakpoint_tracker.debug_channel.send nil\n @breakpoint_listener.join\n end\n end",
"def force_quit; @quit = 2 end",
"def quit(reason = 'bye')\n send_msg(\"QUIT :#{reason}\")\n @sock.close\n exit\n end",
"def exit_program\n puts \"Thanks for playing!\"\n abort\nend",
"def teardown\n puts 'Exit'\n @web_driver.quit\n end",
"def teardown\n @driver.quit\n end",
"def quit\n ui.quit\n Dumon::logger.info 'Terminted...'\n end",
"def close!\n @controller.close! if @controller\n FFI::NCurses.endwin\n Process.exit!\n end",
"def exitProgram\n exit(0)\nend",
"def stop\n driver.stop\n end",
"def close\n driver.close # FIXME?\n end",
"def quit\n @retry, @resignin = nil\n end",
"def quit\n client.quit\n end",
"def teardown\n @driver.quit()\n end",
"def quit\n abort(\"Thank you!\")\n end",
"def teardown\n @driver.quit \n end",
"def stop\n\t\t\tContext::wait if @options[:wait]\n\t\t\tbegin\n\t\t\t\t@logger.finalize(self)\n\t\t\trescue StandardError => e\n\t\t\t\tprint_error(e)\n\t\t\t\traise\n\t\t\tensure\n\t\t\t\t@driver.quit if @driver\n\t\t\tend\n\t\tend",
"def end_game\n\t\tputs \"Goodbye!\"\n\t\texit\n\tend",
"def quit # :nodoc:\n @master = @master.close if @master\n end",
"def teardown\r\n @driver.quit\r\n @driver = nil\r\n end",
"def stop\n @quit = true\n end",
"def trap_signals\n Signal.trap('INT') do\n say \"\\nQuitting...\", :red\n Kernel.exit\n end\n end",
"def exit \n \"exit\" \n end",
"def quit?\n @quit\n end",
"def close\n driver.close\n end",
"def icl_quit( args )\n if !(@foodDB.saved?) || !(@log.saved?)\n icl_save( @foodDB.path )\n end\n\n puts \"Thank you, have a nice day\"\n return 0\n end",
"def stop_app\n if @driver\n driver_quit\n @driver = nil\n end\n end",
"def teardown\r\n # Do nothing\r\n @driver.quit\r\n end",
"def close_driver\n\t$driver.close\nend",
"def teardown\n @driver.close\n @driver.quit\n end",
"def close\n raise SystemExit if SES::Console.enabled\n end",
"def quit(player, input)\n \t\tunless input =~ /quit/i\n \t\t\tprint_line \"You must type the entire word 'quit' to quit.\\n\"\n \t \telse\n \t\t\tprint_line \"Until next time...\"\n \t\t\t$win.refresh\n \t\t\tsleep 3\n \t\t\t$win.close\n \t\t\texit\n \t\tend\n\tend",
"def mouse_quit\n $game_system.se_play($data_system.cancel_se)\n if display_message(ext_text(8997, 42), 1, ext_text(8997, 33), ext_text(8997, 34)) == 0\n @return_data = false\n @running = false\n end\n end",
"def exit_app\n puts \"Chuck Norris disapproves of your choice...\\n\\n\"\n exit!\n end",
"def coolest_exit\n Kernel.exit! 99\n end",
"def exit\n \"Goodbye! Thanks for playing!\"\n end",
"def hook_quit\n\tquit_hooks = {\n\t :escape => :quit,\n\t Rubygame::Events::QuitRequested => :quit,\n\t}\n\tmake_magic_hooks(quit_hooks)\n end",
"def quitting?; @quit > 0 end",
"def mouse_quit\n $game_system.se_play($data_system.cancel_se)\n if display_message(ext_text(8997, 40), 1, ext_text(8997, 33), ext_text(8997, 34)) == 0\n @return_data = false\n @running = false\n end\n end",
"def local_quit(body)\n ### send notice of disconnection?\n Kernel.exit\nend",
"def exit_jukebox\nputs \"Goodbye\"\nend",
"def quit\n watchers.each(&:quit)\n end",
"def teardown\n @fox_driver.quit\n end",
"def seeYa()\n abort(\"\\nQuiting now. Bye!\") \nend"
] | [
"0.7649962",
"0.75097275",
"0.7461979",
"0.7409583",
"0.7335107",
"0.7230508",
"0.7230508",
"0.7108723",
"0.70328236",
"0.703234",
"0.70131856",
"0.6982187",
"0.69693995",
"0.6916052",
"0.68841213",
"0.68841213",
"0.68736315",
"0.683998",
"0.6834304",
"0.682177",
"0.6782976",
"0.67467445",
"0.67307764",
"0.6723212",
"0.6720591",
"0.67072797",
"0.6670117",
"0.6646268",
"0.65607893",
"0.654925",
"0.6523362",
"0.6507718",
"0.6481776",
"0.64768",
"0.6466488",
"0.6421062",
"0.6411667",
"0.6364554",
"0.6306621",
"0.630099",
"0.62800485",
"0.626537",
"0.62638485",
"0.624289",
"0.6241404",
"0.62315243",
"0.6228092",
"0.6224967",
"0.6223411",
"0.6177182",
"0.61725557",
"0.6169156",
"0.615473",
"0.6144505",
"0.61409235",
"0.61384326",
"0.61357677",
"0.61333245",
"0.61091703",
"0.61040187",
"0.60983115",
"0.6089071",
"0.60858554",
"0.60732895",
"0.60645086",
"0.6043182",
"0.60329044",
"0.6032328",
"0.6027911",
"0.60185945",
"0.60174924",
"0.6011556",
"0.6005586",
"0.6000572",
"0.5991867",
"0.5977049",
"0.59694314",
"0.596554",
"0.59644467",
"0.59533155",
"0.59470624",
"0.5945481",
"0.5932029",
"0.5927801",
"0.5927406",
"0.59264475",
"0.59261143",
"0.5920668",
"0.59176046",
"0.5902634",
"0.5901262",
"0.5897539",
"0.5895477",
"0.5890413",
"0.5886243",
"0.58838224",
"0.58786845",
"0.58746564",
"0.5866689",
"0.58616835"
] | 0.784934 | 0 |
Defining an each method for looping through each node | def each
node = @head
while node
yield node
node = node.next_node
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(node, &block); end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def each(node, &block)\n visit(node, &block)\n end",
"def each_node(&block)\n\t\t\tnodes.each(&block)\n\t\tend",
"def each_node(&block)\n nodes.each(&block)\n end",
"def each_node(&block)\n @nodes.each &block\n end",
"def each_node(&block)\n @nodes.each &block\n end",
"def each_node\n list_nodes.each do |node|\n yield node\n end\n end",
"def each_node(&block)\n nodes.each_value(&block)\n end",
"def each_node(&block)\n nodes.each_node &block\n end",
"def each_node(&block)\n nodes.each_node &block\n end",
"def each(&block)\n return enum_for(:each) unless block_given?\n visit { |node| yield node }\n self\n end",
"def each_node\n return to_enum(__method__) unless block_given?\n\n doc.xpath(query).each do |node|\n yield node\n end\n end",
"def each(node,options={},&block)\n all(node,options).each(&block)\n end",
"def each\n each_node do |node|\n yield(node_key(node), node_value(node))\n end \n end",
"def each\n each_node do |node|\n yield(node_key(node), node_value(node))\n end \n end",
"def each(&block)\n root.each(&block)\n end",
"def each_child\n \n end",
"def each(&block)\n # get the first\n node=getnext([])\n $DEBUG.puts \"each: first node is #{node}\"\n while node\n block.call node\n oldnode=node\n node=getnext(node.oid)\n $DEBUG.puts \"each: next of #{oldnode} is #{node}\"\n end\n end",
"def each_node(&block)\r\n @nodes.each { |node| block.call(node) }\r\n end",
"def each(&block)\n root.each(&block)\n end",
"def each\n current_node = @head\n while current_node\n yield(current_node.value) if block_given?\n current_node = current_node.next\n end\n end",
"def each\n\t\t\t@elements.each\n\t\tend",
"def each(&block)\n tree.each(&block)\n end",
"def each \n node=@head\n while node != nil do\n yield node.value\n node = node.next\n end\n end",
"def each(&block)\n each_element(block) if @xml\n end",
"def each\n aux = @head\n while aux!=nil\n yield aux.value\n aux=aux.nest\n end\n end",
"def each &block\n @root.each(&block)\n end",
"def each()\n @tour.each do |node_id|\n yield node_id\n end\n end",
"def each\n @nodes.values.each do |node|\n yield node, node.adjacency_list\n end\n end",
"def each()\n @root.each(\"\") do |k, v|\n yield(k, v)\n end\n end",
"def each(*) end",
"def each\n for each element\n yield(element)\n end\nend",
"def deep_each\n \n end",
"def each\n # takes a block, and runs the block for each\n # node in the list (i.e. the current node is\n # provided as a block variable/\"goalpost\" arg\n # to the block)\n # HINT: look up 'yield'\n return nil unless block_given?\n #\n # puts \"before yield\"\n # val = yield( \"SOME ARGUMENT\" )\n # puts \"after yield: return from yield is #{val}\"\n\n node = @head\n index = 0\n while node\n # run the block which was given to .each, and\n # pass in the current node and index to the block,\n # which will be avaialable as block ('goalpost')\n # variables, updated each iteration\n # i.e. list.each do |current_node, current_index|\n yield node, index\n node = node.next\n index += 1\n end\n\n end",
"def each # And define each on top of next\n loop {yield self.next }\n end",
"def each(&block)\n each_node([], @root, block)\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def each\n \n nodo = @head\n while nodo != nil\n \n yield nodo.value\n nodo = nodo.next\n \n end\n \n end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each; end",
"def each\n end",
"def each\n\n this_node = @head\n\n size.times do |i|\n yield this_node.value\n this_node = this_node.child\n end\n\n return self\n end",
"def custom_hook_each(item, _node)\n item\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each\n end",
"def each(&block)\n Placeholder.each(node_data, &block)\n end",
"def each\n Directory.all.each do |node_id|\n yield find node_id\n end\n end",
"def each\n return enum_for(__method__) unless block_given?\n return if @head.nil?\n\n traverser = @head\n\n until traverser.nil?\n yield traverser\n traverser = traverser.next_node\n end\n end",
"def each\n return enum_for(__method__) unless block_given?\n return if @head.nil?\n\n traverser = @head\n\n until traverser.nil?\n yield traverser\n traverser = traverser.next_node\n end\n end",
"def each # And define each on top of next\n loop { yield self.next }\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def each(&block)\n axis_iterator(:child).each(&block)\n end",
"def each(node, &block)\n return to_enum(__method__, node) unless block_given?\n visit(node, &block)\n end",
"def each(&block)\n end",
"def each(&blk)\n @trees.each_value(&blk)\n end",
"def each\n @children.each {|child| yield child}\n end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block); end",
"def each(&block)\n block.call(self)\n @child_array.each do |node|\n node.each(&block)\n end\n end",
"def each_node(nodes)\n unless ::Nokogiri::XML::NodeSet === nodes\n nodes = [nodes]\n end\n nodes.each do |node|\n yield(node)\n end\n end",
"def eachNode(&block)\n @nodeSets.each { |s|\n s.eachNode &block\n }\n end",
"def each\n return to_enum(__callee__) unless block_given?\n\n node = self\n loop do\n yield node\n break unless (node = node.next_node)\n end\n end",
"def each\n all.each do |el|\n yield el\n end\n end",
"def each\n end",
"def each\n end",
"def eachNode(&block)\n @topo.eachNode(&block) if !@topo.nil?\n end",
"def _each\n @decl_rel._each_node(@node) { |n| yield n }\n end",
"def each\n #if head is not nil we have a list and can interate.\n #simply iterate and yield data from each node\n if !@head.nil?\n current = @head\n while current.next_node != nil\n yield current.data\n current = current.next_node\n end\n yield current.data\n\n end\n end",
"def each(&block)\n node = @Node.new(nil,nil,nil)\n node = @head\n\n while !(node.nil?)\n yield node.value\n\n node = node.next\n end\n end",
"def each &block\n return enum_for(:each) unless block_given?\n return if !@root\n @root.each &block\n end",
"def each(node=@head)\n until node.nil?\n result = yield(node)\n node = node.next_node\n end\n result\n end",
"def each\n\t\titerator = @head\n\t\twhile iterator != nil do\n\t\t\tyield iterator.value\n\t\t\titerator = iterator.next\n\t\tend\n\tend",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def each\n# And define each on top of next\nloop { yield self.next }\nend",
"def _each(&block)\n _next.each(&block) if _next\n end",
"def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end",
"def each_node_model(&block)\n node_models.each_value(&block)\n end",
"def each()\n self.to_a.each { |elt| yield elt }\n end",
"def iterate(itr)\n itr.call(@leaf)\n end",
"def each\n current_node = @head\n (0..@size - 1).each do |_i|\n yield current_node.data\n current_node = current_node.next\n end\n end",
"def each\n raise 'Not implemented'\n end",
"def each &block\n end"
] | [
"0.8541049",
"0.8030135",
"0.80074793",
"0.7959448",
"0.7943027",
"0.7941357",
"0.7941357",
"0.7824405",
"0.78107595",
"0.7760559",
"0.7760559",
"0.7612355",
"0.7590659",
"0.75728285",
"0.75364065",
"0.75364065",
"0.7455355",
"0.7450453",
"0.74457455",
"0.73965573",
"0.7394949",
"0.7380847",
"0.73457974",
"0.7341245",
"0.7326558",
"0.73027766",
"0.7287152",
"0.7283979",
"0.7256114",
"0.7243118",
"0.7237167",
"0.72369885",
"0.72258854",
"0.722469",
"0.71954954",
"0.7190808",
"0.71851945",
"0.71836513",
"0.7172147",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.7162452",
"0.71613884",
"0.71459717",
"0.71250707",
"0.71196204",
"0.71196204",
"0.71196204",
"0.71196204",
"0.71196204",
"0.71196204",
"0.7099711",
"0.7095288",
"0.7086813",
"0.7086813",
"0.7077449",
"0.7072398",
"0.7057691",
"0.70495725",
"0.70313996",
"0.7013338",
"0.70115143",
"0.70095086",
"0.70095086",
"0.70095086",
"0.70095086",
"0.70095086",
"0.70095086",
"0.7004539",
"0.69990313",
"0.69955283",
"0.699277",
"0.69903994",
"0.696951",
"0.696951",
"0.69686615",
"0.6968399",
"0.6964954",
"0.69649446",
"0.69518954",
"0.6951465",
"0.6950221",
"0.6924161",
"0.6924161",
"0.6907491",
"0.68785983",
"0.6873845",
"0.6854174",
"0.68534887",
"0.6844144",
"0.6841874",
"0.6838713"
] | 0.7566883 | 14 |
Finds and returns the 1st node whose value is 'value' | def find(value)
self.each {|node| return node if node.value == value}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end",
"def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == value\n current = current.next_node\n end\n end",
"def find(value)\n current_node = head\n while current_node != nil\n return current_node if current_node.value == value\n current_node = current_node.next\n end\n nil\n end",
"def find(value)\n node = @head \n for i in 0..@size-1 \n return i if node.value == value\n node = node.link \n end\n return nil\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n return false if @head.nil?\n curr_node = @head\n match = false\n while curr_node\n break if match = (curr_node.value == value)\n curr_node = curr_node.next\n end\n\n match\n end",
"def find(value)\n return nil if @head.nil?\n found = nil\n index = 0\n current_node = @head\n while !node.nil? do\n if node.data == value\n found = true\n break\n end\n index += 1\n current_node = node.next\n end\n found == true ? \"#{value} found at index #{index}!\" : nil\n end",
"def find(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n current_node = current_node.right_child\n elsif current_node.data > value\n current_node = current_node.left_child\n else\n return current_node\n end\n end\n return nil\n end",
"def value_of_node(node_name)\n value_of_nodes(node_name).first\nend",
"def search(value)\n\t\t\treturn nil if self.empty?\n\t\t\telement = self.head\n\t\t\twhile element.value != value\n\t\t\t\tif element.next.nil?\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\telement = element.next\n\t\t\t\tend\n\t\t\tend\n\t\t\telement\n\t\tend",
"def find(value, node = @root)\n if node.nil?\n return nil\n end\n\n if value < node.value\n return find(value, node.left_node)\n elsif value > node.value\n return find(value, node.right_node)\n else\n return node\n end\n end",
"def depth_first(value_to_find)\r\n @children.each do |child|\r\n found_node = child.depth_first(value_to_find)\r\n if found_node != nil\r\n return found_node\r\n end\r\n end\r\n\r\n if payload == value_to_find\r\n return self\r\n else\r\n return nil\r\n end\r\n end",
"def find_by_value(value)\n return nil if value.nil? || self.size == 0\n stop_node = self.head\n target = stop_node\n while target && !target.match_by_value(value)\n target = target.next\n break if stop_node.equal?(target)\n end\n target = nil unless target && target.match_by_value(value)\n target\n end",
"def find(value, node = @root)\n return nil if node.nil?\n return node if node.value.eql?(value)\n\n node.value > value ? find(value, node.left) : find(value, node.right)\n end",
"def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end",
"def find(value)\n idx = 0\n node = list\n while node != nil\n return idx if node.value == value\n idx += 1\n node = node.nextNode\n end\n return nil\n end",
"def find(value)\n index = 0\n temp = @head\n while temp\n return index if temp.value == value\n index += 1\n temp = temp.next_node\n end\n nil\n end",
"def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end",
"def find(value, current_node = root)\n return current_node if current_node.nil? || current_node.value == value\n value < current_node.value ? find(value, current_node.left) : find(value, current_node.right)\n\n end",
"def breadth_first(value_to_find)\r\n current_node = self\r\n queue = MyQueue.new \r\n\r\n while current_node != nil\r\n if current_node.payload == value_to_find\r\n return current_node\r\n end\r\n current_node.children.each do |child|\r\n queue.enqueue(child)\r\n end\r\n current_node = queue.dequeue\r\n end\r\n end",
"def find(value)\n current_node = @head\n counter = 0\n until current_node.nil?\n return counter if current_node.value == value\n\n current_node = current_node.next_node\n counter += 1\n end\n nil \n end",
"def find(value, tree_node = @root)\n current_node = tree_node\n while (current_node)\n if value > current_node.value\n current_node = current_node.right\n elsif value < current_node.value\n current_node = current_node.left\n else\n return current_node\n end\n end\n nil\n end",
"def search_cell_by_value(value)\n return nil if self.last.nil?\n \n tail = self.last\n \n while true\n if tail.value == value\n return tail\n elsif tail.successor\n tail = tail.successor\n else\n return nil\n end\n end\n end",
"def find(value, current_index = 0, node = @head)\n return nil if node.nil?\n return current_index if node.value == value\n\n find(value, current_index + 1, node.next_node)\n end",
"def find_before(value)\n node = @head\n return node if !node.next\n return node if node.next.data == value\n\n while (node = node.next)\n return node if node.next && node.next.data == value\n end\n end",
"def find(value)\n i = 1\n current_node = @head\n while current_node != nil do\n return i if current_node.data == value\n current_node = current_node.next\n i += 1\n end\n return nil\n end",
"def depth_first_search(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil\r\n next_node = [tree]\r\n while !next_node.empty?\r\n current = next_node.pop\r\n if verbose\r\n puts \"current = #{current}\"\r\n puts \"head = #{next_node[0]}\"\r\n end\r\n # visited not strictly necessary for future proofs it \r\n if current.visited == false\r\n current.visited = true\r\n return current if current.value == value\r\n current.children.each { |child| next_node.push child if child } \r\n end\r\n end\r\n nil\r\n end",
"def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end",
"def find(value) \n index = 0\n node = @head\n while(node.value != value)\n node = node.next_node\n index += 1\n if(node.value == value)\n return index\n end\n if(node == @tail) && (node.value != value)\n return nil\n end\n end\n return 0 \n end",
"def find(value)\n if head == nil\n nil\n else\n tmp = head\n i = 0\n while tmp != nil && tmp.value != value\n tmp = tmp.next_node\n i += 1\n end\n if tmp == nil\n \"The value is not in the list\"\n else\n i\n end\n end\n end",
"def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end",
"def find_value(value)\n return find() do |item| # find is an enumerable that takes a block - passes each entry in enum to block\n item.data == value # and returns the first for which block is NOT false. So here we say return what we\n end # the first item of which the data matches the value\n end",
"def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend",
"def find(value, current_node = @root)\n # Base case: We found the node or past a leaf node\n return current_node if current_node.nil? || current_node.value == value\n\n return find(value, current_node.left) if value < current_node.value\n\n find(value, current_node.right)\n end",
"def get_value(value)\n if @head == nil #Comprobamos si la lista no esta vacía\n raise RuntimeError, \"Lista vacía, no se puede extraer nodo\"\n else\n\t\t i = @tail\n\t\t @valor=nil\n\t\t while i != nil\n\t\t if i.value == value\n\t\t @valor = i.value\n\t\t end\n\t\t i = i.next\n\t\t end\n end\n @valor\n end",
"def depth_first_search(value)\n search_stack = [@root_node]\n\n until search_stack.empty?\n curr_node = search_stack.pop\n return curr_node if curr_node.value == value\n search_stack << curr_node.left unless curr_node.left.nil?\n search_stack << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end",
"def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end",
"def selectElement(value, node)\n if node != nil\n lastElement = node\n comparacion = @compare.call(value,node)\n\n if comparacion == 0\n return lastElement\n end\n\n if comparacion > 0\n return selectElement(value, node.getRight())\n else\n return selectElement(value, node.getLeft())\n end \n end\n end",
"def find(value)\n if @head.nil?\n 'List is empty'\n else\n current_node = @head\n index = 0\n until current_node.nil?\n\n if current_node.value == value\n return index\n else\n current_node = current_node.next_node\n end\n\n index += 1\n end\n end\n nil\n end",
"def find(value)\n find_root @indices.fetch(value)\n end",
"def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend",
"def breadth_first_search(value)\n search_queue = [@root_node]\n\n until search_queue.empty?\n curr_node = search_queue.shift\n return curr_node if curr_node.value == value\n search_queue << curr_node.left unless curr_node.left.nil?\n search_queue << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end",
"def find_item value\n self.find { |item| item.value == value }\n end",
"def find(value,node=head)\n return 0 unless self.contains?(value)\n head\n loops = 0\n until @current_node.next == nil do\n if @current_node.data == value\n return loops\n end\n self.next_node\n loops += 1\n end\n return loops\n end",
"def node_value\n return @value\n end",
"def with_value(value)\n where(:value => value).first\n end",
"def find_by_value(value)\n by_value[value]\n end",
"def find_by_value(value)\n by_value[value]\n end",
"def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend",
"def breadth_first_search(tree, value)\n tgt_node = nil\n \n queue = Array(tree)\n \n while !queue.empty?\n cur_node = queue.shift \n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.each { |child| queue << child unless child.nil? }\n end\n \n tgt_node\nend",
"def search(value)\n return 'not found' if @root.nil?\n return 'found' if @root.value == value\n\n if value < @root.value\n @root = root.left\n search(value)\n elsif value > @root.value\n @root = root.right\n search(value)\n end\n end",
"def find_value(value) \n find { |item| item.data == value }\n end",
"def find(value)\n return nil if head.nil?\n\n index = 0\n curr = head\n until curr.nil?\n return index if curr.value == value\n\n index += 1\n curr = curr.next\n end\n nil\n end",
"def find(target_value)\n current = self.root\n while current do\n if current.value == target_value\n return current\n elsif current.value > target_value\n current = current.left\n else\n current = current.right\n end\n end\n return nil\n end",
"def find(val)\n found = false\n if !self.head\n return nil\n end\n current = self.head\n while current.next\n if current.value == val\n found = true\n break\n end\n current = current.next\n end\n found ? current : nil\n end",
"def search(value)\r\n temp = @first\r\n index = 0\r\n while !temp.nil?\r\n if temp.value == value\r\n return index\r\n end\r\n temp = temp.next\r\n index += 1\r\n end\r\n return -1\r\n end",
"def [](index)\n node = find_node(index)\n if node != nil then return node.value else return nil end\n end",
"def search(aValue)\r\n temp = @first\r\n position = -1\r\n currentPos = 0\r\n while !temp.nil?\r\n if temp.value == aValue\r\n position = currentPos\r\n end\r\n currentPos = currentPos + 1\r\n temp = temp.next\r\n end\r\n return position\r\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def get(v)\n t = @root\n while t\n case\n when v < t.value1 then t = t.left\n when v == t.value1 then return t.value1\n when t.type == 2 then t = t.mid\n when v < t.value2 then t = t.mid\n when v == t.value2 then return t.value2\n else t = t.right\n end\n end\n nil\n end",
"def value(context, xpath)\n values(context, xpath).first\n end",
"def nodeValue\n @value\n end",
"def search(value)\n return false if is_empty\n\n current = @root\n\n while current != nil\n if current.value == value\n return true\n else\n current = current.value < value ? current.right : current.left\n end\n end\n\n return false\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def first\n # return value if head node is set\n if !@head.nil?\n @head.value\n else\n # otherwise raise an exception\n raise \"List is empty\"\n end\n end",
"def search(value)\r\n current = @head\r\n \r\n until current.nil? \r\n return true if current.data == value\r\n current = current.next\r\n end\r\n \r\n return false\r\n \r\n end",
"def depth_first(value)\n\tend",
"def [](value)\n node_data[value.to_s]\n end",
"def index(value)\n find_index(value, 0, @head, :next, 1)\n end",
"def search(aValue)\r\n temp = @first\r\n indexValue = 0\r\n while !temp.nil?\r\n if temp.value == aValue\r\n return indexValue\r\n end\r\n indexValue += 1\r\n temp = temp.next\r\n end\r\n return -1\r\n end",
"def find(key)\r\n \t\t\t# Start at beginning of the List\r\n \t\t\tcurrent = @head\r\n \t\t\t# Go through list until nil\r\n\t\t\twhile current\r\n\t\t\t\t# If matching key is found return value at node\r\n\t\t\t\tif current.key == key\r\n\t\t\t\t\treturn current.value\r\n\t\t\t\tend\r\n\t\t\t\t# Go to next node\r\n\t\t\t\tcurrent = current.next\r\n\t\t\tend\r\n \t\tend",
"def value\n @children[0]\n end",
"def find(needle) # returns the node with value=value or nil if not found\n next_node = @head\n while next_node && next_node.needle != needle\n next_node = next_node.next\n end\n next_node\n end",
"def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end",
"def value_exists?(value)\n\t\tcurrent_node = @head\n\t\tuntil current_node.value == value \n\t\t\treturn false if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\ttrue \n\tend",
"def find(key)\n if @root.nil?\n return nil\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key == key\n return current_node.value\n elsif current_node.key < key\n current_node = current_node.right\n elsif current_node.key > key\n current_node = current_node.left\n end\n end\n print \"No value found\"\n end",
"def find_node(index)\n\n\t\t#start at the head\n\t\tcounter = 0\n\t\tcurrent_node = @head\n\n\t\t# crawl to index position\n\t\t# outputs each node value for visibility\n\t\twhile counter < index\n\t\t\tcurrent_node = current_node.next\n\t\t\tcounter += 1\n\t\tend\n\n\t\tputs \"Found node at index #{index} with value: #{current_node.data}\"\n\t\tcurrent_node\n\tend",
"def find_all(value)\n nodes = []\n self.each {|node| nodes << node if node.value == value}\n nodes\n end",
"def find(key)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current] \n return current_and_parent_pair[:current].value\n else\n return nil\n end\n end",
"def search(aValue)\n temp = @first\n indexValue = 0\n while !temp.nil?\n if temp.value == aValue\n return indexValue\n end\n indexValue += 1\n temp = temp.next\n end\n return -1\n end",
"def search(value)\n return @searchMethods.searchAtTree(value, @root)\n end",
"def [](index)\n ret = get_node_at_index(index)\n return ret.value if ret != nil\n return ret\n end",
"def select_node(data,key,value)\n data.each_key do |k|\n if data[k].has_key?(key)\n if data[k][key] == value\n return k\n end\n end\n end\nend",
"def delete_value value\r\n #find the pointer to the wanted node using LIST-SEARCH(value)\r\n #then delete that node with LIST-DELETE-BY-NODE(node)\r\n delete_node(self.search(value))\r\n end",
"def searchForValueStartingAt(xml, toStartAt, nodeName, index)\n count = 0\n size = xml.children.size #((Integer)rolle.get(\"childCount\")).intValue();\n for j in 0..size do\n value = xml.children[j]\n if value.name == toStartAt\n return searchForValueAtPos(values,nodeName,index)\n else\n countVals = value.children.size\n for k in 0..countVals do\n #String value = searchForValueStartingAt((Hashtable)values.get(new Integer(k)),nodeName,toStartAt,index);\n valSt = searchForValueStartingAt(value.children[k], toStartAt, nodeName, index)\n if valSt == \"\"\n return valSt\n end\n end\n end\n end\n return \"\"\n end",
"def getFather(value, node, toRemove) \n current = node ##asignamos variable para recorrido\n \n while(current != nil) do ##Recorremos hasta encontrar o no encontrarlo\n if toRemove.getData() > current.getData() #Decidimos direccion\n if current.getRight() == toRemove\n return current\n else\n current = current.getRight() #dezplazamiento a derecha\n end\n else \n if current.getLeft() == toRemove\n return current\n else \n current = current.getLeft()\n end\n end \n end \n \n return nil\n end",
"def recursive_index_of(value, current_node = @first_node, current_index = 0) \n if current_node.data == value\n return current_index\n else\n recursive_index_of(value, current_node.next_node, current_index + 1) if current_node.next_node\n end\n end",
"def find(needle)\n #return the Node object whose value == needle\n node = @head\n while node\n return node if node.value == needle\n node = node.next\n end\n #Return nil if cannot find it\n nil\n end",
"def contains?(value)\n node = @head\n until node.nil?\n return true if node.value == value \n node = node.link\n end\n false\n end",
"def find(value)\n return nil if @head.nil?\n i = 0\n node = @head\n limit = size - 1\n limit.times do\n break if node.data == value\n i += 1\n node = node.next_node\n end \nif node.data == value\n \"#{value} is located in index number #{i}.\"\n i\nelse \n puts \"the given value is not on the list.\"\nend\nend",
"def search(current_node = @root ,value)\n \tif current_node\n\t \tif current_node.value == value\n\t \t\treturn 1\n\t \telsif current_node.value > value\n\t \t\tsearch(current_node.left, value)\n\t \telsif current_node.value < value\n\t \t\tsearch(current_node.right, value)\n\t \tend\n \telse\n \t\treturn 0\n \tend\n end",
"def find(value, column=nil)\n column = header.first unless column\n \n rows.each do |row|\n return row if row.value_at(column) == value\n end\n \n return nil\n end",
"def find(value)\n key = \\\n if value.to_s =~ /^[0-9\\.]*$/\n default_search_param + \"id\"\n else\n default_search_param\n end\n\n where(key => value).first\n end",
"def search_bfs(value)\n return false unless @root_node\n queue = Array.new\n queue.push(@root_node)\n\n while !queue.empty?\n node = queue.shift\n if node.value == value\n return value\n else\n queue.push(node.left) unless node.left.nil?\n queue.push(node.right) unless node.right.nil?\n end\n end\n return nil\n end",
"def breadth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue << current_node.left_child if not current_node.left_child.nil?\r\n queue << current_node.right_child if not current_node.right_child.nil?\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end",
"def find(val)\n self.each {|n| return n if n.data == val }\n end",
"def find_first(value,start,stop)\n return start if time_at(start) > value\n find(:first,value,start,stop)\n end",
"def node(node_name)\n nodes(node_name).first\nend"
] | [
"0.80587685",
"0.80214393",
"0.7959897",
"0.7671774",
"0.764562",
"0.764562",
"0.74783874",
"0.74122894",
"0.7408482",
"0.73552215",
"0.73340523",
"0.7307569",
"0.7260175",
"0.7225086",
"0.7193016",
"0.7160144",
"0.713884",
"0.7131601",
"0.7126046",
"0.71244234",
"0.7061111",
"0.7042303",
"0.70332366",
"0.7014883",
"0.69692904",
"0.6954615",
"0.69402015",
"0.6938328",
"0.6891725",
"0.68704385",
"0.68566275",
"0.68373495",
"0.6831989",
"0.6813413",
"0.681091",
"0.68098116",
"0.6803",
"0.6791595",
"0.6791543",
"0.6774959",
"0.67637885",
"0.67217195",
"0.66568184",
"0.665331",
"0.66181815",
"0.66125584",
"0.66113853",
"0.66078186",
"0.66078186",
"0.6605835",
"0.6602272",
"0.6588261",
"0.65877366",
"0.6571537",
"0.65224123",
"0.6497166",
"0.6495563",
"0.6476492",
"0.64360946",
"0.6418638",
"0.64043343",
"0.63619727",
"0.6357953",
"0.6357064",
"0.63367605",
"0.63367605",
"0.633332",
"0.6324533",
"0.62887657",
"0.62869465",
"0.6283197",
"0.6278546",
"0.6272563",
"0.62680995",
"0.62655896",
"0.625575",
"0.62424254",
"0.62410736",
"0.62335044",
"0.6231915",
"0.6229422",
"0.6221485",
"0.62073815",
"0.6190574",
"0.61759734",
"0.6168574",
"0.6166676",
"0.6164506",
"0.6156219",
"0.61557186",
"0.61466986",
"0.6146153",
"0.6140956",
"0.6140753",
"0.61306036",
"0.61283815",
"0.61209726",
"0.6120604",
"0.61188364",
"0.61127913"
] | 0.81960785 | 0 |
find_all(value) finds and return (in an array) all the nodes whose value is 'value' | def find_all(value)
nodes = []
self.each {|node| nodes << node if node.value == value}
nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elements_by_xpath(value)\n find_by_xpath(value)\n end",
"def find_all_nodes(xpath, select_result_value=false)\n if self.feed_data_type != :xml\n raise \"The feed data type is not xml.\"\n end\n return FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [xpath],\n :select_result_value => select_result_value)\n end",
"def find(value)\n self.each {|node| return node if node.value == value}\n end",
"def xpathall(path,xml)\n r=[]\n XPath.each(xml,path){|x|r<<x}\n r\nend\n",
"def get_all_xpath(values)\n\t\tif values.nil? then\n\t\t\treturn []\n\t\tend\n\t\treturn xpath('//' + values.join(XPATH_JOIN))\n\tend",
"def search_children(node, attribute, search_term)\n matches = []\n end",
"def get_elements(xpath); end",
"def get_all_vals(node, arr)\n # add the value of the node to the array\n arr << node.val\n \n # using a ternary operator, check if there is another node in the list\n # if so, recursively run the function again\n # if not, return the array\n return node.next ? get_all_vals(node.next, arr) : arr\n end",
"def find_all(conditions)\n @root.find_all(conditions)\n end",
"def fakesearch_all_nodes(options = {})\n fakesearch_nodes(nil, options)\nend",
"def find_all(*args)\n element.all(*args)\n end",
"def find_all(&block)\n return to_enum :find_all unless block\n\n ary = []\n self.each{|*val|\n ary.push(val.__svalue) if block.call(*val)\n }\n ary\n end",
"def find_all_nodes(*args)\n nodes = @nodes.find_all_nodes(*args)\n nodes.find_all { |n| context?(n) }\n end",
"def find_all_paths\n found_paths = []\n \n explore(found_paths, nil, @start_node)\n \n found_paths\n end",
"def search(xpath)\n return self.each_element( xpath ){}\n end",
"def value_of_nodes(node_name)\n ns = nodes(node_name)\n ns.map do |n|\n raise \"failed to find #{node_name.inspect} in #{subject.inspect}\" if n.nil?\n n.content\n end\nend",
"def search(value)\n return @searchMethods.searchAtTree(value, @root)\n end",
"def xpath_all(pdoc, path, namespace = '')\n begin\n if namespace != \"\"\n return pdoc.find(path, namespace) if pdoc.find(path, namespace)\n else\n return pdoc.find(path) if pdoc.find(path)\n end\n rescue\n return []\n end\n end",
"def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end",
"def find_all_nodes(*args)\n raise NotImplementedError\n nodes = @database.all_nodes\n # TODO: design node finder syntax\n nodes\n end",
"def xpath_all(pdoc, path, namespace = '')\n if namespace!=\"\"\n return REXML::XPath.match(pdoc, path, namespace)\n else\n return REXML::XPath.match(pdoc, path);\n end\n return []\n end",
"def parse_value(nodes); end",
"def lookup_unbounded( value )\n elements = []\n if value.has_key?( \"children\" )\n value[\"children\"].each do |key, value|\n elements << key if value[\"unbounded\"]\n if value.has_key?( \"children\" )\n elements << lookup_unbounded( value )\n end\n end\n end\n elements\n end",
"def retrieve_elements(filter)\n elements_array = Array.new\n\n if NOKOGIRI\n @xml.xpath(filter.to_s).each { |pelem|\n elements_array << pelem.text if pelem.text\n }\n else\n @xml.elements.each(filter.to_s) { |pelem|\n elements_array << pelem.text if pelem.text\n }\n end\n\n if elements_array.size == 0\n return nil\n else\n return elements_array\n end\n\n end",
"def find_nodes\n puts '1st pass: find nodes'\n find :nodes\n self\n end",
"def search_recursive(root,target_value)\n\n return root if root.payload == target_value\n\n root.children.each do |child|\n node = search_recursive(child,target_value)\n return node if node\n end\n\n return nil\n\nend",
"def search(xpath)\n results = self.find(xpath).to_a\n if block_given?\n results.each do |result|\n yield result\n end\n end\n return results\n end",
"def search(xpath)\n results = self.find(xpath).to_a\n if block_given?\n results.each do |result|\n yield result\n end\n end\n return results\n end",
"def extract_all_nodes(xpath, node = xml, namespaces = DEFAULT_NAMESPACES)\n _extract_nodes(:match, xpath, node, namespaces)\n end",
"def values(context, xpath)\n enum = context.find(xpath) if context\n (enum || []).map { |node| node.value }\n end",
"def each\n return [] if root.nil?\n root.traverse do |node|\n yield node.value\n end\n end",
"def find(value,node=head)\n return 0 unless self.contains?(value)\n head\n loops = 0\n until @current_node.next == nil do\n if @current_node.data == value\n return loops\n end\n self.next_node\n loops += 1\n end\n return loops\n end",
"def finds(value)\n eles_by_json_visible_contains '*', value\n end",
"def search(value)\n\t\t\treturn nil if self.empty?\n\t\t\telement = self.head\n\t\t\twhile element.value != value\n\t\t\t\tif element.next.nil?\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\telement = element.next\n\t\t\t\tend\n\t\t\tend\n\t\t\telement\n\t\tend",
"def find_all_in_scope(node, predicate); end",
"def get_results(with_root = false)\n ret = []\n\n # Iterate over all occupied descendants and create chain data\n @occupied_descendants.each do |node|\n ret << [node.data, node.get_chain(with_root)]\n end\n\n # Return\n ret\n end",
"def all(pattern=nil)\n pattern.nil? ? values : find(pattern)\n end",
"def find(value)\n find_root @indices.fetch(value)\n end",
"def xpath_each(from_root_node, path)\n REXML::XPath.each(from_root_node, path, &Proc.new)\n end",
"def find(value)\n current_node = head\n while current_node != nil\n return current_node if current_node.value == value\n current_node = current_node.next\n end\n nil\n end",
"def bfs(target_value)\n child_arr = [self]\n # children.each {|child| children_arr << child }\n while child_arr.length > 0\n node_to_check = child_arr.shift\n return node_to_check if node_to_check.value == target_value\n node_to_check.children.each { |child| child_arr << child }\n end\n nil\n end",
"def getTags node\n array = [] #array to hold working collection\n \n node.children.each do |child|\n array << Hash[child.name,child.inner_text] unless child.name == 'text' #text \n end\n \n return array\n end",
"def find(value)\n node = @head \n for i in 0..@size-1 \n return i if node.value == value\n node = node.link \n end\n return nil\n end",
"def value\n children = if self.namespace\n xpath('ns:value', ns: self.namespace.href)\n else\n xpath(:value)\n end\n return children.first&.content if children.length < 2\n children.map(&:content)\n end",
"def find_all\n end",
"def search(xpath)\n results = self.find(xpath).to_a\n if block_given?\n results.each do |result|\n yield result\n end\n end\n return results\n end",
"def get_children(element)\n results = []\n return children if element.nil? or element.empty?\n\n matching_spec_elements = @@spec.to_a.select { |v| v[0].upcase.index(element.upcase) == 0 }\n element_keys = matching_spec_elements.map { |s| s[0] }\n #puts \"Expect to find: #{element_keys}\"\n\n begin\n xpath = \"//#{element}\"\n nodes = xml_doc.xpath(xpath)\n #puts \"cluster count: #{nodes.count}\" if element == 'E04'\n\n nodes.each do |node|\n children = {}\n p = Nemsis::Parser.new(node.to_s)\n element_keys.each do |key|\n value = p.parse_element(key)\n value ||= ''\n #puts \"\\t#{key}: '#{value}'\"\n children[key] = value\n end\n results << children\n end\n rescue => err\n puts \"Error in get_children(): xpath [#{xpath}]: #{err}\"\n end\n\n results\n end",
"def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == value\n current = current.next_node\n end\n end",
"def each_node(safe_path, xpath, &block)\n return enum_for(:each_node, safe_path, xpath) unless block\n\n require 'nokogiri'\n\n with_encoding_check(safe_path) do |stream, encoding|\n stream_xml_nodes(stream, xpath, encoding, &block)\n end\n end",
"def match_all(data, &block)\n return nil if @root == nil\n i=0\n while (i<data.length)\n node = @root.find_forward(data, i, data.length-i)\n if (node!=nil && node.value!=nil)\n yield Item.new(i, true, node)\n i += node.length\n else\n i += 1\n end\n end\n end",
"def find_all(selector)\n DOM::NodeList.new `Array.prototype.slice.call(#{@el}.querySelectorAll(#{selector}))`\n end",
"def find(value)\n end",
"def get_content_array(xpath_query)\n scraped_array = Array.new\n pos = 0\n @current_page.search(xpath_query).each do |var|\n scraped_array[pos] = var.content.strip\n pos += 1\n end\n scraped_array\n end",
"def find(*queryKeyValueList)\n results = []\n queryKeyValueList = queryKeyValueList.map { |kv|\n kv = [kv] if not kv.is_a?(Array)\n kv.map { |a| a.to_s }\n }\n # Of node's children, return the matches\n helper = lambda { |node,i|\n results << node if i == queryKeyValueList.size\n # For each children node of node\n queryKey, queryValue = queryKeyValueList[i]\n node[2..-1].each { |childNode|\n # Skip children that don't match\n next if not (queryKey == nil || queryKey == childNode[0])\n next if not (queryValue == nil || queryValue == childNode[1])\n helper.call(childNode, i+1)\n }\n }\n helper.call(@root, 0)\n results\n end",
"def search(xpath)\n xpath = \".#{xpath}\" if !self.is_a?(REXML::Document) and xpath =~ /^\\//\n ret = REXML::XPath.match(self,xpath).map{|elm|\n elm.extend(ElementHelper)\n elm\n block_given? ? (yield elm) : elm\n }\n end",
"def retrieve_all_tags(element, tag = :content)\n result = []\n if(element.respond_to? tag)\n result << element.send(tag)\n end\n if element.respond_to? :children\n element.children.each do |child|\n result += retrieve_all_tags(child, tag)\n end \n end \n return result \nend",
"def find(val)\n self.each {|n| return n if n.data == val }\n end",
"def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end",
"def searchForValue(xml, nodeName)\n #puts \"\\n--------------\\nXMLDocumentHash.searchForValue 979: #{nodeName} \\n#{xml}\\n---------------------------\"\n if(xml == nil)\n return \"\"\n end\n if xml[\"nodeName\"] == nodeName\n hmTemp = xml[0]\n if hmTemp != nil\n\n if hmTemp == nil || hmTemp[\"nodeValue\"] == nil\n return \"\"\n end\n return hmTemp[\"nodeValue\"]\n else\n if xml == nil || xml[\"nodeValue\"] == nil\n return \"\"\n end\n\n return xml[\"nodeValue\"]\n end\n end\n\n attribs = xml[\"nodeAttributes\"]\n #puts \"nodeAttributes : #{attribs}\"\n size = xml[\"childCount\"]\n #puts \"childCount : #{size}\"\n for j in 0..(size-1)\n\n value = xml[j]\n #puts \"\\n--at #{j}-------------Value XMLDocumentHash 1007----\\n#{value}\\n--------------------\"\n if (value != nil && value[\"nodeName\"] == nodeName)\n\n if value == nil || value == nil || value[\"nodeValue\"] == nil\n return \"\"\n end\n return value[\"nodeValue\"]\n else\n\n count = value[\"childCount\"]\n for k in 0..count\n valSt = searchForValue(value[k], nodeName)\n if valSt != @NOT_FOUND && valSt != \"\"\n return value\n end\n end\n end\n end\n return @NOT_FOUND\n end",
"def all_nodes\n nodes = []\n visit_nodes do |node|\n nodes.push node\n end\n nodes\n end",
"def queryfunction(function)\n binaries = []\n Find.find(\"../\") { |p|\n # Skip .git\n if FileTest.directory?(p) && File.basename(p) == \".git\"\n Find.prune\n else\n if File.basename(p) == \"tfile.xml\"\n tmp = queryxml(p, function)\n binaries.concat(tmp)\n end\n end\n }\n\n return binaries\nend",
"def find_by_value(value)\n return nil if value.nil? || self.size == 0\n stop_node = self.head\n target = stop_node\n while target && !target.match_by_value(value)\n target = target.next\n break if stop_node.equal?(target)\n end\n target = nil unless target && target.match_by_value(value)\n target\n end",
"def get_all_urls\r\n val_d_oise = \"http://annuaire-des-mairies.com/val-d-oise.html\"\r\n page = Nokogiri::HTML(URI.open(val_d_oise))\r\n links = page.xpath('//*[@class=\"lientxt\"]').map{|anchor| anchor[\"href\"]}\r\n return links\r\nend",
"def find(value)\n idx = 0\n node = list\n while node != nil\n return idx if node.value == value\n idx += 1\n node = node.nextNode\n end\n return nil\n end",
"def all\n Directory.all.map do |node_id|\n find node_id\n end\n end",
"def all_xpaths(parsed_doc)\n xpaths = parsed_doc.xpath('//*').map do |node|\n node.path.gsub(/\\[\\d*\\]/, \"[]\")\n end.uniq\nend",
"def find(source)\n a = []\n self.each(){ |element| \n if element.source == source then\n\t #puts \"MATCH: [#{element.source}]\"\n\t a << element\n end\n }\n return a\nend",
"def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end",
"def read_nodes(elem)\n return [] if elem == nil\n nodes = []\n elem.elements.each('node') do |node_elem|\n nodes << read_node(node_elem)\n end\n nodes\nend",
"def each_node\n return to_enum(__method__) unless block_given?\n\n doc.xpath(query).each do |node|\n yield node\n end\n end",
"def get_result_list\n result_list = []\n @wait.until { wait_for_element(\"result_list\").length > 10 }\n find_elements(\"result_list\").each do |result|\n result_list.push(result.text)\n end\n result_list\n end",
"def get_results()\n restriction_nodes = []\n result_nodes = []\n if !(@inputs.nil? || @inputs.empty? || @inputs.first.empty?)\n input_set = @inputs.first\n restriction_nodes= input_set.nodes\n result_nodes = input_set.breadth_first_search(true){|node| node.item.text.downcase.include?(@keyword_phrase.to_s.downcase)} \n end\n \n if !@inplace\n results = @server.match_all(parse_keyword_phrase(), restriction_nodes) \n result_nodes = results.map{|item| Xplain::Node.new(item: item)}\n end\n \n result_nodes\n \n end",
"def search keyword\n result = Set.new\n matched = Array.new\n @frame_tree_root_node.each{|node|\n if node.content =~ /#{keyword}/i\n matched << node.name\n end\n } \n @frame_tree_root_node.each{|node|\n if node.is_root?\n result << node.name\n elsif matched.include? node.name\n result << node.name #add id\n node.parentage.each{|item|\n result << item.name\n }\n end\n }\n @frame_tree_root_node.print_tree\n result\n end",
"def nodes(attrs={})\n if attrs.is_a?(Hash) and attrs.has_key?(:type)\n attrs[:type].constantize.find(session, \"label_node_ids LIKE '%#{id}%'\")\n else\n Ecore::Node.find(session, \"label_node_ids LIKE '%#{id}%'\")\n #.inject(NodeArray.new) do |arr,n|\n # n.session = session\n # arr << n\n #end\n end\n end",
"def find(query)\n path = if xml.namespaces.empty?\n \"//#{query}\"\n else\n \"//xmlns:#{query}\"\n end\n\n xml.xpath(path).map do |node|\n hsh = XMLUtils.to_hash node\n block_given? ? yield(hsh) : hsh\n end\n end",
"def searchForValueStartingAt(xml, toStartAt, nodeName, index)\n count = 0\n size = xml.children.size #((Integer)rolle.get(\"childCount\")).intValue();\n for j in 0..size do\n value = xml.children[j]\n if value.name == toStartAt\n return searchForValueAtPos(values,nodeName,index)\n else\n countVals = value.children.size\n for k in 0..countVals do\n #String value = searchForValueStartingAt((Hashtable)values.get(new Integer(k)),nodeName,toStartAt,index);\n valSt = searchForValueStartingAt(value.children[k], toStartAt, nodeName, index)\n if valSt == \"\"\n return valSt\n end\n end\n end\n end\n return \"\"\n end",
"def findAll(selector)\n DOM::NodeList.new `Array.prototype.slice.call(#{@el}.querySelectorAll(#{selector}))`\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def get_array(element, path='.')\n return unless element\n \n result = element/path\n if (result.is_a? Nokogiri::XML::NodeSet) || (result.is_a? Array)\n result.collect { |item| self.get(item) }\n else\n [self.get(result)]\n end\n end",
"def on_test(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n nodes << xml_node if node_matches?(xml_node, ast_node)\n end\n\n return nodes\n end",
"def find(value)\n return nil if @head.nil?\n found = nil\n index = 0\n current_node = @head\n while !node.nil? do\n if node.data == value\n found = true\n break\n end\n index += 1\n current_node = node.next\n end\n found == true ? \"#{value} found at index #{index}!\" : nil\n end",
"def dfs(value)\r\n return self if self.value == value\r\n return nil if self.children == []\r\n check = nil\r\n self.children.each do |child|\r\n check = child.dfs(value)\r\n return check if check != nil\r\n end\r\n return check\r\n end",
"def nodes\n nodes_by_id.values\n end",
"def elements\n if @frame.nil?\n $driver.switch_to.default_content\n else\n $driver.switch_to.frame(@frame.element)\n end\n for locator in @locators\n by, value = locator.first\n if not @root == nil and @root.instance_variable_defined?(\"@locators\") and not @root.locators.nil?\n if $highlight\n @root.highlight(-1,\"green\")\n end\n @elements = @root.find_elements(by,value,self.name)\n else\n @elements = $driver.find_elements(by,value,self.name)\n end\n if @elements.count > 0\n @elements = filter_elements(@elements)\n end\n if @elements.count > 0\n @element = @elements.first\n return @elements\n end\n end\n @element = @elements.first\n @elements\n end",
"def contents(context, xpath)\n enum = context.find(xpath) if context\n (enum || []).map { |node| node.content }\n end",
"def all_nodes\n [self] + descendants\n end",
"def find(value)\n current_node = @head\n counter = 0\n until current_node.nil?\n return counter if current_node.value == value\n\n current_node = current_node.next_node\n counter += 1\n end\n nil \n end",
"def queryxml(xmlfile, function)\n f = File.new(xmlfile, \"r\")\n doc = Nokogiri::XML(f)\n\n binaries = []\n doc.xpath(\"//test/calls/function[text()='#{function}']\").each { |e|\n test = e.parent.parent\n binary = test.xpath('binary').first\n binaries << [File.dirname(xmlfile), binary.text]\n }\n\n f.close\n\n return binaries\nend",
"def on_path(ast_node, context)\n nodes = XML::NodeSet.new\n\n ast_node.children.each do |test|\n nodes = process(test, context)\n\n if nodes.empty?\n break\n else\n context = nodes\n end\n end\n\n return nodes\n end",
"def match(prefix)\n result = []\n current = @root\n current_prefix = prefix\n\n while current != nil && current_prefix != \"\"\n previous, previous_prefix = current, current_prefix\n current, current_prefix = next_node(current, current_prefix)\n end\n\n unless current\n if current_prefix\n return []\n else\n next_nodes = previous[:nodes].select { |prefix, node| prefix.start_with?(previous_prefix) }.values\n end\n else\n next_nodes = [current]\n end\n\n until next_nodes.empty?\n current = next_nodes.pop\n result << current[:value]\n current[:nodes].each { |prefix, node| next_nodes.push(node) }\n end\n\n return result.compact\n end",
"def children\n self.node.children.collect(&:content)\n end",
"def find_nodes(term, opts = {})\n data, _status_code, _headers = find_nodes_with_http_info(term, opts)\n return data\n end",
"def elements(selector)\n @doc.search(selector)\n end",
"def find_eles_by_attr_include(class_name, attr, value)\n @driver.find_elements :xpath, string_attr_include(class_name, attr, value)\n end",
"def elements\n find_by_tag('*')\n end",
"def all( path, hash )\n scrape(path, hash, :/) do |storage, selector, elements|\n @result[storage] ||= Array.new\n elements.each { |element| @result[storage] << select(element, selector) }\n end\n end",
"def find_all\n \n end",
"def each_node(&block)\n nodes.each_value(&block)\n end",
"def find_cool(collections)\n collections.find_all {|element| element if element.has_value?(\"cool\")}\nend"
] | [
"0.73790395",
"0.6820984",
"0.67537713",
"0.62753576",
"0.62564236",
"0.6141319",
"0.61087537",
"0.6062094",
"0.6044982",
"0.60254693",
"0.59540236",
"0.58442485",
"0.5819881",
"0.5805825",
"0.5749595",
"0.5743802",
"0.57175523",
"0.57110125",
"0.5671111",
"0.56692845",
"0.56496537",
"0.5601967",
"0.55519944",
"0.554809",
"0.55334055",
"0.552994",
"0.55176294",
"0.55176294",
"0.5505288",
"0.5498693",
"0.54939705",
"0.5470186",
"0.54460627",
"0.54373163",
"0.5437283",
"0.54260075",
"0.54164016",
"0.541146",
"0.539033",
"0.53825057",
"0.5374702",
"0.53671527",
"0.5366838",
"0.5351871",
"0.5338551",
"0.53352",
"0.5325014",
"0.5314184",
"0.53022563",
"0.52931803",
"0.5291687",
"0.52866966",
"0.5277423",
"0.52725315",
"0.5228418",
"0.5201873",
"0.51978815",
"0.519424",
"0.5177736",
"0.51776123",
"0.5176041",
"0.51621765",
"0.5155578",
"0.5147204",
"0.5144367",
"0.5132258",
"0.51312757",
"0.5118092",
"0.51135224",
"0.51032937",
"0.5094843",
"0.5093672",
"0.5093373",
"0.5085537",
"0.50840795",
"0.5078718",
"0.50672936",
"0.5060445",
"0.5060445",
"0.5054793",
"0.5024736",
"0.50156",
"0.50155044",
"0.5013778",
"0.5011485",
"0.5002155",
"0.4998209",
"0.4995273",
"0.49931052",
"0.49885243",
"0.49881467",
"0.498656",
"0.49864835",
"0.49793923",
"0.49762946",
"0.49711326",
"0.49698988",
"0.49692184",
"0.49659342",
"0.49637625"
] | 0.859019 | 0 |
push(value) adds a value 'value' to the end of the linked list | def push(value)
last.next_node = Node.new(value, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(value)\n @head = LinkedListNode.new(value, @head)\n end",
"def push(value)\n\t\t\t\tif @length == 0\n\t\t\t\t\t@head = @tail = newNode(nil, value, nil)\n\t\t\t\telse\n\t\t\t\t\t@tail.next = newNode(@tail, value, nil)\n\t\t\t\t\t@tail = @tail.next\n\n\t\t\t\t\tif @length == 1\n\t\t\t\t\t\t@head.next = @tail\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t@length += 1\n\t\t\tend",
"def push(value)\n\t\tlast_node = find_last\n\t\tlast_node.next_node = Node.new(value)\n\tend",
"def push(value)\r\n @data = LinkedListNode.new(value, @data)\r\n end",
"def push(value)\r\n @data = LinkedListNode.new(value, @data)\r\n end",
"def push(value)\n # IMPLEMENT ME!\n if @data == nil\n @data = LinkedListNode.new(value)\n else\n @data = LinkedListNode.new(value, @data)\n end\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data)\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data)\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data)\n end",
"def push(value)\r\n @data = LinkedListNode.new(value, @data)\r\n \r\n end",
"def push(value)\r\n if @data == nil\r\n @data = LinkedListNode.new(value)\r\n else\r\n @data = LinkedListNode.new(value, @data)\r\n end\r\n end",
"def push(value)\n newNode = Node.new(value)\n if @head.nil?\n @head = newNode\n @tail = @head\n else \n old_tail = @tail\n @tail = newNode\n @tail.previous = old_tail\n end\n @length += 1\n nil\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data)\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data)\n end",
"def push(value)\n node = Node.new(value)\n if @length == 0\n @head = node\n @tail = node\n else\n @tail.next = node\n @tail = node\n end\n @length += 1\n end",
"def push(value)\r\n if @data != nil\r\n node = LinkedListNode.new(value, @data)\r\n else\r\n node = LinkedListNode.new(value)\r\n end\r\n @data = node\r\n end",
"def push(value)\r\n \t@data = LinkedListNode.new(value, @data)\r\n end",
"def push(value)\n new_head = Node.new value, @head\n @head = new_head\n end",
"def push(value)\r\n @head = Node.new(value, @head)\r\n end",
"def push(value)\n @head = Node.new(value, @head)\n end",
"def push(value)\n if @tail != nil\n @tail.next_node = Node.new(value)\n @tail.next_node.previous = @tail\n @tail = @tail.next_node\n else\n @tail = Node.new(value)\n if @head == nil\n @head = @tail\n end\n end\n @length += 1\n nil\n end",
"def push(value)\n if @tail != nil\n @tail.next_node = Node.new(value)\n @tail.next_node.previous = @tail\n @tail = @tail.next_node\n else\n @tail = Node.new(value)\n if @head == nil\n @head = @tail\n end\n end\n @length += 1\n nil\n end",
"def push(value)\r\n @data = LinkedListNode.new(value, self.data)\r\n end",
"def push(value)\n new_node = LinkedListNode.new(value, @data)\n @data = new_node\n end",
"def push(value)\n new_head = Node.new(value, @head)\n @head = new_head\n if tail.nil?\n @tail = @head\n end\n end",
"def push(value)\n @data = LinkedListNode.new(value, @data) \n end",
"def push(value)\n @data = LinkedListNode.new(value, data)\n end",
"def push(value)\r\n\t\tif @data.nil? \r\n\t\t\t@data = LinkedListNode.new(value) \r\n\t\telse\r\n\t\t\t@data = LinkedListNode.new(value, @data)\r\n\t\tend\r\n\tend",
"def push(value)\n new_node = Node.new(value)\n if length > 0\n new_node.prev_value = @tail\n @tail.next_value = new_node\n @tail = new_node\n if length == 1\n @head.next_value = new_node\n new_node.prev_value = head\n end\n else\n @head = new_node\n @tail = new_node\n end\n @length += 1\n return new_node.value\n end",
"def push(value)\n @data = LinkedListNode.new value, @data\n end",
"def push(value)\r\n # IMPLEMENT ME!\r\n # data = NIL\r\n # push(10) => data = LinkedListNode.new(10, data)\r\n # push(5) => data = LinkedListNode.new(5, data)\r\n # push(1) => data = LinkedListNode.new(1, data)\r\n\r\n @data = LinkedListNode.new(value, @data)\r\n\r\n end",
"def push(value)\n if @data == nil\n node1 = LinkedListNode.new(value)\n @data = node1\n else\n node1 = LinkedListNode.new(value, @data)\n @data = node1\n end\n\n end",
"def push(value)\n # IMPLEMENT ME!\n @top = LinkedListNode.new(value, @top)\n end",
"def push(new_value)\n @data = LinkedListNode.new(new_value, @data)\n end",
"def push(value)\n @data = LLNode.new(value, @data)\n end",
"def append(value)\n # if the list is empty, you need to update head and tail. \n # you can do via push, because in the case append == push\n if isEmpty?\n push(value)\n return\n end\n\n # if the list is not empty, you need to create a new Node\n # after the tail\n @tail.next_node = Node.new(value)\n # since it's a tail-end insertion, the new node is also\n # the tail of the list\n @tail = @tail.next_node\n end",
"def push(value)\r\n @top_node = LinkedListNode.new(value, @top_node)\r\n end",
"def push(value) #adding element at the end of LL\n new_node = Node.new(value) #create new node\n return @head = new_node if @head == nil #if head is nil(list is empty) new node becomes head\n #if list is not empty, we must traverse to last element in the list \n temp_node = @head #starting from the head\n until temp_node.link == nil #last element in the list is element whit link pointing to nil\n temp_node = temp_node.link #traversing through list using link variable\n end\n temp_node.link = new_node #to append node we assign new node ad last nodes link variable\n end",
"def push(value); end",
"def push(value)\r\n stacked = LinkedListNode.new(value, data)\r\n @data = stacked\r\n end",
"def add value\n if @head.nil?\n @length = 1\n @head = GenericList::Node.new(value)\n else\n lst = @head\n ptr = @head.nxt\n while ptr && @proc.call(value, lst.value) <= 0\n lst = ptr\n ptr = ptr.nxt\n end\n @length += 1\n lst.insert value\n end\n end",
"def push(value)\n return seed(value) unless self.tail\n node = Node.new(value)\n node.previous = self.tail\n self.tail.next = node\n self.tail = node\n end",
"def push(value)\n\t\tnode = Node.new(value)\n\t\tif @length==0\n\t\t\t@last = node\n\t\t\t@first = node\n\t\telse\n\t\t\t@last.front = node\n\t\t\tnode.back = @last\n\t\t\t@last = node\n\t\tend\n\t\t@length+=1\n\tend",
"def append( value )\n\n # Find the last node in this list\n # i.e. keep looking at the next node\n # until the next node is 'nil'\n node = @head\n while node.next\n node = node.next\n # ^ kind of like incrementing the loop counter\n end\n\n node.next = Node.new value\n end",
"def push(value)\n insert(value)\n self\n end",
"def append(value)\n new_node = create_node(value) \n if head.nil?\n self.head = new_node\n else\n last_node = tail\n last_node.next_node = new_node\n end\n self.size += 1\n end",
"def append( value )\n last.next = Node.new value\n end",
"def push(value)\n return \"Stack is full\" if is_full\n\n new_node = Node.new(value)\n\n if is_empty\n @head = new_node\n else\n new_node.next = @head\n @head = new_node\n end\n\n @current_size += 1\n end",
"def push(value)\n # IMPLEMENT ME!\n @data = Node.new(value, @data)\n end",
"def append(value)\n\t\tself.tail.next_node = Node.new(value, nil)\n\tend",
"def push(val)\n new_node = Node.new(val)\n if size.zero?\n self.first = new_node\n self.last = new_node\n else\n temp = first\n self.first = new_node\n first.next = temp\n end\n size += 1\n size\n end",
"def add(value)\n current_node = @head\n while current_node.next != nil\n current_node = current_node.next\n end\n current_node.next = Node.new(value, nil)\n end",
"def push(value)\n @count += 1\n new_element = RubyDS::StackQueue::Element.new(value)\n if @head.nil?\n @head = new_element\n else\n new_element.next = @head\n @head = new_element\n end\n end",
"def append( value )\n\n # Find the last node in this list\n # i.e. keep looking at the next node\n # until the next node is 'nil'\n node = @head\n while node.next\n node = node.next\n # kind of like incrementing the loop counter\n end\n\n # puts \"End of loop:\"\n # p node\n\n node.next = Node.new value\n end",
"def append(value)\n node = Node.new(value)\n if last\n last.next = node\n else\n @head = node\n end\n end",
"def append(value)\n new_node = Node.new(value)\n @head ? @tail.next_node = new_node : @head = new_node\n @tail = new_node\n @size += 1\n end",
"def push(val)\n newNode = Node.new(val)\n if(self.length == 0)\n self.head = newNode\n self.tail = newNode\n else\n self.tail.next = newNode\n newNode.prev = self.tail\n self.tail = newNode\n end\n self.length +=1\n return self\n end",
"def append(value)\n if @size == 0\n @head = @tail = LinkedListNode.new(:value => value)\n else\n old_tail = @tail\n @tail = LinkedListNode.new(:value => value)\n old_tail.successor = @tail\n end\n @size += 1\n end",
"def append(value)\n if @size == 0\n @head = Node.new(value)\n else\n node = @head\n node = node.link until node.link.nil?\n node.link = Node.new(value)\n end\n\n @size += 1\n end",
"def append(value)\n if @head == nil\n @head = value \n @tail = value \n else \n @tail.next_node = value\n @tail = value \n end \n end",
"def append(value)\n node = Node.new\n node.value = value\n\n if @head.nil?\n @head = node\n @tail = node\n else\n @tail.next_node = node\n @tail = node\n end\n @size += 1\n end",
"def push_tail(value)\n if value.class == Nodo\n added_node = value\n else\n added_node = Node.new(value)\n end\n\n added_node.next = nil\n added_node.prev = @tail\n\n @tail.next = added_node unless @tail.nil?\n @tail = added_node\n @head = added_node if @head.nil? \n @sz = @sz + 1\n\n return nil\n end",
"def push value\n self.set( self.get_length + 1 , value)\n end",
"def append(value)\n new_node = ListNode.new(value)\n if self.head.nil?\n self.head = self.tail = new_node\n self.size = 1\n else\n set_next_and_prev(self.tail, new_node)\n self.tail = new_node\n self.size += 1\n end\n self.as_string\n end",
"def append(value)\n node = LinkedListNode.new(value, @tail, nil)\n if @size.zero?\n @head = node\n @tail = node\n @size += 1\n return\n end\n\n @tail.next = node\n @tail = node\n @size += 1\n end",
"def append(value)\n\t\t\tif self.empty?\n\t\t\t\tself.prepend(value)\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\telement = self.head\n\t\t\t# loop through each element in the LinkedList, until element.next \n\t\t\t# equals @head, signifying we have reached the end of the list.\n\t\t\twhile(element != self.head)\n\t\t\t\telement = element.next\n\t\t\tend\n\n\t\t\tnew_element = RubyStructures::Node.new(self, value)\n\t\t\t# insert the new element at the end of the LinkedList.\n\t\t\tnew_element.next = element.next\n\t\t\telement.next = new_element\n\t\tend",
"def append(value)\n node = Node.new\n node.value = value\n if head.nil?\n @head = node\n else\n curr = head\n curr = curr.next until curr.next.nil?\n curr.next = node\n end\n head\n end",
"def add(value)\n if head.nil?\n @head = Node.new(value)\n else\n current_node = head\n while current_node.next\n current_node = current_node.next\n end\n current_node.next = Node.new(value)\n end\n end",
"def append(value)\n if @head.nil?\n @head = Node.new(value)\n else\n current_node = @head\n new_node = Node.new(value)\n current_node = current_node.next_node until current_node.next_node.nil?\n current_node.next_node = new_node\n end\n end",
"def add(value)\n node = Node.new(value)\n unless @head\n @head = node\n else\n node.previous = @tail\n @tail.next = node\n end\n @tail = node\n @size += 1\n end",
"def add(val)\n get_node(val) #every new element that has to be added should point to a new node correponding to it.\n list_size = @elements.size\n last_element_index = list_size - 1\n @elements[last_element_index].next_node = list_size\n new_element_index = list_size\n @elements[new_element_index] = @node\n end",
"def push (value)\n @top = Node.new(value, @top)\n end",
"def add(value)\n\t\tif @head != nil \n\t\t\tcurrent = @head\n\t\t\twhile current.nnode != nil\n\t\t\t\tcurrent = current.nnode\n\t\t\tend\n\t\t\tcurrent.nnode = Node.new(value, nil)\n\t\telse\n\t\t\t@head = Node.new(value,nil)\n\t\tend\n\tend",
"def push(value)\n if value == nil\n \tputs 'Nil value (Nothing else to push)'\n \treturn\n end\nnewData = @data ? LinkedListNode.new(value, @data) : LinkedListNode.new(value)\n@data = newData\n\nend",
"def push(value)\n push_at(size, value)\n end",
"def append(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n else\n @tail.next_node = node\n end\n @tail = node\n end",
"def append(value)\n if @head.nil?\n @head = Node.new(value)\n @tail = @head\n else\n @tail.next_node = Node.new(value)\n @tail = @tail.next_node\n end\n end",
"def push_head(value)\n\n if value.class == Nodo\n added_node = value\n else\n added_node = Nodo.new(value)\n end\n\n added_node.prev = nil\n added_node.next = @head\n\n @head.prev = added_node unless @head.nil?\n @head = added_node\n\n @tail = added_node if @tail.nil? \n @sz = @sz + 1\n return nil\n \n end",
"def append(value)\n new_node = Node.new(value)\n @node_counter += 1\n if @head == nil\n @head = new_node\n else\n last_node = traverse_nodes(@head)\n # require 'pry'; binding.pry\n last_node.next_node = new_node\n end\n end",
"def add(val)\n # debugger\n current = @head\n while current.next != nil\n current = current.next\n end\n current.next = Node.new(val, nil)\n \n # current.next.value\n self\n end",
"def push(node_value)\n new_node = Node.new(node_value)\n\n # Steps to run if DLL is empty\n if empty?\n # Set both head and tail to the new node\n @head = new_node\n @tail = new_node\n else\n # If DLL is not empty, start by setting new node's prev to current tail\n new_node.prev = @tail\n # Update the current tail to have new node as its next\n @tail.next = new_node\n # Have tail point to the new node, the true tail now\n @tail = new_node\n end\n\n # Increment size in all cases\n @size += 1\n # Return self for chaining\n self\n end",
"def append(val)\n current = @head\n while current.next?\n current = current.next_node\n end\n new_node = Node.new(val, nil)\n current.next_node = new_node\n end",
"def append(value)\n if @head\n find_tail.next = Node.new(value)\n else\n @head = Node.new(value)\n end\n end",
"def append(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n @tail = node\n else\n @tail.next_node = node\n @tail = @tail.next_node\n end\n end",
"def push(value)\r\n @data << value\r\n end",
"def append(value)\n #needs .last method\n #self.last\n last.next = Node.new(value)\n end",
"def append(value)\n new_node = Node.new(value)\n node = @node\n\n while node.next\n node = node.next\n end\n\n node.next = new_node\n end",
"def add(value)\n @stack.push(value)\n end",
"def push(value)\n node = Node.new(value)\n node.previous = top\n self.top = node\n\n return node\n end",
"def append(value)\r\n newNode = Node.new(value, nil)\r\n\r\n if empty?\r\n @first = newNode\r\n else\r\n @last.next = newNode \r\n end\r\n @last = newNode\r\n @length += 1\r\n self\r\n end",
"def append(value)\r\n newNode = Node.new(value, nil)\r\n\r\n if empty?\r\n @first = newNode\r\n else\r\n @last.next = newNode \r\n end\r\n\r\n @last = newNode\r\n @length += 1\r\n self\r\n end",
"def append(value)\r\n newNode = Node.new(value, nil)\r\n\r\n if empty?\r\n @first = newNode\r\n else\r\n @last.next = newNode \r\n end\r\n\r\n @last = newNode\r\n @length += 1\r\n self\r\n end",
"def append(value)\r\n newNode = Node.new(value, nil)\r\n\r\n if empty?\r\n @first = newNode\r\n else\r\n @last.next = newNode \r\n end\r\n\r\n @last = newNode\r\n @length += 1\r\n self\r\n end",
"def append(value)\n if head == nil\n prepend(value)\n else\n tmp = head\n while tmp.next_node != nil\n tmp = tmp.next_node\n end\n tmp.next_node = Node.new(value)\n end\n end",
"def append(value)\r\n newNode = Node.new(value, nil)\r\n\r\n if empty?\r\n @first = newNode\r\n else\r\n @last.next = newNode \r\n end\r\n\r\n @last = newNode\r\n @length += 1\r\n self\r\n end",
"def add_last(value)\r\n \r\n # if list is empty, insert the new value at the head\r\n if @head.nil?\r\n @head = Node.new(value, nil)\r\n return @head\r\n end \r\n \r\n # otherwise, traverse the list from start to last node ...\r\n current = @head\r\n until current.next.nil?\r\n current = current.next\r\n end\r\n \r\n # ... and insert new node after last node\r\n current.next = Node.new(value, nil)\r\n \r\n end",
"def append(value)\n newNode = Node.new(value, nil)\n\n if empty?\n @first = newNode\n else\n @last.next = newNode \n end\n @last = newNode\n @length += 1\n self\n end",
"def append(value)\n if @head.nil?\n prepend(value)\n else\n find_tail.next = Node.new(value)\n end\n end",
"def push_at(index, value)\n new_node = create_node(value)\n node = node_at(index - 1)\n push_after(node, new_node) if node\n self.head = new_node if index == 0\n self.size += 1\n new_node.data\n end",
"def append(value)\n newNode = Node.new(value, nil)\n\n if empty?\n @first = newNode\n else\n @last.next = newNode \n end\n\n @last = newNode\n @length += 1\n self\n end"
] | [
"0.8621315",
"0.8543513",
"0.8484303",
"0.8457438",
"0.8457438",
"0.84379774",
"0.84340274",
"0.84340274",
"0.84321713",
"0.8428468",
"0.84120625",
"0.84027535",
"0.8401683",
"0.8401683",
"0.83994704",
"0.83962727",
"0.83738476",
"0.8365877",
"0.83572245",
"0.8356332",
"0.83531404",
"0.83531404",
"0.8349722",
"0.8344037",
"0.8331988",
"0.8322025",
"0.8312987",
"0.8292562",
"0.8270121",
"0.82580566",
"0.8246307",
"0.8216555",
"0.8214875",
"0.81126195",
"0.8089098",
"0.8072495",
"0.8025073",
"0.79969835",
"0.7977637",
"0.7977512",
"0.79648244",
"0.7937846",
"0.79295796",
"0.7915528",
"0.78415483",
"0.7837625",
"0.7825569",
"0.7806006",
"0.7778576",
"0.77655226",
"0.77633435",
"0.77436763",
"0.7742858",
"0.7723624",
"0.7722064",
"0.7721825",
"0.77011347",
"0.7693012",
"0.76895654",
"0.7687733",
"0.7685423",
"0.76817924",
"0.766968",
"0.7659835",
"0.7658137",
"0.7646446",
"0.76398534",
"0.7621115",
"0.76104516",
"0.7605454",
"0.7579335",
"0.7563408",
"0.75594807",
"0.7559183",
"0.7549983",
"0.75405926",
"0.7527826",
"0.7517577",
"0.7510056",
"0.7506106",
"0.7503952",
"0.75035137",
"0.7490802",
"0.74887073",
"0.7449922",
"0.74399304",
"0.74382114",
"0.74330986",
"0.74248916",
"0.7423484",
"0.7421256",
"0.7421256",
"0.7421256",
"0.7419304",
"0.73980266",
"0.7394323",
"0.7372547",
"0.73527944",
"0.7343588",
"0.7338457"
] | 0.86422974 | 0 |
Adds a node of value 'value' at the beginning of the linked list | def unshift(value)
@head = Node.new(value, @head)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepend( value )\n new_node = Node.new value\n\n # Whatever node was at the start of the list, it\n # is now the 'next' node for our newly created node\n new_node.next = @head\n\n # The new head of the list is set to be the new\n # node that we just created\n @head = new_node\n end",
"def prepend( value )\n new_node = Node.new value\n\n # Whatever node was at the start of the list, it\n # is now the 'next' node for our newly created node\n new_node.next = @head\n\n # The new head of the list is set to be the new\n # node that we just created\n @head = new_node\n end",
"def prepend(value)\n new_node = Node.new(value)\n @node_counter += 1\n if @head == nil\n @head = new_node\n else\n new_node.next_node = @head\n @head = new_node\n end\n end",
"def prepend(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n else\n node.next_node = @head\n @head = node\n end\n end",
"def prepend(value)\n node = Node.new\n node.value = value\n node.next = head\n @head = node\n end",
"def prepend(value)\n\t\t@head.next_node = Node.new(value, @head.next_node)\n\tend",
"def prepend(value)\n node = Node.new\n node.value = value\n \n if @head.nil?\n @head = node\n @tail = node\n else\n node.next_node = @head\n @head = node\n end\n @size += 1\n end",
"def prepend(value)\n new_node = create_node(value)\n new_node.next_node = head\n self.head = new_node\n self.size += 1\n end",
"def add_first(value)\r\n @head = Node.new(value, @head)\r\n end",
"def prepend(value)\n if @head.nil?\n @head = Node.new(value)\n else\n current_node = @head\n new_node = Node.new(value)\n @head = new_node\n @head.next_node = current_node\n end\n end",
"def prepend( value )\n new_node = Node.new value\n new_node.next = @head\n @head = new_node\n end",
"def add_first(value)\r\n @head = Node.new(value, @head)\r\n end",
"def prepend(value)\n @head = Node.new(value, head)\n end",
"def add_first(value)\r\n current = @head\r\n # add new node with provided value and set next to current\r\n new_node = Node.new(value, current)\r\n # new node becomes head\r\n @head = new_node\r\n end",
"def add_first(value)\r\n new_node = Node.new(value, @head)\r\n @head = new_node\r\n end",
"def prepend(value)\n new_node = Node.new(value)\n new_node.next = @node\n @node = new_node\n end",
"def prepend(value = nil)\n node = @head\n @head = Node.new(value, node)\n end",
"def prepend(value)\n newNode = Node.new(value)\n if @list == nil\n @list = newNode\n else\n prevList = list\n @list = newNode\n @list.nextNode = prevList\n end\n end",
"def prepend(value)\n\t\t\telement = RubyStructures::Node.new(self, value)\n\t\t\telement.next = @head.next\n\t\t\t@head.next = element\n\t\tend",
"def prepend(value)\n @head = Node.new(value, @head)\n @size += 1\n end",
"def prepend(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n @tail = node\n else\n old_head = @head\n @head = node\n @head.next_node = old_head\n end\n end",
"def prepend(value)\n if @head.nil?\n @head = Node.new(value)\n @tail = @head\n else\n new_node = Node.new(value)\n new_node.next_node = @head\n @head = new_node\n end\n end",
"def prepend(value)\n if @head.nil?\n @head = Node.new(value)\n else\n old_point = @head\n @head = Node.new(value)\n @head.next = old_point\n # old_next = @head.next\n # p old_next\n # @head = Node.new(value)\n # @head.next = old_next\n # head is hi\n # replace head with new value\n # make head next the hi attribute\n end\n end",
"def prepend(node_value = nil)\n node = Node.new(node_value)\n if @head.nil?\n @tail = node\n else\n node.next_node = @head\n end\n @head = node\n end",
"def prepend(value)\n p = Node.new(value);\n p.prev = nil;\n p.next = self.head;\n self.head.prev = p;\n self.head = p;\n end",
"def prepend(value)\n new_node = Node.new(value, @head)\n @tail = new_node unless @head\n @head = new_node\n @size += 1\n end",
"def add_first(value)\n new_node = Node.new(value)\n\n if @head != nil # if linked list is not empty\n new_node.next = @head\n end\n\n @head = new_node\n end",
"def insert_before(value)\n node = LinkedListNode(value)\n\n node.next = self\n\n node\n end",
"def add(value)\n\t\tif @head != nil \n\t\t\tcurrent = @head\n\t\t\twhile current.nnode != nil\n\t\t\t\tcurrent = current.nnode\n\t\t\tend\n\t\t\tcurrent.nnode = Node.new(value, nil)\n\t\telse\n\t\t\t@head = Node.new(value,nil)\n\t\tend\n\tend",
"def add_node(value)\n if @head\n @head = Node.new value, @head\n else\n @head = Node.new value, nil\n end\n end",
"def prepend(value) \n if @head == nil\n @head = value \n @tail = value \n else \n value.next_node = @head\n @head = value \n end \n end",
"def add(value)\n current_node = @head\n while current_node.next != nil\n current_node = current_node.next\n end\n current_node.next = Node.new(value, nil)\n end",
"def add_first(value)\n new_node = DoublyLinkedNode.new(value, nil, @head)\n @head.prev = new_node if @head\n @head = new_node\n @tail = new_node if !new_node.next\n end",
"def prepend(value)\n #Instantiate the object to be the new head\n new_node = Node.new value\n #Set its next value to the current head\n new_node.next = @head\n @head.before = new_node\n #Set the new one as the new head by repointing SinglyLinkedList head to it\n @head = new_node\n end",
"def add(value)\n if head.nil?\n @head = Node.new(value)\n else\n current_node = head\n while current_node.next\n current_node = current_node.next\n end\n current_node.next = Node.new(value)\n end\n end",
"def prepend(val)\n new_node = Node.new(val, @head)\n @head = new_node\n end",
"def insert_before(value)\n node = Node(value)\n node.next = self\n node\n end",
"def append_to_front(value)\n\t\tif @head\n node = Node.new(value)\n node.next = @head\n @head = node\n\t\telse \n\t\t\t@head = Node.new(value)\n\t\t\t@tail = @head\n end\n @size += 1\n end",
"def prepend(val)\n\t\t# create a new node\n\t\tnew_node = Node.new(val, @head)\n\t\t# update head\n\t\t@head = new_node\n\tend",
"def insert_head(node_value)\n # If the SLL is empty, create a node with the given value and set it to head\n if empty?\n @head = Node.new(node_value)\n else\n # Otherwise, hold the head in a temporary var\n hold = @head\n # Create a new node and set it as the head\n @head = Node.new(node_value)\n # Set the next prop on the new head to point to the hold var\n @head.next = hold\n end\n\n # Increment size by 1, regardless of how many nodes exist\n @size += 1\n # Return the new head; alternatively, return self to make the methods chainable\n @head\n end",
"def append(value)\n if head == nil\n prepend(value)\n else\n tmp = head\n while tmp.next_node != nil\n tmp = tmp.next_node\n end\n tmp.next_node = Node.new(value)\n end\n end",
"def append(value)\n if @head.nil?\n prepend(value)\n else\n find_tail.next = Node.new(value)\n end\n end",
"def insert_head(value)\n\n\t\tif empty()\n\t\t\t@head = Node.new(value,nil,nil)\n\t\t\t@tail = @head\n\t\telse\n\t\t\t@head.prev = Node.new(value,@head,nil)\n\t\t\t@head = @head.prev;\n\t\tend\n\n\t\t@size = @size + 1\n\t\t\t\n\tend",
"def add_at_head(val)\n if @llist\n old_head = @llist\n @llist = Node.new(val)\n @llist.add_next_node old_head\n else\n @llist = Node.new(val)\n end\n end",
"def insert_by_begin(value)\n\t\tif @head.nil?\n\t\t\t@head = @Node.new(value, nil, nil)\n\t\t\t@tail = @head\n\t\telse\n\t\t\t@head[:prev] = @Node.new(value, @head, nil)\n\t\t\t@head = @head[:prev]\n\t\tend\n end",
"def add_at_head(val)\n first = Node.new(val)\n first.next = @head\n @head = first\n @length += 1\n end",
"def append(value)\n if @head.nil?\n @head = Node.new(value)\n else\n current_node = @head\n new_node = Node.new(value)\n current_node = current_node.next_node until current_node.next_node.nil?\n current_node.next_node = new_node\n end\n end",
"def append(value)\n node = Node.new\n node.value = value\n if head.nil?\n @head = node\n else\n curr = head\n curr = curr.next until curr.next.nil?\n curr.next = node\n end\n head\n end",
"def insert_head(value)\n if @head.nil?\n @head = Nodo.new(value, nil, nil)\n @tail = @head\n else\n @head[:prev] = Nodo.new(value, @head, nil)\n @head = @head[:prev]\n end\n end",
"def append(value)\n new_node = Node.new(value)\n @node_counter += 1\n if @head == nil\n @head = new_node\n else\n last_node = traverse_nodes(@head)\n # require 'pry'; binding.pry\n last_node.next_node = new_node\n end\n end",
"def insert_front(value)\n if @head\n @head = Node.new(value, nil, @head)\n else\n @head = Node.new(value)\n @tail = @head\n end\n @length += 1\n return @head\n end",
"def add(value)\n node = Node.new(value)\n unless @head\n @head = node\n else\n node.previous = @tail\n @tail.next = node\n end\n @tail = node\n @size += 1\n end",
"def append(value)\n node = Node.new(value)\n if last\n last.next = node\n else\n @head = node\n end\n end",
"def append(value)\n if @size == 0\n @head = Node.new(value)\n else\n node = @head\n node = node.link until node.link.nil?\n node.link = Node.new(value)\n end\n\n @size += 1\n end",
"def insert(value)\n new_node = Node.new(value)\n @head.prev = new_node if @head\n new_node.next = @head\n @tail = new_node unless @tail\n @head = new_node\n @count += 1\n end",
"def add(value)\n new_node = Node.new(value)\n if last\n last.next = new_node\n else\n self.first = new_node\n end\n\n return new_node\n end",
"def insert_begin(value)\n\n\t\tif (@head == nil)\n\n\t\t\t@head = @Node.new(value,nil,nil)\n\t\t\t@tail = @head\n\n\t\telse\n\n\t\t\t@head[:prev] = @Node.new(value,@head,nil)\n\t\t\t@head = @head[:prev] \n\n\t\tend\n\n\tend",
"def add_first(value)\n new_node = DoubleNode.new(value, nil, @head)\n\n if @head\n @head.previous = new_node\n end\n\n @head = new_node\n end",
"def insert_before(value)\n node = DoublyLinkedListNode(value)\n\n if self.empty?\n node.previous = self\n else\n node.previous = self.previous\n node.next = self\n self.previous = node\n end\n\n node\n end",
"def insert_before value\n node = Node.new value, self, @prv\n @prv.nxt = node if @prv\n @prv = node\n end",
"def add value\n if @head.nil?\n @length = 1\n @head = GenericList::Node.new(value)\n else\n lst = @head\n ptr = @head.nxt\n while ptr && @proc.call(value, lst.value) <= 0\n lst = ptr\n ptr = ptr.nxt\n end\n @length += 1\n lst.insert value\n end\n end",
"def push_head(value)\n\n if value.class == Nodo\n added_node = value\n else\n added_node = Nodo.new(value)\n end\n\n added_node.prev = nil\n added_node.next = @head\n\n @head.prev = added_node unless @head.nil?\n @head = added_node\n\n @tail = added_node if @tail.nil? \n @sz = @sz + 1\n return nil\n \n end",
"def add_at_head(val)\n @list.unshift(val)\n end",
"def insertHead(value)\n \n n = Node.new(value)\n \n if @head.nil?\n \n @head = n\n @tail = @head\n \n else\n \n @head.next = n\n n.prev = @head\n @head = n\n \n end\n \n end",
"def append(value)\n if @head\n find_tail.next = Node.new(value)\n else\n @head = Node.new(value)\n end\n end",
"def add_first(data)\n new_node = Node.new(value, @head)\n @head = new_node\n end",
"def add_node(value)\n add_node_support(value, :linked_list)\n end",
"def append( value )\n\n # Find the last node in this list\n # i.e. keep looking at the next node\n # until the next node is 'nil'\n node = @head\n while node.next\n node = node.next\n # ^ kind of like incrementing the loop counter\n end\n\n node.next = Node.new value\n end",
"def push(value)\n new_head = Node.new value, @head\n @head = new_head\n end",
"def push(value)\n @head = Node.new(value, @head)\n end",
"def append(value)\n new_node = Node.new(value)\n node = @node\n\n while node.next\n node = node.next\n end\n\n node.next = new_node\n end",
"def insert(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value >= value \n\t\t\t@head = Node.new(value, current_node)\n\t\tend \n\t\tuntil current_node.next_node.value =< value \n\t\t\tbreak if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = Node.new(value, current_node.next_node)\n\tend",
"def push(value)\r\n @head = Node.new(value, @head)\r\n end",
"def prepend(value)\n @array.unshift(Node.new(value,@array[0]))\n end",
"def push(value)\n @head = LinkedListNode.new(value, @head)\n end",
"def append(value = nil, next_node = nil)\n\n if (@head.nil?)\n prepend(value)\n else\n node = @head\n while (node.has_next)\n node = node.next_node\n end\n node.next_node = Node.new(value, next_node)\n end\n\n end",
"def append(value)\n node = Node.new\n node.value = value\n\n if @head.nil?\n @head = node\n @tail = node\n else\n @tail.next_node = node\n @tail = node\n end\n @size += 1\n end",
"def append( value )\n last.next = Node.new value\n end",
"def insert_head(val)\r\n aux = Node.new(val,@head,nil)\r\n @head.prev = aux\r\n @head = aux\r\n end",
"def insert_after(value)\n node = LinkedListNode(value)\n\n node.next = self.next if self.next\n self.next = node\n\n node\n end",
"def append(value)\n\t\t\tif self.empty?\n\t\t\t\tself.prepend(value)\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\telement = self.head\n\t\t\t# loop through each element in the LinkedList, until element.next \n\t\t\t# equals @head, signifying we have reached the end of the list.\n\t\t\twhile(element != self.head)\n\t\t\t\telement = element.next\n\t\t\tend\n\n\t\t\tnew_element = RubyStructures::Node.new(self, value)\n\t\t\t# insert the new element at the end of the LinkedList.\n\t\t\tnew_element.next = element.next\n\t\t\telement.next = new_element\n\t\tend",
"def insert_ascending(value)\r\n \r\n # if list is empty or node should be inserted at the beginning of the list\r\n if @head.nil? || value < @head.data\r\n self.add_first(value)\r\n return\r\n end\r\n \r\n current = @head\r\n previous = nil\r\n until current.nil?\r\n # if node should be inserted before end of list\r\n if current.next != nil && current.next.data >= value\r\n temp = current.next\r\n new_node = Node.new(value, temp)\r\n previous = current\r\n previous.next = new_node\r\n current = temp \r\n \r\n # if node should be inserted at end of list\r\n elsif current.next.nil? && current.data < value\r\n self.add_last(value)\r\n end\r\n current = current.next\r\n end\r\n \r\n end",
"def insert(value)\n node = @current\n @current = LinkNode.call(value, node, :after, self, &@match_value)\n self.head = @current if self.head.nil?\n self.tail = @current if self.tail.equal?(node)\n self.size += 1\n end",
"def insert_head (value) # Insertar desde la cabeza\n\t nodo=Node.new(value,nil,nil)\n nodo.nest = @head\n @head = nodo # el head ahora apunta a este nodo\n if (@tail == nil)\n @tail = nodo\n end\n nodo.prev = nil\n if (nodo.nest != nil)\n nodo.nest.prev = nodo\n end\n end",
"def append(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n @tail = node\n else\n @tail.next_node = node\n @tail = @tail.next_node\n end\n end",
"def insert_head(val)\n node = Node.new(val, nil, @head)\n @tail = node unless @head\n @head.prev = node if @head\n @head = node\n @size += 1\n end",
"def append(value)\n new_node = Node.new(value)\n @head ? @tail.next_node = new_node : @head = new_node\n @tail = new_node\n @size += 1\n end",
"def append(value)\n new_node = create_node(value) \n if head.nil?\n self.head = new_node\n else\n last_node = tail\n last_node.next_node = new_node\n end\n self.size += 1\n end",
"def append(value)\n if @head.nil?\n @head = Node.new(value)\n @tail = @head\n else\n @tail.next_node = Node.new(value)\n @tail = @tail.next_node\n end\n end",
"def append(value)\n\t\tself.tail.next_node = Node.new(value, nil)\n\tend",
"def insert_after(value)\n node = Node(value)\n @next = node\n node\n end",
"def set_head(value)\n @head = new_node(value)\nend",
"def add(val)\n # debugger\n current = @head\n while current.next != nil\n current = current.next\n end\n current.next = Node.new(val, nil)\n \n # current.next.value\n self\n end",
"def insert_beginning(*val)\n \n val.each do |nuevo_nodo|\n \n if @head != nil\n \n @head.previous = nuevo_nodo\n nuevo_nodo.next = @head\n @head = nuevo_nodo\n else\n @head = nuevo_nodo\n end\n @num_nodos += 1\n \n end\n end",
"def unshift(value)\n if @head != nil\n new_head = Node.new(value)\n @head.next_node = new_head\n new_head.previous = @head\n @head = new_head\n else\n push(value)\n end\n end",
"def append(value)\n new_node = ListNode.new(value)\n if self.head.nil?\n self.head = self.tail = new_node\n self.size = 1\n else\n set_next_and_prev(self.tail, new_node)\n self.tail = new_node\n self.size += 1\n end\n self.as_string\n end",
"def insertarHead(value)\n nodo = Node.new(value)\n if @head == nil and @tail == nil\n @head = nodo\n @tail = nodo\n else\n @head.next = nodo\n nodo.prev = @head\n @head = nodo\n end\n @size+=1\n end",
"def unshift(value)\n node = Node.new(value)\n if @length == 0\n @head = node\n @tail = node\n else\n @head.previous = node\n @head = node\n end\n @length += 1\n end",
"def ins_start(value)\n if @head != nil && @head.node_sig != nil\n n = @head\n @head = Node.new(value, n, nil)\n n.edi_ant(@head)\n elsif @head != nil\n n = @head\n @head = Node.new(value, n, nil)\n n.edi_ant(@head)\n @tail = n\n else\n @head = Node.new(value, nil, nil)\n @tail = @head\n end\n end",
"def append(value)\n node = Node.new(value)\n if @head.nil?\n @head = node\n else\n @tail.next_node = node\n end\n @tail = node\n end"
] | [
"0.8733416",
"0.8733416",
"0.8685038",
"0.86434394",
"0.8640737",
"0.86390406",
"0.85841787",
"0.8580805",
"0.85779417",
"0.8562475",
"0.85408056",
"0.85397273",
"0.8533522",
"0.8485086",
"0.84842336",
"0.84461373",
"0.84382164",
"0.84378195",
"0.8435319",
"0.8422685",
"0.84073913",
"0.8392563",
"0.8334513",
"0.8304041",
"0.82901514",
"0.828549",
"0.828375",
"0.82122904",
"0.8171031",
"0.8140718",
"0.8119244",
"0.8109387",
"0.8101772",
"0.80902445",
"0.80512875",
"0.8046233",
"0.8029315",
"0.8018182",
"0.800403",
"0.79925364",
"0.79771197",
"0.79713196",
"0.79505384",
"0.79320794",
"0.7896804",
"0.78814024",
"0.78727645",
"0.7869637",
"0.78632843",
"0.783617",
"0.77693766",
"0.7757817",
"0.7746229",
"0.7735781",
"0.77235603",
"0.7722758",
"0.7706117",
"0.7693937",
"0.7684455",
"0.76750517",
"0.76705855",
"0.7641417",
"0.7640136",
"0.7638419",
"0.7602837",
"0.7602667",
"0.7601105",
"0.75547063",
"0.7550125",
"0.75489676",
"0.7545362",
"0.7542082",
"0.7535023",
"0.753164",
"0.7529177",
"0.752592",
"0.7514655",
"0.749894",
"0.74968916",
"0.7493461",
"0.74908483",
"0.7483902",
"0.7466901",
"0.7436651",
"0.74223673",
"0.7419734",
"0.74103963",
"0.7408255",
"0.74021363",
"0.7392161",
"0.7391391",
"0.73782986",
"0.73744506",
"0.7347039",
"0.7337358",
"0.73171353",
"0.731507",
"0.73120624",
"0.7306549",
"0.7306115"
] | 0.7564068 | 67 |
Returns the last element of the linked list | def last
self.each {|node| return node if node.next_node == nil}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last\n node = @head;\n return node if node.next.nil?\n until (node.next.nil?) #until end of list\n node = node.next\n return node if node.next.nil?\n end\n end",
"def get_last\r\n # return nil if the linked list is empty\r\n if @head.nil?\r\n return nil\r\n end\r\n \r\n # otherwise, go to end of list ...\r\n current = @head\r\n until current.next.nil?\r\n # ... until 'current' is the last node ...\r\n current = current.next\r\n end\r\n \r\n # ... and return data from last node\r\n return current.data\r\n \r\n end",
"def get_last\n return nil if @head.nil? \n pointer = @head \n while !pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end",
"def get_last\n return nil if @head.nil?\n current = @head\n until current.next.nil?\n current = current.next\n end\n return current.data\n end",
"def get_last\n return nil if @head.nil? \n pointer = @head\n\n until pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end",
"def get_last\n return nil if @head.nil?\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end",
"def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end",
"def get_last\n return if @head == nil\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end",
"def get_last\n return nil if !@head\n current = @head\n while current.next\n current = current.next\n end\n return current.data\n end",
"def get_last\n return nil unless @head\n current = @head\n\n while current.next\n current = current.next\n end\n\n return current.data\n end",
"def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while current.next != nil \n current = current.next\n end\n return current.data\n end",
"def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while !current.next.nil?\n current = current.next\n end\n \n return current.data\n end",
"def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end",
"def get_last\n return nil if @head == nil\n\n current_node = @head\n\n while current_node.next != nil\n current_node = current_node.next\n end\n\n return current_node.data\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def last\n node = @head\n while node.next\n node = node.next\n end\n node\n end",
"def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end",
"def get_last\n node = head\n until node.next.nil?\n node = node.next\n end\n return node.data\n end",
"def get_last\r\n return nil if !@head\r\n\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.next \r\n prev = curr\r\n curr = curr.next \r\n else \r\n return curr.data\r\n end\r\n end\r\n\r\n end",
"def last\n list = self\n list = list.tail until list.tail.empty?\n list.head\n end",
"def get_last\n return @head if @head.nil?\n current_node = @head\n\n until current_node.next.nil?\n current_node = current_node.next\n end\n return current_node.data\n end",
"def last_node\n return nil if @head.nil?\n current = @head\n while current.next != nil\n current = current.next\n end\n return current\n end",
"def last\n list.first\n end",
"def last\n \tbegin\n \t raise ArgumentError, \"Empty LinkedList\" if @size <= 0\n \t return @last.prev.data\n \t rescue\n \t puts \"Empty\" \t\t \n\t\t end\n \tend",
"def get_last\n current = head\n if head.nil?\n last_node = head\n else\n while !current.nil?\n last_node = current\n current = current.next\n end\n end\n return last_node.data\n end",
"def get_last\n return nil if @head.nil?\n return last_node.data\n end",
"def get_last\r\n return nil unless @head\r\n cursor = @head\r\n while cursor.next\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end",
"def find_last \n\t\tcurrent_node = @head\n\t\tuntil current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node\n\tend",
"def last(list)\n list[-1]\nend",
"def peek_last\n raise 'No such element' if @size == 0\n @tail.value\n end",
"def last\n node = @head\n while node && node.next\n node = node.next # i += 1\n end\n node\n end",
"def get_last\n return @tail ? @tail.data : nil\n end",
"def last\n if @nxt\n @nxt.last\n else\n self\n end\n end",
"def getLastNode #not counting the sentinel node\n\tunless (@size == 0)\n\t\treturn @last.prev\n\telse\n\t\treturn nil\n\tend\nend",
"def last\r\n self[-1]\r\n end",
"def last\n @tail.val\n end",
"def last\n self[-1]\n end",
"def last\n all[all.size - 1]\n end",
"def last\n @tail\n end",
"def last\n out = nil\n\n each {|i| out = i }\n\n out\n end",
"def last\n at(-1)\n end",
"def last\n self[-1]\n end",
"def last\n @tail.lru_prev\n end",
"def last\n @ordered_elements.last\n end",
"def last_node(node)\n return node if tail?\n last_node(node.next_node)\n end",
"def remove_last\n raise 'No such element' if @size == 0\n elt = @tail.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @tail = @tail.previous\n @tail.next.previous = nil\n @tail.next = nil\n end\n @size -= 1\n return elt\n end",
"def get_last_item(arr)\n\treturn arr[-1]\nend",
"def last() end",
"def last\n to_a.last\n end",
"def last\n\t\t\t@last\n\t\tend",
"def last\n return @rear.head unless @rear.empty?\n @front.last # memoize?\n end",
"def last\n end",
"def last\n @enumerable.last\n end",
"def last\n items.compact.last\n end",
"def last\n tail.data\n end",
"def last_item\n @children[@items.last]\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def add_last(data)\n if @head.nil?\n @head = Node.new(data)\n return @head.data\n else\n current = self.last_node\n current.next = Node.new(data)\n return current.next.data\n end\n end",
"def last_position_in_list\n return nil unless in_list?\n bottom_position_in_list\n end",
"def last\n @children.last\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n contents[contents.size - 1]\n end",
"def last\n all.last\n end",
"def last\n all.last\n end",
"def last\n empty? ? nil : @anchor.prev_node.value\n end",
"def lastElement(arr)\n return arr[arr.length - 1]\nend",
"def last(num = nil)\n return @all.last num if num\n @all.last\n end",
"def last\n node = @tree.maximum\n node.nil? ? default : node.to_a\n end",
"def remove_last\n raise 'Cannot remove element from an empty list.' if empty?\n\n # Extract the data off of the tail node\n # Move the tail to the previous node\n data = @tail.data\n @tail = @tail.prev_node\n @size -= 1\n\n # removes the same element from @head, if it was final element/node\n if empty?\n @head = nil\n else\n # send to garbage collector\n @tail.next_node = nil\n end\n\n return data\n end",
"def last\n @items.last\n end",
"def last; end",
"def last; end",
"def last; end",
"def lastElement\n return @stk[@count]\n end",
"def last\n self.slice(self.size - 1)\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 last\n result ? all.last : limit(1).descending.all.last\n end",
"def last(n = nil)\n if n\n self[-n..-1]\n else\n self[-1]\n end\n end",
"def tail\n last_node(head)\nend",
"def last\n\t\t@tail.info if !@tail.nil?\n\tend",
"def add_last element\n if empty?\n @head = @tail = Node.new(element, nil)\n else\n @tail.next_node = Node.new(element, nil)\n @tail = @tail.next_node\n end\n @size += 1\n\n return nil\n end",
"def add_last element\n if empty?\n @head = @tail = Node.new(element, nil, nil)\n else\n @tail.next_node = Node.new(element, @tail, nil)\n @tail = @tail.next_node\n end\n @size += 1\n\n return nil\n end",
"def last_element(array)\n array[-1]\nend",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def remove_last\n return nil if empty?\n node = @sentinel.prev\n e = node.data\n node.prev.next = @sentinel\n @sentinel.prev = node.prev\n e\n end",
"def last(*args)\n find(:last, *args)\n end",
"def using_last(array)\n array.last\n# returns last item in array \nend",
"def last *a; self.child(*a) + ':last-child' end",
"def remove_last\n # if the head is nil, then we just return nil\n return nil if head.nil?\n # if it's only one node, thet remove_last is equal to pop\n return pop if head.next_node.nil?\n\n # we keep searching for the next node until\n # current.next_node is nil\n prev = @head\n current = @head\n\n while !current.next_node.nil?\n prev = current\n current = current.next_node\n end\n # since current.next_node is nil, we just\n # disconnect it and update the tail reference\n prev.next_node = nil\n @tail = prev\n return current.value\n end",
"def last(*args)\n find(:last, *args)\n end",
"def last(*args)\n find(:last, *args)\n end",
"def get_last\n return @position\n end",
"def last_element_child\n n = self.last_child\n while n do\n if n.node_type == ELEMENT_NODE then\n break\n end\n n = n.previous_sibling\n end\n return n\n end",
"def last(*args)\n find_first_or_last(:last, *args)\n end",
"def last(options={})\n get(\"last\", options)\n end",
"def get_last\n raise NotImplementedError, \"Please implement get_last\"\n end"
] | [
"0.86631894",
"0.86070114",
"0.85368365",
"0.85224015",
"0.8517871",
"0.85147595",
"0.8500174",
"0.8498962",
"0.8478527",
"0.8453789",
"0.8438831",
"0.842848",
"0.84145886",
"0.83945376",
"0.83919555",
"0.83919555",
"0.83917606",
"0.838296",
"0.8368591",
"0.83079076",
"0.8302115",
"0.82730937",
"0.82653743",
"0.8243409",
"0.81782335",
"0.8120736",
"0.80682975",
"0.8010609",
"0.8001671",
"0.793896",
"0.7926612",
"0.7897359",
"0.7806369",
"0.78045845",
"0.7771389",
"0.7725725",
"0.7700929",
"0.76800394",
"0.76510984",
"0.76078194",
"0.76006454",
"0.759655",
"0.75861895",
"0.75398153",
"0.75184435",
"0.7516628",
"0.7364724",
"0.73569757",
"0.73393023",
"0.7334856",
"0.7327087",
"0.72984844",
"0.72967494",
"0.7283416",
"0.7281082",
"0.7277318",
"0.7267275",
"0.7267275",
"0.7267275",
"0.7267275",
"0.7259431",
"0.7256791",
"0.7244076",
"0.72335607",
"0.72335607",
"0.72131115",
"0.7202746",
"0.719796",
"0.71906614",
"0.71770865",
"0.7173088",
"0.7171614",
"0.7171047",
"0.71656036",
"0.715229",
"0.715229",
"0.715229",
"0.7135918",
"0.71101797",
"0.7099815",
"0.70991915",
"0.70986754",
"0.7089661",
"0.7081021",
"0.70723385",
"0.70687526",
"0.70453626",
"0.7038362",
"0.7038362",
"0.70071536",
"0.700361",
"0.70001924",
"0.6997242",
"0.6996993",
"0.6996993",
"0.6988667",
"0.69697547",
"0.6960046",
"0.6956198",
"0.6947703"
] | 0.7898516 | 31 |
Returns the length of the linked list | def length
count = 0
node = @head
while node
count += 1
node = node.next_node
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\n # calculates the length of the list\n counter = @head ? 1 : 0\n node = @head\n while node.next_node\n node = node.next_node\n end\n counter\n end",
"def length\n current_node = @head\n return 0 unless current_node\n list_length = 0\n until current_node.nil?\n list_length += 1\n current_node = current_node.next\n end\n return list_length\n end",
"def length\n count = 0\n pointer = @head \n while !pointer.nil? do\n pointer = pointer.next;\n count += 1;\n end\n return count\n end",
"def length\n current = @head\n length = 0\n return 0 if current.nil?\n \n while !current.nil?\n current = current.next\n length += 1\n end\n return length\n end",
"def length\r\n count = 0\r\n curr = @head \r\n\r\n while curr\r\n count += 1\r\n curr = curr.next\r\n end\r\n\r\n return count\r\n end",
"def length\n length = 0\n current_node = @head\n\n while current_node != nil\n length += 1\n current_node = current_node.next\n end\n\n return length\n end",
"def length\n count = 0\n current = @head\n while current != nil\n count += 1\n current = current.next\n end\n\n return count\n end",
"def length\n return 0 if @head.nil?\n\n count = 0 \n current = @head\n until current.nil?\n count += 1\n # Move the pointer to the next, otherwise will be infinite loop.\n current = current.next\n end\n\n return count\n end",
"def length\n return 0 if @head.nil?\n\n count = 0\n current = @head\n\n until current.nil?\n count += 1\n current = current.next\n end\n\n return count\n end",
"def length\n count = 0\n current = @head\n until current.nil?\n count += 1\n current = current.next\n end\n return count\n end",
"def length\n length = 0\n if !@head\n return length\n else\n current = @head\n while current\n length += 1\n current = current.next\n end\n end\n return length\n end",
"def length\n return 0 if head.nil?\n node = head\n length = 1\n while node.next\n node = node.next\n length += 1\n end\n return length\n end",
"def length\n current_node = @head\n count = 1\n until current_node.next_node.nil?\n current_node = current_node.next_node\n count += 1\n end\n count\n end",
"def length\n count = 0\n current = @head\n while current != nil \n count += 1\n current = current.next\n end\n return count\n end",
"def length\r\n if @head.nil?\r\n return 0\r\n else\r\n length = 1\r\n current = @head\r\n until current.next.nil?\r\n current = current.next\r\n length += 1\r\n end\r\n return length\r\n end\r\n end",
"def length\n count = 0\n current = head\n while !current.nil?\n count += 1\n current = current.next\n end\n return count\n end",
"def length\n count = 0\n current = head\n until current.nil?\n count += 1\n current = current.next\n end\n return count\n end",
"def find_length\n current_node = @head\n length = 0\n while current_node != nil\n length += 1\n current_node = current_node.next\n end\n length\n end",
"def length\n count = 0 \n return count if @head.nil?\n return length_helper(count, @head)\n end",
"def list_size()\n counter = 0\n temp_node = @head #start traversting from first elemnt\n until temp_node == nil #stop when reach end of list\n temp_node = temp_node.link #step though list with link variable\n counter += 1\n end\n counter\n end",
"def length\r\n length = 0\r\n if !@head\r\n return length\r\n else\r\n cursor = @head\r\n while cursor\r\n length += 1\r\n cursor = cursor.next\r\n end\r\n end\r\n return length\r\n end",
"def length\n counter = 0\n return counter if head == nil\n\n node = head\n while node \n counter += 1\n node = node.next\n end\n\n return counter\n end",
"def length\n count = 0\n current = @head\n while current != nil\n count +=1\n current = current.next\n end\n return count\n\n # recursive (not working)\n # if current == nil\n # return 0\n # else\n # return 1 + length(current)\n # end\n end",
"def size\n node = @list\n size = 0\n while node != nil\n size += 1\n node = node.nextNode\n end\n size\n end",
"def length\n # calculates the length of the list\n end",
"def list_size(list)\n return 0 if list.head.nil?\n 1 + list_size(LinkedList.new(list.head.link))\nend",
"def length\r\n @list.length\r\n end",
"def length\n return @list.length\n end",
"def size\n\t\tif @head.next_node != nil\n\t\t\tn = 1\n\t\t\tnode = @head.next_node\n\t\t\twhile node.next_node != nil\n\t\t\t\tn += 1\n\t\t\t\tnode = node.next_node\n\t\t\tend\n\t\t\treturn n\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend",
"def get_length(head)\n return 0 if head.nil?\n length = 1\n tmp = head\n while tmp.next\n length += 1\n tmp = tmp.next\n end\n length\nend",
"def size()\n return nil if is_empty\n\n current = @head\n size = 0\n\n while current != nil\n size += 1\n current = current.next\n end\n\n return size\n end",
"def size\n @list_link.size\n end",
"def size\n @list_link.size\n end",
"def size\n i = 0\n current_node = @head\n while current_node != nil do\n current_node = current_node.next\n i += 1\n end\n return i\n end",
"def size\n return 0 if @head.nil?\n number_of_nodes = 0\n current_node = @head\n while !node.nil? do\n number_of_nodes += 1\n current_node = node.next\n end\n number_of_nodes\n end",
"def determine_length_support\n met_resp = analyze_head_support\n return 0 if met_resp[:node].nil?\n\n # Head is a dummy node, so there is one extra node than the values added to\n # the list\n #\n node, length = self.head.next_node, 0\n until node.nil?\n length += 1\n node = node.next_node\n end\n\n length\n end",
"def size\n count = 1\n current = @head\n while current.next?\n current = current.next_node\n count += 1\n end\n count\n end",
"def size\n i = 0\n node = @head\n while !(node.nil?)\n i += 1\n node = node.next_node\n end\n return i\n end",
"def size\n @count = @head == nil ? 0 : 1\n current_node = @head\n while current_node.next_node != nil\n @count += 1\n current_node = current_node.next_node\n end\n @count\n end",
"def size\n return 0 if @head.nil?\n\n quantity = 1\n node = @head\n until node.next_node.nil?\n quantity += 1\n node = node.next_node\n end\n\n quantity\n end",
"def size \n if @head == nil\n return 0\n elsif @head.next_node == nil\n return 1\n else \n count = 2\n node = @head.next_node\n while node.next_node != nil\n count += 1\n node = node.next_node\n end\n return count\n end \n end",
"def size\n if head == nil\n size = 0\n size\n else\n size = 1\n tmp = head\n while tmp.next_node != nil\n tmp = tmp.next_node\n size += 1\n end\n end\n size\n end",
"def size\n sz = 0\n curr = head\n until curr.nil?\n curr = curr.next\n sz += 1\n end\n sz\n end",
"def size\n if @head.nil?\n count = 0\n else\n count = 1\n current_node = @head\n until current_node.next_node.nil?\n current_node = current_node.next_node\n count += 1\n end\n end\n count\n end",
"def size\n count = 1\n node = @node\n\n while node.next\n count += 1\n node = node.next\n end\n\n count\n end",
"def size\n # return 0 if empty list\n if head.nil?\n return 0\n end\n current = @head\n elements = 1\n\n until current.next_node.nil?\n # loop thru list to end\n # increment\n elements += 1\n # advance to next node\n current = current.next_node\n end\n puts elements\n end",
"def length\n case @type\n when :data\n return 0 if self.empty?\n 1\n when :list\n @data[:list].length\n end\n end",
"def ll_size()\n return @num_nodes\n end",
"def size\n\t\t@node_amount = 1\n\t\t@current_node = @head\n\n\t\twhile @current_node != @tail\n\t\t\t@current_node = @current_node.next_node\n\t\t\t@node_amount += 1\n\t\tend\n\t\treturn @node_amount\n\tend",
"def size()\n\t\tif !@head\n\t\t\treturn 0\n\t\telse\n\t\t\tcount = 1;\n\t\t\tcurrentNode = @head\n\n\t\t\twhile currentNode.getNextNode() do\n\t\t\t\tcurrentNode = currentNode.getNextNode()\n\t\t\t\tcount = count + 1\n\t\t\tend\n\n\t\t\treturn count\n\t\tend\n\tend",
"def size\n if head.nil?\n return 0\n else\n count = 1 # remember, array with indexes 0,1,2,3 is size 4 !\n x = @head\n until x.next_node.nil? #problem alert\n count += 1\n x = x.next_node\n end\n\n return count\n end\n end",
"def size\n redis.llen list_id\n end",
"def size\n return 0 if @head.nil?\n\n n = 0\n self.each { n += 1}\n return n\n end",
"def size\n result, list = 0, self\n until list.empty?\n if list.cached_size?\n return result + list.size\n else\n result += 1\n end\n list = list.tail\n end\n result\n end",
"def size\n list.size\n end",
"def length\n @node[\"length\"]\n end",
"def size(node = @first_pointer)\n if node\n 1 + size(node.next)\n else\n 0\n end\n end",
"def size\n @lists.length\n end",
"def length(list)\n number(list.to_a.size)\n end",
"def size\n self.list.length\n end",
"def size\n @list.size\n end",
"def size\n @list.size\n end",
"def size\n head\n rounds = 1\n while !@current_node.next.nil? do\n self.next_node\n rounds += 1\n end\n rounds\n end",
"def length\n ArelExtensions::Nodes::Length.new [self]\n end",
"def length\n\t\t\t_entity.list.length if _entity.list\n\t\tend",
"def size\n count = 0\n node = @front\n\n while node\n count += 1\n node = node.next_node\n end\n\n count\n end",
"def length\n @length\n end",
"def length\n @length\n end",
"def length\n @length\n end",
"def length\n array_list.length\n end",
"def length\n if (!@name_links.exists)\n return 0\n end\n\n # @name_links.length will equal @remove_buttons.length so it doesn't matter\n # which length we return.\n return @name_links.length\n end",
"def length\n count\n end",
"def length()\n # If there are no items, return 0 for the length.\n if (!@tag.exists)\n return 0\n end\n\n # The number of items one less than the number of tags in the list.\n return @tag.length - 1\n end",
"def size\n return 0 if empty?\n count_node(head, 1)\nend",
"def length\n # If there are no items, return 0 for the length.\n if (!@tag.exists)\n return 0\n end\n\n # The number of items one less than the number of tags in the list.\n return @tag.length - 1\n end",
"def length; count end",
"def length\n @redis.llen @redis_name\n end",
"def length\n @count\n end",
"def length\r\n self.count\r\n end",
"def length\n size\n end",
"def length\n size\n end",
"def length\n @driver_instance.count_list_value(@key)\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 @length\n end",
"def length()\n obj_len = internal_object_length - 1\n return obj_len\n end",
"def count\n if @head.data == nil\n node_count = 0\n else\n node_count = 0\n node = @head\n until node.nil?\n node = node.next_node\n node_count += 1\n end\n end\n node_count\n end",
"def llen(key)\n node_for(key).llen(key)\n end",
"def length\n\t\t@length\n\tend",
"def size_list_entry\n Innodb::List::NODE_SIZE\n end",
"def count\r\n @internal_list.length\r\n end",
"def length\n @items.length\n end",
"def used_bytes\n size = 0\n unless empty?\n actual_node = @tail_node\n while actual_node != nil do\n size += actual_node.value.value.length\n actual_node = actual_node.next_node\n end\n end\n size\n end",
"def size(node = @head, count = 0)\n return count if node.nil?\n\n size(node.next_node, count + 1)\n end",
"def length\n end",
"def length\n each.count\n end",
"def length; end",
"def length; end",
"def length; end"
] | [
"0.89962983",
"0.8955834",
"0.8725703",
"0.8650639",
"0.86448807",
"0.86381394",
"0.85893565",
"0.85469913",
"0.85440654",
"0.8532601",
"0.8526588",
"0.8516422",
"0.849366",
"0.8490331",
"0.84609723",
"0.8437055",
"0.8402402",
"0.8385143",
"0.83397275",
"0.82935214",
"0.82833886",
"0.8259925",
"0.822993",
"0.8228065",
"0.8116953",
"0.8092372",
"0.7995902",
"0.79735786",
"0.793872",
"0.7929685",
"0.79240745",
"0.79231614",
"0.79231614",
"0.79025966",
"0.7866202",
"0.78404415",
"0.78055924",
"0.7788715",
"0.77810097",
"0.7752715",
"0.77482855",
"0.7745428",
"0.7693889",
"0.76599854",
"0.7653215",
"0.7597215",
"0.75193536",
"0.7513491",
"0.75091296",
"0.75031817",
"0.7446469",
"0.74145514",
"0.7379311",
"0.7347659",
"0.73403",
"0.73149633",
"0.7314941",
"0.7309839",
"0.7280266",
"0.72687066",
"0.7246339",
"0.7246339",
"0.72261226",
"0.72010726",
"0.71824557",
"0.7131701",
"0.71190083",
"0.71190083",
"0.71190083",
"0.7104371",
"0.71034014",
"0.7056789",
"0.7054345",
"0.7037861",
"0.6999551",
"0.6995628",
"0.696081",
"0.6946325",
"0.6935401",
"0.69284415",
"0.6917617",
"0.6917298",
"0.69087917",
"0.69087917",
"0.69087917",
"0.6899917",
"0.6897049",
"0.6871379",
"0.6862894",
"0.68358517",
"0.6814235",
"0.6809348",
"0.67954564",
"0.6781269",
"0.6778517",
"0.67739743",
"0.6773257",
"0.67672145",
"0.67672145",
"0.67672145"
] | 0.8568018 | 7 |
The unique name of this Dependency Manager. In general, the name should follow the `_ is the value of DependencyManagertype is the name of the dependency manager. | def name
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#name` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_for(dependency)\n dependency.name\n end",
"def name_for(dependency)\n dependency.name\n end",
"def name_for(dependency)\n dependency.name\n end",
"def manager_name\n manager.name\n end",
"def name()\n return self.manager.dictionary[self]\n end",
"def name_for(dependency)\n dependency.to_s\n end",
"def dependency_name\n name.to_s.sub(/_factory$/, '').to_sym\n end",
"def name\n @name ||= self.class.non_namespaced_name\n end",
"def name\n @name ||= self.to_s.demodulize.underscore\n end",
"def type_name\n @type_name ||= self.name.demodulize.underscore\n end",
"def name\n @name ||= self.class.name\n end",
"def manager_name\n self.manager.name\n end",
"def creator_class_name\n \"#{@clazz.name}Creator\"\n end",
"def type_name\n @type_name ||= name.underscore\n end",
"def my_name\n @my_name ||= self.class.name.split(\"::\").last\n end",
"def name\n @name ||= (@config[:name] || self.class.name.split(/::/).last.titleize)\n end",
"def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end",
"def name\n Properties[self.class] ||= {}\n return Properties[self.class][:name] || \"\"\n end",
"def display_name\n return name unless %w(maven gradle).include?(package_manager)\n name.split(\":\").last\n end",
"def name\n self.class.to_s.split('::').last\n end",
"def name\n underscore(self.class.name)\n end",
"def name\n self.class.simple_name\n end",
"def name_key\n return base_key + \".name\"\n end",
"def name\n (@name ||= namespace).to_s.underscore.symbolize\n end",
"def my_name \n @my_name ||= self.class.name.split(\"::\").last\n end",
"def name\n self.class.name\n end",
"def type_name\n self.class.name.split('::').last.upcase\n end",
"def name\n @dependency.name\n end",
"def name\n @dependency.name\n end",
"def getName()\n\t\t\treturn @_name\n\t\tend",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def name\n self.class.name.split(\"::\").last\n end",
"def name\n self.class.name.split('::').last\n end",
"def type_name\n @type_name ||= StringHelpers.underscore(StringHelpers.demodulize(@value.class.name)).to_sym\n end",
"def key\n self.class.name.split(/::/).last.underscore\n end",
"def name\n raise \"No name defined for #{self.class}\"\n end",
"def name\n self.class.name\n end",
"def name\n self.class.name\n end",
"def name\n self.class.name.split('::').last\n end",
"def serialized_name\n @serialized_name ||= to_s.demodulize.underscore\n end",
"def name\n return self.class.name.split('::').last\n end",
"def name\n self.class.name || self.class.to_s\n end",
"def unique_name(name)\n \"pedant_#{name}_#{pedant_suffix}\"\n end",
"def name\n self.class.name.demodulize.underscore\n end",
"def name\n self._id.to_s\n end",
"def name\n klass.name.split('::').last\n end",
"def __name\n @name\n end",
"def name\n\t\tself.class.name\n\tend",
"def name\n @name ||= Rails.application.class.parent_name.underscore\n end",
"def class_name\n (self.type.to_s || self.class.name).demodulize\n end",
"def base_name\n name\n end",
"def unique_name\n unique_name = @name\n unique_name += \" (#{@disambiguation})\" if @disambiguation\n return unique_name\n end",
"def name\n self.class.name.split(\"::\").last.downcase\n end",
"def mdl_name\n @hammock_cached_mdl_name ||= to_s.sub('Controller', '').singularize.underscore\n end",
"def key\n name = self.class.name.split(\"::\").last\n Util.underscore(name).to_sym\n end",
"def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end",
"def type_name\n MESSAGE_TYPE[self.type_id-1][0]\n end",
"def name\n return \"#{self.root.name} #{@type}\"\n end",
"def manager_id_with_name\n \"[#{manager_id}] #{name.to_s}\"\n end",
"def key\n key = self.name\n key = Economic::Support::String.demodulize(key)\n key = Economic::Support::String.underscore(key)\n key.intern\n end",
"def get_type_name(type)\n type_name = TypeName.new get_class_name(type), get_class_module_path(type), get_class_file_name(type), get_class_file_path(type)\n type_name.parent = make_parents get_class_module_path(type)\n type_name\n end",
"def name\n Properties[self.class] ||= {}\n return Properties[self.class][:name] || 'shell'\n end",
"def mdl_name\n self.class.mdl_name\n end",
"def name\n @module.name\n end",
"def gem_name\n \"#{@account}-#{@name}\"\n end",
"def name\n self.class.name.split('::').last\n end",
"def name\n @class_name\n end",
"def name\n internal_name\n end",
"def name\n NAME\n end",
"def unique_name\n return nil if ignoring_request?\n\n @unique_name ||= begin\n scope_layer = LayerConverters::FindLayerByType.new(self).scope\n if scope_layer\n scope_layer.legacy_metric_name\n else\n :unknown\n end\n end\n end",
"def class_name\n self.to_s.demodulize.underscore\n end",
"def my_short_name\n @my_short_name ||= self.class.name.split(\"_\").last\n end",
"def name\n @_name\n end",
"def model_name\n ::ActiveModel::Name.new(self, nil, ::ActiveSupport::Inflector.demodulize(self))\n end",
"def name\n @ruby_class.name\n end",
"def key\n name.underscore.tr('/', '_').to_sym\n end",
"def name\n # override this after inheriting\n # should return a string with no spaces\n # this is the name used to reference the validator in config files\n raise NotImplementedError\n end",
"def name\n @name ? @name.to_s : unique_id\n end",
"def transaction_name\n @module.split(\"::\").last.underscore.singularize\n end",
"def name\n @type_name\n end",
"def name\n\t\tmodule_info['Name']\n\tend",
"def full_item_type_name\n prefix = ''\n prefix = \"#{self.class.implementation_prefix.ns_underscore}__\" if self.class.implementation_prefix.present?\n\n \"#{prefix}#{implementation_model_name}\"\n end",
"def ident\n return \"#{self.owner}/#{self.name}\"\n end",
"def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end",
"def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end",
"def class_name\n self.class.to_s.split('::').last\n end",
"def generate_identifier\n self.identifier ||= self.name.parameterize.underscore\n end",
"def class_name\n @class_name ||= derive_class_name\n end",
"def unique_name\n \"#{project.name} / #{name}\"\n end",
"def unique_object_name_for(name)\n \"#{name}_#{SecureRandom.hex(5)}\"\n end",
"def name\n underscore const_name\n end",
"def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end",
"def service_key\n (is_a?(Module) ? name : self.class.name).demodulize.underscore.to_sym\n end",
"def readable_name\n \"(#{@type}) #{@name}\"\n end",
"def factory_name\n @factory_name ||= self.name.underscore.downcase\n end",
"def getName()\n return @name ;\n end",
"def unique_name_for(item)\n item.to_s\n end"
] | [
"0.68291986",
"0.68291986",
"0.68291986",
"0.66925323",
"0.6687717",
"0.6595005",
"0.65885156",
"0.65880954",
"0.6515661",
"0.6497887",
"0.6472964",
"0.6430907",
"0.63553137",
"0.6346615",
"0.63086575",
"0.630731",
"0.629868",
"0.62757766",
"0.6240983",
"0.62269354",
"0.6226874",
"0.61989313",
"0.6191052",
"0.6188897",
"0.6186839",
"0.61676395",
"0.6157323",
"0.6149219",
"0.6149219",
"0.6141304",
"0.6131106",
"0.6131106",
"0.6131106",
"0.6131106",
"0.6129717",
"0.6126534",
"0.6125814",
"0.6124089",
"0.61233157",
"0.6120854",
"0.6120854",
"0.6104578",
"0.60888",
"0.6086945",
"0.60836726",
"0.6081851",
"0.607933",
"0.60761",
"0.6068508",
"0.6062484",
"0.60508937",
"0.6045934",
"0.6043439",
"0.6021879",
"0.60142773",
"0.60140246",
"0.60091704",
"0.60073584",
"0.60017914",
"0.59884846",
"0.59881634",
"0.59841704",
"0.5973362",
"0.59636223",
"0.59622085",
"0.59474266",
"0.5933566",
"0.59248394",
"0.5916159",
"0.59037375",
"0.58970344",
"0.58787256",
"0.5877463",
"0.58715224",
"0.5854878",
"0.5847372",
"0.5844543",
"0.5842637",
"0.58270276",
"0.58147585",
"0.5809024",
"0.5806853",
"0.580281",
"0.57996166",
"0.5796621",
"0.5794585",
"0.5791624",
"0.5791624",
"0.5788344",
"0.57865286",
"0.57838666",
"0.576868",
"0.5762776",
"0.5762665",
"0.5761812",
"0.5761812",
"0.57572097",
"0.57511276",
"0.5749235",
"0.5746998"
] | 0.6398306 | 12 |
The "type" of dependencies this manager manages. This can be the language, tool, etc. | def type
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#type` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n @klass.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) ? \"class\" : \"module\"\n end",
"def type\n @type ||= self.class.name.split('::').last\n end",
"def dependency name, version, type = :runtime\n raise \"Unknown dependency type: #{type}\" unless\n [:runtime, :dev, :development, :developer].include? type\n\n ary = if type == :runtime then\n extra_deps\n else\n extra_dev_deps\n end\n\n ary << [name, version]\n end",
"def type\n type_and_version[0]\n end",
"def type\n types.first\n end",
"def type\n @type.name\n end",
"def type\n memoized_info[:type]\n end",
"def type\n @props[:type]\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n types.first\n end",
"def type_klass; end",
"def type; self.class.name.split('::').last.to_sym; end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self_class.to_s.to_sym\n end",
"def __type; @type == TYPE_BUILDING ? \"Building\" : \"Unit\"; end",
"def type\n self.class::TYPE\n end",
"def deploys_to_class(type)\n (\n \"Building::%s\" % CONFIG[\"units.#{type.underscore}.deploys_to\"]\n ).constantize\n end",
"def type\n\t\tself.class.type\n\tend",
"def type\n\t\tself.class.type\n\tend",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type\n end",
"def type\n @type ||= calculate_type\n end",
"def type\n TYPES[@type_id]\n end",
"def type\n read_attr :type, :to_sym\n end",
"def type\n @types ||= strip(:type)\n end",
"def type\n @config[:caching][:type]\n end",
"def type\n @type ||= File.extname(path)[1..-1]\n end",
"def type\n _type.split(\"::\").last.downcase\n end",
"def get_type\n\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n return @type\n end",
"def type\n object.class.name\n end",
"def type\n object.class.name\n end",
"def type\n object.class.name\n end",
"def type\n self.class.to_s.split('::').last.downcase.to_sym\n end",
"def rel_type\n getType().name()\n end",
"def type\n end",
"def name\n @dependency.name\n end",
"def name\n @dependency.name\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n self.class.type\n end",
"def type\n return @type if @type != \"unknown\"\n info\n @type\n end",
"def type\n self.class.name.split(':').last.downcase\n end",
"def type\n @type\n end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def klass\n type.to_s.classify.constantize\n end",
"def type\n @@type\n end",
"def type\n @@type\n end",
"def type\n Type.new(type_param).yard_type_string\n end",
"def _type\n self.class.to_s\n end",
"def type_definition_provider\n attributes.fetch(:typeDefinitionProvider)\n end",
"def dependencies\n manager.dependencies\n end",
"def type\n self.class.class_name.downcase\n end",
"def type\n munson.type\n end",
"def type\n @type ||= begin\n base_type = case\n when is_many?, is_many_ints?\n :multi\n when @associations.values.flatten.length > 1\n :string\n else\n translated_type_from_database\n end\n \n if base_type == :string && @crc\n base_type = :integer\n else\n @crc = false unless base_type == :multi && is_many_strings? && @crc\n end\n \n base_type\n end\n end",
"def type\n self.class\n end",
"def type\n declaration.type if declaration.respond_to? :type\n end",
"def type_class(type)\n TYPES[type]\n end",
"def pkg_manager\n @pkg_manager ||=\n DependencyLib.dependency_types.detect do |dt|\n dt.system_manager? @shell\n end\n end",
"def types\n configuration[:types]\n end",
"def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end",
"def type\n @type.to_s\n end",
"def type\n TYPES_BY_EXTENSION.fetch extension, :unknown\n end",
"def model_type\n @model_type\n end",
"def type\n return @options[:type] || DEF_TYPE\n end",
"def type_name\n @type_name ||= self.name.demodulize.underscore\n end",
"def type\n self.class.name.split(/#{NSEP}/).last.gsub(/Object$/, '').downcase.to_sym\n end",
"def model_type\n self.class.model_type\n end",
"def dependency_name\n name.to_s.sub(/_factory$/, '').to_sym\n end",
"def toolbox(type)\n end",
"def toolbox(type)\n end",
"def toolbox(type)\n end",
"def compute_type(type_name)\n type_name_with_module(type_name).split(\"::\").inject(Object) do |final_type, part| \n final_type = final_type.const_get(part)\n end\n end"
] | [
"0.6768606",
"0.64739126",
"0.64718497",
"0.6274962",
"0.61399627",
"0.61187696",
"0.608098",
"0.60559875",
"0.60549706",
"0.60549706",
"0.60549706",
"0.601348",
"0.6011569",
"0.59861875",
"0.59820884",
"0.59820884",
"0.59820884",
"0.59811634",
"0.59806734",
"0.5944626",
"0.5923362",
"0.5899092",
"0.5899092",
"0.5898636",
"0.5898636",
"0.5898636",
"0.5897629",
"0.5894587",
"0.5887393",
"0.588487",
"0.5849044",
"0.58481336",
"0.5847966",
"0.58440495",
"0.5829416",
"0.5814695",
"0.5814695",
"0.5814695",
"0.5814695",
"0.5814695",
"0.5814695",
"0.5814695",
"0.58087236",
"0.5795644",
"0.5795299",
"0.5795299",
"0.5785858",
"0.5777162",
"0.5767833",
"0.57383025",
"0.57383025",
"0.5728228",
"0.5728228",
"0.5728228",
"0.5711822",
"0.5710157",
"0.5688523",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.56837785",
"0.5677516",
"0.56756246",
"0.56756246",
"0.5668012",
"0.5651662",
"0.56504965",
"0.5637479",
"0.56329757",
"0.56318545",
"0.563108",
"0.56284213",
"0.5627016",
"0.56266445",
"0.56203634",
"0.56166315",
"0.5607672",
"0.5604778",
"0.5602767",
"0.55958295",
"0.55938566",
"0.5591866",
"0.55886674",
"0.5586165",
"0.5585521",
"0.5577646",
"0.5577646",
"0.5577646",
"0.5575975"
] | 0.7233944 | 0 |
A humanreadable description of the files/folders that indicate this dependency manager is in use. | def signature
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#signature` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe\n\t\t\"Shows the folder and files of the present working directory.\"\n\tend",
"def file_name_list\n @target.source_build_phase.file_display_names\n end",
"def fs_description\n repo_paths = root_paths || [ File.dirname(child_paths[\"cookbooks\"][0]) ]\n result = \"repository at #{repo_paths.join(\", \")}\"\n if versioned_cookbooks\n result << \" (Multiple versions per cookbook)\"\n else\n result << \" (One version per cookbook)\"\n end\n child_paths.each_pair do |name, paths|\n if paths.any? { |path| !repo_paths.include?(File.dirname(path)) }\n result << \" #{name} at #{paths.join(\", \")}\\n\"\n end\n end\n result\n end",
"def getInstalledFiles\n warning \"This dependency (#{@Name}) doesn't support getting file list for \" \\\n 'precompiled binary'\n false\n end",
"def fs_description\n repo_path = File.dirname(child_paths['cookbooks'][0])\n result = \"repository at #{repo_path}\\n\"\n if Chef::Config[:versioned_cookbooks]\n result << \" Multiple versions per cookbook\\n\"\n else\n result << \" One version per cookbook\\n\"\n end\n child_paths.each_pair do |name, paths|\n if paths.any? { |path| File.dirname(path) != repo_path }\n result << \" #{name} at #{paths.join(', ')}\\n\"\n end\n end\n result\n end",
"def human_readable_description\n \"GitLab Secure Files Storage [#{self.project_id}]\"\n end",
"def dir; end",
"def dir; end",
"def dir; end",
"def summary(recursive=false)\n failures = failures(recursive)\n successes = successes(recursive)\n newfiles = new_files(recursive)\n total = failures.size + successes.size + newfiles.size\n summary = \"#{@dir} #{recursive ? \" and sub-directories\" : \"\"} contains #{total} files: #{successes.size} stored, #{failures.size} failed, #{newfiles.size} new\"\n return summary \n end",
"def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end",
"def files\n files_equivs = \"\"\n @package.documents.each do |file|\n ActiveRecord::Base.logger.info(\"#{file.attach_file_name} #{file.install_path}\")\n files_equivs += \"#{file.attach_file_name} #{file.install_path}\\n\\t\"\n end\n files_equivs\n end",
"def output_files\n get_info :output_files\n end",
"def list_files\n fail('Requires implementation')\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def directories; end",
"def directories; end",
"def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end",
"def describe\n\t\t\"Show the present working directory.\"\n\tend",
"def print_tree_size()\n\t\tputs \"Total size for #{@folder_walker.folder} is #{commify(@folder_walker.total_size)}\"\n\tend",
"def watchable_dirs; end",
"def dirs; end",
"def dirs; end",
"def rc_dirs; end",
"def stat\n factory.system.dir_stat(@path)\n end",
"def path_info(opts)\n # file_names is implemented in each store.\n {\n file_names: file_names(opts),\n possible: possible_paths(opts),\n existing: existing_paths(opts)\n }\n end",
"def cmd_dirs_changed\n print_tree(DirsChangedEditor)\n end",
"def actual_path_length\n folders.count\n end",
"def modified_files\n `git diff --cached --name-only --diff-filter=ACM --ignore-submodules=all`.split \"\\n\"\n end",
"def dependency_list\n @target.dependencies.map(&:display_name)\n end",
"def previously_changed_files\n `git show --pretty=\"format:\" --name-only`.split(\"\\n\")\n end",
"def get_unknown_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-un', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"New files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def applicable_files; end",
"def show_folders\n\n w=WinReg.new(@file)\n w.debug=@debug\n\n FOLDER_DEFAULTS.each do |key|\n @location = w.read_key(FOLDERS_BASE+'\\\\'+key[:name])\n puts \"#{key[:name]} -> #{@location}\" if @verbose\n end\n end",
"def to_s\n\t\treturn self.valid_dirs.join( SEPARATOR )\n\tend",
"def git_modified_files_info()\n modified_files_info = Hash.new\n updated_files = (git.modified_files - git.deleted_files) + git.added_files\n updated_files.each {|file|\n modified_lines = git_modified_lines(file)\n modified_files_info[File.expand_path(file)] = modified_lines\n }\n modified_files_info\n end",
"def obsolete_files; end",
"def disk_usage_information\n super\n end",
"def info\n paths = bashify_note_paths(matching_notes(:all_if_empty => true))\n puts `wc $(find #{paths} -type f)` \n end",
"def inspect\n \"File: #{@name} #{@ext}\"\n end",
"def installed_spec_directories; end",
"def repository_display\n if ENV['EAD'].present?\n if File.directory?(Rails.root.join(ENV['EAD']))\n return ENV['EAD'].split(\"\\/\")[-1]\n else\n return ENV['EAD'].split(\"\\/\")[-2]\n end\n end\n end",
"def modified_files\n diff = git.diff(local_branch, remote_branch(local_branch))\n diff.stats[:files].keys\n end",
"def inspect\n \"#<HG Versioned File: #{to_s}>\"\n end",
"def misc_directory_file_count\n self.directory_listings.non_primary_data.map {|d| d.files.size}.reduce(0, :+)\n end",
"def dir_name\n @dir_name ||= select { |type,value| type == :dir_name }.map do |(type,value)|\n value\n end\n end",
"def measures_directory(osw)\n measures_dir = nil\n osw.measurePaths().each do |p|\n if p.has_relative_path()\n measures_dir = p\n break\n end\n end\n return OpenStudio::toString(osw.absoluteRootDir() / measures_dir)\nend",
"def status_prefix\n \" #{Logger.hierarchy execution_order}rakefile:#{@linenumber.to_s.bold} \"\n end",
"def dependencies\n manager.dependencies\n end",
"def inspect\n ((@name.nil?) ? \"Unnamed package\" : \"\\\"#{@name}\\\"\" )+\" (#{@links.length} links, #{@passwords.length} passwords)\"+((@comment == \"\") ? \"\" : \"\\n# #{@comment}\")\n end",
"def to_s\n \"#{@name} => Files: \\n\\t#{@files.join \"\\n\\t\"}\\n Subpackages:\n \\t#{@subpackages.keys.join \"\\n\\t\"}\"\n end",
"def folder_required\n @folder_required ||= folder_lib + 'required'\n end",
"def files_to_inspect\n @files_to_inspect ||= FileList.new(\n root: root,\n engine_config: engine_config,\n linter_config: linter_config\n )\n end",
"def os_dependencies\n []\n end",
"def display_files(pathname)\n # `find` doesn't follow symlinks, so we should instead\n realpath = ArduinoCI::Host.symlink?(pathname) ? ArduinoCI::Host.readlink(pathname) : pathname\n\n # suppress directories and dotfile-based things\n all_files = realpath.find.select(&:file?)\n non_hidden = all_files.reject { |path| file_is_hidden_somewhere?(path) }\n\n # print files with an indent\n puts \" Files (excluding hidden files): #{non_hidden.size}\"\n non_hidden.each { |p| puts \" #{p}\" }\nend",
"def LoadedProjectFiles\n @LoadedProjectFilesList\n end",
"def currently_changed_files\n `git status --porcelain`.split(\"\\n\").map{ |file| file.split.last }\n end",
"def stats_before_compil\n # Readme available?\n if File.exists?('readme.txt')\n @log_file.puts \"\\nLe fichier README existe !\\n\"\n @log_file.puts IO.read('readme.txt')\n end\n\n # Stats on files\n files_before_compil = Dir::entries('.') - ['.', '..', @results_file_dir]\n @log_file.puts \"\\nLe projet est composé des fichiers suivants :\"\n files_before_compil.each { |e| @log_file.puts \"\\t-#{e}\" }\n\n # Stats on number of lines\n nb_lines = `wc -l *.h *.c`\n @log_file.puts \"\\nStatistiques :\\n #{nb_lines}\"\n\n files_before_compil\n end",
"def name_on_disk\n self.class.library_directory_name(@name)\n end",
"def file_desc\n \"Files (#{file_ext(',')})\"\n end",
"def get_dir_name\n return @builder['dir_label'].text\n end",
"def pathBaseSummary()\n return \"#{@resultBaseDir}/#{getConf(:basenameSummary)}\" ;\n end",
"def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend",
"def dir\n @data['info']['name']\n end",
"def inspect\n \"#<#{self.class}: #{@cwd}>\"\n end",
"def inspect\n \"#<#{self.class}: #{@cwd}>\"\n end",
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def name\n\t\t\tself.nice_folder_name\n\t\tend",
"def workspace_info\n @dir + WORKSPACE_INFO_FILENAME\n end",
"def file_description\n @descriptive_detail.file_description\n end",
"def directories_to_watch\n []\n end",
"def dir_changed(baton)\n if baton[0]\n # The directory hasn't been printed yet,\n # so print it out.\n puts baton[1] + '/'\n\n # Make sure we don't print this directory out twice\n baton[0] = nil\n end\n end",
"def description()\r\n #out puts what the command is doing and the path it is taking to do it\r\n puts \"Creating a Directory: #{@DirectoryPath}\"\r\n end",
"def display_folders(options = {} )\n\n @@FOLDER.each do |f|\n if options[:folders]\n\n next unless File.directory?(f)\n\n end\n if options[:files]\n next unless File.file?(f)\n end\n if options[:fullpath]\n puts File.absolute_path(f)\n else\n puts f\n end\n end\n end",
"def info\n {\n root: File.expand_path(\"../../../../\", __FILE__)\n }\n end",
"def inspect\n #N Without this output, we won't know what class it belongs to or what the relative path and file content hash is\n return \"RelativePathWithHash[#{relativePath}, #{hash}]\"\n end",
"def defender_additional_guarded_folders\n return @defender_additional_guarded_folders\n end",
"def show_modified_files_coverage\n unless @project.nil?\n markdown modified_files_coverage_table\n end\n end",
"def directory\n @recently_added_tools = Tool.ordered_by(\"recently_added\").limit(5)\n end",
"def output_project_files_debugging\n\t\tself.prompt.say( \"Project files:\", color: :bright_green )\n\t\ttable = self.generate_project_files_table\n\t\tif table.empty?\n\t\t\tself.prompt.warn( \"None.\" )\n\t\telse\n\t\t\tself.prompt.say( table.render(:unicode, padding: [0,1]) )\n\t\tend\n\t\tself.prompt.say( \"\\n\" )\n\n\t\tself.prompt.say( \"Version from:\" )\n\t\tself.prompt.say( \" \" + self.version_from.to_s, color: :bold )\n\t\tself.prompt.say( \"\\n\" )\n\tend",
"def file_name\n 'unused'\n end",
"def file_dir # :nodoc:\n nil\n end",
"def infos_path\n\t@infos_path ||= File.join(main_folder, 'infos.yaml')\nend",
"def describe\n f = file!\n puts \"Current target: #{f.basename}\"\n puts '*' * 70\n File.open(f).each do |line|\n puts \" #{line}\"\n end\n puts '*' * 70\n end",
"def taken_paths\n if @target.exist?\n @target.children.select { |path| jobdir_name?(path.basename.to_s) }\n else\n []\n end\n end",
"def libraries_edit_display\n string = \"\"\n self.library.each do |l|\n string += \"#{l.branch_name}\\n \"\n end\n string\n end",
"def show_asset_files\n display_collection_of_folders_docs_tasks\n end",
"def files\n Hash(@config[:files]).keys\n end",
"def tracked_files; end",
"def showSizes(filename)\n if File.exists?(filename)\n puts(File.stat(filename).size)\n elsif File.directory?(filename)\n puts(Dir.entries(filename).select {|f| !File.directory? f}.size)\n end\nend",
"def file_list\n @file_list\n end",
"def measures_dir\n ''\n end",
"def tool_tip\n\t\treturn \"Delimited list of custodian and path of each duplicate of a given item.\"\n\tend",
"def packages\n FileList[package_path('.*')]\n end",
"def folder_name\n @folder_name\n end",
"def available_files\n @available_files ||= @json_searchers.keys.sort.join(\"\\n \").brown\n end",
"def check_dep_path(pkg)\n path = dep_path(pkg[:name])\n if File.directory?(path)\n return [path, []]\n else\n return [path, [\"Not installed by `mix deps.get` in deps/\"]]\n end\n end",
"def to_s\n if (altered_files + status[:deleted]).any?\n then parents.first.to_s + \"+\"\n else parents.first.to_s\n end\n end",
"def inspect\n File.basename @__path\n end"
] | [
"0.6525566",
"0.64706236",
"0.62717277",
"0.6154704",
"0.5927859",
"0.5830693",
"0.58079696",
"0.58079696",
"0.58079696",
"0.5676699",
"0.5674685",
"0.5625328",
"0.56200796",
"0.5604361",
"0.559843",
"0.5549027",
"0.5549027",
"0.5543946",
"0.55379945",
"0.5514648",
"0.54611963",
"0.5438204",
"0.5438204",
"0.54134494",
"0.54047436",
"0.5387456",
"0.53842914",
"0.53821784",
"0.53816336",
"0.53620017",
"0.5351328",
"0.5349935",
"0.5348635",
"0.5348635",
"0.5337612",
"0.53373647",
"0.53262323",
"0.53187287",
"0.52717483",
"0.5269338",
"0.5263028",
"0.525484",
"0.52499",
"0.52469116",
"0.52467924",
"0.52282125",
"0.5226011",
"0.52185506",
"0.52090746",
"0.5207983",
"0.5205003",
"0.519131",
"0.51878977",
"0.5187546",
"0.5167747",
"0.51654583",
"0.51637524",
"0.5162003",
"0.5161999",
"0.51578885",
"0.51510525",
"0.5136952",
"0.51338637",
"0.5133765",
"0.5131656",
"0.512847",
"0.5127509",
"0.5127509",
"0.51242554",
"0.51184124",
"0.51170635",
"0.51163757",
"0.5113707",
"0.5110312",
"0.5107662",
"0.5104869",
"0.5102969",
"0.51007116",
"0.51007056",
"0.509934",
"0.50955456",
"0.50901026",
"0.50879467",
"0.50874805",
"0.50863534",
"0.50863427",
"0.5085709",
"0.50850075",
"0.5079856",
"0.50793207",
"0.50721717",
"0.5067126",
"0.50659955",
"0.50636095",
"0.5063144",
"0.504886",
"0.504756",
"0.5044153",
"0.50419337",
"0.5037248",
"0.5029156"
] | 0.0 | -1 |
Whether or not we were able to detect that this dependency manager is currently in use in our directory | def detected?
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#detected?` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies_satisfied?\n missing_dependencies.empty?\n end",
"def dependency_met?\n true\n end",
"def dependencies_resolved?\n !@resolved_dependencies.nil?\n end",
"def exist?\n ruby_gems_fetcher.started?\n end",
"def dependencies_met?\n @dependencies_met ||= command_dependencies_met?(command_options)\n end",
"def has_dependencies?\n update_for.length > 0 or requires.length > 0\n end",
"def candidates_exist_for_all_uninstalled?\n packages_missing_candidates.empty?\n end",
"def package_manager\n false\n end",
"def still_used?(target, deleted: nil)\n modified_tree = @tree.tree.clone\n modified_tree.delete(deleted)\n\n deps_to_check = (@top_level - [Gem::Dependency.new(deleted)])\n\n while !deps_to_check.empty? do\n candidate = deps_to_check.pop.name\n\n next if candidate == deleted\n next if candidate == \"bundler\"\n return true if candidate == target\n\n if modified_tree[candidate].nil?\n warn_of_bad_tracing(candidate)\n else\n deps_to_check += modified_tree[candidate].dependencies\n end\n end\n\n false\n end",
"def installed?\n return prefix.children.length > 0\n rescue\n return false\n end",
"def is_dependencies_installed?\n is_pkgs = @ssh.do_ssh_cmd('which puppet && which git')\n if is_pkgs[:exit_code] != 0\n abort 'Please install git and puppet on the targeted node'\n end\n true\n end",
"def candidates_exist_for_all_forced_changes?\n forced_packages_missing_candidates.empty?\n end",
"def dependencies_have_failed?\n return @dependencies_have_failed unless @dependencies_have_failed.nil?\n failed = select do |task|\n task.failed?\n end\n debug \"Found failed dependencies: #{failed.map { |t| t.name }.join ', '}\" if failed.any?\n @dependencies_have_failed = failed.any?\n end",
"def require_manager_name?\n !!(self.registered_download.require_manager_name?)\n end",
"def installed?\n false\n end",
"def needed?\n topology.packages.length > 1\n end",
"def has_conflicts?\n return true unless Gem.env_requirement(name).satisfied_by?(version)\n self.dependencies.any? do |dep|\n if dep.runtime?\n spec = Gem.loaded_specs[dep.name]\n spec and not spec.satisfies_requirement? dep\n else\n false\n end\n end\n end",
"def incomplete_install?\n builtin_module_list = %w[aggregate canary puppetdb_fact secure_env_vars puppet_connect]\n (Dir.children(Bolt::Config::Modulepath::MODULES_PATH) - builtin_module_list).empty?\n end",
"def dep_defined?\n @dep_defined\n end",
"def is_dependency_installed?\n if self.dependable\n $db.services.each do |service|\n if service[:service_type] == self.type\n return true\n end\n end\n end\n false\n end",
"def installed?\n (dir = installed_prefix).directory? && dir.children.length > 0\n end",
"def dependencies_installed?(database)\n dependencies.all?{|_, d| d.installed?(database)}\n end",
"def installed?\n self.class.installed?(@repo)\n end",
"def has_dependency?\n return true unless @dependency.nil?\n end",
"def trackable?\n begin\n package_branch.version_tracker.looks_good?\n rescue NoMethodError\n false\n end\n end",
"def getInstalledFiles\n warning \"This dependency (#{@Name}) doesn't support getting file list for \" \\\n 'precompiled binary'\n false\n end",
"def has_dependency?(dependency)\n !find(dependency).nil?\n end",
"def check_system_python\n @candidate_pythons = lookup_local_pythons\n return 0 != @candidate_pythons.length\n end",
"def dependencies_installed?(builder)\n warn_if_gif2webp_missing builder\n cwebp_installed? builder\n end",
"def installable?\n uninstallable_reasons.empty?\n end",
"def outdated?\n\t\t\t# Existing directories are never outdated\n\t\t\t!built?\n\t\tend",
"def warnings?\n !gem?(\"shelly-dependencies\")\n end",
"def installed?\n !IO.popen(\"which #{self}\"){|i| i.read}.empty?\n end",
"def used?\n zombie_check\n m = Metadata.new(@repo.branch(@repo.current_branch))\n return m.has_pod?(@name)\n end",
"def installed?\n File.exists?(@path)\n end",
"def deps_satisfied?(deps)\n deps.each do |dep|\n if dep.to_s =~ /^no_(.*)$/\n return false if @used_legos.include?( $1 )\n else\n return false unless @used_legos.include?( dep.to_s )\n end\n end\n\n true\nend",
"def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend",
"def alive?\n !@native_manager.nil?\n end",
"def validate_dependencies_are_present!\n if @podfile_dependency_cache.target_definition_list.all?(&:empty?)\n add_warning 'The Podfile does not contain any dependencies.'\n end\n end",
"def folder_reachable?\n Dir.exists? folder_path\n end",
"def gem_only_available?()\n return !determine_common_folder() && is_dtk_common_core_gem_installed?\nend",
"def meets_requirements?\n if dirname = Micro.installed_gem_dirnames(name).last\n Gem::Version.from_gem_dirname(dirname) >= @version_requirements.version\n end\n end",
"def managed?(component)\n File.directory?(File.join(freezer_dir, component)) || in_submodule?(component)\n end",
"def installed?\n ::File.exist?(PATH)\n end",
"def node_modules?\n !!name.match(/node_modules\\//)\n end",
"def system_load_ok?\n true\n end",
"def satisfied?\n dependencies.none? { |_, v| v.empty? }\n end",
"def installed?\n !!@installed\n end",
"def installed?\n results = target_files.map {|f| is_my_file?(f) }\n return false if results.include? false\n return true\n end",
"def config_tool_needed?\n false\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def bundler_installed?\n\t`(gem spec bundler -v > /dev/null 2>&1)`\n end",
"def running?\n File.exist?(@lock_file)\n end",
"def dependencies_are_ready?\n return @dependencies_are_ready unless @dependencies_are_ready.nil?\n return false if @dependencies_have_failed\n ready = all? do |task|\n task.successful? or task.skipped?\n end\n debug 'All dependencies are ready' if ready\n @dependencies_are_ready = ready\n end",
"def failed?\n status == :failed or dependencies_have_failed?\n end",
"def running?\n !!managers\n end",
"def fresh?(environment)\n # Check freshness of all declared dependencies\n @dependency_paths.all? { |dep| dependency_fresh?(environment, dep) }\n end",
"def dependencies_satisfied?(deps)\n deps.all? do |dep|\n depprop = Proposal.where(barclamp: dep[\"barclamp\"], name: dep[\"inst\"]).first\n depprop_queued = depprop[\"deployment\"][dep[\"barclamp\"]][\"crowbar-queued\"] rescue false\n depprop_deployed = (depprop[\"deployment\"][dep[\"barclamp\"]][\"crowbar-status\"] == \"success\") rescue false\n\n depprop && !depprop_queued && depprop_deployed\n end\n end",
"def IncompleteInstallationDetected(mounted_to)\n # by default, installation is complete\n ret = false\n\n Builtins.foreach([Installation.run_yast_at_boot]) do |check_this|\n check_this = Builtins.sformat(\"%1/%2\", mounted_to, check_this)\n if FileUtils.Exists(check_this) == true\n Builtins.y2milestone(\n \"File %1 exists, installation is incomplete\",\n check_this\n )\n ret = true\n raise Break\n end\n end\n\n ret\n end",
"def up_to_date?(outputdir)\n f = effective_output_path(outputdir)\n Puppet::FileSystem::exist?(f) && (Puppet::FileSystem::stat(@path) <=> Puppet::FileSystem::stat(f)) <= 0\n end",
"def has_remote_package_sets?\n each_remote_package_set.any? { true }\n end",
"def installed?\n !installed_version.nil?\n end",
"def ok?\n @specs.all? do |spec|\n spec.runtime_dependencies.all? do |dep|\n @specs.find { |s| s.satisfies_requirement? dep }\n end\n end\n end",
"def is_running?\n omnibus_helper = OmnibusHelper.new(node)\n omnibus_helper.service_up?(service_name) || (delegated? && omnibus_helper.service_up?(delegate_service_name) && is_ready?)\n end",
"def fresh?(environment)\n # Check freshness of all declared dependencies\n @dependency_paths.all? do |dep|\n dep.digest == environment.file_hexdigest(dep.pathname.to_s)\n end\n end",
"def usable_repository?\n repository_cache.directory? &&\n run_and_output(\"#{git} remote -v | grep origin\").include?(uri)\n end",
"def gemspec?\n !gemspecs.empty?\n end",
"def ri_installed?\n File.exist? @ri_dir\n end",
"def ri_installed?\n File.exist? @ri_dir\n end",
"def scoped?\n @scope_block.present? || enabled_dependencies.any? { |d| dependency_scoped?(d) }\n end",
"def ready?\n File.exist?(desktop_path) && \n File.directory?(libs_path)\n end",
"def available\n return unless Node.source.eql?(:asset)\n\n errors.add(:dependency_not_found, name) unless TTY::Which.exist?(name)\n end",
"def has_windows_gemfile_lock?\n return true unless @has_gemfile\n super\n end",
"def local_valid_repo?\n @local_dir_path.directory?\n end",
"def dependencies_satisfied?(klass)\n plugin_keys = klass.included_plugins.map { |plugin| Plugins.lookup_name(plugin) }\n (dependencies.keys - plugin_keys).none?\n end",
"def allow_missing?(dependency)\n false\n end",
"def pkg_manager\n @pkg_manager ||=\n DependencyLib.dependency_types.detect do |dt|\n dt.system_manager? @shell\n end\n end",
"def warnings?\n !gem?(\"shelly-dependencies\") || gem?(\"shelly\")\n end",
"def ready?\n pending? and not dependencies_have_failed? and dependencies_are_ready? and concurrency_available?\n end",
"def installed?\n path.exist? || path.symlink?\n end",
"def check_for_libraries; end",
"def check_dependents \r\n self.class.send(:dependent_tables).each{|sym_dependent_table|\r\n raise LookupItemInUseException.new if self.send(sym_dependent_table).size > 0\r\n }\r\n end",
"def resolve_dependency(_completed_operation)\n true\n end",
"def ok?\n @specs.all? { |spec|\n\tspec.dependencies.all? { |dep|\n\t @specs.find { |s| s.satisfies_requirement?(dep) }\n\t}\n }\n end",
"def need_backup_setup?\n backup_sources.active.empty?\n end",
"def session_has_services_depend?\n\t\tbegin\n\t\t\treturn !!(session.sys.registry and session.railgun)\n\t\trescue NoMethodError\n\t\t\treturn false\n\t\tend\n\tend",
"def needed?\n return true if snapshot? && File.exist?(name) && (update_snapshot? || old?)\n super\n end",
"def lkrg_installed?\n cmd_exec('test -d /proc/sys/lkrg && echo true').to_s.strip.include? 'true'\n rescue\n raise 'Could not determine LKRG status'\n end",
"def prefer_indep_over_os_packages?; @prefer_indep_over_os_packages end",
"def dependency_backward_any?\n backward_dependencies.any?\n end",
"def module_loaded?\n /^#{new_resource.modname}/.match?(::File.read(\"/proc/modules\"))\n end",
"def installed?\n revision && install_path.exist?\n end",
"def dependent?\n @flags.include?(:dependent)\n end",
"def depends_on?(node)\n dependency_list = []\n @dependencies.each do |d|\n dependency_list << d if node.run_list.include? d\n end\n [dependency_list.any?, dependency_list]\n end",
"def systemd?\n false\n end",
"def environment?\n dir?('.bundle') || dir?('.virtualenv') || dir?('node_modules')\n end",
"def installed?\n source_api.number_of_units.positive? && positive_availability?\n end",
"def gem_listed?(gem)\n lockfile_specs.map(&:name).include? gem\n end",
"def check_for_executable; end"
] | [
"0.687721",
"0.6756084",
"0.6721105",
"0.66868156",
"0.66477644",
"0.66351885",
"0.66005546",
"0.65266544",
"0.65060323",
"0.64795166",
"0.6398061",
"0.6378547",
"0.63436997",
"0.6313732",
"0.6296466",
"0.6296143",
"0.62767833",
"0.62705517",
"0.62301517",
"0.62250626",
"0.6214667",
"0.62005544",
"0.61940074",
"0.6190171",
"0.6176047",
"0.6174238",
"0.6172967",
"0.61683434",
"0.6163565",
"0.6156501",
"0.6150374",
"0.6107448",
"0.60748124",
"0.6043948",
"0.60088724",
"0.6004103",
"0.59916735",
"0.59873575",
"0.5985538",
"0.59753376",
"0.5962395",
"0.59613895",
"0.59578955",
"0.5951945",
"0.5946808",
"0.5940291",
"0.5935643",
"0.5928427",
"0.5924008",
"0.59163606",
"0.5908274",
"0.5908274",
"0.5908274",
"0.59065384",
"0.5902909",
"0.58923465",
"0.587598",
"0.5870612",
"0.5868464",
"0.58659554",
"0.58649606",
"0.5859119",
"0.5857425",
"0.58572453",
"0.58531696",
"0.5835397",
"0.5835075",
"0.58338505",
"0.5828634",
"0.5828634",
"0.58248055",
"0.58209634",
"0.58188236",
"0.5813175",
"0.5808746",
"0.58077234",
"0.5805782",
"0.57961583",
"0.57913077",
"0.57902986",
"0.5785751",
"0.5783753",
"0.57793057",
"0.5767029",
"0.57616264",
"0.57582635",
"0.5741716",
"0.5740789",
"0.5738282",
"0.57349753",
"0.5724042",
"0.5719575",
"0.5716148",
"0.5715975",
"0.571138",
"0.57055855",
"0.57053447",
"0.5701744",
"0.56990945",
"0.5697166"
] | 0.61650556 | 28 |
The command to run to install dependency if one or more is missing | def install_command
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#install_command` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_requirement(requirement)\n if paths_for_extconf = Creosote::Package.installed(requirement, :default_only => true)\n puts \"requirement #{requirement} is already installed at #{paths_for_extconf.inspect}.\"\n paths_for_extconf = [paths_for_extconf].flatten\n add_extconf_args_for requirement, paths_for_extconf\n else\n puts \"requirement #{requirement} is not yet installed. Installing...\"\n paths_for_extconf = Creosote::Package.install(requirement, :default => true)\n paths_for_extconf = [paths_for_extconf].flatten\n add_extconf_args_for requirement, paths_for_extconf\n end\n end",
"def require_dependency_with_check(dependency)\n begin\n require dependency\n rescue LoadError => e\n puts \"You need to install #{dependency} before we can proceed\"\n end\nend",
"def install_dependencies\n raise 'Not implemented'\n end",
"def install_dep(name, version, install_dir = nil)\n install_dir ||= '/etc/puppet/modules'\n \"mkdir -p #{install_dir} && (puppet module list | grep #{name}) || puppet module install -v #{version} #{name}\"\nend",
"def install_dependencies\n\t\tself.prompt.say \"Installing dependencies\"\n\t\truby '-S', 'gem', 'i', '-Ng'\n\tend",
"def add_always_install(dependency)\n request = Gem::Resolver::DependencyRequest.new dependency, nil\n\n found = find_all request\n\n found.delete_if do |s|\n s.version.prerelease? and not s.local?\n end unless dependency.prerelease?\n\n found = found.select do |s|\n Gem::Source::SpecificFile === s.source or\n Gem::Platform::RUBY == s.platform or\n Gem::Platform.local === s.platform\n end\n\n found = found.sort_by do |s|\n [s.version, Gem::Platform.sort_priority(s.platform)]\n end\n\n newest = found.last\n\n unless newest\n exc = Gem::UnsatisfiableDependencyError.new request\n exc.errors = errors\n\n raise exc\n end\n\n unless @force\n found_matching_metadata = found.reverse.find do |spec|\n metadata_satisfied?(spec)\n end\n\n if found_matching_metadata.nil?\n ensure_required_ruby_version_met(newest.spec)\n ensure_required_rubygems_version_met(newest.spec)\n else\n newest = found_matching_metadata\n end\n end\n\n @always_install << newest.spec\n end",
"def install_command\n if (RUBY_PLATFORM =~ /linux/ or RUBY_PLATFORM =~ /darwin/) and Process.uid != 0\n cmd = \"sudo gem install\"\n $gems_missing.each do |current_gem|\n cmd = cmd + \" #{current_gem}\"\n end\n if $gems_missing_version.length != 0\n $gems_missing_version.each do |current_gem|\n if cmd == \"sudo gem install\"\n cmd = cmd + \" #{current_gem}\"\n else\n cmd = cmd + \" && sudo gem install #{current_gem}\"\n end\n end\n end\n else\n cmd = \"gem install\"\n $gems_missing.each do |current_gem|\n cmd = cmd + \" #{current_gem}\"\n end\n if $gems_missing_version.length != 0\n $gems_missing_version.each do |current_gem|\n if cmd == \"gem install\"\n cmd = cmd + \" #{current_gem}\"\n else\n cmd = cmd + \" & gem install #{current_gem}\"\n end\n end\n end\n end\n cmd = cmd.delete \",\" \"'\"\n cmd = cmd.gsub(\"=\", \"-v\")\n return cmd\nend",
"def build_dependency\n npm_install\nend",
"def install_command\n command = ['helm', 'upgrade', name, chart] +\n install_flag +\n reset_values_flag +\n optional_tls_flags +\n optional_version_flag +\n rbac_create_flag +\n namespace_flag +\n value_flag\n\n command.shelljoin\n end",
"def install_build_dependencies(build_dependencies) # rubocop:disable Metrics/AbcSize\n http = []\n pkgutil = []\n noasks = [\"instance=overwrite\", \"partial=nocheck\", \"runlevel=nocheck\", \"idepend=nocheck\", \"rdepend=nocheck\", \"space=nocheck\", \"setuid=nocheck\", \"conflict=nocheck\", \"action=nocheck\", \"basedir=default\"]\n noask_command = noasks.map { |noask| \"echo '#{noask}' >> /var/tmp/noask\" }.join('; ')\n\n build_dependencies.each do |build_dependency|\n if build_dependency =~ /^http.*\\.gz/\n # Fetch, unpack, install...this assumes curl is present.\n package = build_dependency.sub(/^http.*\\//, '')\n http << \"tmpdir=$(#{mktemp}); (cd ${tmpdir} && curl --silent --show-error --fail -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)\"\n else\n # Opencsw dependencies. At this point we assume that pkgutil is installed.\n pkgutil << build_dependency\n end\n end\n\n command = ''\n unless pkgutil.empty?\n command << \"/opt/csw/bin/pkgutil -y -i #{pkgutil.join(\"\\s\")}; \"\n end\n\n unless http.empty?\n command << \"echo -n > /var/tmp/noask; #{noask_command}; \"\n command << http.join('; ')\n end\n\n command\n end",
"def install_command\n return \"brew install\" if in_path?(:brew)\n return \"sudo apt-get install\" if in_path?(\"apt-get\")\n return \"sudo yum install\" if in_path?(\"yum\")\n end",
"def install\n result = @dependency_manager.install_dependencies\n if @dependency_manager.should_install?('libvirt')\n result = result.and_then { install_vagrant_plugins }\n .and_then { create_libvirt_pool }\n .and_then { export_libvirt_default_uri }\n end\n if @dependency_manager.should_install?('terraform')\n result = result.and_then { install_terraform }\n end\n if result.error?\n @ui.error(result.error)\n else\n @ui.info('Dependencies successfully installed.')\n @ui.info('Please restart your computer in order to apply changes.')\n end\n result\n end",
"def dist_install_s( *args )\n if args.last.is_a?( Hash )\n args = args.dup\n opts = args.pop\n else\n opts = {}\n end\n\n args = dist_map_packages( args )\n\n if opts[ :succeed ]\n \"yum install -q -y #{args.join ' '} || true\"\n else\n \"yum install -q -y #{args.join ' '}\"\n end\n end",
"def install_dependencies\n\n # sudo apt-get install postgresql-client libpq5 libpq-dev\n # sudo apt-get install ruby1.9-dev\n # sudo apt-get install make\n \n # Install the pg gem\n puts \"> Installing the pg gem\".green\n system \"gem install pg\" unless $simulate\n \n # Install the nokogiri gem\n puts \"> Installing the nokogiri gem\".green\n system \"gem install nokogiri\" unless $simulate\n\nend",
"def install_command\n cmd = \"#{top.sudo} bash\"\n cmd += \" -s -- -v #{required_version}\" unless required_version.nil?\n cmd\n end",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n args << pipproxyarg\n lazy_pip *args\n end",
"def required(gem_name, gem_install_name = nil)\n Required::required gem_name, gem_install_name\nend",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n lazy_pip *args\n end",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n lazy_pip *args\n end",
"def install_gem; end",
"def install_gems\n puts \"[Checking for missing required gems]\"\n while (gemspecs = get_requirements).any?\n gemspecs.each do |gemspec|\n install_gem(gemspec)\n end\n end\n end",
"def package_if_necessary(pkg)\n if !package_is_installed?(pkg)\n banner \"#{pkg}...\"\n run \"apt-get -y install #{pkg}\"\n end\n end",
"def install(confirmation_needed = true)\n self.class.install(@repo,confirmation_needed)\n end",
"def apt_install(pkg, check=false)\n if check && pkg_installed?(pkg)\n info %{Package \"#{pkg}\" is already installed, skipping.}\n else\n run %{apt-get install -y #{pkg}}\n end\nend",
"def install\n self.run_preseed if @resource[:responsefile]\n should = @resource[:ensure]\n\n checkforcdrom\n cmd = %w{-q -y}\n\n keep = \"\"\n if config = @resource[:configfiles]\n if config == :keep\n cmd << \"-o\" << 'DPkg::Options::=--force-confold'\n else\n cmd << \"-o\" << 'DPkg::Options::=--force-confnew'\n end\n end\n\n str = @resource[:name]\n case should\n when true, false, Symbol\n # pass\n else\n # Add the package version and --force-yes option\n str += \"=#{should}\"\n cmd << \"--force-yes\"\n end\n\n cmd << :install << str\n\n aptget(*cmd)\n end",
"def install_one_of_packages host, packages\n error = nil\n packages.each do |pkg|\n begin\n return host.install_package pkg\n rescue Beaker::Host::CommandFailure => e\n error = e\n end\n end\n raise error\n end",
"def install_dependencies(dependencies, force, install_dir)\n return if @options[:ignore_dependencies]\n installed_gems = []\n dependencies.each do |dependency|\n if @options[:include_dependencies] ||\n\t ask_yes_no(\"Install required dependency #{dependency.name}?\", true)\n remote_installer = RemoteInstaller.new(@options)\n installed_gems << remote_installer.install(\n\t dependency.name,\n\t dependency.version_requirements,\n\t force,\n\t install_dir)\n else\n raise DependencyError.new(\"Required dependency #{dependency.name} not installed\")\n end\n end\n installed_gems\n end",
"def install\n should = @resource.should(:ensure)\n self.debug \"Ensuring => #{should}\"\n wanted = @resource[:name]\n\n # XXX: We don't actually deal with epochs here.\n case should\n when true, false, Symbol\n # pass\n else\n # Add the package version\n wanted += \"-#{should}\"\n end\n output = rug \"--quiet\", :install, \"-y\", wanted\n\n unless self.query\n raise Puppet::ExecutionFailure.new(\n \"Could not find package #{self.name}\"\n )\n end\n end",
"def install\n command = resource_or_provider_command\n self.class.validate_command(command)\n\n command_options = get_install_command_options\n execute([command, command_options])\n end",
"def install\n install_gems(dependencies)\n end",
"def autoinstall(*packages)\n all_packages_installed = packages.all? { |pkg| Path.which pkg }\n\n unless all_packages_installed\n cmd([\"sudo apt-get install ?\", packages.join(' ')])\n end\nend",
"def ensure_gem_installed(g)\n unless Gem.available? g\n run \"sudo gem install #{g}\"\n end\nend",
"def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end",
"def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend",
"def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend",
"def fetch_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-v' : '-q')}\"\n end",
"def install\n should = @resource.should(:ensure)\n self.debug \"Ensuring => #{should}\"\n wanted = @resource[:name]\n\n # XXX: We don't actually deal with epochs here.\n case should\n when true, false, Symbol\n # pass\n else\n # Add the package version\n wanted = \"#{wanted}-#{should}\"\n end\n\n #This has been tested with following zypper versions\n #SLE 10.2: 0.6.104\n #SLE 11.0: 1.0.8\n #OpenSuse 10.2: 0.6.13\n #OpenSuse 11.2: 1.2.8\n #Assume that this will work on newer zypper versions\n\n #extract version numbers and convert to integers\n major, minor, patch = zypper_version.scan(/\\d+/).map{ |x| x.to_i }\n self.debug \"Detected zypper version #{major}.#{minor}.#{patch}\"\n\n #zypper version < 1.0 does not support --quiet flag\n quiet = \"--quiet\"\n if major < 1\n quiet = \"--terse\"\n end\n\n license = \"--auto-agree-with-licenses\"\n noconfirm = \"--no-confirm\"\n\n #zypper 0.6.13 (OpenSuSE 10.2) does not support auto agree with licenses\n if major < 1 and minor <= 6 and patch <= 13\n zypper quiet, :install, noconfirm, wanted\n else\n zypper quiet, :install, license, noconfirm, wanted\n end\n\n unless self.query\n raise Puppet::ExecutionFailure.new(\n \"Could not find package #{self.name}\"\n )\n end\n end",
"def execute_installation\n #start logging\n set_log_file @options[:log]\n \n download_and_decompress(@options[:prefix], [REDIS_URL, SQLITE3_URL, NGINX_URL])\n \n install_redis if @options[:redis]\n install_sqlite\n configure_nginx @options\n\n install_all_gems\n install_rhoconnect\n \n #remove downloaded tarballs\n cleanup options[:prefix]\n end",
"def run_if_installed(output = true, &blk)\n return yield if Config.installed?\n inform \"You need to run `dotify setup` before you can run this task.\" if output\n end",
"def install\n # nothing to do\n end",
"def install_brew_pkg(options,pkg_name)\n pkg_status = check_brew_pkg(options,pkg_name)\n if pkg_status.match(/Not installed/)\n message = \"Information:\\tInstalling Package \"+pkg_name\n command = \"brew install #{pkg_name}\"\n execute_command(options,message,command)\n end\n return\nend",
"def install_deps(*deps)\n return unless Sunshine.auto_dependencies?\n\n options = {:call => @shell, :prefer => pkg_manager}\n options.merge! deps.delete_at(-1) if Hash === deps.last\n\n args = deps << options\n Sunshine.dependencies.install(*args)\n end",
"def core_fetch_dependency(package_name, vers, type, verbose)\n prerelease = false\n if vers == '>= 0-pre'\n prerelease = true\n vers = '>= 0'\n else\n prerelease = vers =~ /[a-zA-Z]/\n end\n\n dep = LibGems::Dependency.new(package_name, vers, type)\n cur_installed = LibGems.source_index.search(dep)\n\n begin\n installed = BPM::Remote.new.install(package_name, vers, prerelease)\n rescue LibGems::GemNotFoundException\n # If we have it locally but not remote, that's ok\n installed = []\n end\n\n cur_installed.each do |ci|\n installed.reject! { |i| ci.name == i.name && ci.version == i.version }\n end\n\n installed.each do |i|\n say \"~ Fetched #{i.name} (#{i.version}) from remote\"\n end\n\n end",
"def test_bad_chicken_deps\n check_deps_fail BadChickenBall unless `/usr/bin/which csc`.chomp.empty?\n end",
"def dependency_met?\n true\n end",
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n puts \"[*] - esearchy requires #{name}.\"\n if RUBY_PLATFORM =~ /mingw|mswin/\n \tsystem \"gem install #{name}\"\n else\n \tsystem \"sudo gem install #{name}\"\n end\nend",
"def pkg_cmd; \"#{pkg_binary}\" end",
"def install(verbose = false)\n title = ctx.message(\"core.php_deps.installing\")\n success = ctx.message(\"core.php_deps.installed\")\n failure = ctx.message(\"core.php_deps.error.install_error\")\n\n CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do\n composer(verbose)\n end\n end",
"def pip_install(file, target)\n Rake::FileUtilsExt.sh(\n \"pip install --requirement=#{file} --target=#{target} \" \\\n \"--ignore-installed\"\n )\n end",
"def dependencies_met?\n @dependencies_met ||= command_dependencies_met?(command_options)\n end",
"def update_dependencies()\n\t\"berks vendor cookbooks #{(@debug ? '-d' : '-q')}\"\n end",
"def install cmd=nil, &block\n @install = cmd || block\n end",
"def gem_if_necessary(gem)\n grep = args = nil\n if gem =~ /(.*)-(\\d+\\.\\d+\\.\\d+)$/\n gem, version = $1, $2\n grep = \"^#{gem}.*#{version}\"\n args = \" --version #{version}\"\n else\n grep = \"^#{gem}\"\n end\n if fails?(\"gem list #{gem} | grep '#{grep}'\")\n banner \"#{gem}...\"\n run \"gem install #{gem} #{args} --no-rdoc --no-ri\"\n return true\n end\n false\n end",
"def install(dry = false)\n create_dirs(dry) unless @needs_dir.nil?\n link(dry) unless @links.nil?\n run_shell_commands(dry) unless @commands.empty?\n end",
"def programChecker(cmd)\n if which(cmd).nil?\n abort(\"EXITING: Please install #{cmd} before continuing\")\n end\nend",
"def pre_install; end",
"def install\n nil\n end",
"def check!\n Capistrano::Deploy::Dependencies.new(configuration) do |d|\n d.remote.file(Capistrano::Puppet::Service::Webrick::SERVICE_INIT).or(\"`#{Capistrano::Puppet::Service::Webrick::SERVICE_INIT}' does not exist. Please run `cap deploy:setup'.\")\n end\n end",
"def install_requirements(upgrade: false)\n if new_resource.options\n # Use a string because we have some options.\n cmd = '-m pip.__main__ install'\n cmd << ' --upgrade' if upgrade\n cmd << \" #{new_resource.options}\"\n cmd << \" --requirement #{Shellwords.escape(requirements_path)}\"\n else\n # No options, use an array to be slightly faster.\n cmd = %w{-m pip.__main__ install}\n cmd << '--upgrade' if upgrade\n cmd << '--requirement'\n cmd << requirements_path\n end\n output = python_shell_out!(cmd, user: new_resource.user, group: new_resource.group, cwd: new_resource.cwd).stdout\n if output.include?('Successfully installed')\n new_resource.updated_by_last_action(true)\n end\n end",
"def is_dependencies_installed?\n is_pkgs = @ssh.do_ssh_cmd('which puppet && which git')\n if is_pkgs[:exit_code] != 0\n abort 'Please install git and puppet on the targeted node'\n end\n true\n end",
"def install\n end",
"def install\n end",
"def install(env); end",
"def install\n bin.install \"appsody\"\n bin.install \"appsody-controller\" \n ohai \"Checking prerequisites...\"\n #system \"docker\"\n retval=check_prereqs\n\n if retval\n ohai \"Done.\"\n else\n opoo \"Docker not detected. Please ensure docker is installed and running before using appsody.\"\n end\n end",
"def install\n end",
"def install_dependencies(spec)\n di = Gem::DependencyInstaller.new\n\n spec.development_dependencies.each do |dep|\n unless source_index.search(dep).last\n if config[\"install_development_dependencies\"]\n say \"Installing test dependency #{dep.name} (#{dep.requirement})\"\n di.install(dep) \n else\n if ask_yes_no(\"Install development dependency #{dep.name} (#{dep.requirement})?\")\n say \"Installing test dependency #{dep.name} (#{dep.requirement})\"\n di.install(dep) \n else\n alert_error \"Failed to install dependencies required to run tests. Aborting.\"\n raise Gem::TestError\n end\n end\n end\n end\n end",
"def install!\n cmd = [attributes.gem_binary, 'install']\n cmd << '-v' << attributes.version if attributes.version\n cmd << '--source' << attributes.source if attributes.source\n cmd << '--prerelease' if attributes.prerelease\n cmd << attributes.package_name\n\n run_command(cmd)\n end",
"def run_package_for_missing(bundle_info)\n puts 'Packaging dependencies missing for current platform'\n\n $usePrecompiled = true\n\n puts 'Making sure databases are loaded...'\n databases = getDefaultDatabases\n\n if databases\n success 'Databases loaded'\n else\n onError 'database loading failed'\n end\n\n to_package = []\n\n all_dependencies.each do |dep|\n puts \"Checking dependency: #{dep.Name}\"\n\n precompiled = getSupportedPrecompiledPackage dep\n\n next if precompiled\n\n puts 'No precompiled available. Creating package'\n\n to_package.append dep\n end\n\n if to_package.empty?\n success 'No missing precompiled dependencies found'\n return\n end\n\n package_dependencies to_package, bundle_info\nend",
"def prepare_command\n info(\"Preparing the SUT and Pester dependencies...\")\n resolve_downloads_paths!\n really_wrap_shell_code(install_command_script)\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend",
"def requirement\n @dependency.requirement\n end",
"def install_sol11_pkg(options,pkg_name)\n pkg_test = %x[which #{pkg_name}]\n if pkg_test.match(/no #{pkg_name}/)\n message = \"Information:\\tChecking Package \"+pkg_name+\" is installed\"\n command = \"pkg info #{pkg_name} 2>&1| grep \\\"Name:\\\" |awk \\\"{print \\\\\\$3}\\\"\"\n output = execute_command(options,message,command)\n if not output.match(/#{pkg_name}/)\n message = \"Information:\\tChecking publisher is online\"\n command = \"pkg publisher | grep online\"\n output = execute_command(options,message,command)\n if output.match(/online/)\n message = \"Information:\\tInstalling Package \"+pkg_name\n command = \"pkg install #{pkg_name}\"\n execute_command(options,message,command)\n end\n end\n end\n return\nend",
"def prepare_for_installation; end",
"def install_package(target_package_path); raise NotImplementedError; end",
"def if_missing_dependencies\n #TODO: Test on Linux\n missing = []\n [['ffmpeg','-version'], ['mp3splt', '-v'], ['mp3wrap']].each do |cmdline|\n begin\n out, err, status = Open3.capture3(*cmdline)\n rescue\n missing.push(cmdline.first)\n end #begin\n end #...].each do |cmdline|\n yield(missing) unless missing.empty?\n end",
"def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end",
"def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end",
"def prefer_indep_over_os_packages?; @prefer_indep_over_os_packages end",
"def check_and_install_packages_if_needed host, package_list\n package_list.each do |string|\n alternatives = string.split('|')\n next if alternatives.any? { |pkg| host.check_for_package pkg }\n\n install_one_of_packages host, alternatives\n end\n end",
"def node_module_exists(command, install_instructions = 'npm install -g')\n cmd = `if hash #{command} 2>/dev/null; then echo \"true\"; else echo \"false\"; fi`\n if cmd.include? \"false\"\n command_msg = \"Missing command #{command}\"\n abort \"#{command_msg}: Please run `#{install_instructions} #{command}` And try again\\n\"\n exit 1\n end\n end",
"def install(opts=nil, &block)\n communicate.sudo(install_dependencies_cmd, opts, &block)\n super\n end",
"def install_gem(name, options = {})\n dep = Gem::Dependency.new(name, options[:version] || '>0')\n if Gem::SourceIndex.from_installed_gems.search(dep).empty?\n puts \"Installing #{name} ...\"\n rb_bin = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])\n args = []\n args << 'sudo' << 'env' << \"JAVA_HOME=#{ENV['JAVA_HOME']}\" if sudo_needed? and RAKE_SUDO\n args << rb_bin << '-S' << 'gem' << 'install' << name\n\n if (dep.respond_to? :requirement)\n args << '--version' << dep.requirement.to_s\n else\n # Dependency.version_requirements deprecated in rubygems 1.3.6\n args << '--version' << dep.version_requirements.to_s\n end\n\n args << '--source' << options[:source] if options[:source]\n args << '--source' << 'http://gems.rubyforge.org'\n args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']\n sh *args\n end\nend",
"def deps(pkg) # FIXME: \"*** PACKAGE MAY NOT BE DELETED *** \"\n if pkg.status != :available\n components = `#{@cmd} -n #{pkg.name}`.split(\"Requires:\\n\")\n if components.size > 1\n return components[1].strip\n else\n return \"[No depends]\"\n end\n else\n if File.exist?(File.expand_path(\"~/Library/Application Support/Guigna/pkgsrc/INDEX\"))\n # TODO: parse INDEX\n end\n \"[Not available]\"\n end\n end",
"def install\n should = @resource[:ensure]\n\n package_name = @resource[:name]\n case should\n when true, false, Symbol\n # pass\n else\n package_name += \"-#{should}\"\n end\n\n output = brew(:install, package_name)\n\n # Fail hard if there is no formula available.\n if output =~ /Error: No available formula/\n raise Puppet::ExecutionFailure, \"Could not find package #{@resource[:name]}\"\n end\n end",
"def apt_get_update_install\n @app.packages.present? ? install_additional_packages : update_apt\n end",
"def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end",
"def requires(*args)\n normalize_list(args).each do |dependency|\n @available.add_required(dependency)\n end\n end",
"def test_bad_node_deps\n check_deps_fail \"notapackage\" => :node if which('node')\n end",
"def test_bad_node_deps\n check_deps_fail \"notapackage\" => :node if which('node')\n end",
"def installed?(cmd)\n !Garcon::FileHelper.which(cmd).nil?\n end",
"def installed?(command)\n MakeMakefile.find_executable(command)\n end",
"def install_dependent_roles\n ansible_directory = File.join(\"deployment\", \"ansible\")\n ansible_roles_txt = File.join(ansible_directory, \"roles.txt\")\n\n File.foreach(ansible_roles_txt) do |line|\n role_name, role_version = line.split(\",\")\n role_path = File.join(ansible_directory, \"roles\", role_name)\n galaxy_metadata = galaxy_install_info(role_name)\n\n if galaxy_metadata[\"version\"] != role_version.strip\n unless system(\"ansible-galaxy install -f -r #{ansible_roles_txt} -p #{File.dirname(role_path)}\")\n $stderr.puts \"\\nERROR: An attempt to install Ansible role dependencies failed.\"\n exit(1)\n end\n\n break\n end\n end\nend",
"def sub_install\n @already_installed = installed? if @already_installed == nil\n if @already_installed and !Settings.opt_redo\n raise BakerError, \"#{@program} is already installed (use -r to reinstall)\"\n end\n shell(install_script, source_dir)\n end"
] | [
"0.68881327",
"0.67534816",
"0.6500015",
"0.6431194",
"0.6401981",
"0.6361711",
"0.6311167",
"0.6275268",
"0.62538075",
"0.62434673",
"0.62385434",
"0.6215292",
"0.6120765",
"0.6111655",
"0.6102539",
"0.6102082",
"0.60575306",
"0.6020774",
"0.6020774",
"0.6009196",
"0.599297",
"0.59875613",
"0.59863573",
"0.59846",
"0.59698224",
"0.5934874",
"0.589901",
"0.5898274",
"0.5883308",
"0.588247",
"0.5871449",
"0.58711696",
"0.5869837",
"0.5869837",
"0.5863165",
"0.5825896",
"0.58204675",
"0.57988596",
"0.5792576",
"0.5787608",
"0.5786149",
"0.5777024",
"0.576862",
"0.57685286",
"0.57650137",
"0.57618725",
"0.57609016",
"0.57599753",
"0.57517",
"0.5744747",
"0.5743511",
"0.5740117",
"0.5739208",
"0.5737624",
"0.57373685",
"0.5728257",
"0.5727283",
"0.5723329",
"0.5721313",
"0.570751",
"0.570362",
"0.56934315",
"0.56934315",
"0.56867236",
"0.56719893",
"0.5670357",
"0.5658494",
"0.56465656",
"0.564521",
"0.56410795",
"0.5640876",
"0.5640876",
"0.5635857",
"0.5635857",
"0.5635857",
"0.5635857",
"0.5635857",
"0.563223",
"0.5632185",
"0.56132495",
"0.56111896",
"0.5608448",
"0.5604103",
"0.5604103",
"0.56013715",
"0.5598809",
"0.5588079",
"0.5585981",
"0.5579005",
"0.5575996",
"0.5572206",
"0.5564982",
"0.555574",
"0.55385053",
"0.55349714",
"0.55349714",
"0.55274385",
"0.55249953",
"0.5524247",
"0.5520782"
] | 0.6348831 | 6 |
Implementation's of this method in subclasses are the methods that are responsible for all the heavylifting when it comes to determining the dependencies (and their licenses). They should return an array of `LicenseScout::Dependency`. | def dependencies
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def licenses\n licenses = []\n uris = metadata[dataset_uri][dct.license.to_s]\n if uris.nil?\n []\n else\n uris.each do |uri|\n l = metadata[uri]\n licenses << License.new(:uri => uri, :name => l[dct.title.to_s])\n end\n return licenses\n end\n rescue\n []\n end",
"def dependencies_for(specification)\n []\n end",
"def dependencies\n []\n end",
"def licenses *names\n names.to_strings.each do |name| \n begin\n module_name = \"#{name.camelize}License\"\n clazz = module_name.constantize\n clazz.new(self).enforce!\n rescue\n raise \"License #{module_name} not found\"\n end\n end\n end",
"def dependencies\n []\n end",
"def licenses *names\n names.to_strings.each do |name| \n begin\n module_name = \"#{name.camelize}License\"\n clazz = module_name.constantize\n rescue\n raise \"License #{module_name} is not defined\"\n end\n\n begin\n clazz.new(self).enforce!\n rescue\n raise \"License #{clazz} could not be enforced using #{self.inspect}\"\n end\n end\n end",
"def licenses\n @licenses ||= []\n end",
"def depend_upon(match_name) #, constraint)\n list = []\n each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end",
"def dependencies\n @dependencies.collect { |name, dependency| dependency }\n end",
"def dependencies( *args )\n names = args # note: for now assume all args are just names\n # e.g. 'pluto-models', 'pluto-update', etc.\n deps = @versions.select do |rec| names.include?( rec[0] ) end\n .map do |rec| [rec[0], rec[1]] end\n\n ## todo/fix: throw exception if dependency is missing!\n ## names.size == deps.size\n puts \"names.size == deps.size #{names.size} == #{deps.size}\"\n deps\n end",
"def licenses\n if @licenses.nil?\n @licenses = self.links.select do |link|\n link.rel == \"license\"\n end\n end\n return @licenses\n end",
"def dependencies\n @dependencies.values\n end",
"def depends_upon(match_name) #, constraint)\n list = []\n $LEDGER.each do |name, libs|\n case libs\n when Library\n list << libs if libs.requirements.any?{ |r| match_name == r['name'] } \n else\n libs.each do |lib|\n list << lib if lib.requirements.any?{ |r| match_name == r['name'] } \n end\n end\n end\n list\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies\n @dependencies ||= []\n end",
"def getDependencies service\r\n deps = []\r\n Util.csprojs(service).each do |csproj|\r\n deps += getDeps(csproj) \r\n end\r\n return deps.uniq\r\nend",
"def dependencies\n version_req = if options[:version]\n ::Gem::Requirement.create(options[:version])\n else\n ::Gem::Requirement.default\n end\n if gem_dir\n ::Gem.clear_paths; ::Gem.path.unshift(gem_dir)\n ::Gem.source_index.refresh!\n end\n deps = []\n ::Gem.source_index.each do |fullname, gemspec| \n if version_req.satisfied_by?(gemspec.version)\n deps << ::Gem::Dependency.new(gemspec.name, \"= #{gemspec.version}\")\n end\n end\n ::Gem.clear_paths if gem_dir\n deps.sort\n end",
"def dependencies(include_parent = false)\n []\n end",
"def dependencies(include_parent = false)\n []\n end",
"def dependencies(include_parent = false)\n []\n end",
"def dependencies\n EMPTY_SET\n end",
"def find_licenses_in_source\n license_files = []\n\n @find_class.find(@gem_source) do |path|\n license_files << path if path.include?(\"LICENSE\")\n end\n\n license_files\n end",
"def dependencies\n @dependencies ||= []\n end",
"def dependencies( names )\n names.each do |name|\n if calculation = fetch( name, nil )\n calculation.dependencies.each do |dependency|\n names << dependency unless names.include?( dependency )\n end\n end\n end\n end",
"def dependencies\n @dependencies\n end",
"def dependencies\n return @dependencies unless @dependencies.nil?\n @dependencies = [ ]\n lockfile.each_line do |line|\n if line =~ /^\\s{4}([-\\w_.0-9]+)\\s*\\((.*)\\)/\n @dependencies << [$1, $2]\n end\n end\n @dependencies\n end",
"def dependencies\n to_a.reject { |a| a.filename.eql?(self.filename) }\n end",
"def dependencies_for(specification)\n specification.dependencies\n end",
"def dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def get_dependencies\n @dependencies\n end",
"def dependency_list\n @target.dependencies.map(&:display_name)\n end",
"def licenses\n data[:licenses]\n end",
"def licenses(options = {})\n Licensee::License.all(options)\n end",
"def gem_requirements_to_array(*deps)\n deps.map do |dep|\n dep.requirement.requirements.map do |op, version|\n \"#{op} #{version}\"\n end.sort\n end\n end",
"def get_dependencies(_fidl, _interaction_types, _project_dependencies)\n # noop\n end",
"def dependencies\n node.output[carrier].keys\n end",
"def dependencies(&block)\n deps = ::OSGi::Dependencies.new(project)\n deps.read\n deps.dependencies + deps.projects\n end",
"def dependencies\n cached_dependencies\n .reject { |d| ignored?(d) }\n .each { |d| add_additional_terms_from_configuration(d) }\n end",
"def find_all req\n res = []\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number]\n res << Gem::DependencyResolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def requirements\n []\n end",
"def check_dependencies\n fetch_module_dependencies.map do |dependency, constraint|\n dependency = dependency.sub('-', '/')\n current = dependency == @updated_module ? SemanticPuppet::Version.parse(@updated_module_version) : @forge.get_current_version(dependency)\n [dependency, constraint, current, constraint.include?(current)]\n end\n end",
"def dependencies\n self.class.dependencies\n end",
"def required_dependencies\n dependencies - optional_dependencies\n end",
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : spec.runtime_dependencies\n deps.each do |dep|\n if self.satisfies_requirement?(dep)\n sats = []\n find_all_satisfiers(dep) do |sat|\n sats << sat\n end\n out << [spec, dep, sats]\n end\n end\n end\n out\n end",
"def dependencies\n @dependencies ||= {}\n end",
"def js_dependencies_array\n if scripts != :none\n get_vendor_scripts\n get_gem_scripts\n end\n @js_array\n end",
"def get_all_requires(code = @code)\n if code.is_a?(Array) then\n requires = (code.select { |sub| is_require?(sub) }).map! do |sub|\n get_require(sub)\n end\n code.each do |sub|\n requires += get_all_requires(sub)\n end\n return requires\n else\n return []\n end\n end",
"def complete_licenses\n License.selectable\n .sort_by(&:identifier)\n .map { |license| [\"#{license.identifier} (#{license.name})\", license.id] }\n end",
"def requirements\n []\n end",
"def dependencies_from_array(dependents)\n # Referring to an array of dependents\n # Can be a mixed array (eg [:publishers, Publisher2])\n dependents.inject([]) do |klasses, dependent|\n if dependent.is_a? Symbol\n # Referring to an array of stages (eg [:publishers, :emailers])\n klasses << dependents_for_stage(dependent)\n else\n # Referring to an array of jobs (eg [Publisher1, Publisher2])\n klasses << [dependent] + dependents_for(dependent)\n end\n end.flatten.uniq\n end",
"def dependencies\n @dependencies ||= Set.new\n end",
"def find_dependencies(deps=nil, verbose=false)\n \n deps ||= all_dependencies\n\n search_list = Array(deps)\n found = []\n ret = []\n \n # if we discover a new local package via indirect dependencies then\n # it's dependencies will be fetchable one time.\n fetchable = Set.new\n \n until search_list.empty?\n name, version = search_list.shift\n\n if dup = found.find{|p| p.name == name}\n # already found, check for conflicts\n next if satisfied_by?(version, dup.version)\n raise PackageConflictError.new(name, dup.version, version)\n end\n\n pkg = locate_package(name, version, verbose)\n if pkg.nil? && fetchable.include?(name)\n fetchable.reject! { |x| x == name }\n core_fetch_dependency(name, version, :runtime, true) \n pkg = locate_package name, version, verbose\n end\n \n raise PackageNotFoundError.new(name, version) unless pkg\n\n found << pkg\n\n # Look up dependencies of dependencies\n new_deps = Array(pkg.dependencies) + Array(pkg.dependencies_build)\n if has_local_package? pkg.name\n new_deps += Array(pkg.dependencies_development)\n new_deps.each { |dep| fetchable.add dep.first }\n end\n \n search_list += new_deps\n\n ret << pkg\n end\n\n ret\n end",
"def dependencies(name)\n dependencies = []\n submodule = submodule(name)\n if submodule.has_key?(:dependencies)\n submodule[:dependencies].each do |dependency|\n dependencies << dependency\n dependencies << dependencies(dependency)\n end\n end\n\n dependencies.flatten.uniq.sort\n end",
"def dependencies(include_parent = false)\n include_parent ? [ parent ] : []\n end",
"def dependencies\n self.config.depends || []\n end",
"def dependencies\n raise \"#{self.class} needs to overwrite dependencies\"\n end",
"def dependencies\n\t\t0\n\tend",
"def dependencies\n @target_dependencies + (@parent ? @parent.dependencies : [])\n end",
"def dependencies\n @dependencies ||= begin\n YARD::Registry.all(:dependency)\n end\nend",
"def getWcfDependencies service\r\n deps = []\r\n Util.csprojs(service).each do |csproj|\r\n deps += getWcfDeps(csproj) \r\n end\r\n return deps.uniq\r\nend",
"def add_depend_list\n list = ''\n if @depedencies.nil? or @depedencies.size == 0\n list = ''\n elsif @depedencies.class == String\n list = \"=> [:#{@depedencies}] \"\n elsif @depedencies.class == Array\n list = '=> [ '\n need_comma = false\n for element in @depedencies\n list = list + ', ' if need_comma\n list = list + \":#{element}\"\n @log.info \" - dependent from : #{element}\"\n need_comma = true\n end\n list = list + ' ] '\n else\n @log.fatal { \"Cannot parse dependencies [#{@depedencies}]\" }; exit\n end\n return list\n end",
"def locked_specs_as_deps\n deps = @dependencies & @locked_deps\n\n @dependencies.each do |dep|\n next if deps.include?(dep)\n deps << dep if @locked_specs.any? { |s| s.satisfies?(dep) }\n end\n\n meta_deps = @locked_specs.for(deps).map do |s|\n dep = Gem::Dependency.new(s.name, s.version)\n @locked_deps.each do |d|\n dep.source = d.source if d.name == dep.name\n end\n dep\n end\n end",
"def requirements\n @requirements ||= []\n end",
"def gem_requirements_from_array(what, array)\n array.map do |dep|\n Gem::Dependency.new(what, *dep)\n end\n end",
"def extract_declares!\n # By default, nothing to do.\n return []\n end",
"def getdeps(pkg)\n deps = []\n @pkg.each {|k, v| deps << k if v.include?(pkg) }\n\n return deps\n end",
"def find_dependencies\n\t\tunless GEMDEPS_FILE.readable?\n\t\t\tself.prompt.warn \"Deps file (%s) is missing or unreadable, assuming no dependencies.\" %\n\t\t\t\t[ GEMDEPS_FILE ]\n\t\t\treturn []\n\t\tend\n\n\t\tfinder = Rake::DevEiate::GemDepFinder.new( GEMDEPS_FILE )\n\t\tfinder.load\n\t\treturn finder.dependencies\n\tend",
"def dependencies\n manager.dependencies\n end",
"def dependencies(pkg)\n pkg.resolve_optional_dependencies\n deps_rock_packages = pkg.dependencies.map do |pkg_name|\n debian_name(Autoproj.manifest.package(pkg_name).autobuild)\n end.sort\n\n pkg_osdeps = Autoproj.osdeps.resolve_os_dependencies(pkg.os_packages)\n # There are limitations regarding handling packages with native dependencies\n #\n # Currently gems need to converted into debs using gem2deb\n # These deps dependencies are updated here before uploading a package\n # \n # Generation of the debian packages from the gems can be done in postprocessing step\n # i.e. see convert_gems\n \n deps_osdeps_packages = []\n native_package_manager = Autoproj.osdeps.os_package_handler\n _, native_pkg_list = pkg_osdeps.find { |handler, _| handler == native_package_manager }\n\n deps_osdeps_packages += native_pkg_list if native_pkg_list\n\n # Update global list\n @osdeps += deps_osdeps_packages\n\n non_native_handlers = pkg_osdeps.collect do |handler, pkg_list|\n if handler != native_package_manager\n [handler, pkg_list]\n end\n end.compact\n\n non_native_handlers.each do |pkg_handler, pkg_list|\n # Convert native ruby gems package names to rock-xxx \n if pkg_handler.kind_of?(Autoproj::PackageManagers::GemManager)\n pkg_list.each do |name,version|\n @ruby_gems << [name,version]\n deps_osdeps_packages << debian_ruby_name(name)\n end\n else\n raise ArgumentError, \"cannot package #{pkg.name} as it has non-native dependencies (#{pkg_list}) -- #{pkg_handler.class} #{pkg_handler}\"\n end\n end\n\n # Remove duplicates\n @osdeps.uniq!\n @ruby_gems.uniq!\n\n # Return rock packages and osdeps\n [deps_rock_packages, deps_osdeps_packages]\n end",
"def requires\n sort!\n sources.map {|s| s.requires }.flatten - provides\n end",
"def computeDependences(list)\n dependences = OCMSet.new\n\n OCMSet::SECTIONS.each do |section|\n @require[section].each do |req|\n found = false\n\n list.each do |iface|\n for context in iface.provide do\n if context[section].include?(req) then\n dependences[section] << iface\n found = true\n break\n end\n end\n end\n\n raise \"#{@id.name}: no dependence found for #{req.name}.\" unless found\n end\n end\n\n return dependences.values.flatten.uniq\n end",
"def satisfied_by(versions, constraints)\n satisfied = []\n # versions.select {|version| self::satisfies?(version, constraints) }\n versions.map do |version|\n if self::satisfies?(version, constraints)\n satisfied << version\n end\n end\n satisfied\n end",
"def customized_licenses\n @research_output.plan.template.licenses.map { |license| [\"#{license.identifier} (#{license.name})\", license.id] }\n end",
"def gem_dependencies(list, gem_dependencies, options = {})\n gem_dependencies.each do |gd|\n if options['excludes'] && options['excludes'].to_s.split(',').include?(gd.name)\n next\n end\n\n gs = gd.matching_specs.first\n if gs\n unless list[gs.name]\n list[gs.name] = gs\n unless gs.dependencies.empty?\n list = gem_dependencies(list, gs.dependencies, options)\n end\n end\n else\n unless list[gd.name]\n list[gd.name] = Gem::Specification.new(\n gd.name,\n gd.requirements_list.last.scan(/[\\d\\.\\w]+/).first\n )\n rm_dep = remote_dependencies(gd.name, gd.requirements_list.last)\n unless rm_dep.empty?\n list = gem_dependencies(list, rm_dep, options)\n end\n end\n end\n end\n\n list\n end",
"def find_all(req)\n res = []\n\n return res unless @remote\n\n if @to_fetch.include?(req.name)\n prefetch_now\n end\n\n versions(req.name).each do |ver|\n if req.dependency.match? req.name, ver[:number], @prerelease\n res << Gem::Resolver::APISpecification.new(self, ver)\n end\n end\n\n res\n end",
"def validate_dependencies # :nodoc:\n warning_messages = []\n @specification.dependencies.each do |dep|\n prerelease_dep = dep.requirements_list.any? do |req|\n Gem::Requirement.new(req).prerelease?\n end\n\n warning_messages << \"prerelease dependency on #{dep} is not recommended\" if\n prerelease_dep && !@specification.version.prerelease?\n\n open_ended = dep.requirement.requirements.all? do |op, version|\n not version.prerelease? and (op == '>' or op == '>=')\n end\n\n if open_ended\n op, dep_version = dep.requirement.requirements.first\n\n segments = dep_version.segments\n\n base = segments.first 2\n\n recommendation = if (op == '>' || op == '>=') && segments == [0]\n \" use a bounded requirement, such as '~> x.y'\"\n else\n bugfix = if op == '>'\n \", '> #{dep_version}'\"\n elsif op == '>=' and base != segments\n \", '>= #{dep_version}'\"\n end\n\n \" if #{dep.name} is semantically versioned, use:\\n\" \\\n \" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}\"\n end\n\n warning_messages << [\"open-ended dependency on #{dep} is not recommended\", recommendation].join(\"\\n\") + \"\\n\"\n end\n end\n if warning_messages.any?\n warning_messages.each {|warning_message| warning warning_message }\n end\n end",
"def deps(sequence)\n return [] unless checker.valid? # Exit early if it's bad data\n all = [] # Start collecting the list.\n CeleryScript::TreeClimber.travel(tree, ->(n) {\n # Iterate over each node, looking for \"args of interest\".\n # Tools, sub sequences, etc.\n ARGS_OF_INTEREST.map do |arg, klass|\n id = n&.args&.fetch(arg, nil)&.value\n all.push(klass.find(id)) if id\n end\n })\n\n # Filter out the target sequence to prevent runaway recursion.\n # It would be impossible to delete recursive sequences otherwise.\n all.select! { |d| !(d.is_a?(Sequence) && (d.id == sequence.id)) }\n\n # Finally, output the data in a format that can directly be used by\n # SequenceDependency#create!().\n return all.uniq.map do |d|\n { sequence: sequence, dependency_type: d.class, dependency_id: d.id }\n end\n end",
"def build_dependencies(pkginfo)\n dependencies = []\n pkgdeps = pkginfo.dependencies\n deps = pkgdeps[:rock_pkginfo].select do |pkginfo|\n pkg_name = debian_name(pkginfo, true)\n !rock_release_platform.ancestorContains(pkg_name)\n end .map { |p| p.name }\n\n gems = pkgdeps[:nonnative].select do |gem,version|\n pkg_ruby_name = debian_ruby_name(gem, false)\n pkg_prefixed_name = debian_ruby_name(gem, true)\n\n !( rock_release_platform.ancestorContains(gem) ||\n rock_release_platform.ancestorContains(pkg_ruby_name) ||\n rock_release_platform.ancestorContains(pkg_prefixed_name))\n end .map{ |p| p[0] }\n\n deps.concat(gems)\n deps\n end",
"def dependency_versions(args = {}, &bl)\n versions = args[:versions] || {}\n check_deps = args[:dev] ? dev_deps : deps\n\n check_deps.each do |dep|\n unless versions.key?(dep.name)\n begin\n gem = Polisher::Gem.retrieve(dep.name)\n versions.merge! gem.versions(args, &bl)\n rescue\n unknown = Polisher::VersionChecker.unknown_version(:all, dep.name, &bl)\n versions.merge! dep.name => unknown\n end\n end\n\n args[:versions] = versions\n end\n\n versions\n end",
"def dependent_specs\n runtime_dependencies.map {|dep| dep.to_specs }.flatten\n end",
"def dependency_paths\n @dependency_paths ||= []\n end",
"def dependencies_for(source, acc = [])\n ds = dependencies.select { |d| d.last == source }.\n map { |d| d.first }\n return acc if ds.empty?\n acc = acc | ds\n ds.each { |d| acc = acc | dependencies_for(d, acc) }\n acc\n end",
"def dependencies\n if @options[:dependencies]\n deps = [] << @options[:dependencies]\n deps.flatten.collect { |item|\n item = File.join(item,'**/*') if File.directory?(item)\n Dir.glob item\n }.flatten.uniq.collect { |item|\n File.directory?(item) ? nil : item\n }.compact\n else\n false\n end\n end",
"def dependencies_for(specification)\n specification.dependencies(@cache, @resolver_ui)\n end",
"def initialize(licenses: [], notices: [], metadata: {})\n @licenses = [licenses].flatten.compact.map { |l| DependencyRecord::License.new(l) }\n @notices = [notices].flatten.compact\n @metadata = metadata\n end",
"def os_dependencies\n []\n end",
"def deps(pkg) # FIXME: \"*** PACKAGE MAY NOT BE DELETED *** \"\n if pkg.status != :available\n components = `#{@cmd} -n #{pkg.name}`.split(\"Requires:\\n\")\n if components.size > 1\n return components[1].strip\n else\n return \"[No depends]\"\n end\n else\n if File.exist?(File.expand_path(\"~/Library/Application Support/Guigna/pkgsrc/INDEX\"))\n # TODO: parse INDEX\n end\n \"[Not available]\"\n end\n end",
"def dependency_versions(args = {}, &bl)\n versions = args[:versions] || {}\n check_deps = args[:dev] ? dev_deps : deps\n\n check_deps.each do |dep|\n unless versions.key?(dep.name)\n begin\n gem = Polisher::Gem.retrieve(dep.name)\n versions.merge! gem.versions(args, &bl)\n rescue\n unknown = Polisher::VersionChecker.unknown_version(:all, dep.name, &bl)\n versions.merge! dep.name => unknown\n end\n end\n\n args[:versions] = versions\n end\n\n versions\n end",
"def all_requires\n []\n end",
"def all_requires\n []\n end",
"def find_all req\n res = []\n\n name = req.dependency.name\n\n @all[name].each do |uri, n|\n if req.dependency.match? n then\n res << Gem::DependencyResolver::IndexSpecification.new(\n self, n.name, n.version, uri, n.platform)\n end\n end\n\n res\n end",
"def depends\n return @depends if @depends\n\n deps = survey.dependencies.includes({:dependency_conditions => {:question => :answers}})\n\n resps = self.responses.includes(:answer)\n\n # gather if the dependencies are met in a hash\n @depends = deps.all.reduce({}) do |mem, v|\n mem[v.id] = v.is_met? self, resps\n mem\n end\n end",
"def runtime_dependencies\n dependencies.select(&:runtime?)\n end",
"def dependencies(options = {})\n # backward compatibility\n options = { :scopes => options } if Array === options\n\n # support symbols, but don't fidget with nil\n options[:scopes] = (options[:scopes] || SCOPES_WE_USE).map { |s| s.to_s if s }\n\n # try to cache dependencies also\n @depends_for_scopes ||= {}\n unless depends = @depends_for_scopes[options]\n declared = project['dependencies'].first['dependency'] rescue nil\n depends = (declared || [])\n depends = depends.reject { |dep| value_of(dep['optional']) =~ /true/ } unless options[:optional]\n depends = depends.map { |dep|\n spec = pom_to_hash(dep, properties)\n apply = managed(spec)\n spec = apply.merge(spec) if apply\n\n next if options[:exclusions] && options[:exclusions].any? { |ex| dep['groupId'] == ex['groupId'] && dep['artifactId'] == ex['artifactId'] }\n\n # calculate transitive dependencies\n if options[:scopes].include?(spec[:scope])\n spec.delete(:scope)\n\n exclusions = dep['exclusions'].first['exclusion'] rescue nil\n transitive_deps = POM.load(spec).dependencies(:exclusions => exclusions, :scopes => (options[:scopes_transitive] || SCOPES_TRANSITIVE) ) rescue []\n\n [Artifact.to_spec(spec)] + transitive_deps\n end\n }.flatten.compact #.uniq_by{|spec| art = spec.split(':'); \"#{art[0]}:#{art[1]}\"}\n @depends_for_scopes[options] = depends\n end\n depends\n end",
"def dependencies\n members.each_with_object([]) do |attr_name, depends|\n value = send(attr_name)\n value = pipeline.objects.fetch(value) if value.is_a?(Symbol)\n depends << value.dependencies << value if value.is_a?(PipelineObject)\n end.flatten\n end",
"def dependencies_for_job(dependents)\n if dependents.is_a? Symbol\n # Referring to another stage (eg :publishers)\n dependents_for_stage(dependents)\n elsif dependents.is_a? Array\n # Referring to an array of dependencies (eg [:publishers, Publisher2])\n dependencies_from_array(dependents)\n else\n # Referring to another job (eg Publisher1)\n [dependents] + dependents_for(dependents)\n end\n end"
] | [
"0.6979492",
"0.68642575",
"0.6855722",
"0.6850754",
"0.6844061",
"0.684021",
"0.67019534",
"0.6685572",
"0.66536504",
"0.65131265",
"0.6511361",
"0.6506128",
"0.64482623",
"0.64454293",
"0.64454293",
"0.64454293",
"0.64454293",
"0.643095",
"0.6416843",
"0.63927746",
"0.63927746",
"0.63927746",
"0.6362662",
"0.6360732",
"0.63509893",
"0.6253492",
"0.62397605",
"0.6207319",
"0.61332333",
"0.61059904",
"0.6102576",
"0.6102576",
"0.6102576",
"0.60912025",
"0.6047607",
"0.6037228",
"0.6030536",
"0.60198975",
"0.6017462",
"0.6002665",
"0.5995661",
"0.59889024",
"0.59783876",
"0.5964533",
"0.5957407",
"0.59214956",
"0.59087086",
"0.58915657",
"0.58726317",
"0.58713055",
"0.5868292",
"0.5864977",
"0.58613247",
"0.5856302",
"0.5856016",
"0.5807332",
"0.5765524",
"0.57541794",
"0.5752274",
"0.57499665",
"0.57459164",
"0.5745615",
"0.57451534",
"0.5738943",
"0.57383",
"0.5738269",
"0.5731705",
"0.57234204",
"0.57228255",
"0.57216245",
"0.57192594",
"0.5716675",
"0.5714343",
"0.57122606",
"0.5711802",
"0.57052845",
"0.5694694",
"0.56945443",
"0.5690872",
"0.56708336",
"0.56569016",
"0.56523454",
"0.5641315",
"0.56317514",
"0.56223327",
"0.56191206",
"0.56130904",
"0.5613058",
"0.56105274",
"0.56092316",
"0.559549",
"0.5592339",
"0.5587851",
"0.5587851",
"0.5585755",
"0.5585433",
"0.55812114",
"0.5580188",
"0.5575608",
"0.5562959"
] | 0.69650996 | 1 |
A helper that allows you to quickly create a new Dependency (with the type) | def new_dependency(name, version, path)
LicenseScout::Log.debug("[#{type}] Found #{name} #{version}#{" #{path}" unless path.nil?}")
Dependency.new(name, version, path, type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d(*args)\n Dependency.new(*args)\n end",
"def as_a_dependency\n Aws::Templates::Utils::Dependency.new(object)\n end",
"def add_dependency_with_type(dependency, type, requirements)\n requirements = if requirements.empty?\n Gem::Requirement.default\n else\n requirements.flatten\n end\n\n unless dependency.respond_to?(:name) &&\n dependency.respond_to?(:requirement)\n dependency = Gem::Dependency.new(dependency.to_s, requirements, type)\n end\n\n dependencies << dependency\n end",
"def initialize(name, *requirements)\n case name\n when String then # ok\n when Regexp then\n msg = [\"NOTE: Dependency.new w/ a regexp is deprecated.\",\n \"Dependency.new called from #{Gem.location_of_caller.join(\":\")}\"]\n warn msg.join(\"\\n\") unless Gem::Deprecate.skip\n else\n raise ArgumentError,\n \"dependency name must be a String, was #{name.inspect}\"\n end\n\n type = Symbol === requirements.last ? requirements.pop : :runtime\n requirements = requirements.first if 1 == requirements.length # unpack\n\n unless TYPES.include? type\n raise ArgumentError, \"Valid types are #{TYPES.inspect}, \" +\n \"not #{type.inspect}\"\n end\n\n @name = name\n @requirement = Gem::Requirement.create requirements\n @type = type\n @prerelease = false\n\n # This is for Marshal backwards compatibility. See the comments in\n # +requirement+ for the dirty details.\n\n @version_requirements = @requirement\n end",
"def artifact(type, params = nil, &blk)\n artifact_object = create_artifact_object(type, params, &blk)\n self[artifact_object.label] = artifact_object\n artifact_object.as_a_dependency.to_self\n end",
"def create\n @dependency = Dependency.new(dependency_params)\n\n respond_to do |format|\n if @dependency.save\n format.html { redirect_to @dependency, notice: 'Dependency was successfully created.' }\n format.json { render :show, status: :created, location: @dependency }\n else\n format.html { render :new }\n format.json { render json: @dependency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def Factory (name, attrs = {})\n Factory.create(name, attrs)\nend",
"def direct_dependency(type, result = T.unsafe(nil)); end",
"def dependency name, version, type = :runtime\n raise \"Unknown dependency type: #{type}\" unless\n [:runtime, :dev, :development, :developer].include? type\n\n ary = if type == :runtime then\n extra_deps\n else\n extra_dev_deps\n end\n\n ary << [name, version]\n end",
"def add(name:, depends_on:, **kwargs)\n check_for_missing_dependencies!(depends_on)\n graph[name] = dependency_class.new(kwargs.merge(name: name, depends_on: depends_on))\n end",
"def create\n name_to_const.new\n end",
"def make(thing) end",
"def create_object\n definition.sought_type.new\n end",
"def create_dependency_graph\n service_types.map do |key, i|\n i.service_producers.map do |j|\n j.factory.machine.depends.each do |k|\n binding.pry unless service_types[k.name]\n service_types[k.name].join(i)\n end\n j.factory.machine.requires.each do |k|\n binding.pry unless service_types[k.name]\n i.join(service_types[k.name])\n end\n end\n end\n end",
"def build(attrs = {})\n attrs[:type] ? attrs[:type].constantize.new(attrs) : new(attrs)\n end",
"def initialize(dependency, requester)\n @dependency = dependency\n @requester = requester\n end",
"def create(type, opts = nil)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.new(type.to_sym, opts, @comm)\n after_create(new_resource) if respond_to? :after_create\n children << new_resource\n new_resource\n end",
"def object_with_type(cl)\n o = cl.allocate.compile_time_init\n name = cl.name.split(\"::\").last.to_sym\n o.set_type @types[name]\n o\n end",
"def add_dependency(dep)\n unless dep.is_a?(Dependency)\n raise TypeError, 'illegal argument type: must be a Dependency'\n end\n\n raise NotImplementedError\n end",
"def parse_dependency(name, op) # :nodoc:\n return Gem::Dependency.new name, op unless peek[0] == :text\n\n version = get(:text).value\n\n requirements = [\"#{op} #{version}\"]\n\n while peek.type == :comma do\n get :comma\n op = get(:requirement).value\n version = get(:text).value\n\n requirements << \"#{op} #{version}\"\n end\n\n Gem::Dependency.new name, requirements\n end",
"def create; super(:type); end",
"def convert_package_to_dependency(pkg)\n path, errors = check_dep_path(pkg)\n Dependency.new(\n name: pkg[:name],\n version: pkg[:version],\n path: path,\n metadata: pkg[:metadata].merge(\"type\" => self.class.type),\n errors: errors + Array(pkg[:error])\n )\n end",
"def factory(klass, *args)\n klass.new(*args)\n end",
"def create(type:, **options)\n find(type).new(**options)\n end",
"def create\n identify.tap { type }\n end",
"def make_node(type, *args)\n elem = type.new self, *args\n @nodes << elem\n self.core_node ||= elem.id\n elem.expand\n elem\n end",
"def build (name, attrs = {})\n factory_by_name(name).build(attrs)\n end",
"def build (name, attrs = {})\n factory_by_name(name).build(attrs)\n end",
"def depend(location, type, *args)\n deps = fetch(:dependencies, {})\n deps[location] ||= {}\n deps[location][type] ||= []\n deps[location][type] << args\n set :dependencies, deps\n end",
"def depend(location, type, *args)\n deps = fetch(:dependencies, {})\n deps[location] ||= {}\n deps[location][type] ||= []\n deps[location][type] << args\n set :dependencies, deps\n end",
"def new_commit(type)\n Commit.new.tap do |commit|\n commit.type = type\n end\nend",
"def create_referring_record\n return unless @ref_record_type\n\n @referring_record = find_referring_record\n ModelReference.create_with @referring_record, self if @referring_record\n end",
"def build *args\n Factory.build factory_name, *args\n end",
"def depend(location, type, *args)\n deps = fetch(:dependencies, {})\n deps[location] ||= {}\n deps[location][type] ||= []\n deps[location][type] << args\n set :dependencies, deps\n end",
"def add_dependency(path, dependency); end",
"def Factory(name, attributes = {})\n Factory.build_via_new(name, attributes).save!\nend",
"def add_dependency(target)\n unless dependencies.map(&:target).include?(target)\n container_proxy = project.new(Xcodeproj::Project::PBXContainerItemProxy)\n container_proxy.container_portal = project.root_object.uuid\n container_proxy.proxy_type = '1'\n container_proxy.remote_global_id_string = target.uuid\n container_proxy.remote_info = target.name\n\n dependency = project.new(Xcodeproj::Project::PBXTargetDependency)\n dependency.target = target\n dependency.target_proxy = container_proxy\n\n dependencies << dependency\n end\n end",
"def create(type, opts = {}, creation_opts = {}, &creation_callback)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)\n after_create(new_resource) if respond_to? :after_create\n\n self.synchronize do\n children << new_resource\n end\n new_resource\n end",
"def create_project(name, type)\nend",
"def dep(parent,child=nil)\n deps[parent]\n\n if child\n deps[child]\n deps[parent] << child\n end\n end",
"def create(param)\n\t\traise NotImplementedError\n\tend",
"def build_new(*args)\n self.class.new(*args)\n end",
"def dependency_name\n name.to_s.sub(/_factory$/, '').to_sym\n end",
"def simple_factory(opts_={})\n Cartesian::Factory.new(opts_)\n end",
"def initialize(identifier, *requirements)\n unless String === identifier\n raise ArgumentError,\n \"dependency identifier must be a String, was #{identifier.inspect}\"\n end\n\n requirements = requirements.first if 1 == requirements.length # unpack\n\n @identifier = identifier\n @requirement = FoobarMod::Requirement.create requirements\n end",
"def create_resource(type, title, parameters = {})\n parameters = parameters.merge(:name => title)\n resource = Puppet::Type.type(type.to_sym).new(parameters)\n catalog.add_resource(resource)\n resource\n end",
"def depend_on(dependant, env = environment.name, requirement = nil)\n fail('Dependant cannot be nil') if dependant.nil? || dependant.eql?('')\n fail('Environment cannot be nil') if env.nil? || env.eql?('')\n dep = if dependant == :all\n if env == :all\n Stacks::Dependencies::MultiServiceDependency.new(self,\n Stacks::Dependencies::AllKubernetesSelector.new(requirement),\n requirement)\n else\n fail('Selection by a specific environment not yet support for :all dependency')\n end\n elsif dependant.is_a?(Array)\n selectors = dependant.map { |d| Stacks::Dependencies::ServiceSelector.new(d, env) }\n Stacks::Dependencies::SingleServiceDependency.new(self,\n Stacks::Dependencies::MultiSelector.new(selectors),\n requirement)\n else\n Stacks::Dependencies::SingleServiceDependency.new(self,\n Stacks::Dependencies::ServiceSelector.new(dependant, env),\n requirement)\n end\n\n @depends_on << dep unless @depends_on.include? dep\n end",
"def create_reference\n self.reference or Reference.new\n end",
"def new\n @composer = Composer.new\n end",
"def add_dependency(name)\n dependencies[name]\n end",
"def create_for_request(params)\n klass = self.class.products.detect{|a| a.recognize_receive_request?(params)}\n return nil if klass.nil?\n klass.new\n end",
"def dependency(val)\n dependencies << val\n dependencies.dup\n end",
"def create_repository(name, dbmod)\n c = Class.new\n mod1 = if Repository.constants.include?(name)\n Repository.const_get(name)\n else\n mod = Module.new\n Repository.const_set(name, mod)\n mod\n end\n dbmod.const_set name, c\n end",
"def create(type, parent, lineno: nil, filename: nil)\n klass = registered_types[type]\n\n raise ::KeyError, \"Undefined node type #{type.inspect}\" if klass.nil?\n\n klass.new(type, parent, lineno: lineno, filename: filename)\n end",
"def create_dependancies\n create_course_plan()\n end",
"def create!\n raise NotImplementedError\n end",
"def construct\n end",
"def gem(name, *reqs)\n if dep = @dependency_names[name]\n dep.requirement.concat reqs\n else\n dep = Gem::Dependency.new name, *reqs\n @dependency_names[name] = dep\n @dependencies << dep\n end\n end",
"def create(tag)\n klass = Class.new self\n klass.tag tag\n klass\n end",
"def create_proxy ref\n proxy_class = @known_proxies[ref._remote_class_name]\n return ref unless proxy_class\n proxy_class.new(ReferenceCreationData.new(ref))\n end",
"def create_factory(namespace = nil)\n namespace ||= @@counter.increment.to_s\n return @@factory.factory(namespace)\n end",
"def make_reference(package_id, name)\n Variable.new(name, package_id)\n end",
"def initialize(dependency, activated, failed_dep=dependency)\n @dependency = dependency\n @activated = activated\n @failed_dep = failed_dep\n end",
"def initialize(dependency, activated, failed_dep=dependency)\n @dependency = dependency\n @activated = activated\n @failed_dep = failed_dep\n end",
"def instantiate!; end",
"def create(type)\n @call_params[:type] = type\n @client.call(self.class, __callee__.to_s, @call_params)\n end",
"def <<(dependency)\n if @dependencies.key? dependency.name\n @dependencies[dependency.name].merge!(dependency)\n else\n @dependencies[dependency.name] = dependency\n end\n end",
"def create\n @genre_dependency = GenreDependency.new(genre_dependency_params)\n\n respond_to do |format|\n if @genre_dependency.save\n format.html { redirect_to @genre_dependency, notice: 'Genre dependency was successfully created.' }\n format.json { render :show, status: :created, location: @genre_dependency }\n else\n format.html { render :new }\n format.json { render json: @genre_dependency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(name:, depends_on: [])\n @name = name\n @depends_on = depends_on\n end",
"def instantiate(*args)\n clazz.new(*args)\n end",
"def create_type(name, **options)\n register(Type.new_submodel(typename: name, registry: self, **options))\n end",
"def newobj(type, name, hash)\n transport = Puppet::TransObject.new(name, \"file\")\n transport[:path] = path\n transport[:ensure] = \"file\"\n assert_nothing_raised {\n file = transport.to_ral\n }\n end",
"def new\n @theory = Theory.new\n end",
"def factory(*args, &block)\n factory_path = FactoryPathFetcher.fetch\n name = args.first.to_s\n\n FactoryBotStrategy.factory_definitions[name] ||= []\n FactoryBotStrategy.factory_definitions[name] << factory_path\n\n super\n end",
"def add_reference( type, source, component, name, weight=nil )\n r = Ref.new( type, source, component, name, \n weight ? weight : Ref::DEFAULT_WEIGHT )\n add_reference_obj(r)\n return r\n end",
"def set_dependency\n @dependency = Dependency.find(params[:id])\n end",
"def cask(name); dep name, :template => \"icelab:cask\"; end",
"def factory?; @factory; end",
"def create(type, holder)\n # takes a type and holder args\n type = normalise type\n # normalises type\n fail UnrecognisedAccountType unless types[type]\n # tries to find account type, if it fails, raises an exception\n account_class = types[type]\n # sets account constant equal to account_class local variable\n account_class.new(holder, current_id)\n # calls .new on account class, passes holder and current_id method which returns the current id\n end",
"def new #:nodoc:\n end",
"def name\n @dependency.name\n end",
"def name\n @dependency.name\n end",
"def Factory(name, *args, &block)\n puts \"*** WARNING *** You should migrate over to using the proper Cobble methods as this won't be here forever!\"\n Cobble.create(name, *args, &block)\nend",
"def build_singleton0(type_name); end",
"def get_transfer(type)\n type = type[0].upcase + type[1..-1]\n try_require(type)\n Transfer.const_get(type).new(@options, @files) \n end",
"def create data_object_class, opts={}\n data_object = make data_object_class, opts\n data_object.create\n data_object\n end",
"def create name, object_type, config={}\n klass = @@sources[[name, object_type]]\n raise \"No Source registered with name #{name} and type #{object_type}.\" unless klass\n klass.new(config)\n end",
"def try_require(type, name); end",
"def deploys_to_class(type)\n (\n \"Building::%s\" % CONFIG[\"units.#{type.underscore}.deploys_to\"]\n ).constantize\n end",
"def create_relation(node, target_type)\n relation = @factory.new_relation\n \n # Read all defined data fields\n if node.attributes['direction']\n relation.direction = node.attributes['direction'].to_sym\n else\n relation.direction = Model::Relation::DIR_BOTH\n end\n \n if node.attributes['type']\n relation.type = Utils.add_namespace(node.attributes['type'], Model::NS_REL_1)\n end\n \n relation.begin_date = read_date_attribute(node, 'begin')\n relation.end_date = read_date_attribute(node, 'end')\n \n if node.attributes['attributes']\n node.attributes['attributes'].split(' ').each {|attribute|\n relation.attributes << Utils.add_namespace(attribute, Model::NS_REL_1)\n }\n end\n \n # Set the target. Either use the target included in the relation\n # or create a new target according to the target type if no target\n # is present.\n case target_type\n when Model::Relation::TO_ARTIST\n if node.elements['artist']\n target = create_artist node.elements['artist']\n else\n target = @factory.new_artist\n target.id = Model::MBID.parse(node.attributes['target'], :artist)\n end\n when Model::Relation::TO_RELEASE\n if node.elements['release']\n target = create_release node.elements['release']\n else\n target = @factory.new_release\n target.id = Model::MBID.parse(node.attributes['target'], :release)\n end\n when Model::Relation::TO_TRACK\n if node.elements['track']\n target = create_track node.elements['track']\n else\n target = @factory.new_track\n target.id = Model::MBID.parse(node.attributes['target'], :track)\n end\n when Model::Relation::TO_LABEL\n if node.elements['label']\n target = create_label node.elements['label']\n else\n target = @factory.new_label\n target.id = Model::MBID.parse(node.attributes['target'], :label)\n end\n when Model::Relation::TO_URL\n target = node.attributes['target']\n end\n \n relation.target = target\n \n return relation\n end",
"def create_field_reference( source, name, type_info )\n QueryParts::FieldReference.new(type_info, source, name)\n end",
"def create!(name, params = {})\n item = build(name, params)\n item.save!\n item\nend",
"def reference(name, type)\n \n end",
"def make(*args)\n raise NotImplementedError.new('Must override')\n end",
"def create(type, opts = {}, creation_opts = {}, &creation_callback)\n unless request_supported_children_type.include?(type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n opts[:parent_certificate] = @certificate if @certificate\n opts[:parent] = self\n\n call_hook(:before_create, self, type, opts)\n\n new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)\n\n log_metadata(self.uid, new_resource.uid, :create)\n\n call_hook(:after_create, self, new_resource)\n\n self.synchronize do\n children << new_resource\n end\n new_resource\n end",
"def di_wire(name, clazz, *args, &block)\n init_proc = lambda{ clazz.new(*args) }\n di_define_method(name, init_proc, block)\n end",
"def create_instance type, options=nil\n class_name = \"#{type.to_s.camel_case}Generator\"\n registered_entities.each do |entity|\n if(entity.to_s.match(/::#{class_name}$/) || entity.to_s.match(/^#{class_name}$/))\n return entity.new\n end\n end\n raise Sprout::Errors::MissingGeneratorError.new \"Could not find any generator named: (#{class_name}). Perhaps you need to add a RubyGem to your Gemfile?\"\n end",
"def create_dependencies(con)\n @resolving_dependencies = true\n dependencies.each do |_, d|\n fail CircularDependencyError.new(name, d.name) if d.resolving_dependencies\n d.create_dependencies(con)\n d.create_or_update!(con)\n end\n @resolving_dependencies = false\n end",
"def create_object\n sut.send(:new)\n end",
"def create\n @dependence = Dependence.new(dependence_params)\n\n respond_to do |format|\n if @dependence.save\n format.html { redirect_to @dependence, notice: 'Dependence was successfully created.' }\n format.json { render :show, status: :created, location: @dependence }\n else\n format.html { render :new }\n format.json { render json: @dependence.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.70160085",
"0.6388023",
"0.62843645",
"0.61787224",
"0.6020573",
"0.59608924",
"0.5925612",
"0.5895755",
"0.5841771",
"0.5823852",
"0.5804395",
"0.57698995",
"0.5739764",
"0.5675239",
"0.567129",
"0.5561659",
"0.55614346",
"0.5532884",
"0.5526409",
"0.5510601",
"0.54771894",
"0.54721177",
"0.5467415",
"0.54398954",
"0.54347265",
"0.5401282",
"0.5397357",
"0.5397357",
"0.538574",
"0.538574",
"0.5374402",
"0.53489107",
"0.5342246",
"0.53419214",
"0.533844",
"0.5325995",
"0.5314295",
"0.53118324",
"0.53007466",
"0.5293366",
"0.52812105",
"0.52768",
"0.52637947",
"0.5253789",
"0.5243502",
"0.5225982",
"0.5196354",
"0.5174313",
"0.51704025",
"0.51698166",
"0.5162815",
"0.51484925",
"0.5130295",
"0.51260155",
"0.5124966",
"0.5112503",
"0.5091829",
"0.50915164",
"0.50840056",
"0.50822073",
"0.5082039",
"0.5067468",
"0.506593",
"0.506593",
"0.5063032",
"0.5061077",
"0.50546336",
"0.5054611",
"0.5047531",
"0.5044762",
"0.50434875",
"0.503189",
"0.50304335",
"0.5028759",
"0.50250757",
"0.50111616",
"0.500775",
"0.500195",
"0.50002825",
"0.49926034",
"0.4984565",
"0.4984565",
"0.49834558",
"0.49816644",
"0.49815556",
"0.4973596",
"0.49728853",
"0.49704528",
"0.49670458",
"0.49597108",
"0.49567232",
"0.49564436",
"0.4950654",
"0.49461183",
"0.49402866",
"0.49387458",
"0.4930054",
"0.4928482",
"0.4913361",
"0.49129456"
] | 0.694366 | 1 |
Creates and returns a new RecBack MazeHelper object. Many options are supported: [:width] The number of columns in the maze. [:height] The number of rows in the maze. [:seed] The maze algorithm to use. This should be a class, | def initialize(options = {})
@width = (options[:width] || 10).to_i
@height = (options[:height] || @width).to_i
@seed = (options[:seed] || rand(0xFFFF_FFFF)).to_i
@grid = Array.new(height) {Array.new(width, 0)}
srand(@seed)
# start carving the maze passage from the upper-left corner
carve_passages_from(0, 0, @grid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redesign\r\n\t\tm = MazeMaker.new(@n,@m)\r\n\t\t@maze = m.make_maze\r\n\tend",
"def get_maze(full=true)\n Maze.new(@width, @height, @start_p, @end_p, full)\n end",
"def generate\n carve maze.cell_at(0,0)\n maze\n end",
"def initialize(options = {})\n @width = (options[:width] || 10).to_i\n @height = (options[:height] || @width).to_i\n @seed = (options[:seed] || rand(0xFFFF_FFFF)).to_i\n @grid = Array.new(height) { Array.new(width, 0) }\n\n srand(seed)\n end",
"def initialize(width, height)\n @grid = Array.new(height) { Array.new(width) }\n create_maze(0, 0, 3)\n end",
"def initialize(maze, options)\n @options = DEFAULTS.merge(options)\n\n [:background, :wall_color, :cell_color, :solution_color].each do |c|\n @options[c] = ChunkyPNG::Color.from_hex(@options[c]) if String === @options[c]\n end\n\n @paths = @options[:paths] || []\n\n if @options[:solution]\n path = maze.new_solver(type: @options[:solution]).solve.to_path(color: @options[:solution_color])\n @paths = [path, *@paths]\n end\n end",
"def create_maze(row, col, direction)\n curr_cell = Cell.new\n @grid[row][col] = curr_cell\n\n curr_cell.walls[direction] = false\n\n directions = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n 4.times do\n index = rand(directions.length)\n direction = directions.delete_at(index)\n direction_from =\n case direction\n when [0, 1]\n 0\n when [0, -1]\n 2\n when [1, 0]\n 3\n when [-1, 0]\n 1\n end\n\n direction_to =\n case direction\n when [0, 1]\n 2\n when [0, -1]\n 0\n when [1, 0]\n 1\n when [-1, 0]\n 3\n end\n new_row = row + direction[0]\n new_col = col + direction[1]\n\n unless new_row.negative? ||\n new_col.negative? ||\n new_row >= @grid.length ||\n new_col >= @grid[0].length ||\n @grid[new_row][new_col]\n\n curr_cell.walls[direction_to] = false\n create_maze(new_row, new_col, direction_from)\n end\n end\n end",
"def redesign()\n\t\tr_maze= maze {|r,c| r_maze[r][c].to_i}\n\t\t(1..row-2).each {|r| (1..col-2).each {|c| r_maze[r][c] = Random.rand(2).to_s}}\n\t\treturn r_maze\n\tend",
"def initializeMaze(size)\n return Array.new(size[0] + 1){Array.new(size[1] + 1, '#')}\nend",
"def create_maze(file)\n line = file.gets\n if line == nil then return end\n\n # read 1st line, must be maze header\n sz, sx, sy, ex, ey = line.split(/\\s/)\n #course is the maze course\n @course = Array.new(sz.to_i)\n @course.map!{Array.new(sz.to_i)}\n \n @course[sx.to_i][sy.to_i] = Cell.new(sx.to_i, sy.to_i)\n \n @start_x = sx.to_i\n @start_y = sy.to_i\n @course[sx.to_i][sy.to_i].change_mode(\"Start\")\n \n @course[ex.to_i][ey.to_i] = Cell.new(ex.to_i, ey.to_i)\n @end_x = ex.to_i\n @end_y = ey.to_i\n @course[ex.to_i][ey.to_i].change_mode(\"End\")\n \n @paths = Array.new\n # read additional lines\n while line = file.gets do\n\n # begins with \"path\", must be path specification\n if line[0...4] == \"path\"\n p, name, x, y, d = line.split(/\\s/)\n ds = d.split(//)\n temp = Path.new(nil, nil, nil, nil)\n temp.initialize(name, x.to_i, y.to_i, ds)\n @paths.push(temp)\n \n # otherwise must be cell specification (since maze spec must be valid)\n else\n x, y, d, w = line.split(/\\s/,4)\n if @course[x.to_i][y.to_i] == nil\n @course[x.to_i][y.to_i] = Cell.new(x.to_i,y.to_i)\n end\n \n ds = d.split(//)\n ws = w.split(/\\s/)\n (0...ds.size).each { |i| \n @course[x.to_i][y.to_i].new_direction(ds[i], ws[i])}\n end\n end\n end",
"def initialize(maze, meta={})\n @maze = maze\n @paths = Hash.new(0)\n @cells = Hash.new(0)\n @meta = meta\n end",
"def redesign(); load(MazeRedesign.new(across,down).produce) end",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED, a=DEFAULT_ANIMATE, d=DEFAULT_DELAY )\n\t\t# \n\t\t# Invoke super-constructor\n\t\t#\n\t\tsuper(w,h,s)\n\n\t\t@frontier = []\n\n\t\t# \n\t\t# Only prepare the maze beforehand if we are doing \"static\" (i.e., animate = false) drawing\n\t\t#\n\t\t@delay = d\n\t\t@animate = a\n\t\tif not @animate\n\t\t\tcarve_passages\n\t\tend\n\tend",
"def initialize(seeds)\n @grid = Array.new(9) { Array.new(9, nil) }\n @rows = {}\n @columns = {}\n @squares = {}\n 1.upto(9) do |i|\n @rows[i] = Hash.new(false)\n @columns[i] = Hash.new(false)\n @squares[i] = Hash.new(false)\n end\n seed_board(seeds)\n end",
"def make_graph\n\t\t@graph = Graph.new(@width2, @height2, @maze)\n\tend",
"def initialize(window, width, height, rooms_width, rooms_height)\n @window = window\n @width, @height = width, height\n @rooms_width, @rooms_height = rooms_width, rooms_height\n\n # Create RoomGenerator\n generator = RoomGenerator.new(@window, @rooms_width, @rooms_height)\n \n @rooms = Array.new(@height) do |l|\n Array.new(@width) do |c|\n generator.generate_room(c, l)\n end\n end\n \n puts \"Created maze of #{@width}*#{@height} rooms.\"\n puts \"=> #{@width*@rooms_width}*#{@height*@rooms_height} squares\"\n end",
"def redesign\n new_maze = Maze.new\n #continues until it gets a valid maze\n while !new_maze.loaded?\n new_maze = self.create_minimum\n string = new_maze.save\n string.strip!\n #tries to load the maze\n new_maze.load string, (@old_maze.width-1)/2, (@old_maze.height-1)/2\n #resets the maze full of walls if it is needed again\n @maze = Maze.new\n @maze.load @old_string, (@old_maze.width-1)/2, (@old_maze.height-1)/2, true\n end\n new_maze\n end",
"def initialize\n @start_vertical = nil\n @start_horizontal = nil\n @processed_maze = nil\n end",
"def initialize (n, m)\n @r = m\n @c = n\n @n = m * 2 + 1\n @m = n * 2 + 1\n @maze_mat = Array.new(@n){Array.new(@m)}\n end",
"def initialize n, m\n\t\t@width = n \n\t\t@height = m \n\t\t@width2 = @width * 2 + 1\n\t\t@height2 = @height * 2 + 1\n\t\t@maze = Array.new(@height2) {Array.new(@width2)}\n\tend",
"def setup_maze_presenter(algorithm, state)\n state[:current_grid_length] = INITIAL_MAZE_GRID_LENGTH\n state[:remaining_time] = TIME_LIMIT\n state[:algorithm] = algorithm\n state[:needs_reset] = true\n state[:footsteps] = []\n state[:level_record] = []\n state[:algorithm_state] = {}\n state[:pop_sound] = Gosu::Sample.new('assets/music/pop.ogg')\n state[:warning_sound] = Gosu::Sample.new('assets/music/warning.ogg')\nend",
"def initialize(maze, a=maze.start, b=maze.finish)\n @maze = maze\n @a = a\n @b = b\n @solution = nil\n end",
"def initialize(args={})\n @size = args[:size] || 10\n @seed = args[:seed] || 20\n raise ArgumentError, \"seed is larger than board size (size**2)\" if size**2 < seed\n @born = 0\n @died = 0\n @prospered = 0\n\n @board = Table.new(rows: size, cols: size, obj: Cell)\n #seed_board\n end",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED)\n \t @width = w\n\t @height = h\n\t @seed = s\n\t \n\t srand(@seed)\n\t \n\t # TODO --> remove grid??\n\t @grid = Array.new(h) { Array.new(w,0) }\n end",
"def recur_divide(x, y, w, h, dir)\n #we first check the size of our given part of the maze\n if w >= 5 and h >= 5\n #then we set where we want to add the wall in the maze\n check_h_cut = dir == \"H_cut\"\n c = (w-1)/2\n wall_x = x + (check_h_cut ? 1 : (rand(c - 1)+1)*2)\n r = (h-1)/2\n wall_y = y + (check_h_cut ? (rand(r - 1)+1)*2 : 1)\n\n #the incrementing number for maze\n incre_x = check_h_cut ? 2 : 0\n incre_y = check_h_cut ? 0 : 2\n\n #every time we break the maze into two part, we need to leave a hole in\n #the wall so that we could enter from one part to the other\n hole_x = wall_x + (check_h_cut ? rand(c)*2 : 0)\n hole_y = wall_y + (check_h_cut ? 0 : rand(r)*2)\n wall_length = check_h_cut ? c : r\n\n #draw the wall here\n wall_length.times do\n if wall_x != hole_x || wall_y != hole_y\n maze_mat[wall_y][wall_x] = 1\n end\n wall_x += incre_x\n wall_y += incre_y\n end\n\n #recirsively divide the maze into two parts and then draw the wall the the two parts\n new_x = x\n new_y = y\n new_w = check_h_cut ? w : wall_x - x + 1\n new_h = check_h_cut ? wall_y - y + 1 : h\n recur_divide(new_x, new_y, new_w, new_h, cut_dir(new_w, new_h)) #this is the top/left part of the maze\n new_x = check_h_cut ? x : wall_x\n new_y = check_h_cut ? wall_y : y\n new_w = check_h_cut ? w : w - wall_x + x\n new_h = check_h_cut ? h - wall_y + y : h\n recur_divide(new_x, new_y, new_w, new_h, cut_dir(new_w, new_h)) #this is the bottom/right part of the maze\n end\n end",
"def initialize (n, m)\n\t\t@width = n \n\t\t@height = m \n\t\t@array = []\n\t\t@maze = Array.new(n*2 + 1) {Array.new(m*2 + 1)}\n\tend",
"def initialize (n,m)\n\t\t@row = 2*m + 1\n\t\t@col = 2*n + 1\n\t\t@maze = []\n\t\t@visited = Array.new(row){Array.new(col) {|x| x = false}}\n\t\t@trace = []\n\n\tend",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def redesign\n @waiting = []\n @maze_table = Array.new(2*@m+1){Array.new(2*@n+1, \"1\")}\n for i in 0..2*@m\n for j in 0..2*@n\n @maze_table[i][j] = \"w\" if i%2==1 && j%2==1\n end\n end\n sx = 2*rand(@m)+1\n sy = 2*rand(@n)+1\n @maze_table[sx][sy] = \"0\"#set cell\n add_neighbor(sx, sy)\n until @waiting.empty?\n wall, cell, dir = @waiting.delete_at(rand(@waiting.length))\n pre = [cell[0]-2, cell[1]] if dir == \"down\"\n pre = [cell[0]+2, cell[1]] if dir == \"up\"\n pre = [cell[0], cell[1]-2] if dir == \"right\"\n pre = [cell[0], cell[1]+2] if dir == \"left\"\n if @maze_table[cell[0]][cell[1]] == \"w\" && count_walls(pre[0],pre[1]) > 1\n @maze_table[cell[0]][cell[1]] = \"0\"\n @maze_table[wall[0]][wall[1]] = \"0\"\n add_neighbor(cell[0], cell[1]) \n end\n end\n end",
"def make_maze\n\tk = 0\n\t\tfor i in 0 ..@height*2\n\t\t\tfor j in 0 ..@width*2\n\t\t\t\t@maze[i][j] = @array[k]\n\t\t\t\tprint @maze[i][j]\n\t\t\t\tk += 1\n\t\t\tend\n\t\t\tputs \"\"\n\t\tend\n\tend",
"def seed\n @matrix = @matrix.each_with_index do |cell|\n x, y = *cell\n Life::Cell.new(x, y, self)\n end\n end",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED )\n \t @width = w\n\t @height = h\n\t @seed = s\n\n\t srand(@seed)\n\n\t @grid = Array.new(h) { Array.new(w,0) }\n end",
"def set_maze\n @maze = Maze.find(params[:id])\n end",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED )\n\t\t@width = w\n\t\t@height = h\n\t\t@seed = s\n\n\t\tsrand(@seed)\t\n\n\t\t@grid = Array.new(h) { Array.new(w,0) }\n\tend",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED )\n\t\t@width = w\n\t\t@height = h\n\t\t@seed = s\n\n\t\tsrand(@seed)\t\n\n\t\t@grid = Array.new(h) { Array.new(w,0) }\n\tend",
"def initialize(width=30, height=30, random=true, random_seed=[true,false].to_a)\n\n @width=width\n @height=height\n\n #create an array\n @cells = ConwayModel::create_grid(width, height, random, random_seed)\n end",
"def initialize(maze)\n @cells_to_visit = []\n @cells_visited = []\n @solved_path = []\n @maze = maze\n end",
"def maze_maker number_of_nodes\n return_maze = Hash.new{ |h, k| h[k] = [] }\n\n nodes = gen_first_path number_of_nodes\n\n nodes.each do |k, v|\n return_maze[k] = add_nodes_to_node(return_maze, k, 4, nodes)\n end\n\n end_marker return_maze\n\n return_maze\nend",
"def maze_gaming(across,down,op)\n maze = Maze.new(across,down)\n if(op == 'size')\n load_input(maze)\n else\n maze.load(op)\n maze.display if(maze.valid == true)\n end\n if(maze.valid == true)\n solve_and_redesign(maze)\n end\n end",
"def redesign()\n random = Random.new\n count = 0\n maze_new_string = \"\"\n while count < @rows*@columns\n num = random.rand(2)\n maze_new_string = maze_new_string + num.to_s\n count+=1\n end\n load(maze_new_string)\n end",
"def initialize(params = {})\n @row, @column = params[:row], params[:column]\n @laby = params[:maze].labyrinth # the maze labyrinth\n {empty:' ',wall:'#',start:'A',stop:'B'}.each do |status, value|\n @status = status if value == params[:value]\n end\n end",
"def initialize\n yield self if block_given?\n @width ||= 10\n @height ||= 20\n\n @graph = []\n @height.times do |y|\n row = []\n t = @graph.empty? ? true : false\n b = @graph.size == (@height - 1) ? true : false\n\n @width.times do |x|\n l = row.empty? ? true : false\n r = row.size == (@width - 1) ? true : false\n\n row << Room.new do |room|\n room.top = t\n room.bottom = b\n room.left = l\n room.right = r\n room.y = y\n room.x = x\n end\n\n end\n @graph << row\n end\n end",
"def initialize(seed)\n @seed = @r = seed\n end",
"def initialize(seed)\n @seed = @r = seed\n end",
"def initialize width, height, cycle_detection = true, seed_network = nil\n \n @randomizer = proc {rand(2)}\n \n @cycle_detection_enabled = cycle_detection\n \n @width = width\n @height = height\n\n if seed_network\n self.network = seed_network\n else\n generate_network\n end\n \n reset_history\n \n end",
"def initialize(options = {})\n @col, @colOff, @row, @rowOff = 0, 0, 0, 0\n parse_options options\n end",
"def draw_maze_presenter(window, state)\n grid = state[:grid]\n game_state = state[:game_state]\n player = state[:player]\n remaining_time = state[:remaining_time]\n\n grid.each do |grid_row|\n grid_row.each do |cell|\n next unless game_state == GameState::CREATING_MAZE || player_near_cell?(player, cell, VISIBLE_ZONE)\n\n # Only draws the cell if the game is not running (i.e. maze is being created or game finished)\n # or if the cell is close to the player\n draw_cell(window, cell, cell == player, grid.length)\n end\n end\n cell_width = window.width / grid.length\n\n scanner_rect = if state[:algorithm] == MazeAlgorithm::DEPTH_FIRST\n depth_first_scanner_rect(cell_width, state[:algorithm_state])\n else\n iterative_division_scanner_rect(cell_width, state[:algorithm_state])\n end\n if game_state == GameState::CREATING_MAZE\n window.draw_rect(scanner_rect.x_pos,\n scanner_rect.y_pos,\n scanner_rect.width,\n scanner_rect.height,\n Gosu::Color.argb(SCANNER_COLOR))\n end\n\n Gosu::Font.new(20).draw_text(remaining_time.floor,\n window.width - 30, # draw x\n 5, # draw Y\n 1, # draw Z\n 1, # scale x\n 1, # scale y\n Gosu::Color.argb(LIGHT_GREEN_COLOR))\nend",
"def fullmaze\n\t\ttopbottom = \"+-\" * @width + \"+\"\n\t\tmiddle = \"|\" + \" |\" * @width\n\t\treturn topbottom + (middle + topbottom) * @height\n\tend",
"def create\n @maze = current_user.mazes.new(maze_params)\n generateMaze\n respond_to do |format|\n if @maze.save\n format.html { redirect_to @maze, notice: 'Labirinto criado com sucesso.' }\n format.json { render :show, status: :created, location: @maze }\n else\n format.html { render :new }\n format.json { render json: @maze.errors, status: :unprocessable_entity }\n end\n end\n #respond_to do |format|\n #format.html { redirect_to new_maze_path}\n end",
"def generate\n cells.destroy_all\n \n x = 0\n while x < width do\n y = 0\n while y < height do\n cells.create(:x => x, :y => y)\n y += 1\n end\n x += 1\n end\n \n # A wall is like this: [cell1,cell2]\n walls = []\n \n cells.each do |cell|\n walls += ([cell]*4).zip(cell.neighbours)\n end\n \n walls.shuffle!\n \n walls.each do |cell, neighbour|\n cell.create_edge_to_and_from(neighbour) unless neighbour.nil? || cell.reachable?(neighbour)\n end\n \n @solution ||= cells.first.shortest_path_to(cells.last)\n end",
"def initialize(maze)\n\t\t# Build the 2D area, like this: [%w{# # #}, %w{#A#}, %w{#B#}]\n\t\t@area = maze.split(/\\r?\\n/).map {|r| r.split(//) }\n\t\t#Find start & the end - 2 arrays with coordinates: [row,column]\n\t\t@area.each_with_index do |r, ri|\n\t\t\tr.each_with_index do |c, ci|\n\t\t\t\t@start = [ri,ci] if c == StartMark\n\t\t\t\t@end = [ri,ci] if c == EndMark\n\t\t\t\tbreak if @start && @end\n\t\t\tend\n\t\t\tbreak if @start && @end\n\t\tend\n\t\tthrow ArgumentError.new('No start and/or end positinos provided on the maze') if !@start || !@end\n\tend",
"def setup_grid(seed_file)\n # Read the seed file\n file_object = File.open(seed_file)\n seed_data = file_object.readlines\n file_object.close\n\n @columns = seed_data[0].chomp.length\n @rows = seed_data.size\n\n # Init grid contents for rows and columns\n init_contents(@rows, @columns)\n\n # Loop through seed data and setup grid contents\n row = 0\n for each_line in seed_data\n column = 0\n each_line.chomp.each_char do |chr|\n cell = @contents[row][column] # Take out the Cell to set it's state\n cell.state = chr\n @contents[row][column] = cell\n column += 1\n end\n row += 1\n end\n end",
"def initialize(height=29, width=33)\n @height = height\n @width = width\n @hexes = Array.new(height) { Array.new(width) }\n\n height.times do |h|\n width.times do |w|\n if h == 0 && w == 0\n\t @hexes[h][w] = Plain.new\n\telsif h == 0\n\t @hexes[h][w] = @hexes[h][w-1].generate_adjacent\n\telsif w == 0\n\t @hexes[h][w] = @hexes[h-1][w].generate_adjacent\n\telse\n\t possible_parents = [@hexes[h][w-1], @hexes[h-1][w]]\n\t if w % 2 == 1\n\t possible_parents << @hexes[h-1][w-1]\n\t possible_parents << @hexes[h-1][w+1] if w < @width - 1\n\t end\n\t begin\n\t @hexes[h][w] = possible_parents.sample.generate_adjacent\n\t rescue\n\t puts \"Error occurred at indices (#{h}, #{w})\"\n\t print possible_parents\n\t print '\\n'\n\t @hexes[h][w] = Plain.new\n\t end\n\tend\n end\n end\t\n end",
"def initialize(seed_file)\n setup_grid(seed_file)\n end",
"def create_minimum\n for y in 0...@maze.height\n for x in 0...@maze.width\n tile = @maze.get_tile(x,y)\n if tile.is_room\n @rooms.push tile\n tile.type = 0\n @maze.size+=1\n self.create_connection tile\n end\n end\n end\n\n #populates the maze until it reaches the given maze's size\n while @maze.size<@size\n self.create_connection @rooms.sample\n end\n\n #if it somehow goes over the given maze size just redesign it again, I don't think this gets hit but it's here incase my algorithm is screwy\n if @maze.size>@size\n @maze = Maze.new\n @maze.load @old_string, (@old_maze.width-1)/2, (@old_maze.height-1)/2, true\n end\n\n @maze\n end",
"def initialize\n @x = 20\n @y = 12\n @grid ||= generate_grid\n @generator_flag ||= false\n end",
"def display_maze_with_png(grid)\n \nend",
"def initialize(mX, mY, mT, mW)\n @MapX = mX\n @MapY = mY\n @MapTerrain = mT\n @MapWeather = mW\n \n rt = Random.new()\n @@mapContent = Array.new(2) {Array.new(3) {|index| index = rt.rand(4)}}\n #(0..5).each {|x| @@mapContent[x] = (0..5).each {|y| @@mapContent[x][y] = rt.rand(4)}}\n end",
"def step_through_maze_generator(grid, state)\n case state[:algorithm]\n when MazeAlgorithm::DEPTH_FIRST\n step_through_depth_first_maze_generator(grid, state[:algorithm_state])\n when MazeAlgorithm::ITERATIVE_DIVISION\n step_through_iterative_division_maze_generator(grid, state[:algorithm_state])\n end\nend",
"def carve_passages\n\n\t\t# \n\t\t# Select random pointin the grid to begin carving\n\t\t#\n\t\tmark( rand(@width) , rand(@height) )\n\n\t\t# \n\t\t# Marking an empty matrix creates a frontier. \n\t\t# Keep going until there is no frontier.\n\t\t#\n\t\tuntil @frontier.empty?\n\n\t\t\t# \n\t\t\t# Randomly select a frontier point, and \n\t\t\t# randomly selected one of the neighboring\n\t\t\t# points to that frontier point.\n\t\t\t#\n\t\t\tx, y = @frontier.delete_at( rand(@frontier.length) )\n\t\t\tn = neighbors(x, y)\n\t\t\tnx, ny = n[ rand(n.length) ]\n\n\t\t\t#\n\t\t\t# \"Knock down\" the wall between the selected\n\t\t\t# frontier point and its neighbor.\n\t\t\t#\n\t\t\tdir = direction(x, y, nx, ny)\n\t\t\t@grid[y][x] |= dir\n\t\t\t@grid[ny][nx] |= @@OPPOSITE[dir]\n\n\t\t\t# \n\t\t\t# Recursively mark the newly selected point.\n\t\t\t#\n\t\t\tmark(x, y)\n\n\t\t\t#\n\t\t\t# If we are animating, display the maze\n\t\t\t#\t\t\n\t\t\tif @animate\n\t\t\t\tdisplay\n\t\t\t\tsleep @delay \n\t\t\tend\n\t\tend\n\n\t\t#\n\t\t# If we are animating, display the maze (one last time)\n\t\t#\n\t\tif @animate\n\t\t\tdisplay\n\n\t\t\t# \n\t\t\t# Output maze metadata.\n\t\t\t#\n\t\t\tputs metadata\n\t\tend\n\tend",
"def initialize(options)\n @tile_source = options[:source]\n raise \"Missing options[:source].\" unless @tile_source\n @tile_source = Magick::Image.read(@tile_source)[0] if @tile_source.is_a?(String)\n @tile_size = options[:size] || DEFAULT_TILE_SIZE\n @tile_overlap = options[:overlap] || DEFAULT_TILE_OVERLAP\n @tile_format = options[:format] || DEFAULT_TILE_FORMAT\n @max_tiled_height = @tile_source.rows\n @max_tiled_width = @tile_source.columns\n @tile_quality = options[:quality] || DEFAULT_QUALITY\n @overwrite = options[:overwrite] || false\n @destination = options[:destination] || File.join(Dir.pwd, \"tiles\")\n end",
"def draw\n \t #\n\t # Draw the \"top\" line.\n\t #\n\t puts \" \" + \"_\" * (@width * 2 - 1)\n\n\t #\n\t # Draw each of the rows.\n\t #\n\t @height.times do |y|\n\t \tprint \"|\"\n\t\t@width.times do |x|\n\t\t # TODO --> remote \"grid\" references??\n\t\t # render \"bottom\" using \"S\" switch\n\t\t print( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\n\t\t # render \"side\" using \"E\" switch\n\t\t if @grid[y][x] & @@E != 0\n\t\t print( ( (@grid[y][x] | @grid[y][x+1]) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t else\n\t\t print \"|\"\n\t\t end\n\t\tend\n\t\tputs\n\t end\n\n \t #\n\t # Output maze metadata.\n\t #\n\t puts \"#{$0} #{@width} #{@height} #{@seed}\"\n end",
"def initialize\n\t\t@rows = 8\n\t\t@cols = 8\n\t\t@grid = Array.new(rows) { Array.new(cols) }\n\tend",
"def initialize(width, height, debug=false)\n @grid = []\n @width = width; @height = height\n @debug = debug\n debug_counter = debug ? 0 : nil\n height.times do |row_idx|\n line = []\n width.times do |column_idx|\n debug_counter = decremented_value_of(debug_counter)\n line << Element.new(debug_counter, row_idx, column_idx, self)\n end\n @grid << line\n end\n end",
"def initialize(options, seeds = [])\n @options = options\n end",
"def maze_escape(maze, start)\n ans = maze_escape_helper(maze, start)\n @maze_cache = Hash.new { |hash, key| hash[key] = {} }\n ans\n end",
"def initialize(width: 100, height: 100, size: 5)\n @width = width.clamp(0, 1000) # width of cell grid\n @height = height.clamp(0, 1000) # height of cell grid\n @size = size.clamp(3, 100) # size of each cell on viewport\n\n # calculate game viewport size\n @viewport_width = width * size\n @viewport_height = height * size\n\n # setup game environment\n @environment = Environment.new(\n width: width,\n height: height\n )\n\n # populate environment with random\n # population of live cells\n @environment.seed_random\n\n # setup tick\n @tick = Tick.new(@environment)\n\n # setup gosu window config\n super @viewport_width, @viewport_height\n self.caption = \"Game of Life\"\n end",
"def initialize(width, height)\n\n # ensure heights and widths are odd\n width += 1 if width.odd?\n height += 1 if height.odd?\n @width = width\n @height = height\n\n # Initilize cell array\n initialise_cell_array()\n\n # Block the perimeter\n block_perimeter()\n\n # Generate rooms\n generate_rooms()\n\n # Generate corridors\n generate_corridors()\n\n # Trim tree\n trim_tree()\n end",
"def initialize(width, height, tile_width: 1, tile_height: 1)\n @tiles = (0...height).step(tile_height).map.with_index do |console_y, map_y|\n (0...width).step(tile_width).map.with_index do |console_x, map_x|\n Tile.new map_x,\n map_y,\n [console_y, console_x] # reversed for Console::setpos\n end\n end\n\n @height = height / tile_height\n @width = width / tile_width\n end",
"def initialize(size)\n @size = size\n @matrix = generate_matrix\n end",
"def initialize(size=10, max_height=5)\n if !size.positive?\n raise ArgumentError, \"Board size must be greater than zero!\"\n else\n @size = size\n @max_height = max_height\n @min_word_length = 2\n @grid = Hash.new do |h, (row, col)|\n if row < 0 || col < 0 || num_rows <= row || num_columns <= col\n raise IllegalMove, \"#{row}, #{col} is out of bounds!\"\n else\n h[[row, col]] = [] # Initialize with empty array\n end\n end\n end\n end",
"def vertical_connections\n resulting_maze << Maze.new(@size, 1)\n\n carved = (0...@size).group_by { |key| @uf.find(key) }.values.inject([]) do |changed, soc| # soc = set of cells\n soc.shuffle[0,1+rand(soc.size)].each do |cell|\n resulting_maze.carve_wall([cell,-1],[cell,-2])\n changed << cell\n end\n changed\n end\n\n ( (0...@size).to_a - carved ).each { |c| @uf.reassign(c) }\n\n self\n end",
"def initialize(world, seeds = [])\n @world = world\n @seeds = seeds\n plant_seeds\n end",
"def initialize(fill_board = true)\n @grid = Array.new(8) { Array.new(8) }\n\n setup_grid if fill_board\n end",
"def initialize(x, y, width, height, modes)\n super(x, y, width, height, 32, 32)\n \n @row_max = modes.size\n @column_max = 1\n \n @modesList = []\n window_update(modes)\n self.index = 0\n end",
"def make_room max_w,max_h\n\t{\n\t\tx: rand(@grid_w - max_w - 1) + 1,\n\t\ty: rand(@grid_h - max_h - 1) + 1,\n\t\tw: rand(max_w) + 1,\n\t\th: rand(max_h) + 1,\n\t}\n\tend",
"def create_image\n @cols = @cmd_options[0]\n @rows = @cmd_options[1]\n\n if is_valid_matrix?\n tmp = [];\n @rows.times do |row|\n @cols.times do |col|\n tmp << @default_color\n end\n end\n @matrix = tmp.each_slice(@cols).to_a\n else\n raise RangeError, \"Invalid Matrix. Pixel co-ordinates should be pair of integers: a column number between 1 and 250, and a row number between 1 and 250\"\n end\n end",
"def initialize(world=World.new, seeds=[])\n @world = world\n @seeds = seeds\n @total_generations = 1\n @generation = 0\n\n if @seeds.length == 0\n @world.populate!\n end\n\n @seeds.each do |row|\n @world.board[row[0]][row[1]].alive = true\n end\n end",
"def initialize options={}\n opts = {\n :left => nil,\n :right => nil,\n :root => nil,\n :value => rand(40)\n }.merge options\n @left=opts[:left]\n @right=opts[:right]\n @value=opts[:value]\n @root=opts[:root]\n end",
"def initialize (*args)\n if (args.length == 2)\n setup_with_dims(args[0], args[1])\n\n # below we're basically re-writing what's in each_with_index except we're passing matrix instead of element\n # For performacne reasons we don't just want to pass block around.\n if block_given?\n @fm.each_with_index do |el, index|\n yield self, get_row_from_index(index), get_col_from_index(index)\n end\n end\n\n\n elsif (args.length == 1)\n setup_with_rows(args[0])\n end\n end",
"def initialize(parse_args=false)\n # general:\n #@mode = 'default' # the mode of the generator: either 'defaut' or 'MM' (memory management)\n @mode = 'jit' # the mode of the generator: either 'defaut' or 'MM' (memory management) or 'MM_extreme'\n @mainClassName = 'Test' # Name of a main class\n @package = '' # Add java package name\n @outer_control = true # Ability to setup a random seed for Java code\n @outer_control_prob = 3 # 1 - 100% invocations, 2 - 50% invocations, 3 - 33% invocations, etc.\n @max_size = 100 # max length of arrays and loops; should not be less than 10\n @max_stmts = 15 # generated statements max count\n #@max_nlen = 3 # max length of a random name\n @max_arr_dim = 2 # array max dimension\n @width = 120 # width of resulting text\n @max_shift = 110 # max indentatation of a text line\n @p_big_array = 20 # probability of big array creation\n @min_big_array = 12276 # 12kB for byte type, 24kB for short and char, 48kB for int and float, 96kB for double\n @max_big_array = 1000000 # a random size to add to a big array\n # methods:\n @max_meths = 10 # max count of methods (excluding main) in a class\n @max_args = 5 # max count of a method arguments\n @max_classes = 0 # max count of classes. The actual number can be greater due to foreign class fields generation\n @max_threads = 0 # max count of runThread(Runnable obj) usage\n @p_constructor = 0 # probability of non-trivial constructor\n @max_callers_chain = 2 # Maximum chain of methods calling each other (including constructors)\n @p_non_static_method = 50 # probability of non-static method\n # expressions:\n # MAX_NUM = 100\n # MAX_NUM = 0x80000000 # max int + 1\n @max_num = 0x10000 # 16-bit int + 1 - max int literal\n @max_exp_depth = 3 # max depth of expression recursion\n @p_null_literal = 30 # probability of null literal\n # statements:\n @max_if_stmts = 4 # max count of statements in if part of if statement\n @max_el_stmts = 4 # max count of statements in else part of if statement\n @max_try_stmts = 6 # max count of statements in try\n @max_loop_stmts = 5 # max count of statements in a loop\n @max_loop_depth = 3 # max depth of nested loops\n @start_frac = 16 # fraction of the max value of induction var for initial value\n @min_small_meth_calls = 100 # minimal number of small method calls\n @max_small_meth_calls = 10000 # maximal number of small method calls\n\n # expression probabilities:\n @p_invoc_expr = 25 # probability of method invocation in expression\n @p_inl_invoc_expr = 2 # probability of inlinable method invocation in expression\n \n # variables:\n @p_volatile = 15 # probability of a variable being volatile\n \n # Var types description:\n # non_static - non-static field of a current class\n # static - static field of a current class\n # local - local variable of a current method\n # static_other - static field of a foreign class, example: Class1.iFld\n # local_other - non-static field of an object of a foreign class, example: Object1.iFld\n # block - the variable is declared in current block (loop)\n @var_types = ProbTab.new({'non_static'=>1, 'static'=>1, 'local'=>10, 'static_other'=>1,'local_other'=>1, 'block'=>3})\n @types = ProbTab.new({'Array'=>2, 'Object'=>0, 'boolean'=>1, 'String'=>0, 'byte'=>1, 'char'=>0, 'short'=>1,\n 'int'=>1, 'long'=>1, 'float'=>1, 'double'=>1})\n @exp_kind = ProbTab.new({'literal'=>20, 'scalar'=>8, 'array'=>2, 'field'=>0, 'oper'=>10,\n 'assign'=>1, 'cond'=>0, 'inlinvoc'=>0, 'invoc'=>5, 'libinvoc'=>2})\n @op_cats = ProbTab.new({'relational'=>2, 'boolean'=>1, 'integral'=>5, 'arith'=>30,\n 'uarith'=>5, 'indecrem_pre'=>3, 'indecrem_post'=>3, 'boolean_assn'=>1,\n 'integral_assn'=>1, 'arith_assn'=>2, 'object_assn'=>0, 'array_assn'=>25})\n @ind_kinds = ProbTab.new({'-1'=>12, '0'=>18, '+1'=>12, 'any'=>1})\n @operators = {'relational' => ProbTab.new({'=='=>1, '!='=>1, '<'=>1, '<='=>1, '>'=>1, '>='=>1}),\n 'boolean' => ProbTab.new({'=='=>1, '!='=>1, '&'=>1, '|'=>1, '^'=>1, '&&'=>1, '||'=>1, '!'=>1}),\n 'integral' => ProbTab.new({'&'=>1, '|'=>1, '^'=>1, '<<'=>1, '>>'=>1, '>>>'=>1, '~'=>1}),\n 'arith' => ProbTab.new({'+'=>1, '-'=>1, '*'=>1, '/'=>1, '%'=>1}),\n 'uarith' => ProbTab.new({'-'=>1}),\n 'indecrem_pre' => ProbTab.new({'++'=>1, '--'=>1}),\n 'indecrem_post'=> ProbTab.new({'++'=>1, '--'=>1}),\n 'boolean_assn' => ProbTab.new({'='=>1}),\n 'integral_assn'=> ProbTab.new({'='=>1, '&='=>1, '|='=>1, '^='=>1, '<<='=>1, '>>='=>1, '>>>='=>1}),\n 'arith_assn' => ProbTab.new({'='=>1, '+='=>1, '-='=>1, '*='=>1, '/='=>1, '%='=>1}),\n 'object_assn' => ProbTab.new({'='=>1}),\n 'array_assn' => ProbTab.new({'='=>1})}\n # statement probabilities:\n @p_empty_seq = 2 # probability of empty sequence of statements\n @p_else = 40 # probability of Else in If statement\n @p_triang = 30 # probability of induction var in For initial value expr\n @p_meth_reuse = 50 # probability of re-using known meth in an invocation\n @p_return = 10 # probability of return statement\n @p_var_reuse = 60 # probability of reusing existing var or arr\n @p_class_reuse = 70 # probability of reusing existing class\n @p_big_switch = 1 # probability of big switch\n @p_packed_switch = 60 # probability of packed switch\n @for_step = ProbTab.new({-3=>1, -2=>1, -1=>4, 1=>32, 2=>1, 3=>1})\n @p_ind_var_type = ProbTab.new({'int'=>20, 'long'=>5, 'float'=>1, 'double'=>1}) # induction var types\n @stmt_list = {\n # class weight weight-in-loop scale-down-factor\n ForLoopStmt => [24, 12, 1.5],\n WhileDoStmt => [ 8, 4, 1.5],\n EnhancedForStmt => [ 4, 2, 1.5],\n ContinueStmt => [ 0, 1, 1],\n BreakStmt => [ 0, 1, 1],\n IfStmt => [ 2, 3, 1.5],\n SwitchStmt => [ 1, 1, 1],\n AssignmentStmt => [ 1, 40, 1],\n IntDivStmt => [ 0, 1, 1],\n ReturnStmt => [ 0, 1, 1],\n TryStmt => [ 1, 2, 1],\n ExcStmt => [ 1, 2, 1],\n VectStmt => [ 0, 8, 1],\n InvocationStmt => [ 1, 1, 2],\n CondInvocStmt => [ 10, 1, 2],\n SmallMethStmt => [ 10, 1, 2],\n NewThreadStmt => [ 3, 1, 2]\n }\n parseArgs() if parse_args\n if @mode == 'default'\n @types.setValue('Array', 0)\n @types.setValue('Object', 0)\n @p_big_array = 0\n @p_constructor = 0\n @max_threads = 0\n elsif @mode == 'jit'\n @types.setValue('Array', 0)\n @types.setValue('Object', 0)\n @p_big_array = 0\n @p_constructor = 0\n @max_threads = 0\n @stmt_list[InvocationStmt] = [10,20,1]\n @stmt_list[CondInvocStmt] = [30,20,1]\n @exp_kind.setValue('invoc',100)\n @exp_kind.setValue('libinvoc',50)\n @max_meths = 10\n end\n $EXC_LIST.map!{|x| x==$USER_DEF_EXC ? $USER_DEF_EXC+@mainClassName : x}\n $USER_DEF_EXC=$USER_DEF_EXC+@mainClassName\n $TEST_CLASS_NAME = \"TestClass\"+@mainClassName\n end",
"def initialize config={}, &block\n\n h = config.fetch(:height, nil)\n w = config.fetch(:width, nil)\n t = config.fetch(:row, nil)\n l = config.fetch(:col, nil)\n if h && w && t && l\n #@window = Window.new :height => h, :width => w, :top => t, :left => l\n @window = Window.new h, w, t, l\n # else window will be created in repaint, and form will pass it to widgets before their first\n # repaint\n end\n @form = Form.new @window\n @buttons = [\"Ok\", \"Cancel\"] ## default button, can be overridden\n\n config.each_pair { |k,v| instance_variable_set(\"@#{k}\",v) }\n @config = config\n @row = 0\n @col = 0\n @row_offset = 1\n @col_offset = 2\n \n @color_pair = CP_BLACK\n\n @maxrow = 3\n\n instance_eval &block if block_given?\n #yield_or_eval &block if block_given? TODO\n\n end",
"def initialize(town_name, max_r, max_faker, seed)\r\n @name = town_name\r\n @max_rubies = max_r\r\n @max_fake_rubies = max_faker\r\n @random = Random.new(seed)\r\n # Initialize neighbors to be empty list\r\n @neighbors = []\r\n end",
"def initialize(options={}, &block)\n if options[:size]\n options[:width] = options[:size][0]\n options[:height] = options[:size][1]\n end\n options = DefaultOptions.merge(options)\n\n @width = options[:width]\n @height = options[:height]\n @output = options[:filename] || 'test'\n @stacksize = 0\n @colorspace = CGColorSpaceCreateDeviceRGB() # => CGColorSpaceRef\n @autoclosepath = false\n\n case options[:type]\n when :pdf\n @filetype = :pdf\n # CREATE A PDF DRAWING CONTEXT\n # url = NSURL.fileURLWithPath(image)\n url = CFURLCreateFromFileSystemRepresentation(nil, @output, @output.length, false)\n pdfrect = CGRect.new(CGPoint.new(0, 0), CGSize.new(width, height)) # Landscape\n #@ctx = CGPDFContextCreateWithURL(url, pdfrect, nil)\n consumer = CGDataConsumerCreateWithURL(url);\n pdfcontext = CGPDFContextCreate(consumer, pdfrect, nil);\n CGPDFContextBeginPage(pdfcontext, nil)\n @ctx = pdfcontext\n when :image, :render\n # CREATE A BITMAP DRAWING CONTEXT\n @filetype = File.extname(@output).downcase[1..-1].intern if options[:type] == :image\n\n @bits_per_component = 8\n @colorspace = CGColorSpaceCreateDeviceRGB() # => CGColorSpaceRef\n #alpha = KCGImageAlphaNoneSkipFirst # opaque background\n alpha = KCGImageAlphaPremultipliedFirst # transparent background\n\n # 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaPremultipliedFirst; 57141 bytes/row.\n bytes = @bits_per_component * 4 * @width.ceil\n @ctx = CGBitmapContextCreate(nil, @width, @height, @bits_per_component, bytes, @colorspace, alpha) # => CGContextRef\n when :context\n @ctx = options[:context]\n else\n raise \"ERROR: output file type #{ext} not recognized\"\n end\n\n # antialiasing\n CGContextSetAllowsAntialiasing(@ctx, true)\n\n # set defaults\n fill # set the default fill\n nostroke # no stroke by default\n strokewidth # set the default stroke width\n font # set the default font\n antialias # set the default antialias state\n autoclosepath # set the autoclosepath default\n quality(options[:quality]) # set the compression default\n push # save the pristine default default graphics state (retrieved by calling \"reset\")\n push # create a new graphics state for the user to mess up\n if block_given?\n case block.arity\n when 0\n send(:instance_eval, &block)\n else\n block.call(self)\n end\n end\n end",
"def initialize options = {}\n @board ||= options[:board] || :general\n @format ||= options[:format] || :ascii\n\n yield self if block_given?\n\n @current = \"\"\n @last = \"\"\n end",
"def initialize(options = {})\n @fen = options.fetch(:fen, FEN_INITIAL)\n @height = options.fetch(:height, 6)\n @moves = Array.new(MAXPLY)\n parse_position(@fen)\n end",
"def initialize(x, y, width, height, options = {})\n @x = x\n @y = y\n @width = width\n @height = height\n @children = []\n if options[:sprite]\n self.sprite = options[:sprite]\n end\n if block_given?\n yield self\n end\n end",
"def seed= seed\n @seed = seed\n @frontier = empty_neighbours(@seed)\n end",
"def initialize\n @choices = %w(1 2 3 4 5 6 7 8 9)\n @puzzle = [0] * 81\n @rows = [[], [], [], [], [], [], [], [], []]\n @columns = [[], [], [], [], [], [], [], [], []] \n @boxes = [[], [], [], [], [], [], [], [], []]\n end",
"def maze_escape(maze, start)\n end",
"def maze_escape(maze, start)\n end",
"def setup\n size(800, 200)\n new_tree\nend",
"def maze_params\n params.require(:maze).permit(:adjacencyList, :solutionMaze, :startingPoint, :endPoint, :sizeMaze)\n end",
"def initialize(pos)\n @position = pos\n @grid = Array.new(8){Array.new(8)}\n populate_grid\n @visited_positions = [pos]\n @move_tree = build_move_tree\n end",
"def initialize ()\n\t\t@board = [\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \" ,\" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" X \", \" O \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" O \", \" X \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \"]\n\t\t@board_arr\t\t= Array(0..@board.length-1)\n\t\t@board_height\t= 8\n\t\t@board_width \t= 8\n\tend",
"def seed; end",
"def initialize(size=DEFAULT_SIZE)\n super(SIZE_GRID, SIZE_GRID + HEIGHT_INFO_BLOCK, false)\n self.caption = 'A* Pathfinding Visualizer'\n @font = Gosu::Font.new(28)\n @message = 'Choose the start node.'\n @grid = Grid.new(self, size, size, SIZE_GRID)\n @start = @end = nil\n @needs_reset = false\n end",
"def initialize(width, height)\n\n\t\t# ensure heights and widths are odd\n\t\twidth += 1 if width.odd?\n\t\theight += 1 if height.odd?\n\t\t@width = width\n\t\t@height = height\n\n\t\t# Initilize cell array\n\t\tinitialise_cell_array()\n\n\t\t# Block the perimeter\n\t\tblock_perimeter()\n\n\t\t# Generate rooms\n generate_rooms()\n\n\t\t# Generate corridors\n\t\tgenerate_corridors()\n\n\t\t# Trim tree\n\t\ttrim_tree()\n\tend",
"def initialize\n self.make_board\n end",
"def initialize(setup)\n @grid = Array.new(8) { Array.new(8, nil)}\n\n if setup\n setup_pieces\n end\n end"
] | [
"0.60306096",
"0.5867004",
"0.5722799",
"0.5674609",
"0.55316454",
"0.5510154",
"0.54470944",
"0.5416506",
"0.5395136",
"0.5344716",
"0.5318697",
"0.52820045",
"0.5241874",
"0.5171722",
"0.5171573",
"0.5103918",
"0.5090913",
"0.5081683",
"0.5038239",
"0.49908844",
"0.49598753",
"0.49444863",
"0.49332064",
"0.48911515",
"0.48837274",
"0.48722452",
"0.4828539",
"0.48111343",
"0.47782248",
"0.47733656",
"0.47729954",
"0.47533193",
"0.47449043",
"0.47372353",
"0.47372353",
"0.47349",
"0.47326824",
"0.4698958",
"0.4687621",
"0.46729994",
"0.46655625",
"0.4664144",
"0.46637848",
"0.46637848",
"0.46317628",
"0.46193793",
"0.46141663",
"0.4599823",
"0.45772135",
"0.45764452",
"0.45622543",
"0.4557298",
"0.4549337",
"0.45227578",
"0.45222446",
"0.451926",
"0.44702032",
"0.44653255",
"0.44399637",
"0.4349432",
"0.4348511",
"0.43219015",
"0.43172932",
"0.43133917",
"0.42930928",
"0.4293052",
"0.42919898",
"0.4290065",
"0.4276508",
"0.4270959",
"0.42562518",
"0.42512405",
"0.42505556",
"0.42325076",
"0.42305216",
"0.4208371",
"0.42046326",
"0.4195094",
"0.41891676",
"0.41875994",
"0.4186728",
"0.4185476",
"0.41848284",
"0.4175433",
"0.41731367",
"0.41598603",
"0.41522205",
"0.41501164",
"0.41490385",
"0.41431934",
"0.41431934",
"0.41406184",
"0.41379067",
"0.41350198",
"0.41316345",
"0.41283387",
"0.41230294",
"0.41198483",
"0.411303",
"0.4112693"
] | 0.680969 | 0 |
3. The recursivebacktracking algorithm itself | def carve_passages_from(cx, cy, grid)
# the list of directions the algorithm will be moving to carve the maze passage
# the array is randomized to minimize bias
directions = [N, S, E, W].shuffle
# the algorithm iterates over all the direction (for a given cell coordinate)
directions.each do |direction|
# determines the cell coordinate in the given direction
nx = cx + DX[direction]
ny = cy + DY[direction]
# checking if the selected cell is valid or not
# - it should be within the grid boundaries of the maze
# - AND it should not have been visited before (zero-valued coordinate)
unless ny.between?(0, grid.length - 1) && nx.between?(0, grid[ny].length - 1) && grid[ny][nx] == 0
next
end
# carve the cell passage out of the current cell to the next
grid[cy][cx] |= direction
grid[ny][nx] |= OPPOSITE[direction]
# recursively call the function to the new cell
carve_passages_from(nx, ny, grid)
end
@grid = grid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_solution\n\n end",
"def backtrack(nums, cur_array, result)\n if cur_array.size == nums.size\n result << cur_array.clone\n\n return\n end\n\n (0..nums.length - 1).each do |i|\n next if cur_array.include?(nums[i])\n\n cur_array << nums[i]\n\n backtrack(nums, cur_array, result)\n\n cur_array.pop\n end\nend",
"def dfs_rec(target,current,array_length,stack,visited)\n left = current.find_left_child[0]\n right = current.find_right_child[0]\n parent = current.find_parent[0]\n if current.value == target\n return current\n elsif visited.length == array_length\n return nil\n elsif !left.nil? && !visited.include?(left)\n stack.push(left)\n visited.push(left)\n dfs_rec(target,left,array_length,stack,visited)\n elsif !right.nil? && !visited.include?(right)\n stack.push(right)\n visited.push(right)\n dfs_rec(target,right,array_length,stack,visited)\n else\n stack.pop\n dfs_rec(target,parent,array_length,stack,visited)\n end\nend",
"def recursive_function(solutions, s)\n # puts \"BEGINNING RECURSIVE FUNCTION\" #NICE TO HAVE\n # print_board s[:moves] #NICE TO HAVE\n if not validate_state(s)\n return false\n end\n if check_solved(s)\n s[:solved] = true\n # puts \"A solution has been found.\" #NICE TO HAVE\n # print_state_data(s) #NICE TO HAVE\n solutions.push(deep_copy_solution(s[:moves]))\n return true\n end\n derive_moves_metadata(s)\n poss_moves = get_poss_next_moves(s)\n # This given thing actually doesn't work yet.\n # I need to make sure that the given thing only gets triggered when the two\n # moves that this one is based on are ALSO given.\n # Iow, given moves can only come from pre-existing given moves.\n # TODO: Get the below portion of code figured out.\n # Read the above TODO comment about this for more information and\n # possible alternative approaches to optimizing around given moves.\n #\n # if poss_moves.length == 1\n # s[:given_moves].push(s[:m]) # THIS LINE NEEDS TO BE TESTED !!!***\n # puts \"Move \" + s[:m].to_s + \" has been discovered to be given.\"\n # print_state_data(s)\n # end\n while not poss_moves.empty?\n # puts \"poss_moves: \" + poss_moves.to_s #NICE TO HAVE\n s[:prospective_move] = poss_moves.shift()\n s[:prospective_move][:r] = s[:regions][s[:prospective_move][:y]][s[:prospective_move][:x]]\n apply_move(s)\n recursive_function(solutions, s)\n undo_move(s)\n # print_board s[:moves] #NICE TO HAVE\n end\n return s\nend",
"def solve_next\n while stack.length > 0\n guesses, guesses_index, board = stack.pop\n # skip if all possible guesses at this level are done\n next if guesses_index >= guesses.size\n stack << [guesses, guesses_index + 1, board]\n board = board.duplicate\n guess = guesses[guesses_index]\n board.board[guess[0]] = guess[1]\n guesses = PuzzleDeducer.new(board).deduce\n return [stack, board] if guesses.nil?\n stack << [guesses, 0, board]\n end\n [[], nil]\n end",
"def DFS_solution\n\n\t\t# Checking if I got the final solution\n\t\tif @graph.solution?\n\t\t\tif DEBUG\n\t\t\t\tputs \"Solution found:\\n#{@graph.plot_graph}\"\n\t\t\tend\n\t\t\treturn 0\n\t\tend\n\n\t\t# If not i'll find which are the possible next actions from this state\n\t\t# and iterates on them.\n\t\tresult = -1\n\t\t@graph.find_next_actions\n\t\tif DEBUG\n\t\t\tputs \"Un-A -> #{@graph.get_current_node.get_unexplored_actions}\"\n\t\tend\n\t\t# TODO Make this correct, i am skipping a level in the structures\n\t\t@graph.get_current_node.get_unexplored_actions.each do |i|\n\t\t\t# I have to create a new node starting from the current one and \n\t\t\t# knowing the action we have chosen\n\t\t\t@graph.next_state( i )\n\t\t\tresult = self.DFS_solution\n\t\t\t# With break I have to pass over all the calls in the recursive\n\t\t\t# stack, with return it skips all these steps.\n\t\t\t# break if result == 0\n\t\t\treturn 0 if result == 0\n\t\tend\n\n\t\t# If I get here means that with this configuration I will not get to a\n\t\t# solution, so I have to delete what I did in this step.\n\t\t# I'll delete the last positioned Queen, replacing it with a nil.\n\t\tunless result == 0\n\t\t\tif DEBUG\n\t\t\t\tputs \"BACKWARD!\"\n\t\t\tend\n\t\t\t@graph.delete_last_action\n\t\t\treturn -1 \n\t\tend\n\n\tend",
"def recursive => nil",
"def backtrackingSolver()\n size = @blankSpots.size\n index = 0\n while index < size\n @gameboard[@blankSpots[index]] += 1\n if @gameboard[@blankSpots[index]] > 9\n @gameboard[@blankSpots[index]] = 0\n index -= 1\n elsif validateBoard()\n index += 1\n end\n end\nend",
"def solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend",
"def recursive_guess(partially_solved_board)\n return nil if partially_solved_board == nil\n\n until solved?(partially_solved_board)\n partially_solved_board.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n if square.is_a?(Array)\n square = solve_suite(row, square, row_idx, col_idx, partially_solved_board)\n if square.empty?\n return nil\n end\n square.each do |potential_solution|\n potential_board = partially_solved_board\n potential_board[row_idx][col_idx] = potential_solution\n if recursive_guess(potential_board) != nil\n p potential_board\n return potential_board\n else\n return nil\n end\n end\n end\n end\n end\n end\n\n partially_solved_board\nend",
"def find_answer(row , board, queens)\r\n open = board.check_open(row)\r\n\r\n if open.empty?\r\n #if there are no solutions here, so this doesn't work\r\n return []\r\n\r\n elsif row == 7 and queens.size() < 7\r\n #if we're at the last row, but don't have enough queens\r\n return []\r\n\r\n elsif row == 7 and queens.size() == 7 and open.size < 1\r\n # we're at the last row with no solution\r\n return []\r\n\r\n elsif row == 7 and queens.size() == 7 and open.size() == 1\r\n # we're at the last row, and we have a final solution\r\n\r\n # Creates a new board for us to use recursively\r\n new_board1 = Board.new\r\n queens.each do | coords |\r\n new_board1.set_closed(coords[0], coords[1])\r\n end\r\n new_board1.set_closed(open[0], row)\r\n new_board1.set_solution\r\n\r\n #creates the final array of coordinates the queens are at\r\n final = queens.push([open[0], row])\r\n\r\n $solutions_array.push(final)\r\n $solutions_boards.push(new_board1)\r\n\r\n return final\r\n\r\n else # we're not at last row, and we still have a solution to try from open\r\n\r\n open.each do | spot |\r\n new_board = Board.new\r\n\r\n queens.each do | coords |\r\n new_board.set_closed(coords[0], coords[1])\r\n end\r\n new_board.set_closed(spot, row)\r\n\r\n new_queens = Array.new\r\n new_queens.concat(queens)\r\n new_queens.push([spot, row])\r\n\r\n new_row = row + 1\r\n\r\n find_answer(new_row, new_board, new_queens)\r\n end\r\n end\r\nend",
"def solution(a, b)\n return 0 if a == 0 && b == 0 # why do anything?\n\n nummoves = 0 # track moves\n board = Board.new(a, b) # handle visited squares\n\n queue = [ {x: 0, y: 0} ] \n while queue.size > 0 && nummoves < MAX_MOVES do \n nummoves = nummoves + 1 \n\n # \"drain queue\" to check and mark as checked\n queue.each do |square|\n board.push square\n square[:moves] = []\n\n MOVES.each do |move|\n nextmove = { x: move[:x] + square[:x], y: move[:y] + square[:y] }\n return nummoves if nextmove[:x] == a && nextmove[:y] == b\n if board.in_bounds?(nextmove[:x], nextmove[:y]) && !board.visited?(nextmove[:x], nextmove[:y]) \n square[:moves].push nextmove \n end\n end\n end \n \n # enqueue children since we haven't hit our mark\n newq = []\n queue.each do |square|\n newq.concat square[:moves]\n end\n queue = newq.uniq\n end\n \n -1\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def dfs(i, j, visited, m, group)\n # These arrays are used to get row and\n # column numbers of 4 neighbours\n # of a given cell\n rowNbr = [-1, 0, 0, 1]\n colNbr = [ 0, -1, 1, 0]\n\n # Mark this cell as visited\n visited[i][j] = true\n group += 1\n #puts \"dfs #{i}, #{j} group:#{group}\"\n # Recurse for all connected neighbours\n 0.upto(4 - 1) do |k|\n if isSafe(i + rowNbr[k], j + colNbr[k], visited, m)\n # puts \"k:#{k} i:#{i + rowNbr[k]}, j:#{j + colNbr[k]}\"\n group = dfs(i + rowNbr[k], j + colNbr[k], visited, m, group)\n end\n end\n #puts \"RETURN:#{group}\"\n return group\nend",
"def solution(x, a)\n leaves = {}\n path = 0\n for i in (0..a.count - 1)\n leaf = a[i]\n if leaf <= x\n unless leaves[leaf]\n path += 1 \n return i if path == x\n end\n leaves[leaf] = true\n end\n end\n return -1\nend",
"def step0(debug=false)\n\n # make sure we don't step beyond the solution\n return nil if done?\n\n t0 = Time.now\n @nb_iter += 1\n\n puts \"+++iteration #{@nb_iter}+++\" if debug\n puts \"nb problems = #{@pb_list.length}\" if debug\n\n best_pb = @pb_list.shift\n @rejected_grids.push(best_pb.grid)\n\n puts \"best problem:\" if debug\n puts best_pb.show_stats if debug\n\n if best_pb.min_depth == 1 then\n\n # we can create a problem with all the steps included at once\n new_steps = []\n best_pb.each_poss(1) do |poss|\n new_steps.push(Step.new(poss.row, poss.col, poss.first))\n end\n @nb_try += 1\n begin\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n rescue RuntimeError\n # the combination of depth=1 solution caused a conflict\n puts \"Impossible solution for best problem, discard it\" if debug\n @nb_discard += 1\n end\n else\n\n # we need to create a new problem for each possibility\n best_pb.each_poss(best_pb.min_depth) do |poss|\n poss.each do |v|\n @nb_try += 1\n new_steps = [Step.new(poss.row, poss.col, v)]\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n end\n end\n end\n\n # resort the list by max_poss / min_dof\n @pb_list.sort! do |x,y|\n res = x.max_poss <=> y.max_poss\n res = x.dof <=> y.dof if res == 0\n res\n end\n\n @duration += Time.now - t0\n\n #return the solution if we have one\n if @pb_list.empty? then\n return null\n else\n return @pb_list[0]\n end\n\n end",
"def solve(begX, begY, endX, endY)\n #first create two points object as starting point and destination\n start = Point.new(begX,begY)\n @final = Point.new(endX,endY)\n #first initialize these objects in case that there are\n #data left after last iteration of solve\n @tnode = nil\n @traceSet = Set.new\n @traceArray = Array.new\n if start.isEqual(@final)\n @tnode = start\n true\n else\n @traceSet.add(start.to_S)\n @traceArray.push(start)\n\n #start sloving\n newp = @traceArray.shift\n #we don't stop until all the possible pathes are tested\n\n while newp != nil && @tnode == nil do\n #test each route and if we reach the destination, immediately break\n #the while loop\n\n #test if we can move upward\n move(2*newp.x+1,2*newp.y,newp.x,newp.y-1,newp)\n\n #test if we can move downward\n move(2*newp.x+1,2*newp.y+2,newp.x,newp.y+1,newp)\n\n #test if we can move leftward\n move(2*newp.x,2*newp.y+1,newp.x-1,newp.y,newp)\n\n #test if we can move rightward\n move(2*newp.x+2,2*newp.y+1,newp.x+1,newp.y,newp)\n\n #move to the next cell\n newp = @traceArray.shift\n end\n\n #if the current cell is nil, it means we have no solution for this maze puzzle\n if newp == nil\n false\n else #else return true\n true\n end\n end\n end",
"def faster_fib_helper(solution_arr, current, n)\n # n is negative\n if n < 0\n raise ArgumentError, \"Fib(n) error - n must be 0 or larger.\"\n\n # base cases n = 0 , n = 1\n elsif n == 0 || n == 1\n return n\n\n # the other case we check for is if current has reached n\n # this means we can end the recursion\n # and the final return value will be the sum of the previous two\n # elements in solution_arr we have been saving up until this point\n elsif current == n\n # n or current works here since they're the same value at this point\n # can do this because now the array only holds two elements at a time.\n return solution_arr[0] + solution_arr[1]\n\n # otherwise we shovel the next fib # to the back of the array\n # again, found by summing the two elements in front\n # and recusively call the helper with current incremented\n else\n # we only have current number of elements at this point\n # we have to specifically save this in solution_arr, if we do it in the function call\n # it will create a new slot instead of re-using the old one i think\n solution_arr = [solution_arr[1], solution_arr[0] + solution_arr[1]]\n return faster_fib_helper(solution_arr, current + 1, n)\n end\n\nend",
"def tree_search(problem, fringe)\n # \"\"\"Search through the successors of a problem to find a goal.\n # The argument fringe should be an empty queue.\n # Don't worry about repeated paths to a state. [Fig. 3.8]\"\"\"\n # Since we dont worry about repeated paths this can lead to infinite loops\n fringe.append(Node.new(problem.initial))\n while fringe.len > 0\n node = fringe.pop()\n return node if problem.goal_test(node.state) if node\n fringe.extend(node.expand(problem)) if node\n end\n return nil\nend",
"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 guess\n \t# loop 1\n\t while true do\n\t\t @sudoku.each_with_index do |row, rowindex|\n\t\t row.each_with_index do |cell, cellindex|\n\t\t \t# *******************************************************\n\t\t \t# this part same as solve! method\n\t\t col = @sudoku.transpose[cellindex]\n\t\t # return to previous loop (loop 2) if sudoku board is completely solved\n\t\t return if !@sudoku.flatten.include?(0)\n\t\t next if cell != 0\n\t\t solutions=(1..9).to_a\n\t\t 1.upto(9) {|x| solutions.delete(x) if row.include?(x)}\n\t\t 1.upto(9) {|x| solutions.delete(x) if col.include?(x)}\n\t\t box_x=(rowindex./3)*3\n\t\t box=[]\n\t\t 3.times do\n\t\t \tbox_y=(cellindex./3)*3\n\t\t \t3.times do\n\t\t \t\tbox << @sudoku[box_x][box_y]\n\t\t \t\tbox_y += 1\n\t\t \tend\n\t\t box_x += 1\n\t\t \tend\n\t\t \t\t1.upto(9) {|x| solutions.delete(x) if box.include?(x)}\n\t\t \t\t# *******************************************************\n\t\t \t\t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t \treturn if solutions == []\n\t\t \tsolutions_index = 0\n\t\t \t# loop through each number in solutions array (loop 2)\n\t\t \twhile true do\n\t\t \t\t# replace current grid with a number with in solutions\n\t\t\t @sudoku[rowindex][cellindex] = solutions[solutions_index]\n\t\t\t # call itself\n\t\t\t guess\n\t\t\t # code start from this line if no solution found from previous recursion (from return if solutions == [])\n\t\t\t # break the loop if sudoku board is completely solved\n\t\t\t break if !@sudoku.flatten.include?(0) \n\t\t\t # change index to the next number in solutions\n\t\t\t solutions_index += 1\n\t\t\t \tif rowindex == 0 && cellindex ==0 && solutions_index == solutions.length\n\t\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t\t \t# stop recursion and goes to next loop(loop 1) if no solutions found at all\n\t\t\t\t \tbreak\n\t\t\t \telsif solutions_index == solutions.length\n\t\t\t \t@sudoku[rowindex][cellindex] = 0\n\t\t\t \t# return to previous loop/previous unsolved grid(loop 2) if no solutions found for current grid\n\t\t\t \treturn\n\t\t\t \tend\n\t\t \tend\n\t \tend\n\t \tend\n \tend\n end",
"def solve(begX, begY, endX, endY)\n # set solution to false\n solution = false\n # create a temp array that is a copy of the maze\n temp = @maze\n # creates an empty queue\n queue = Queue.new\n # enqueue the beginning coordinates as an array\n queue.enq([begX, begY])\n while !queue.empty? && !solution\n # create a current value that is the array of the currently examined coordinates\n # get x and y separate for simplicity\n current = queue.pop\n x=current[0]\n y=current[1]\n # if x and y are the end coordinates, push them on to the maze trace array\n # and set solution to true to trigger an end to the while loop\n if x == endX && y == endY\n @maze_trace.push(current)\n solution = true\n else\n # else still push the coordinates to the trace array\n # set the corresponding value in the temp array to 1\n # enqueue the coordinates above, below, left and right of current\n # only enqueue the elements that pass the check_path method\n # note that we change the temp value to \"1\" so that previously visited coordinates\n # fail the check_path method. This ensures we don't revisit coordinates\n @maze_trace.push(current)\n temp[x][y] = \"1\"\n queue.enq([x+1,y]) if check_path(x+1,y,temp)\n queue.enq([x-1,y]) if check_path(x-1,y,temp)\n queue.enq([x,y+1]) if check_path(x,y+1,temp)\n queue.enq([x,y-1]) if check_path(x,y-1,temp)\n end\n end\n if solution\n puts \"Path found from point #{begX},#{begY} to point #{endX},#{endY}\"\n else\n puts \"No path exists between given points\"\n # If the path is not found clear the maze_trace array which has elements stored nonetheless\n @maze_trace.clear\n end\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def find_from(current, left)\n total = current[0].reduce(:+)\n if left.length == 3\n fejs = left.permutation(3).to_a.select { |f, e, j|\n t1 = f + e + current[0][1]\n t2 = e + j + current[-1][-1]\n t1 == t2 && t2 == total\n }\n fejs.empty? ? [] : fejs.map { |fej|\n f, e, j = fej\n current + [[j, current[-1][-1], e], [f, e, current[0][1]]]\n }\n else\n left.flat_map { |inner|\n outer = total - current[-1][-1] - inner\n if (left - [inner]).include?(outer)\n find_from(current + [[outer, current[-1][-1], inner]],\n left - [inner, outer])\n else\n []\n end\n }\n end\nend",
"def count_recursive(n, m)\n if n < 0 or m < 0\n return 0\n end\n if n == 0\n return 1 # We found one solution!\n end\n return count_recursive(n, m-1) + count_recursive(n - S[m], m)\n\nend",
"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 solve(args)\n @seen_stack, @need_to_check, solved = [], [], false\n current_cell, finish = map[args[:begX]][args[:begY]], map[args[:endX]][args[:endY]]\n @seen_stack.push(current_cell)\n @need_to_check.push(current_cell)\n\n until @need_to_check.empty? || solved\n current_cell = @need_to_check.shift\n @seen_stack.push(current_cell)\n check_possible_paths(current_cell, finish)\n solved = true if current_cell == finish\n end\n solved\n end",
"def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend",
"def solve_biro_recursion\n\t\ttime do\n\t\t\tans = self.biro_recursion(@size, @size)\n\t\t\tputs \"The number of routes through a #{@size}x#{@size} grid is #{ans}.\"\n\t\tend\n\tend",
"def solve\r\n matrix = @maze\r\n finished = false\r\n\r\n start = Discovered.new(@starting_point[:x],@starting_point[:y],nil)\r\n frontier = []\r\n visited = []\r\n frontier << start\r\n\r\n while !frontier.empty? && !finished\r\n \r\n current_node = frontier.shift # take first item from queue\r\n if visited.include? [current_node.x,current_node.y]\r\n next\r\n else\r\n visited << [current_node.x,current_node.y]\r\n x = current_node.x\r\n y = current_node.y\r\n if (matrix[y][x] == 'G')\r\n finished = true\r\n else\r\n frontier << look_for_valid_moves(x,y,matrix,current_node,visited)\r\n frontier.flatten!\r\n end\r\n end\r\n end\r\n\r\n if finished\r\n @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] = 'X'\r\n while !current_node.parent.nil?\r\n current_node = current_node.parent\r\n @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] = @labyrinth.maze[:graphic_matrix][current_node.y][current_node.x] == 'S' ? 'S' : '.'\r\n end\r\n puts \"Maze solved:\\n\"\r\n @labyrinth.to_screen\r\n else\r\n print \"Goal was not found... :(\"\r\n end\r\n end",
"def minimum_jumps(arr)\n # two arrays. One to keep track of minimum number of jumps needed to reach\n # the position. The other to keep track of which index was needed to reach\n # a given index position.\n num_jumps = [0]\n jump_idx = [nil]\n # use two pointers, one being the destination index and the other\n # being which index to jump from to reach it.\n destination_idx = 1\n while destination_idx < arr.length\n current_idx = find_starting_idx(destination_idx, jump_idx)\n p [current_idx, destination_idx]\n # break the inner while loop once we find an answer\n while current_idx < destination_idx && num_jumps[destination_idx].nil?\n if can_jump?(arr, current_idx, destination_idx)\n num_jumps[destination_idx] = num_jumps[current_idx] + 1\n jump_idx[destination_idx] = current_idx\n end\n current_idx += 1\n end\n destination_idx += 1\n end\n p jump_idx\n num_jumps.last\nend",
"def recurse(curr, k, nums, res, start)\n# add, recurse, undo\n # basically forcing a base case\n if k == 0\n res << curr[0..-1] \n return\n end\n # start elims duplicates (like [3, 2] [2, 3])\n i = start\n while i < nums.length\n curr << nums[i]\n recurse(curr, k - 1, nums, res, i + 1)\n curr.pop\n i+=1\n end\n \n end",
"def death(arr,pos,m)\n #define an empty result string\n result = \"\"\n #If the array size is 1, just return the first index\n if arr.size == 1\n return arr[0].to_s\n end\n #If the position is bigger than the size of the array\n if pos+m > arr.size\n #Set the pos back into size of the array\n pos = (pos+m)%arr.size\n # append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append to result a recursive call to death\n result += death(arr,pos,m)\n #return the result\n return result\n end\n #If the position is small than the size of the array\n if arr.size > pos+m \n #The next target is updated according to m\n pos = pos + m\n #Append the number in the position to result\n result << arr[pos].to_s\n #delete the number (a.k.a. kill it)\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n \n return result\n end\n #if the target is past the end of the array\n if arr.size == pos+m \n #set the position to 0\n pos = 0\n #Append that number\n result << arr[pos].to_s\n #delete it\n arr.delete_at(pos)\n #Append the result of a recursive call to death\n result += death(arr,pos,m)\n #return\n return result\n end\nend",
"def fib_helper(solution_arr, current, n)\n # n is negative\n if n < 0\n raise ArgumentError, \"Fib(n) error - n must be 0 or larger.\"\n\n # base cases n = 0 , n = 1\n elsif n == 0 || n == 1\n return n\n\n # the other case we check for is if current has reached n\n # this means we can end the recursion\n # and the final return value will be the sum of the previous two\n # elements in solution_arr we have been saving up until this point\n elsif current == n\n # n or current works here since they're the same value at this point\n return solution_arr[n - 1] + solution_arr[n - 2]\n\n # otherwise we shovel the next fib # to the back of the array\n # again, found by summing the two elements in front\n # and recusively call the helper with current incremented\n else\n # we only have current number of elements at this point\n solution_arr << (solution_arr[current - 1] + solution_arr[current - 2])\n return fib_helper(solution_arr, current + 1, n)\n end\nend",
"def solve!\n c = i = changed = 0\n while i = ((i+1)..(changed+81)).find{|x|!cells[x % 81]}\n NEIGHBOURHOODS[c = i % 81].each do |neighbours|\n pn = neighbours.inject(possibilities[c]){|r, j| (j != c) ? (r &\n~possibilities[j]) : r}\n if v = SINGLEBIT[pn]\n set_cell(changed = i = c, v) \n break \n end\n end\n end\n\n return self if cells.all?\n return nil if possibilities.any?{|p| p.zero?}\n\n p, i = possibilities.zip((0..80).to_a).select{|a, b|numbits(a) > 1}.\n min{|a, b|numbits(a[0]) <=> numbits(b[0])}\n\n eachbit(p){|j| b=clone.set_cell(i, j).solve! and return b}\n return nil\n end",
"def ways_traverse_brute(map)\n visited = Array.new(map.length) { Array.new(map[0].length, false) }\n saved = Array.new(map.length) { Array.new(map[0].length, 0) }\n\n visited[0][0] = true\n ways_traverse_brute_rec(0, 0, visited, map)\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 solve\n node = @list.first_node\n traversed_nodes = {}\n\n loop do\n return node if traversed_nodes[node]\n traversed_nodes[node] = true\n node = node.next\n break unless node\n end\n end",
"def backtrack!(nodes)\n while true\n return nil if nodes.empty? # backtracked back to 0, so we are done\n \n # We tried nodes.last and it didn't work, so\n # pop it off and uncover the corresponding columns.\n node = nodes.pop\n node.unchoose_except_self_column\n \n # Try the next node in this column.\n x = node.down\n\n return x unless x.is_a? Column\n \n # Our downwards iteration has gone full-circle\n # back to the column object where it started.\n x.uncover # Uncover the column.\n end\n end",
"def greedy_backwards(starting)\n working = starting.join('')\n # sorted = @replace_from.keys.sort_by {|k| k.length }\n sorted = @replace_from.keys\n i = 0\n puts \"Start: #{i} - #{working}\"\n sorted.each do |s|\n while working.include? s.join do\n working = working.sub(s.join,@replace_from[s])\n i += 1\n puts \"Step: #{i} - #{working}\"\n end\n end\n return i if working == 'e'\n i += greedy_backwards(split_molecule(working))\n i\n end",
"def solve(a)\n return [[1]] if a == 1\n prev = solve(a - 1)\n last = prev.last\n new_row = [1]\n (0..last.length - 2).each do |i|\n new_row << last[i] + last[i + 1]\n end\n new_row << 1\n prev << new_row\nend",
"def dfs(root, sum, flag)\n return if root.nil?\n @count += 1 if root.val == sum\n dfs(root.left, sum - root.val, false)\n dfs(root.right, sum - root.val, false)\n if flag\n dfs(root.left, sum, true)\n dfs(root.right, sum, true)\n end\nend",
"def play_recursive(deck)\n seen = Set.new\n\n (1..).each do\n key = (deck[0] + [-1] + deck[1]).join(\",\")\n return 0 if seen.include?(key)\n\n seen.add(key)\n cards = deck.map(&:shift)\n winner = if cards[0] <= deck[0].size && cards[1] <= deck[1].size\n d0 = deck[0].take(cards[0])\n d1 = deck[1].take(cards[1])\n if d0.max > d1.max\n 0 # P1 has to win this subgame\n else\n play_recursive([deck[0].take(cards[0]), deck[1].take(cards[1])])\n end\n elsif cards[0] > cards[1]\n 0\n else\n 1\n end\n deck[winner] += winner.zero? ? cards : cards.reverse\n return 1 if deck[0].empty?\n return 0 if deck[1].empty?\n end\n end",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def trace_states_looking_for_left_recursion(s, visited_states, list_of_recursive_cycles)\n if (s.is_accept_state)\n # this rule must be nullable!\n # At least one epsilon edge reached accept state\n return true\n end\n if (visited_states.contains(s))\n # within same rule, we've hit same state; quit looping\n return false\n end\n visited_states.add(s)\n state_reaches_accept_state = false\n t0 = s.attr_transition[0]\n if (t0.is_a?(RuleClosureTransition))\n ref_trans = t0\n ref_rule_def = ref_trans.attr_rule\n # String targetRuleName = ((NFAState)t0.target).getEnclosingRule();\n if (@visited_during_recursion_check.contains(ref_rule_def))\n # record left-recursive rule, but don't go back in\n @grammar.attr_left_recursive_rules.add(ref_rule_def)\n # System.out.println(\"already visited \"+refRuleDef+\", calling from \"+\n # s.enclosingRule);\n add_rules_to_cycle(ref_rule_def, s.attr_enclosing_rule, list_of_recursive_cycles)\n else\n # must visit if not already visited; send new visitedStates set\n @visited_during_recursion_check.add(ref_rule_def)\n call_reached_accept_state = trace_states_looking_for_left_recursion(t0.attr_target, HashSet.new, list_of_recursive_cycles)\n # we're back from visiting that rule\n @visited_during_recursion_check.remove(ref_rule_def)\n # must keep going in this rule then\n if (call_reached_accept_state)\n following_state = (t0).attr_follow_state\n state_reaches_accept_state |= trace_states_looking_for_left_recursion(following_state, visited_states, list_of_recursive_cycles)\n end\n end\n else\n if (t0.attr_label.is_epsilon || t0.attr_label.is_semantic_predicate)\n state_reaches_accept_state |= trace_states_looking_for_left_recursion(t0.attr_target, visited_states, list_of_recursive_cycles)\n end\n end\n # else it has a labeled edge\n # now do the other transition if it exists\n t1 = s.attr_transition[1]\n if (!(t1).nil?)\n state_reaches_accept_state |= trace_states_looking_for_left_recursion(t1.attr_target, visited_states, list_of_recursive_cycles)\n end\n return state_reaches_accept_state\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 nextContent(tryArray, tail) # Dr. Ivey this is my late night recursion function (works wonders though), takes care of the combinations\n if(tryArray[tail] < $count-1) #try to just increment last position\n tryArray[tail] += 1\n elsif( (tail-1) >= 1) # if that doesn't work, try previous position\n tryArray[tail] = 1\n nextContent(tryArray, (tail-1) )\n elsif( (tail == 1 ) && $tail < $numOfComb ) # if that fails, need to add another element to the tryArray\n tryArray[tail] = 1\n $tail += 1\n tryArray[$tail] = 1 \n else\n puts \"No answer found with combination of up to #{$numOfComb} consecutive tiles of your total of #{$count-1} dominos/tiles\"\n exit(0)\n end\n \n \n return tryArray\nend",
"def work(toy_index, cube)\n if $debug && cube.available_heads.empty?\n puts \"\\t\" * toy_index + \"Working for piece #{toy_index} but it has no available heads; recursing.\"\n end\n\n if $debug\n puts \"\\t\" * toy_index + \"Working for piece #{toy_index} which has #{cube.available_heads.count} available heads. Cube:\"\n cube.display_in_line(toy_index)\n end\n\n cube.available_heads.each do |available_head|\n cah = C.new(available_head[:face], available_head[:row], available_head[:left])\n\n puts \"\\t\" * toy_index + \"Attempting to place piece #{toy_index} from head #{cah.to_s}\" if $debug\n\n [:vertical_up, :vertical_down, :sideways_right, :sideways_left, :long_far, :long_near].each do |orientation|\n if cube.place! piece: $toy[toy_index], orientation: orientation, c: cah\n puts \"\\t\" * toy_index + \"\\tPlaced piece #{toy_index} in orientation #{orientation}\" if $debug\n\n if cube.complete?\n $solution_counter += 1\n puts \"====================== SOLUTION #{$solution_counter} FOUND! ===========================\"\n cube.display_in_line\n else\n if toy_index <= $toy.size && !cube.available_heads.empty?\n work(toy_index + 1, cube.clone2)\n else\n puts \"\\t\" * toy_index + \"Not progressing to piece #{toy_index + 1}, no available heads.\" if $debug\n end\n end\n\n puts \"\\t\" * toy_index + \"Undo orientation #{orientation} and progressing to the next one.\" if $debug\n cube.undo!\n else\n puts \"\\t\" * toy_index + \"\\t\\tTried to place piece #{toy_index} in orientation #{orientation} but it didn't work\" if $debug\n end\n end\n puts \"\\t\" * toy_index + \"Tried all possible orientations, moving to the next available head.\" if $debug\n end\n puts \"\\t\" * toy_index + \"Tried all available heads. Recurse back from piece #{toy_index} to piece #{toy_index - 1}.\" if $debug\nend",
"def solution(a, b)\n stack = [[a[0], b[0]]]\n if a.size > 1\n (1..a.size - 1).each do |i|\n if stack.last[1] <= b[i]\n stack << [a[i], b[i]] # no one dies\n next\n end\n while stack.size > 0 && stack.last[0] < a[i] && stack.last[1] > b[i] # fish to left dies\n stack.pop\n end\n if stack.size == 0 || stack.last[1] == b[i]\n stack << [a[i], b[i]]\n end\n end\n end\n stack.size\nend",
"def non_deterministic_search(goal_vertex)\n @explored = {}\n @stack = [] #\n non_deterministic_recursive(self, goal_vertex)\n @stack\n end",
"def f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend",
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend",
"def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend",
"def DFSb(v, vf) #wyszukiwanie mostow w grafie\n $d[v] = $cv\n low = $cv\n $cv = $cv + 1\n 0.upto($n-1) do |i|\n if $a[v][i] > 0 and i != vf\n if $d[i] == 0\n temp = DFSb(i, v)\n low = temp if temp < low\n else\n low = $d[i] if $d[i] < low\n end\n end\n end\n if vf > -1 and low == $d[v]\n $a[vf][v] = 2\n $a[v][vf] = 2\n end\n return low\nend",
"def problem_104\n all = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\n k = 2\n low_fn0,low_fn1 = 1,1\n hi_fn0,hi_fn1 = 1,1\n loop do\n k += 1\n low_fn0,low_fn1 =(low_fn0 + low_fn1) % 10_000_000_000, low_fn0\n hi_fn0, hi_fn1 = hi_fn0 + hi_fn1, hi_fn0\n if hi_fn0 > 1_000_000_000_000_000_000\n hi_fn0 /= 10\n hi_fn1 /= 10\n end\n front = false\n next unless k > 300\n hi = hi_fn0.to_s[0,9].split(//)\n if (hi & all).length == 9\n puts \"front #{k}\" \n front = true\n end\n if (low = low_fn0.to_s).length >= 9\n low = low[-9,9].split(//)\n if (low & all).length == 9\n puts \"back #{k}\" \n return k if front\n end\n end\n end\nend",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def find_closest_value(target, item_count, acc_sum, k, multi)\n\tputs \"calling function\"\n\n #puts \"k = \" + k.to_s + \" acc_sum = \" + acc_sum.to_s + \" multi = \" + multi.to_s\n #puts \"k = \" + k.to_s + \" multi = \" + multi.to_s\n #item_count.each { |x| puts x }\n\n\n #checks current accumulated value with current max value to find the best match of given subset\n if acc_sum > $max_val\n $max_val = acc_sum\n #puts \"max value set \" + acc_sum.to_s\n #item_count.each { |x| puts x }\n $max_mul = item_count\n puts \"#{item_count}\"\n return item_count\n end\n\n #item_count contains the list of multipliers. is set here to the multiplier value\n item_count[k] = multi\n #item_count.insert(k, multi)\n puts multi.to_s\n #BASE CASE TO END RECURSION\n if multi == 0\n return 0\n end\n\n #If exact match found to target the max value is set and returns false to destroy whole recursive stack\n if acc_sum + $price[k] * item_count[k] == target\n $max_val = acc_sum + $price[k] * item_count[k]\n #item_count[k] = item_count[k] + 1\n puts \"max value set \" + $max_val.to_s\n $max_mul = item_count\n $max_mul.each { |x| puts x }\n return false\n\n#This step used to go deeper into the recursive stack only if more elements are present in the given set\n#And also checks if current value + old accumulated value doesnt exceed the target sum given\n elsif k + 1 < $n && acc_sum + $price[k] * item_count[k] <= target\n item_count = find_closest_value(target, item_count, acc_sum + $price[k] * item_count[k], k+1, (target-$price[k] * item_count[k])/$price[k+1])\n #used to destroy recursion when perfect match is found\n puts \"Next max value set \" + $max_val.to_s\n if item_count == false\n return false\n end\n end\n\n # if k+1 < $n && acc_sum + $price[k] * (item_count[k-1] - 1) + ((target - acc_sum) / $price[k + 1]) * $price[k + 1] <= target\n # item_count[k] = item_count[k] - 1\n # find_closest_value(target, item_count, acc_sum + $price[k] * item_count[k - 1], k+1, (target - acc_sum)/$price[k+1])\n # end\n\n # elsif\n temp = [0,0,0,0,0,0]\n #puts \"k last = \" + k.to_s\n #item_count.each { |x| puts x }\n #recursive call with multiplier reduced by 1 for the same element in the set\n find_closest_value(target, temp, acc_sum, k, multi - 1)\n # end\nend",
"def visitor(i,j,n,m,grid,visited)\n if (i<0 || i>n-1 || j<0 || j>m-1 || grid[i][j]==0 || visited[i][j])\n return 0\n else visited[i][j] = true\n score = 1\n score += visitor(i-1,j-1,n,m,grid,visited)\n score += visitor(i-1,j,n,m,grid,visited)\n score += visitor(i-1,j+1,n,m,grid,visited)\n score += visitor(i,j-1,n,m,grid,visited)\n score += visitor(i,j+1,n,m,grid,visited)\n score += visitor(i+1,j-1,n,m,grid,visited)\n score += visitor(i+1,j,n,m,grid,visited)\n score += visitor(i+1,j+1,n,m,grid,visited)\n return score\n end\nend",
"def subsets_3(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx == nums.length\n\n nums[current_idx..-1].each_with_index do |num, i|\n solution << num\n subsets(nums, results, solution, current_idx + i + 1)\n solution.pop\n end\n\n results\nend",
"def solve(minemap, miner, exit, answer = [])\n# this block sets variables for dimension max indexes\n# declares variables for the current miner position\n# declares variables for the exit position\n# I did this for easier manipulation of the values\n# than referring to and changing a hash constantly\n# it also sets up an array possible values the map\n# can take on, with the direction a miner should travel\n# replacing true, which signals to the miner that he\n# should not return to that position (probably not necessary\n# because false would work just as well unless two branches\n# are both valid, but right, left, up, down could probably\n# be eliminated\n\n x_max = minemap.size - 1\n y_max = minemap[0].size - 1\n x = miner['x']\n y = miner['y']\n ex = exit['x']\n ey = exit['y']\n walls = %w(right left up down branch)\n walls.push(false)\n\n# copying the map so it can be manipulated (again, probably\n# not necessary and, even if it is, my copy_array should be\n# expanded to multi dimensional arrays)\n\n copy = Array.new(x_max+1){Array.new(y_max+1)}\n (0..x_max).each do |x|\n (0..y_max).each do |y|\n copy[x][y] = minemap[x][y]\n end\n end\n\n# loops while not at exit\n\n while x != ex || y != ey\n\n# sets a boolean array to 4 trues, then checks\n# each possible move to false if unavailable\n\n rlud = [true, true, true, true]\n rlud[0] = false if x == x_max || walls.include?(copy[x+1][y])\n rlud[1] = false if x == 0 || walls.include?(copy[x-1][y])\n rlud[2] = false if y == 0 || walls.include?(copy[x][y-1])\n rlud[3] = false if y == y_max || walls.include?(copy[x][y+1])\n\n# if there is nowhere to turn, the answer array is set to an array \n# of size equal to thenumber of elements in the map, because this \n# number is more than the possible number of steps the miner could\n# take in an actual solution, then returns this array as answer\n# this signals the previous call of solve that the branch was a \n# dead end (this will not happen on the first iteration by if\n# the initial conditions are valid)\n\n answer = Array.new((x_max + 1) * (y_max + 1)) if rlud.count(true) == 0 \n return answer if rlud.count(true) == 0\n\n# if there is only one path (only one true in the boolean array)\n# then the position is updated, the step is pushed to the answer\n# array and the copy of the original position is set to a string\n# indicating the miner must travel\n\n if rlud.count(true) == 1 \n if rlud[0] == true\n copy[x][y] = \"right\" \n answer.push('right')\n x += 1\n elsif rlud[1] == true\n copy[x][y] = \"left\" \n answer.push('left')\n x -= 1\n elsif rlud[2] == true\n copy[x][y] = \"up\" \n answer.push('up')\n y -= 1\n else\n copy[x][y] = \"down\"\n answer.push('down')\n y += 1 \n end \n\n# if there is more than one possible move, this section\n# calls the branch explore with the direction to explore\n# as one parameter and a copy of the answer to be appended \n# to in case a valid path is found, if a dead end is reached\n# branch_explore will mark the initial branch position as false\n\n else\n copy[x][y] = false\n if rlud[0] == true\n r = copy_array(answer)\n r = branch_explore(copy, 'right', exit, r, x, y, x_max, y_max)\n end \n if rlud[1] == true\n l = copy_array(answer)\n l = branch_explore(copy, 'left', exit, l, x, y, x_max, y_max)\n end\n if rlud[2] == true\n u = copy_array(answer) \n u = branch_explore(copy, 'up', exit, u, x, y, x_max, y_max)\n end\n if rlud[3] == true\n d = copy_array(answer)\n d = branch_explore(copy, 'down', exit, d, x, y, x_max, y_max)\n end\n\n# this section pushes the answer arrays that are valid paths to\n# a branch array \n\n branch_array = [] \n branch_array.push(r.size) if x != x_max && copy[x+1][y].to_s == \"branch\"\n branch_array.push(l.size) if x != 0 && copy[x-1][y].to_s == \"branch\"\n branch_array.push(u.size) if y != 0 && copy[x][y-1].to_s == \"branch\"\n branch_array.push(d.size) if y != y_max && copy[x][y+1].to_s == \"branch\"\n\n# this determines which of the potential valid paths is shorts and \n# set the answer to that array\n \n min = branch_array.min\n answer = copy_array(r) if r != nil && r.size == min\n answer = copy_array(l) if l != nil && l.size == min\n answer = copy_array(u) if u != nil && u.size == min\n answer = copy_array(d) if d != nil && d.size == min\n end\n end\n\n# return the answer\n\n answer\nend",
"def solution_checker(array)\n if array.length > 1\n # Create a board that can be manipulated without affecting the original board\n internal_board = []\n column_counter = 1\n row_counter = 1\n 4.times do\n 4.times do\n internal_board.push(Square.new([column_counter, row_counter]))\n column_counter = column_counter + 1\n end\n row_counter = row_counter + 1\n column_counter = 1\n end\n #Label squares on the board as occupied\n array.each do |piece|\n square = internal_board.find {|s| s.location == piece.location}\n square.occupied = true\n square.piece = piece\n end\n array.each_with_index do |piece, index|\n if array.include?(piece) && piece != array.last\n original_square = internal_board.find {|s| s.location == piece.location}\n blocker = piece.impediments?([(array[index + 1]).column, (array[index + 1]).row], internal_board)\n if blocker\n break\n elsif piece.move([(array[index + 1]).column, (array[index + 1]).row])\n captured_piece = array[index + 1]\n array.uniq!{|piece| piece.location}\n original_square.occupied = false\n original_square.piece = nil\n new_moves = array.permutation.to_a\n new_moves.each do |new_array|\n new_array.map {|a| a.dup}\n end\n new_moves.each do |new_array|\n solution_checker(array)\n end\n else\n break\n end\n else\n break\n end\n end\n end\nend",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def jump_back\n @banned_points[@path.last.hash] = @path.pop\n @current_point = @path.last || (@path << @start_vector).last\n @current_cost = get_cost @current_point\n @banned_points.delete @start_vector.hash\n @initial_run = true\n if @debug_level > 1\n puts \"Jumping back\"\n puts \"Banning #{@banned_points.last.inspect}\"\n end\n end",
"def solve\n possibleMovements.each do |delta|\n moveBy delta\n break if solve\n undoMoveBy delta\n end\n adjacentToFinish?\n end",
"def main()\n rules = { # a/bc/bcd/bcdd/bcda/bcdbc/bcbc/cbc/aa/\n 'abcd' => [''],\n 'a' => ['bc'],\n 'bc' => ['bcd', 'c'],\n 'd' => ['a', 'db'],\n 'db' => ['b'],\n 'cbc' => ['ab'],\n '...' => ['a']\n }\n rows= [\n 'bd',\n ]\n moves = 10\n width = 7\n solver = Solver.new(rules, moves, width)\n game_data = GameState.new(rules, rows[0], width)\n solution = solver.find_solution(game_data)\n\n if !solution.nil?\n solution.each do |move|\n puts(move.to_s)\n end\n else\n puts 'No solution found'\n end\nend",
"def solve\n @time = Time.new\n while true\n if @stack.pop == 0\n else\n while (not @stack.empty?) && (@stack.peek == 1)\n @stack.pop\n end\n if not @stack.empty?\n @stack.pop\n else\n b = Time.new\n @time = b - @time\n return\n end\n \n end\n \n @current_configuration[@stack.size] = 1\n @stack.push(1)\n while @stack.size < @dimension\n @current_configuration[@stack.size] = 0\n @stack.push(0)\n end\n \n conf = Configuration.new(@current_configuration, @problem)\n curr_fitness = conf.fitness\n if curr_fitness > @best_fitness\n @best_fitness = curr_fitness\n for i in 0..@current_configuration.size - 1\n @best_configuration[i] = @current_configuration[i]\n end\n \n end\n \n end\n \n \n end",
"def DFS(rootNode,searchValue)\n\tstack = []\n\tpath = []\n\tpath[0] =rootNode\n\t# Initializes the stack with rootNode\n\tstack[0]=rootNode\n\t# while there is something in the stack keep running\n\twhile stack.length != 0\n\t\t# if checkFunction(searchValue,stack[0]) == true\n\t\tif checkFunction(searchValue,stack[0]) == true\n\t\t\t# return true and path\n\t\t\treturn TracePath(stack[0])\n\t\t# else\n\t\telse\n\t\t\t#remove stack[0] from the stack and inmidiately stores it in temp\n\t\t\ttemp = stack.shift\n\t\t\t#if there is right brach in the formely stack[0] now stored in temp\n\t\t\tif temp.getRB\n\t\t\t\t#insert the rigth branch at the beginning of the stack\n\t\t\t\tstack.unshift(temp.getRB)\n\t\t\tend\n\t\t\t#if there is left branch in the formely stack[0] now stored in temp\n\t\t\tif temp.getLB\n\t\t\t\t#insert the left brach at the beginning of the stack.\n\t\t\t\tstack.unshift(temp.getLB)\n\t\t\t\t\n\t\t\tend\n\t\t\t#insert the temp in the path array to keep track of the path used for the search\n\t\t\tputs temp.display\n\t\tend\n\tend\n\t# return false becuase at this point the function did not find the value\n\treturn false\nend",
"def pathfinder(maze, counter=0, unexplored_territory=true, starting_cell=[])\n\n # This while loop goes over the maze once, looking for a 'F' in a cell (maze[row][col]), and adding 0 to ENWS if possible\n while counter==0\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == 'F' # Looking for the first starter cell\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n maze[row+mod[0]][col+mod[1]] = counter if maze[row+mod[0]][col+mod[1]] == ' '\n end\n end\n end\n end\n counter+=1\n end\n\n print_maze(maze).inspect if $debug\n no_solution = false\n\n\n # This while loop goes through and looks for either blank spaces adjacent to numbers, or 'S' in a cell.\n while unexplored_territory\n dig_dug = true\n maze.each_with_index do |array, row|\n array.each_with_index do |cell, col|\n if cell == (counter-1) # mapping out the maze, one by one\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[row+mod[0]][col+mod[1]] == 'S'\n unexplored_territory, starting_cell, dig_dug = false, [row, col], false\n elsif maze[row+mod[0]][col+mod[1]] == ' '\n maze[row+mod[0]][col+mod[1]], dig_dug = counter, false\n end\n end\n end\n end\n end\n unexplored_territory, no_solution = false, true if dig_dug # check for progress, no solutions found if true\n counter+=1\n if $debug\n system('clear') or system('cls')\n print_maze(maze)\n sleep(1.0/4.0) if $slow\n end\n end\n\n counter = counter - 3 # Getting the counter ready for reverse mapping\n return [['No Solution']] if no_solution # 5.\tIF there is no solution, then print an appropriate message and re-display the menu\n unless no_solution\n\n\n # This while loop goes and looks for the route back following descending numbers.\n while counter >= 0\n maze[starting_cell[0]][starting_cell[1]] = '*'\n [[0,1],[-1,0],[0,-1],[1,0]].each do |mod|# east, north, west, south checked one at a time\n if maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]].is_a?(Integer) && maze[starting_cell[0]+mod[0]][starting_cell[1]+mod[1]] == counter\n starting_cell = [starting_cell[0]+mod[0],starting_cell[1]+mod[1]]\n end\n end\n counter -= 1\n end\n\n maze[starting_cell[0]][starting_cell[1]] = '*' # Sets the last cell to *\n\n\n # This set of loops goes through and clears out integers from the maze\n maze.each_with_index do |row, r|\n row.each_with_index do |col, c|\n if col.is_a?(Integer)\n maze[r][c] = ' '\n end\n end\n end\n\n # Return the finished product\n maze\n end\nend",
"def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end",
"def subsets_2(nums, results = [], solution = [], current_idx = 0)\n results << solution.clone\n return if current_idx >= nums.length\n\n current_idx.upto(nums.length - 1) do |i|\n solution << nums[i]\n subsets(nums, results, solution, i + 1)\n solution.pop\n end\n\n results\nend",
"def permutations(array)\n return [array] if array.length <= 1\n \n \n # Similar to the subsets problem, we observe that to get the permutations\n # of [1, 2, 3] we can look at the permutations of [1, 2] which are\n # [1, 2] and [2, 1] and add the last element to every possible index getting\n # [3, 1, 2], [1, 3, 2], [1, 2, 3], [3, 2, 1], [2, 3, 1]\n \n # pop off the last element\n first = array.shift\n # make the recursive call\n perms = permutations(array)\n # we will need an array to store all our different permutations\n total_permutations = []\n \n \n # Now we iterate over the result of our recusive call say [[1, 2], [2, 1]]\n # and for each permutation add first into every index. This new subarray\n # gets added to total_permutations.\n perms.each do |perm|\n (0..perm.length).each do |i|\n total_permutations << perm[0...i] + [first] + perm[i..-1]\n end\n end\n total_permutations\nend",
"def solve\n\t\tres = solveRec()\n\t\treturn res if res == [-1]\n\t\twhile ((nextIter = solveRec()) != [])\n\t\t\tres += nextIter\n\t\tend\n\n\t\treturn res;\n\tend",
"def trips_dfs(start, finish, stops, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n s = visited.size # stops, including added vertex\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles if we hit finish vertex too early\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach stops\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, stops, 0)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, stops, 0)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && dist(visited.last, vertex) != \"NO SUCH ROUTE\" && s <= stops\n visited << vertex\n path = visited\n\n if vertex == finish && s == stops\n paths << path\n print \"\\n*** Path: #{path}, Stops: #{s}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n trips_dfs(start, finish, stops, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3) && stops <= 1\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def find_beeper()\n while not next_to_a_beeper?()\n move_toward_beeper()\n end\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend",
"def backtrack\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # current x, y, target x, y and resulting path\n cx, cy, x, y, result = @tx, @ty, 0, 0, []\n # find the way back from destination to start\n loop do\n # change current coordinates\n cx, cy = cx - x, cy - y\n # stop if reached corrected start position\n break if cx == @sx && cy == @sy\n # add movement command\n pix.times {result.unshift(Cache::TDirs[@closed[cx, cy]])}\n # track back next node\n x, y = Cache::DirOffsets[@closed[cx, cy]]\n end\n # modify found path if pixel movement is being used\n modify(result) if pix > 1\n # return result\n return result\n end",
"def branch_explore(copy_of_map_arr, direction, exit_hash, copy_of_answer_array, x, y, x_max, y_max)\n x += 1 if direction == 'right'\n x -= 1 if direction == 'left'\n y -= 1 if direction == 'up'\n y += 1 if direction == 'down'\n temp_miner = {'x' => x, 'y' => y}\n copy_of_answer_array = solve(copy_of_map_arr, temp_miner, exit_hash, copy_of_answer_array)\n if copy_of_answer_array.size == ((x_max + 1) * (y_max + 1)) \n copy_of_map_arr[x][y] = false \n else\n copy_of_map_arr[x][y] == \"branch\"\n end\n x -= 1 if direction == 'right'\n x += 1 if direction == 'left'\n y += 1 if direction == 'up'\n y -= 1 if direction == 'down'\n copy_of_answer_array\nend",
"def recur(current, remaining)\n if current.size == $size\n word = current.join\n if $dictionary.include? word and not $solutions.include? word\n $solutions << word\n puts word\n end\n elsif current.size < $size\n remaining.each do |r|\n new_cur = Array.new current\n new_remaining = Array.new remaining\n new_remaining.delete_at new_remaining.index(r)\n new_cur << r\n recur(new_cur, new_remaining)\n end\n end\nend",
"def solution(h)\n h.inject([1, [h.first]]) do |(blocks, stack), n|\n next [blocks+1, stack.push(n)] if stack.last < n\n stack.pop while stack.any? && stack.last > n\n next [blocks, stack] if stack.last == n\n \n [blocks+1, stack.push(n)]\n end.first\nend",
"def factorial(number)\n if number == 1 # <-- BASE CASE: scenario that tells recusion when to stop\n return 1\n else\n number * factorial(number - 1) # <-- RULE: determines when recursion should continue\n end\nend",
"def solve(begX, begY, endX, endY)\n\t\tstart = [begX, begY]\n\t\tstack = []\n\t\tmove_trace = []\n\t\t#checks to see if start or end have \"wall\" value\n\t\tif get_value(begX, begY) == 1 || get_value(endX, endY) == 1\n\t\t\tputs \"Invalid start or finish location\"\n\t\t\treturn false\n\t\tend\n\t\tstack.push(start)\n\t\tmove_trace.push(start)\n\t\twhile !stack.empty?\n\t\t\tcurrent = stack.pop()\n\t\t\tif current == [endX, endY]\n\t\t\t\tputs \"The maze is solved\"\n\t\t\t\tputs \"The cells you visited are: \"\n\t\t\t\treturn move_trace\n\t\t\tend\t\t\n\n\t\t\ttrace(current).each do |node|\n\t\t\t\tif !move_trace.include? node\n\t\t\t\t\tstack.push(node)\n\t\t\t\t\tmove_trace.push(node)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tputs \"Cannot be solved\"\n\t\treturn false\n\tend",
"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 DP_solve(a)\n max, head, tail = 0, 0, 0\n cur_head = 0\n sum = [ [0, a[0]].max ] # base case\n (1...a.size).each do |j|\n sum[j] = [0, sum[j-1] + a[j]].max # bottom-up\n cur_head = j if sum[j-1] == 0 and sum[j] > 0\n if sum[j] > max\n head = cur_head\n tail = j\n max = sum[j]\n end\n end\n return max, head, tail\nend",
"def find_hamiltonian_recursively( current )\n # remove the current node from the list of unvisited nodes and to the journey\n @journey << @unvisited.delete( current )\n \n\n if @unvisited.empty?\n # All states have been visisted. Therefore, the @journey must\n # contain a valid Hamiltonian path. Let's output it and return.\n puts \"[#{@journey.map{|state| \":#{state.to_s}\"}.join(', ')}]\"\n return true\n else\n # Go through each of the neighbours, and check to see if they are in the unvisited\n # list\n @graph[ current ].each do |neighbour|\n if @unvisited.include?( neighbour )\n # possible path via this neighbour\n return true if find_hamiltonian_recursively( neighbour )\n end\n end\n end\n\n # Return current to the unvisited list and remove from the journey, and return to allow\n # another route to be explored.\n @unvisited.push( current )\n @journey.pop\n\n return false\n end",
"def try_solve(game, totmines)\n\t# First, build up a list of trivial regions.\n\t# One big region for the whole board:\n\tregions = [[totmines]]\n\tfor r in 0...game.length do for c in 0...game[0].length do\n\t\tregions[0][0] -= 1 if game[r][c] === 19\n\t\tregions[0].append([r, c]) if game[r][c] < 10\n\tend; end\n\t# And then a region for every cell we know about.\n\tnew_region = nil # Predeclare the new_region lambda?? I think this is necessary?\n\tbase_region = -> (r, c) do\n\t\treturn if game[r][c] < 10 || game[r][c] == 19\n\t\tregion = get_unknowns(game, r, c)\n\t\treturn if region.length == 1 # No unknowns\n\t\tnew_region.call(region)\n\tend\n\tnew_region = -> (region) do\n\t\tif region[0] == 0 then\n\t\t\t# There are no unflagged mines in this region!\n\t\t\tfor rc in region[1..-1] do\n\t\t\t\t# Dig everything. Whatever we dug, add as a region.\n\t\t\t\tfor dug in dig(game, rc[0], rc[1]) do\n\t\t\t\t\tbase_region.call(dug[0], dug[1])\n\t\t\t\tend\n\t\t\tend\n\t\telsif region[0] == region.length - 1 then\n\t\t\t# There are as many unflagged mines as unknowns!\n\t\t\tfor rc in region[1..-1] do\n\t\t\t\tflag(game, rc[0], rc[1]);\n\t\t\tend\n\t\telse\n\t\t\tregions.append(region)\n\t\tend\n\tend\n\tfor r in 0...game.length do for c in 0...game[0].length do\n\t\tbase_region.call(r, c)\n\tend; end\n\t# Next, try to find regions that are strict subsets of other regions.\n\tfound = true\n\twhile found do\n\t\tfound = false\n\t\tfor r1 in regions do\n\t\t\t# TODO: Don't do this quadratically. Recognize which MIGHT be subsets.\n\t\t\tr1set = r1[1..-1].to_set\n\t\t\tfor r2 in regions do\n\t\t\t\tnext if r2.length <= 1\n\t\t\t\tr2set = r2[1..-1].to_set\n\t\t\t\tnext unless r2set < r1set\n\t\t\t\tnewreg = (r1set - r2set).to_a\n\t\t\t\tnewreg.insert(0, r1[0] - r2[0])\n\t\t\t\tr1.slice!(0, r1.length) # Wipe the old region - we won't need it any more\n\t\t\t\tnew_region.call(newreg);\n\t\t\t\tfound = true\n\t\t\t\tbreak # No point scanning other r1 pairings\n\t\t\tend\n\t\tend\n\t\t# Prune the region list. Any that have been wiped go; others get their\n\t\t# cell lists pruned to those still unknown.\n\t\tscanme, regions = regions, []\n\t\tfor region in scanme do\n\t\t\tfor i in 1...region.length do\n\t\t\t\tbreak if i >= region.length # if we shorten the array, stop short\n\t\t\t\tcell = game[region[i][0]][region[i][1]]\n\t\t\t\tnext if cell < 10\n\t\t\t\tregion.slice!(i);\n\t\t\t\tregion[0] -= 1 if cell == 19\n\t\t\t\tfound = true # Changes were made.\n\t\t\tend\n\t\t\tnew_region.call(region) if region.length > 1 # Might end up being all-clear or all-mines, or a new actual region\n\t\tend\n\tend\n\treturn regions.length == 0\nend",
"def traverse_tree?(positions, letters, game)\n return true if letters == []\n next_positions = indexes_of_letter(letters.shift, game)\n positions.each do |position|\n neighbours = adjacent_from_array(position, next_positions)\n return traverse_tree?(neighbours, letters, game) if neighbours.any?\n end\n return false\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend",
"def dfs_rec knight, target, collector=[]\n\n if knight\n puts \"#{knight.position} and #{target}\"\n\n \n\n if knight.position == target\n collector.push knight\n end\n moves = knight.moves.size - 1\n moves.times do |num|\n dfs_rec knight.moves[num], target, collector\n end\n end\n\n return collector\nend",
"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 nck_recursive(n, k)\n if k == 0 || k == n\n return 1\n else\n return nck_recursive(n-1, k) + nck_recursive(n-1, k-1)\n end\nend",
"def step(debug=false)\n\n # make sure we don't step beyond the solution\n return nil if done?\n\n t0 = Time.now\n @nb_iter += 1\n\n puts \"+++iteration #{@nb_iter}+++\" if debug\n puts \"nb problems = #{@pb_list.length}\" if debug\n\n best_pb = @pb_list.shift\n @rejected_grids.push(best_pb.grid)\n\n puts \"best problem:\" if debug\n puts best_pb.show_stats if debug\n\n if best_pb.min_depth == 1 then\n\n # we can create a problem with all the steps included at once\n new_steps = []\n best_pb.each_poss(1) do |poss|\n new_steps.push(Step.new(poss.row, poss.col, poss.first))\n end\n @nb_try += 1\n begin\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n rescue RuntimeError\n # the combination of depth=1 solution caused a conflict\n puts \"Impossible solution for best problem, discard it\" if debug\n @nb_discard += 1\n end\n else\n\n # we will just process the problem that reduce the most the possibilities\n # on its row, col and box\n poss_list = best_pb.sorted_poss { |x, y| x.min_poss <=> y.min_poss }\n poss = poss_list[0]\n poss.each do |v|\n @nb_try += 1\n new_steps = [Step.new(poss.row, poss.col, v)]\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n end\n end\n\n # resort the list by max_poss / min_dof\n @pb_list.sort! do |x,y|\n res = x.max_poss <=> y.max_poss\n res = x.dof <=> y.dof if res == 0\n res\n end\n\n @duration += Time.now - t0\n\n #return the solution if we have one\n if @pb_list.empty? then\n return nil\n else\n return @pb_list[0]\n end\n\n end",
"def dfs(root, result)\n return if root.nil?\n result << root.val if root.left.nil? && root.right.nil?\n dfs(root.left, result)\n dfs(root.right, result)\nend",
"def right_hand_solve\n until @buckets[1] == @target\n fill_right\n until @buckets[1].zero?\n right_to_left\n break if @buckets.include?(@target)\n empty_left\n break if @buckets.include?(@target)\n right_to_left\n break if @buckets.include?(@target)\n end\n end\n end",
"def find_solution(possibilities, *rest)\n return [possibilities.first] if rest.empty?\n\n possibilities.each do |inst|\n copy = rest.map(&:clone)\n\n copy.each { |instrs| instrs.delete(inst) }\n\n codes = [inst].concat(find_solution(*copy))\n\n return codes if codes.none?(&:nil?)\n end\n\n [nil]\nend",
"def dfs_rec(target)\n dfs_recursive_helper(target,@root)\n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def fibs_rec(i, j, cnt, n)\n if(cnt > n)\n return i\n else\n k = i + j\n print i, \", \"\n i = j\n j = k\n fibs_rec(i, j, cnt += 1, n)\n end\nend",
"def search\n prepare_search\n catch :success do\n # Main iteration loop\n @max_iterations.times do |iteration|\n begin # RuntimeError rescue block\n # At the start of each iteration\n prepare_each_run\n if @banned_points.has_key?(path.last) && path.size == 1\n throw :success\n end\n debug_each_iteration iteration\n going = catch :keep_going do\n message = catch :jump_back do\n # cost_vector is a list of all adjacent points with their \n # respective costs\n candidate_list = get_candidate_list\n begin # IndexError rescue block\n # If we've run out of all possible points, step back and keep \n # trying. Only works when candidate_list#size is the largest\n # dimension, i.e., for a normal Array of NArrays. For NArray, \n # #size gives the total number of elements.\n if @interval_index >= candidate_list.size \n throw :jump_back, \"index #{@interval_index} is out of range\"\n end\n # Load up the candidate from the cost_vector\n candidate = candidate_list[@interval_index]\n candidate_cost = get_cost candidate\n # Skip all candidates that are banned, are already in the path, \n # or don't get us any closer.\n while (@banned_points.has_key? candidate.hash) || (@path.include? candidate) || (candidate_cost >= @current_cost)\n @interval_index += 1\n # If we've exhausted all possible intervals, jump back\n if @interval_index >= candidate_list.size\n @banned_points[candidate.hash] = 1\n throw :jump_back, \"index #{@interval_index} is out of range\"\n end\n # Get the movement that is at the current index\n candidate = candidate_list[@interval_index]\n candidate_cost = get_cost candidate\n end\n # Add it to the path!\n @path << candidate\n @current_cost = candidate_cost\n rescue IndexError => er\n puts \"\\nIndexError: #{er.message}\"\n print er.backtrace.join(\"\\n\")\n throw :jump_back\n rescue RangeError => er\n # If handle_range_error has not been defined in a subclass, any \n # call will just re-raise the exception\n handle_range_error er\n end\n # Judge success\n if @current_cost < @epsilon\n @current_point = @path.last\n prepare_result\n throw :success\n else\n @initial_run = true\n throw :keep_going, true\n end\n end # catch :jump_back\n if @debug_level > 1\n puts message\n end\n jump_back\n end # catch :keep_going\n if going\n keep_going\n going = false\n end\n rescue RuntimeError => er\n puts \"\\n#{er.message}\"\n print er.backtrace.join(\"\\n\")\n print \"\\n\\nPath: #{@path.to_a}\\n\"\n break\n end #RuntimeError block\n end # main iteration loop\n end # catch :success\n debug_final_report\n prepare_data\n @data\n end",
"def dfs_rec(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil \r\n return nil if tree.visited == true\r\n tree.visited = true\r\n return tree if tree.value == value\r\n puts \"current = #{tree}\" if verbose\r\n left = dfs_rec(tree.children[0], value, args)\r\n return left if left != nil\r\n right = dfs_rec(tree.children[1], value, args)\r\n return right # if right != nil\r\n end",
"def dfs_object(root_node, target)\n #two base cases\n return root_node if root_node.value == target\n # return nil if root_node.parent.nil? #when there are no parents, we know we're back at the actual root of the tree\n\n root_node.children.each do |child_node|\n result = dfs(child_node, target)\n\n #returning nil at this point would cut short\n if result #is not nil\n return result\n end\n end\n\n nil\nend"
] | [
"0.7402316",
"0.66856354",
"0.66034263",
"0.6580423",
"0.6365315",
"0.6355879",
"0.6336874",
"0.62735224",
"0.62715316",
"0.6267701",
"0.62094975",
"0.6182158",
"0.61466336",
"0.6127211",
"0.6094551",
"0.5991565",
"0.59739006",
"0.59681904",
"0.59101814",
"0.5901398",
"0.58935577",
"0.5852534",
"0.5847401",
"0.58467937",
"0.58327985",
"0.58206916",
"0.5806852",
"0.58058614",
"0.5791472",
"0.57814574",
"0.57809144",
"0.5762594",
"0.574292",
"0.5711726",
"0.571086",
"0.5710322",
"0.5703624",
"0.5700584",
"0.5685237",
"0.5678737",
"0.565805",
"0.56551677",
"0.5653877",
"0.56459093",
"0.5643052",
"0.5639995",
"0.5639461",
"0.56367433",
"0.563306",
"0.5632938",
"0.5622851",
"0.5622",
"0.5617645",
"0.5604502",
"0.5595546",
"0.55911374",
"0.5584314",
"0.5579083",
"0.5576287",
"0.55663985",
"0.55654067",
"0.55569816",
"0.5556181",
"0.5555816",
"0.5550641",
"0.5549828",
"0.5544035",
"0.5537418",
"0.5536731",
"0.5530723",
"0.5524693",
"0.5522759",
"0.5503851",
"0.5500684",
"0.54943085",
"0.5494058",
"0.54902154",
"0.5485568",
"0.5484474",
"0.5478378",
"0.5478234",
"0.5477585",
"0.547395",
"0.5472846",
"0.5464749",
"0.5457113",
"0.54540265",
"0.54539335",
"0.5450157",
"0.54466677",
"0.54417485",
"0.5439287",
"0.54371667",
"0.54332626",
"0.5432419",
"0.54243356",
"0.54198074",
"0.54156584",
"0.541452",
"0.54091877",
"0.5408577"
] | 0.0 | -1 |
Returns the value of the given option. If the value responds to `call` the method is invoked and the return value of this call is returned. | def option(name, default = nil)
value = self.class.options[name.to_sym]
value = default if default and !value
if value.respond_to? :call then value.call else value end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method, *args)\n if opt = get(method)\n opt.value\n else\n raise NoMethodError, method\n end\n end",
"def value\n options_hash[option_id]\n end",
"def value(op)\n raise \"Option '#{op}' not accepted\" if !accepts? op\n raise \"Option '#{op}' not specified\" if !has? op\n return @options[op].value\n end",
"def value_of(option_name)\n return value if option_name == self.name\n return nil unless has_group?\n group.value_of(option_name)\n end",
"def get_raw_value_for_option(option=nil)\n if option.class == Hash && !block_given?\n return @j_del.java_method(:getRawValueForOption, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))\n end\n raise ArgumentError, \"Invalid arguments when calling get_raw_value_for_option(option)\"\n end",
"def call(_value)\n raise NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end",
"def _get_option(name)\n\n # Start with nothing\n value = nil\n\n # First, get the default value by cycling through the allowed options\n method = self.class.metadata[:allowed_options].each do |allowed_option|\n value = allowed_option[:default] if allowed_option[:name] == name\n end\n\n # Then, cycle through the user-provided options\n @user_options.each do |user_option|\n value = user_option[name] if user_option.key?(name)\n end\n\n value\n end",
"def call(_value)\n fail NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end",
"def value\r\n assert_exists\r\n option_value\r\n end",
"def get_option_value(name=nil)\n if name.class == String && !block_given?\n return ::Vertx::Util::Utils.from_object(@j_del.java_method(:getOptionValue, [Java::java.lang.String.java_class]).call(name))\n end\n raise ArgumentError, \"Invalid arguments when calling get_option_value(name)\"\n end",
"def evaluate_attr_redactor_option(option)\n if option.is_a?(Symbol) && respond_to?(option)\n send(option)\n elsif option.respond_to?(:call)\n option.call(self)\n else\n option\n end\n end",
"def value\n @method.call\n end",
"def call(instance)\n instance.respond_to?(self.value, true) ? instance.send(self.value) : self.value\n end",
"def get_opt(option)\n type = @@option_types.fetch(option) \\\n { raise ArgumentError, \"Unknown option: #{option}\" }\n \n value, size = get_opt_pointers type\n \n rc = LibZMQ.zmq_getsockopt @pointer, option, value, size\n ZMQ.error_check true if rc==-1\n \n if type == :string\n value.read_string(size.read_int-1)\n elsif type == :bool\n value.read_int == 1\n else\n value.send :\"read_#{type}\"\n end\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 method_missing(sym, *args)\n return @options[sym]\n end",
"def option(opt)\n @options[opt]\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def [](option)\n send(option)\n end",
"def option_value(opt_name)\n val = option(opt_name)\n val = (val.is_a?(String) and val.strip == '') ? nil : val\n return val\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 evaluate_attr_encrypted_option(option)\n if option.is_a?(Symbol) && respond_to?(option, true)\n send(option)\n elsif option.respond_to?(:call)\n option.call(self)\n else\n option\n end\n end",
"def [](flag)\n (o = option(flag)) && o.value\n end",
"def evaluate_attr_encrypted_option(option)\n if option.is_a?(Symbol) && respond_to?(option)\n send(option)\n elsif option.respond_to?(:call)\n option.call(self)\n else\n option\n end\n end",
"def value\n self.lazy_proc?(@value) ? self.coerce(@value.call) : @value\n end",
"def get_value\n @get_value_handler.call\n end",
"def set(option, value)\n define_method(option) { value }\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 call_option(context, name, *args)\n handler = find_option(name)\n context.instance_exec(*args, &handler)\n end",
"def value\n value = @value.nil? ? config[:default] : @value\n\n if [true, false, nil].include?(value) && config[:as].to_s != 'count'\n return value\n end\n\n type = config[:as]\n if type.respond_to?(:call)\n type.call(value)\n else\n if callable = types[type.to_s.downcase.to_sym]\n callable.call(value)\n else\n value\n end\n end\n end",
"def value\n return method(@value_method).call if @value_method != nil\n case @type\n when :switch\n return switch\n when :variable, :bar\n return variable\n end\n end",
"def call_valuemethod(name, value)\n if method = self.class.value_option(name, :method) and self.respond_to?(method)\n begin\n event = self.send(method)\n rescue Puppet::Error\n raise\n rescue => detail\n puts detail.backtrace if Puppet[:trace]\n error = Puppet::Error.new(\"Could not set '#{value} on #{self.class.name}: #{detail}\", @resource.line, @resource.file)\n error.set_backtrace detail.backtrace\n raise error\n end\n elsif block = self.class.value_option(name, :block)\n # FIXME It'd be better here to define a method, so that\n # the blocks could return values.\n self.instance_eval(&block)\n else\n devfail \"Could not find method for value '#{name}'\"\n end\n end",
"def get_option(opt)\n @optlist.each do |o|\n return o if (opt.is_a?(Symbol) && o.name == opt) || (opt.is_a?(Fixnum) && o.opt == opt)\n end\n nil\n end",
"def value\n return method(@value_method).call if @value_method != nil\n case @type\n when :switch\n return switch\n when :variable, :bar\n return variable\n else\n 0\n end\n end",
"def value\n case @value\n when Proc\n @value.call\n else\n @value\n end\n end",
"def method_missing(method, *args)\n return options.send(method, *args) if options.respond_to?(method)\n super\n end",
"def method_missing(method_sym, *arguments, &block)\n return @options[method_sym] if @options.include?(method_sym)\n super\n end",
"def fetch(flag)\n o = option(flag)\n if o.nil?\n cleaned_key = clean_key(flag)\n raise UnknownOption.new(\"option not found: '#{cleaned_key}'\", \"#{cleaned_key}\")\n else\n o.value\n end\n end",
"def get_opt(opt)\n @options[opt] || nil\n end",
"def option_value!(option)\n if option.is_short\n if @matched_options[option.name].nil?\n @matched_options[option.name] = 0\n end\n\n @matched_options[option.name] += 1\n else\n @matched_options[option.name] = true\n end\n end",
"def getOrElse *args\n @val\n end",
"def getOption(name)\n return @options[name]\n end",
"def option(which, bit)\n options(which)[bit].to_i\n end",
"def on(option)\n @options[option]\n end",
"def value_of v, *args\n if v.is_a? Symbol\n context.get v\n elsif v.respond_to? :call\n context.instance_exec *args, &v\n else\n v\n end\n end",
"def get_option(opt, default=nil, allow_nil=true)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if (default or allow_nil)\n raise(\"No plugin.#{opt} configuration option given\")\n end",
"def get_option(opt, default=nil, allow_nil=true)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if (default or allow_nil)\n raise(\"No plugin.#{opt} configuration option given\")\n end",
"def method_missing(method, *args, &block)\n if method =~ /(.+)\\?$/\n options[$1.to_sym].present?\n else\n options[method]\n end\n end",
"def option\n return @manager.configurable.class.configuration.options[key]\n end",
"def value()\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n @tag.option.selected(true).innerText.strip\n end",
"def value()\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n @tag.option.selected(true).innerText.strip\n end",
"def value()\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n @tag.option.selected(true).innerText.strip\n end",
"def value()\n $tracer.trace(\"\\tAction: #{format_method(__method__)}\")\n @tag.option.selected(true).innerText.strip\n end",
"def get_value(flag)\n\t\tfp = @flag_pairs.get_value(flag)\n\t\tif !@no_vals.include?(flag)\n\t\t\tif @args.has_key?(flag)\n\t\t\t\treturn @args[flag]\n\t\t\telsif @args.has_key?(fp) && fp != nil\n\t\t\t\treturn @args[fp]\n\t\t\telse\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def retrieve_option(name)\n if options['user-data']\n retrieve_from_userdata(name, options['user-data-type'], options['user-data-source'])\n else\n options[name] || name\n end\n end",
"def call_if_exists(obj, method, default_value = true)\n if obj.respond_to?(method)\n return obj.send(method)\n else\n return default_value\n end\n end",
"def value_or(_val = nil)\n @value\n end",
"def get value, option={}\n if value.is_a? Hash\n if value[:index]\n get_from_local_index value, option\n elsif option[:noindex]\n option.delete(:noindex)\n query_without_index value, option\n else\n get_from_index value, option\n end\n else\n get_from_key value, option\n end\n end",
"def option_for(field, option)\n @options[field][option] if @options[field]\n end",
"def evaluate_attr_encrypted_option(option, object)\n if option.is_a?(Symbol) && object.respond_to?(option)\n object.send(option)\n elsif option.respond_to?(:call)\n option.call(object)\n else\n option\n end\n end",
"def value!\n if ok?\n @value\n else\n raise @error\n end\n end",
"def get_option(opt, default=nil)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if default\n\n raise(\"No plugin.#{opt} configuration option given\")\n end",
"def value\n selected&.value\n end",
"def get_option(options, key, default_value = \"\")\n result = options.has_key?(key) ? options[key] : nil\n result = default_value if result.nil? || result == \"\"\n result \n end",
"def get\n val\n end",
"def get\n val\n end",
"def get_option(opt, default=nil)\n return @config.pluginconf[opt] if @config.pluginconf.include?(opt)\n return default if default\n\n raise(\"No plugin.#{opt} configuration option given\")\n end",
"def call(instance)\n self.value.call(instance, self.attribute)\n end",
"def method\n options.fetch(:method, nil)\n end",
"def evaluate_option(name, *args)\n unless proc = self[name]\n return yield if block_given?\n return\n end\n\n # TODO: it would be better if user_options was nil per default and then we just don't pass it into lambdas.\n options = self[:pass_options] ? Options.new(self, user_options, represented, decorator) : user_options\n\n proc.evaluate(exec_context, *(args << options)) # from Uber::Options::Value.\n end",
"def lookup_in_options(value)\n if options.include?(value)\n return value\n elsif options_are_labeled? && pair = options.detect {|option| option.include?(value.to_s) }\n return pair.last\n else\n raise \"Value '#{value}' isn't one of the options for #{self.name}.\"\n end\n end",
"def value\n return options[:input_html][:value] if options[:input_html]&.key?(:value)\n\n val = object.public_send(method)\n return val.join(', ') if val.is_a?(Array)\n\n val\n end",
"def value\n if @value_set\n @value\n else\n value_from_response\n end\n end",
"def value\n # double-checked locking is safe because we only update once\n return @value if @fulfilled\n\n @mutex.synchronize do\n unless @fulfilled\n begin\n @value = @task.call\n rescue\n @value = @default\n ensure\n @fulfilled = true\n end\n end\n return @value\n end\n end",
"def method\n @method ||= options[:method]\n end",
"def get(name, default = nil)\n\t\t\t\tname = name.to_sym\n\n\t\t\t\tif @options[name][:value] != nil then\n\t\t\t\t\t@options[name][:value]\n\t\t\t\telsif default != nil then\n\t\t\t\t\tdefault\n\t\t\t\telse\n\t\t\t\t\t@options[name][:default]\n\t\t\t\tend\n\t\t\tend",
"def get(value)\n value\n end",
"def value\n @value || default_value\n end",
"def get_value name=nil\n @value\n end",
"def get(val=true)\n @get = val\n end",
"def call(value)\n @matchers.each do |matcher|\n status, return_value = matcher.call(value)\n return return_value if status\n end\n\n if @default\n _, return_value = @default.call(value)\n return_value\n else\n nil\n end\n end",
"def option?(key)\n key = key&.to_sym\n @value.key?(key) || option_method(key).present?\n end",
"def method\n options[:method] || :get\n end",
"def execute(data)\n data.respond_to?(option.first) ? data.send(*option) : data\n end",
"def get_option(key)\n o = @grammar.get_locally_defined_option(key)\n if (!(o).nil?)\n return o\n end\n if (!(@parent).nil?)\n return @parent.get_option(key)\n end\n return nil # not found\n end",
"def option_from(config, option, default = nil)\n config.respond_to?(option) ? config.send(option) : default\n end",
"def value\n mutex.lock\n execute_task_once\n apply_deref_options(@value)\n ensure\n mutex.unlock\n end",
"def get_option(option_name)\n\t\toption = nil\n\t\t# Could use ternary conditional expressions here (bool ? true_value : false_value) but chose not to for readability\n\t\tif use_short_option?(option_name)\n\t\t\tdebug_log \"Short version has been flagged for option: #{option}\"\n\t\t\tcase option_name\n\t\t\twhen 'badge'\n\t\t\t\toption = \"-b\"\n\t\t\telse\n\t\t\t\traise \"Option not supported: #{option_name}\"\n\t\t\tend\n\t\telse\n\t\t\tdebug_log \"Short version not flagged for option: #{option}. Using long version.\"\n\t\t\tcase option_name\n\t\t\twhen 'badge'\n\t\t\t\toption = \"--badge\"\n\t\t\telse\n\t\t\t\traise \"Option not supported: #{option_name}\"\n\t\t\tend\n\t\tend\n\n\t\treturn option\n\n\tend",
"def get(options = nil)\n options ||= {}\n options[:method] = :get\n call options\n end",
"def get_option(hash, key)\n hash[key.to_sym] || hash[key] || nil\n end",
"def cli_option(key)\n return @cli_options[key]\n end",
"def get_option(option, default = (default_not_passed = true; false))\n option = option.strip\n return false if option.blank?\n # Filters the value of an existing option before it is retrieved.\n pre = apply_filters(\"pre_option_#{option}\", false, option, default)\n\n return pre if pre != false\n # return false if defined? WP_SETUP_CONFIG\n passed_default = !default_not_passed\n if true #! wp_installing()\n # prevent non-existent options from triggering multiple queries\n notoptions = Rails.cache.read 'Railspress::' + 'options' + '/' + 'notoptions'\n if !notoptions.blank? && notoptions[option]\n # Filters the default value for an option.\n return apply_filters( \"default_option_#{option}\", default, option, passed_default)\n end\n\n alloptions = wp_load_alloptions\n\n if alloptions[option]\n value = alloptions[option]\n else\n value = Rails.cache.fetch('Railspress::' + 'options' + '/' + option) {\n Railspress::Option.where(option_name: option).pluck(:option_value).first\n }\n if value.nil? # option does not exist, so we must cache its non-existence\n notoptions = {} unless notoptions.kind_of? Hash\n notoptions[ option ] = true\n Rails.cache.write 'Railspress::' + 'options' + '/' + 'notoptions', notoptions\n # This filter is documented in wp-includes/option.php */\n return apply_filters(\"default_option_#{option}\", default, option, passed_default)\n end\n end\n else\n # not implementing this case\n end\n # If home is not set use siteurl.\n if 'home' == option && '' == value\n return get_option('siteurl')\n end\n\n if %w(siteurl home category_base tag_base).include? option\n value = Railspress::FormattingHelper.untrailingslashit(value)\n end\n\n # Filters the value of an existing option.\n apply_filters( \"option_#{option}\", Railspress::Functions.maybe_unserialize(value), option).freeze\n end"
] | [
"0.69873524",
"0.6936445",
"0.68559176",
"0.66902703",
"0.66789705",
"0.66745156",
"0.66509557",
"0.6608145",
"0.6527887",
"0.6506515",
"0.647163",
"0.6436",
"0.6361123",
"0.6308047",
"0.6226083",
"0.6215216",
"0.62105024",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.61020684",
"0.6092648",
"0.6084711",
"0.6075148",
"0.60703015",
"0.60656506",
"0.6025112",
"0.60104877",
"0.5959024",
"0.5959021",
"0.5954818",
"0.59427494",
"0.5917728",
"0.5873698",
"0.58617723",
"0.5849147",
"0.58370805",
"0.58170825",
"0.5791203",
"0.5790754",
"0.57866514",
"0.578242",
"0.5779992",
"0.5747068",
"0.5739668",
"0.5701091",
"0.5691741",
"0.5673236",
"0.5673236",
"0.56672525",
"0.5648391",
"0.5644599",
"0.5644599",
"0.5644599",
"0.5644599",
"0.56407833",
"0.56381106",
"0.5638005",
"0.5635014",
"0.561558",
"0.5598838",
"0.5587045",
"0.55758816",
"0.55734426",
"0.5570441",
"0.5550323",
"0.55488175",
"0.55488175",
"0.55437505",
"0.554138",
"0.5537011",
"0.55187213",
"0.550171",
"0.54953283",
"0.549151",
"0.54872704",
"0.54846996",
"0.5484359",
"0.54823536",
"0.54790556",
"0.5478642",
"0.54729956",
"0.54650474",
"0.5457734",
"0.5456759",
"0.5455647",
"0.54393035",
"0.543078",
"0.5430219",
"0.5412839",
"0.5405297",
"0.53997654",
"0.5399455",
"0.5389007"
] | 0.6426646 | 12 |
Sets a number of options based on the given Hash. | def set_multiple(options)
options.each do |option, value|
set(option, value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options(hash)\n @options.merge! hash\n end",
"def set_options(hash)\n hash.keys.each do |key|\n var = '@' << key.to_s\n # = 1.9.* Fix\n # The map method applied on instance_variables is used to force elements to be String\n # because on 1.9.* Ruby versions, these elements are Symbol (i.e. :@directory).\n raise(\"Key #{key} not supported.\") unless instance_variables.map {|v| v.to_s}.include? var\n instance_variable_set(var, hash[key])\n end\n end",
"def options=(hash={})\n hash.each { |key,value| write_option(key, value) }\n end",
"def options_from_hash(options_hash)\n options_hash.each do |name, definition|\n option = Option.new\n definition.each do |key, value|\n Array(value).each { |hit| option.send(key, hit) }\n end\n @@options << [name.to_s, option]\n end\n end",
"def set_options(hash)\n @collections ||= []\n hash.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n @collections << key if value.kind_of?(CollectionsFactory)\n end\n end",
"def options=(val)\n raise(ArgumentError, \"Options must recieve a hash\") unless val.kind_of?(Hash)\n @options = val\n end",
"def options=(val)\n raise(ArgumentError, \"Options must recieve a hash\") unless val.kind_of?(Hash)\n @options = val\n end",
"def options(hash = {}, &block)\n # if we are passing in a hash to define our options, use that straight\n options_from_hash(hash) unless hash.empty?\n\n # Setup all instance variables\n reset! if hash.empty?\n @@args ||= ARGV\n\n # Eval the passed block to define the options.\n instance_eval(&block) if block_given?\n\n # Parse what we've got.\n parse unless parsed?\n end",
"def set_options(opts)\n common_options(opts)\n end",
"def set hash\n hash.each_pair do |k,v|\n self.send(:\"#{k}=\", v)\n end\n \n self\n end",
"def option_attributes=(options_hash)\n self.options.clear\n options_hash.each do |option_hash|\n option = option_hash[:id].blank? ? Option.new : Option.find(option_hash[:id])\n option.name = option_hash[:name]\n self.options << option\n end\n end",
"def options *options\n if options.size > 0\n @options = {}\n options.each do |a|\n a.is_a?(Hash) ?\n @options.update(a) :\n a.is_a?(Array) ?\n @options.update(Hash[a.zip(a)]) :\n @options.update(a => a)\n end\n end\n @options\n end",
"def set_params(hash)\n hash.each do |k,v|\n set_param(k, v)\n end\n end",
"def merge_options!(hash)\n hash.merge!(@options)\n end",
"def options_arguments=(val)\n raise(ArgumentError, \"Options must recieve a hash\") unless val.kind_of?(Hash)\n @options_arguments = val\n end",
"def options=(opts)\n myopts = {}\n opts.each do |key, val|\n debug \"looping on key #{key}, val #{val}\"\n debug \"class of key is #{key.class}\"\n tftpassert(\"options keys must be symbols\") { key.class == Symbol }\n myopts[key.to_s] = val.to_s\n end\n @options = myopts\n end",
"def set_options(options = {})\n options.each_pair do | key, value |\n send \"#{key}=\", value\n end\n end",
"def apply_options! options = {}\n options.each_pair do |key, value| \n send(\"#{key}=\", value) if self.respond_to?(:\"#{key}=\")\n end \n end",
"def init_hash(hash)\n if hash[:parser]\n self.parser=hash[:parser]\n elsif hash[:many]\n init_many hash\n elsif hash[:match]\n init hash[:match]\n elsif hash[:any]\n init_any hash[:any]\n else\n raise \"extended-options patterns (specified by a hash) must have either :parser=> or a :match=> set\"\n end\n\n self.name = hash[:as] || self.name\n self.optional ||= hash[:optional] || hash[:optionally]\n self.could_match ||= hash[:could]\n self.negative ||= hash[:dont]\n end",
"def opts_reset!(hash)\n opts.reset!\n opts.configure_from_hash(hash)\n end",
"def initialize\n OPTIONS.each_pair do |key, value|\n send(\"#{key}=\", value)\n end\n end",
"def set(hash)\n hash.each do | key, value |\n setting = settings.find_by_key(key) || settings.new(:key => key)\n setting.value = value\n setting.save!\n end\n end",
"def initialize(hash)\r\n @question = hash['Question']\r\n\r\n @options = []\r\n hash['Options'].each {|option| @options << option}\r\n\r\n @answer = hash['Answer']\r\n end",
"def set_glade_hash(hash)\r\n return unless hash.is_a?(Hash)\r\n hash.each { |key,val| fill_control( key.to_s, val.to_s) }\r\n end",
"def options(opts)\n opts.each { |k,v| merge_options(k, v) }\n end",
"def apply_options! options = {}\n options.each_pair do |key, value|\n send(\"#{key}=\", value) if self.respond_to?(:\"#{key}=\")\n end\n end",
"def configure(options_hash = {})\n keys.each do |key|\n if options_hash[key]\n instance_variable_set(:\"@#{key}\", options_hash[key])\n end\n end\n if block_given?\n yield self\n end\n return self\n end",
"def set_options(options={})\n @options.merge!(options)\n end",
"def set(options)\n options.each do |k, v|\n send(\"#{k}=\", v) if respond_to? \"#{k}=\"\n end\n end",
"def initialize(optHash)\n @optHash=optHash\n setParameters()\nend",
"def load(hash)\n @opts = hash\n end",
"def set_options(options)\n @options.merge!(options)\n end",
"def options(original_hash=nil, key, value)\n j = Hash.new\n j[key] = value\n j.merge(original_hash) unless original_hash.nil?\n j\n end",
"def initialize(arghash = {})\n @options = DEFAULTS.merge arghash\n end",
"def set_options(params)\n @options = RoutificApi::Options.new(params)\n end",
"def set_fields(hash, keys=hash.keys)\n super hash, keys\n end",
"def options\n VALID_OPTIONS_KEYS.each_with_object({}) do |k, options|\n options[k] = send(k)\n end\n end",
"def merge(config_hash)\n config_hash.each_pair { |option, value| set_option(option, value) }\n self\n end",
"def set_selectbox_options\n set_kind_option\n set_scheduled_times_option\n set_user_option\n end",
"def set_all(hash)\n set_restricted(hash, false, false)\n end",
"def set(hash)\n set_restricted(hash, :default)\n end",
"def set(hash)\n set_restricted(hash, :default)\n end",
"def set(options_hash)\n options_hash.each do |label_or_range, contents|\n _debug(\"setting '#{label_or_range}' to '#{contents}'\")\n unless Soroban::Helpers.range?(label_or_range)\n _add(label_or_range, contents)\n next\n end\n fc, fr, tc, tr = Soroban::Helpers.getRange(label_or_range)\n if fc == tc || fr == tr\n raise ArgumentError, \"Expecting an array when setting #{label_or_range}\" unless contents.kind_of? Array\n cc, cr = fc, fr\n contents.each do |item|\n set(\"#{cc}#{cr}\" => item)\n cc.next! if fr == tr\n cr.next! if fc == tc\n end\n raise Soroban::RangeError, \"Supplied array doesn't match range length\" if cc != tc && cr != tr\n else\n raise ArgumentError, \"Can only set cells or 1-dimensional ranges of cells\"\n end\n end\n end",
"def options\n\t\t\tVALID_OPTIONS_KEYS.inject({}) do |option,key|\n\t\t\t\toption.merge!(key => send(key))\n\t\t\tend\n\t\tend",
"def set(options)\n parse_options options\n end",
"def set_dyn_params(hash)\n hash.each do |k,v|\n set_dyn_param(k, v)\n end\n end",
"def set(hsh = {})\n hsh.each { |name, val| self.set_attr(name,val) }\n self\n end",
"def set_params!(param_hash={})\n param_hash.each { |k,v| @set_params[k.to_s] = v }\n end",
"def set(key, value, **options); end",
"def initialize(*args)\n args.each do |arg|\n if arg.kind_of? Hash\n arg.each do |k,v|\n self.send(\"#{k}=\", v)\n end\n end\n end\n end",
"def initialize(options = {})\n options = Tumblife.options.merge(options)\n Configuration::OPTIONS_KEYS.each do |key|\n send(\"#{key}=\", options[key])\n end\n end",
"def set(hash)\n set_restricted(hash, nil, nil)\n end",
"def make_option_list\n @data = @option.values\n if @data.is_a?(Hash)\n @keys = @data.keys\n @data = @data.values\n end\n end",
"def make_option_list\n @data = @option.values\n if @data.is_a?(Hash)\n @keys = @data.keys\n @data = @data.values\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def initialize(options = {})\n reset_options\n options.each_pair do |key, value|\n send(\"#{key}=\", value) if VALID_OPTIONS_KEYS.include?(key)\n end\n end",
"def opts=(o=nil)\n raise \"opts must be a hash\" unless (o ||= {}).is_a? Hash\n @opts = o\n end",
"def apply_options(options)\n options.keys.each do |key|\n send(\"#{key}=\", options[key]) if respond_to? key\n end\n end",
"def options\n VALID_OPTIONS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def set_opts(options)\n @opt ||= options\n end",
"def set (hash)\n @data.merge! hash\n end",
"def initialize(hash, base_key, options_hash = {})\n self.options = options_hash\n\n @hash = hash\n @base_key = base_key\n end",
"def options\n VALID_OPTIONS_KEYS.reduce({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def apply hash\n hash.each_key do |k|\n send k.to_s+\"=\",hash[k]\n end\n self\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def options\n VALID_OPTIONS_KEYS.inject({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def set(key, value)\n raise(ArgumentError, \"Argument 'key' must be a String or Symbol.\") unless key.is_a?(String) || key.is_a?(Symbol)\n raise(ArgumentError, \"Not a valid type for Options.[]=\") unless @@valid_types.include?(value.class)\n self.update({key => value})\nend",
"def initialize(attrs={})\n attrs = Hull.options.merge(attrs)\n Config::VALID_OPTIONS_KEYS.each do |key|\n instance_variable_set(\"@#{key}\".to_sym, attrs[key])\n end\n end",
"def with(options = {})\n options.each_pair do |option, value|\n @options[\"=#{option}\"] = value\n end\n self\n end",
"def set_parameters(hash_or_instance)\n parameters = extract_parameters_from_hash_or_instance(hash_or_instance)\n parameters.each do |k,v|\n send \"#{k}=\", v\n end\n end",
"def initialize(options={})\r\n options.each do |k, v|\r\n self.send(\"#{k}=\", v)\r\n end\r\nend",
"def set(opts={})\n if block_given?\n old_opts = $opts.dup\n $opts.merge! opts\n yield\n $opts.merge! old_opts\n else\n $opts.merge! opts\n end\nend",
"def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end",
"def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end",
"def from_hash(hash)\n options = new\n options.timeout = hash[:timeout]\n if hash[:sudo].is_a?(String)\n options.sudo_user = hash[:sudo]\n elsif hash[:sudo].is_a?(Hash)\n options.sudo_user = hash[:sudo][:user]\n options.sudo_password = hash[:sudo][:password]\n elsif hash[:sudo] == true\n options.sudo_user = 'root'\n end\n options.raise_on_error = !!hash[:raise_on_error]\n options.stdin = hash[:stdin]\n options.stdout = hash[:stdout]\n options.stderr = hash[:stderr]\n options.file_to_stream = hash[:file_to_stream]\n options\n end",
"def build_variants_from_option_values_hash\n ensure_option_types_exist_for_values_hash\n values = option_values_hash.values\n values = values.inject(values.shift) { |memo, value| memo.product(value).map(&:flatten) }\n\n values.each do |ids|\n variant = variants.create({ :option_value_ids => ids, :price => master.price }, :without_protection => true)\n end\n save\n end",
"def option_set\n @options ||= {}\n end",
"def options\n VALID_OPTIONS_KEYS.reduce({}) do |option, key|\n option.merge!(key => send(key))\n end\n end",
"def initialize(options)\n\t\t\t@options = options\n\t\t\toptions.keys.each do |key|\n\t\t\t\tif respond_to?(key)\n\t\t\t\t\tsend(\"#{key}=\",options[key])\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def set_options(object, options = {})\n options.each_pair do |option, value| \n case option\n when :settings # works for windows and tabs, for example :settings => \"Grass\"\n begin\n object.current_settings.set(@terminal.settings_sets[value])\n rescue Appscript::CommandError => e\n puts \"Error: invalid settings set '#{value}'\"\n end\n when :bounds # works only for windows, for example :bounds => [10,20,300,200]\n # the only working sequence to restore window size and position! \n object.bounds.set(value)\n object.frame.set(value)\n object.position.set(value)\n when :selected # works for tabs, for example tab :active => true\n delayed_option(option, value, object)\n when :miniaturized # works for windows only\n delayed_option(option, value, object)\n when :name\n # ignore it.\n else # trying to apply any other option\n begin\n object.instance_eval(option.to_s).set(value)\n rescue\n puts \"Error setting #{option} = #{value} on #{object.inspect}\"\n end\n end\n end\n end",
"def set_hash_length(opts)\n opts = check_params(opts,[:lengths])\n super(opts)\n end",
"def set_options(opts)\n if not opts.nil?\n @options[\"min_tokens\"] = opts[\"min_tokens\"] if not opts[\"min_tokens\"].nil?\n @options[\"max_tokens\"] = opts[\"max_tokens\"] if not opts[\"max_tokens\"].nil?\n @options[\"matching_method\"] = opts[\"matching_method\"] if not opts[\"matching_method\"].nil?\n @options[\"threshold\"] = opts[\"threshold\"] if not opts[\"threshold\"].nil?\n @options[\"top_n\"] = opts[\"top_n\"] if not opts[\"top_n\"].nil?\n end\n end",
"def set_options(object, options = {})\n options.each_pair do |option, value|\n case option\n when :settings # works for windows and tabs, for example :settings => \"Grass\"\n begin\n object.current_settings.set(@terminal.settings_sets[value])\n rescue Appscript::CommandError => e\n puts \"Error: invalid settings set '#{value}'\"\n end\n when :bounds # works only for windows, for example :bounds => [10,20,300,200]\n # the only working sequence to restore window size and position! \n object.bounds.set(value)\n object.frame.set(value)\n object.position.set(value)\n when :selected # works for tabs, for example tab :active => true\n delayed_option(option, value, object)\n when :miniaturized # works for windows only\n delayed_option(option, value, object)\n when :name\n # ignore it.\n else # trying to apply any other option\n begin\n object.instance_eval(option.to_s).set(value)\n rescue\n puts \"Error setting #{option} = #{value} on #{object.inspect}\"\n end\n end\n end\n end",
"def set_option_list\n @staffer_status_opts = ordered_list(grap_item_list(\"staffer_status\"))\n @cont_source_opts = ordered_list(grap_item_list(\"cont_source\"))\n @sfdc_type_opts = ordered_list(grap_item_list(\"sfdc_type\"))\n @sfdc_tier_opts = ordered_list(grap_item_list(\"sfdc_tier\"))\n @sfdc_sales_person_opts = ordered_list(grap_item_list(\"sfdc_sales_person\"))\n @cont_status_opts = ordered_list(grap_item_list(\"cont_status\"))\n @job_opts = ordered_list(grap_item_list(\"job\"))\n # @state_opts = ordered_list(grap_item_list(\"state\"))\n @state_opts = ordered_list(list_of_states)\n @email_status = ordered_list(email_status_list)\n end",
"def initialize(options={})\n options.each{|k,v|send(\"#{k}=\",v)}\n end",
"def initialize(options={})\n options.each{|k,v|send(\"#{k}=\",v)}\n end",
"def initialize(options={})\n options.each{|k,v|send(\"#{k}=\",v)}\n end",
"def build_opts(hash, *args)\n opts = args\n hash.each do |key, value|\n case key\n when :secure, :soft\n value == :yes && opts << '--%s' % key\n when :appname, :appversion\n when :name\n else\n opts << '--%s' % key << value\n end\n end\n opts << hash[:appname]\n opts << hash[:appversion]\n opts.compact\n end",
"def _ssh_options(mash)\n (mash || {}).inject({}) {|hash, (k, v)| hash[k.to_sym] = v; hash}\n end",
"def options\n OPTIONS.each_with_object({}) do |name, hash|\n hash[name] = raw.fetch(name, nil)\n end\n end",
"def merge!(hash={}, &block)\n @static_options = Variables.merge( @static_options, handle_array_and_deprecate(hash) )\n @dynamic_options = block if block_given?\n\n self\n end",
"def set_attributes(options)\n @options.keys.each do |opt_name|\n instance_variable_set(\"@#{opt_name}\", options[opt_name])\n end\n end",
"def options\n Hash[ * VALID_OPTIONS_KEYS.map { |key| [key, send(key)] }.flatten ]\n end",
"def set_options(options)\n options.each do |param,value|\n method = param.to_s + \"=\"\n if respond_to? method\n self.send(method, value)\n else\n raise ArgumentError, \"Invalid parameter #{param} to object class #{self.class}\"\n end\n end\n end",
"def set_options(opts)\n opts.version, opts.banner = options.version, options.banner\n opts.set_program_name 'LinkShrink'\n\n options.api.map do |k, v|\n arg = k.to_s.downcase\n\n opts.on_head(\"-#{arg[0]}\", \"--#{arg}\", argument_text_for(k)) do\n options.api[k] = true\n end\n end\n\n opts.on_tail('-v', '--version',\n 'display the version of LinkShrink and exit') do\n puts opts.ver\n exit\n end\n\n opts.on_tail('-h', '--help', 'print this help') do\n puts opts.help\n exit\n end\n end",
"def build_variants_from_option_values_hash\n ensure_option_types_exist_for_values_hash\n values = option_values_hash.values\n values = values.inject(values.shift) { |memo, value| memo.product(value).map(&:flatten) }\n\n values.each do |ids|\n variant = variants.create(option_value_ids: ids, variant_price: master_price)\n end\n\n save\n end"
] | [
"0.73296225",
"0.7243865",
"0.7079869",
"0.7010588",
"0.68728894",
"0.66257674",
"0.66257674",
"0.65781736",
"0.6542026",
"0.6473097",
"0.64149195",
"0.6387717",
"0.63875043",
"0.62927765",
"0.6228895",
"0.61993",
"0.6193409",
"0.6168272",
"0.61671865",
"0.61397",
"0.6136911",
"0.61367947",
"0.61359656",
"0.61355627",
"0.6120223",
"0.6119463",
"0.6104655",
"0.6059883",
"0.6048563",
"0.60231894",
"0.5969212",
"0.5961204",
"0.5955081",
"0.59548414",
"0.5923631",
"0.5908127",
"0.5907707",
"0.5879647",
"0.587231",
"0.5869318",
"0.58600175",
"0.58600175",
"0.5859803",
"0.58541656",
"0.5838758",
"0.5835815",
"0.5804303",
"0.5801866",
"0.5797994",
"0.57853717",
"0.57848215",
"0.5754684",
"0.5742723",
"0.5742723",
"0.57314265",
"0.57297206",
"0.57230836",
"0.5721904",
"0.5712381",
"0.5700524",
"0.5695727",
"0.5688503",
"0.5679961",
"0.56776327",
"0.56773317",
"0.56773317",
"0.56773317",
"0.56773317",
"0.56773317",
"0.56773317",
"0.5663503",
"0.56591976",
"0.5653089",
"0.5650701",
"0.56462204",
"0.5640085",
"0.5634418",
"0.5633135",
"0.5632998",
"0.56323636",
"0.56303966",
"0.56219786",
"0.56216276",
"0.56143236",
"0.56129587",
"0.56111723",
"0.56046546",
"0.5577129",
"0.5576554",
"0.5576554",
"0.5576554",
"0.55750924",
"0.5567881",
"0.555986",
"0.555715",
"0.5550597",
"0.55497384",
"0.5547697",
"0.55429834",
"0.5541676"
] | 0.56712615 | 70 |
Returns browser windows array. | def windows(opts = {})
WindowCollection.new self, opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def windows\n @driver.getWindowList.map do |java_window|\n QuickWindow.new(self,java_window)\n end.to_a\n end",
"def firefox_windows(w = nil)\n\t\t\tcollection = []\n\t\t\twindows = nil\n\t\t\tif w\n\t\t\t\twindows = [w]\n\t\t\telse\n\t\t\t\twindows = X11::Display.instance.screens.collect{|s| s.root_window}\n\t\t\tend\n\t\t\twindows.each do |window|\n\t\t\t\tif window.class == 'Gecko'\n\t\t\t\t\tcollection << window\n\t\t\t\tend\n\t\t\t\twindow.children.each do |c|\n\t\t\t\t\tcollection << firefox_windows(c)\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn collection.flatten.compact\n\t\tend",
"def windows(window = nil)\n @windows ||= []\n if window\n @windows << window\n @windows.uniq!\n end\n @windows\n end",
"def window_handles\n driver.window_handles\n end",
"def window_handles\n bridge.window_handles\n end",
"def windows\n IITWindowCollection.new(@ole.Windows)\n end",
"def get_window_count\n return @browser.windows.count\n end",
"def find_windows(options = {})\n query = XDo::FFILib::XDoSearch.from_options options\n windows_pointer = FFI::MemoryPointer.new :pointer, 1\n count_pointer = FFI::MemoryPointer.new :ulong, 1\n XDo::FFILib.xdo_window_search @_pointer, query, windows_pointer,\n count_pointer\n count = count_pointer.read_ulong\n windows = windows_pointer.read_pointer.read_array_of_long(count)\n windows.map { |window| XDo::Window.new self, window }\n end",
"def window_handles; end",
"def collect_visible_windows\n scene = SceneManager.scene\n scene.instance_variables.collect do |varname|\n scene.instance_variable_get(varname)\n end.select do |ivar|\n ivar.is_a?(Window) && !ivar.disposed? && ivar.visible\n end\n end",
"def windows?; end",
"def named_windows\n return [] unless children\n children.inject([]) do | names, child |\n names << child.name if child.name\n names += child.named_windows if child.kind_of?(Parent)\n names\n end\n end",
"def browsers\n @browsers ||= @data[\"agents\"].keys.map{|b| PUBLIC_BROWSER_NAMES[b] }.sort\n end",
"def get_window_number()\r\n $jssh_socket.send(\"getWindows().length;\\n\", 0)\r\n @@current_window = read_socket().to_i - 1\r\n \r\n # Derek Berner 5/16/08 \r\n # If at any time a non-browser window like the \"Downloads\" window \r\n # pops up, it will become the topmost window, so make sure we \r\n # ignore it.\r\n @@current_window = js_eval(\"getWindows().length\").to_i - 1\r\n while js_eval(\"getWindows()[#{@@current_window}].getBrowser\") == ''\r\n @@current_window -= 1;\r\n end\r\n\r\n # This will store the information about the window.\r\n #@@window_stack.push(@@current_window)\r\n #puts \"here in get_window_number window number is #{@@current_window}\"\r\n return @@current_window\r\n end",
"def item_list_windows\n instance_variables.map{ |v|instance_variable_get v}.select{|w|w.is_a?(Window_ShopItems) }\n end",
"def [](value)\n old = 'using indexing with windows'\n new = 'Browser#switch_window or Browser#window with :title, :url or :element selectors'\n reference = 'http://watir.com/window_indexes'\n Watir.logger.deprecate old, new, reference: reference, ids: [:window_index]\n\n window_list[value]\n end",
"def desktops\n @desktops ||= if available?\n Libatspi.get_desktop_count.times.map do |idx|\n Desktop.new(Libatspi.get_desktop(idx))\n end\n else\n []\n end\n end",
"def each\n (0..VIM::Window.count - 1).each do |ix|\n yield Window.new(VIM::Window[ix])\n end\n end",
"def window_titles\n @_window_titles\n end",
"def open_pages\n quick_windows.select { |win| win.name == \"Document Window\" }\n end",
"def get_window_area()\n get_children_area(\"WINDOW\")\n end",
"def get_window_object()\n driver.manage.window\nend",
"def get_window_object()\n driver.manage.window\nend",
"def page\n Bowline::Desktop::Proxy.new(\n windows.length == 1 ? windows.first : windows\n )\n end",
"def get_window_area()\n get_children_area(\"WINDOW\")\n end",
"def windows?\n @windows\n end",
"def show_windows\n end",
"def window_handle\n driver.window_handle\n end",
"def window\n @win\n end",
"def store_active_windows\n restore_active_windows\n @windows.each do |win|\n if win.active\n @active_windows.push(win)\n win.deactivate\n end\n end\n end",
"def win\n @win\n end",
"def render\n @windows.each_value(&:render)\n end",
"def browsers_for names\n names.map do |name|\n begin\n Browser.subclasses.find do |browser|\n browser.matches_name? name\n end.new\n rescue\n raise \"Unsupported browser `#{name}'\"\n end\n end\n end",
"def all_monitors\n web + groups\n end",
"def windows_processes\n\t\trequire 'win32ole'\n\t\twmi = WIN32OLE.connect(\"winmgmts://\")\n\t\twmi.ExecQuery(\"select * from win32_process\").map do |proc_info|\n\t\t\tparse_oleprocinfo(proc_info)\n\t\tend\n\tend",
"def windows_processes\n\t\trequire 'win32ole'\n\t\twmi = WIN32OLE.connect(\"winmgmts://\")\n\t\twmi.ExecQuery(\"select * from win32_process\").map do |proc_info|\n\t\t\tparse_oleprocinfo(proc_info)\n\t\tend\n\tend",
"def content_windows\n content = {\n score_window: Curses::Window.new(4, 14, 4, 3),\n lvl_window: Curses::Window.new(3, 5, 11, 3),\n lines_window: Curses::Window.new(3, 7, 11, 10),\n highscores_window: Curses::Window.new(24, 14, 17, 3),\n tetris_window: Curses::Window.new(40, 20, 4, 20),\n next_window: Curses::Window.new(10, 14, 4, 43)\n }\n\n content.each do |_name, window|\n window.noutrefresh\n end\n content\nend",
"def browser_window\n IITBrowserWindow.new(@ole.BrowserWindow)\n end",
"def store_all_window_names variable_name\r\n command 'storeAllWindowNames', variable_name\r\n end",
"def customWindowsToEnterFullScreenForWindow(window)\n\t\t[window]\n\tend",
"def get_process_array(wmi)\r\n # This looks clumsy, but the processes object doesn't support #map. :)\r\n processes=wmi.ExecQuery(\"select * from win32_process where name='WINWORD.EXE'\")\r\n ary=[]\r\n processes.each {|p|\r\n ary << p.ProcessId\r\n }\r\n processes=nil\r\n ary\r\nend",
"def web\n @monitors.map{|x| MonitorStatus.new(x)}\n end",
"def get_window_size\n Ncurses.refresh\n cols, rows = [], []\n Ncurses.stdscr.getmaxyx rows, cols\n [rows.first, cols.first]\n end",
"def index\n @windows = Window.all\n end",
"def index\n @windows = Window.all\n end",
"def create_optional_windows\n @macmm_optional_windows = []\n $game_system.macmm_optional_windows.reverse.each { |sym|\n cw = MA_CustomizableMenu::CUSTOM_WINDOWS[sym]\n if cw.nil?\n manual_custom_window(sym)\n else\n auto_custom_window(sym)\n end\n }\n end",
"def get_browser_keys(browsers)\n @browser_keys = []\n\n # Iterates through every browser and adds the key to an array of browsers.\n browsers.each do |key, browser|\n @browser_keys.push(key)\n end\nend",
"def get_browser_keys(browsers)\n @browser_keys = []\n\n # Iterates through every browser and adds the key to an array of browsers.\n browsers.each do |key, browser|\n @browser_keys.push(key)\n end\nend",
"def window\r\n return $window\r\n end",
"def list_buffers\n arr = []\n @_buffers_conf.each_with_index do |e, i|\n t = e[:title] || \"no title for #{i}\"\n #$log.debug \" TITLE is #{e.title} , t is #{t} \"\n arr << t\n end\n ix = popuplist arr\n buffer_at ix\n end",
"def vanilla_windows?; end",
"def current_window\n @driver.window_handle\n rescue Selenium::WebDriver::Error::NoSuchWindowError\n nil\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 selected_window\n list_windows[@command_window.item]\n end",
"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 get_browser_contexts\n {\n method: \"Target.getBrowserContexts\"\n }\n end",
"def widgets(win_name)\n @driver.getQuickWidgetList(win_name).map do |java_widget|\n case java_widget.getType\n when QuickWidget::WIDGET_ENUM_MAP[:button]\n QuickButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:checkbox]\n QuickCheckbox.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dialogtab]\n QuickDialogTab.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dropdown]\n QuickDropdown.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:editfield]\n QuickEditField.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:label]\n QuickLabel.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:radiobutton]\n QuickRadioButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeview]\n QuickTreeView.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeitem]\n QuickTreeItem.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:thumbnail]\n QuickTreeItem.new(self,java_widget)\n else\n QuickWidget.new(self,java_widget)\n end\n end.to_a\n end",
"def get_window; @window; end",
"def window_size()\n\t@browser.window.resize_to(x, y)\nend",
"def hwnd\n Functions.control_hwnd(@window.hwnd, @locators)\n end",
"def close_multiple_browsers(browser_instance)\n\n# if browser_instance == \"ie\"\n# Sys::ProcTable.ps.each{|ps|\n# if ps.name.downcase==browser_instance+\"xplore.exe\"\n# Process.kill('KILL',ps.pid)\n# end}\n# end\n# if browser_instance != \"ie\"\n $browser.close\n# end\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 create_all_windows\n en_tm_sb_caw\n create_target_window\n end",
"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 browser_contents\n browser.contents\n end",
"def active_window\n if File.exists?(wmii_namespace)\n 'wmiir cat /client/sel/ctl | sed 1q'\n else\n %q[xprop -root _NET_ACTIVE_WINDOW | awk '/#/ { print $(NF) ; exit } END { exit 1 }' || xdotool getwindowfocus]\n end\nend",
"def widgets(window)\n\n # If window specifies window name, and the active window has this name\n # use its id to get the widgets,\n if window.is_a? String\n active_win_id = driver.getActiveQuickWindowID()\n active_win_name = driver.getQuickWindowName(active_win_id)\n\n #If the active window is of same type, then grab that one, not first\n if active_win_name == window #e.g. Both Document Window\n window = active_win_id\n end\n end\n driver.getQuickWidgetList(window).map do |java_widget|\n case java_widget.getType\n when QuickWidget::WIDGET_ENUM_MAP[:button]\n QuickButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:checkbox]\n QuickCheckbox.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dialogtab]\n QuickDialogTab.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dropdown]\n QuickDropdown.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:editfield]\n QuickEditField.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:label]\n QuickLabel.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:radiobutton]\n QuickRadioButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeview]\n QuickTreeView.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeitem]\n QuickTreeItem.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:thumbnail]\n QuickTreeItem.new(self,java_widget)\n else\n QuickWidget.new(self,java_widget)\n end\n end.to_a\n end",
"def windows_app_list\n Launchy.log \"#{self.class.name} : Using 'start' command on windows.\"\n %w[ start ]\n end",
"def get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def usable_window\n window = @windows.last\n window if window.loaded?\n end",
"def get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def scan_window\n return nil unless scan_windows\n scan_windows.first\n end",
"def test_default\n w = Window_Selectable_Implemented.new(0,0,160,128,$data_items.compact)\n @windows.push(w)\n end",
"def getwin(file)\n Ncurses.getwin(file)\n end",
"def window_parameters\n [2, 2, 316, 64]\n end",
"def get_sessions\n\t\tsessions = Session.get_week(self.user_id, self.start_date)\n\t\tget_nice_array(sessions)\n\tend",
"def window(title, timeout = 0)\n timeout = 30 if timeout == 0\n $webdriver.switch_to.default_content \n if not $marathon.windowMatchingTitle(title)\n bmark = MyBenchMark.new\n bmark.report(\"Waiting for window '\" + title + \"'\") {\n wait = Wait.new(:timeout => timeout, :message => \"Waiting for window '\" + title + \"'\")\n begin\n wait.until {\n waitSucceeded = false\n $webdriver.window_handles.each { |h|\n $webdriver.switch_to.window(h) unless waitSucceeded\n waitSucceeded = true if $marathon.windowMatchingTitle(title)\n }\n waitSucceeded\n }\n ensure\n bmark.close\n end\n }\n end\n $marathon.current_search_context = $webdriver\n $marathon.namingStrategy.setTopLevelComponent($marathon.getDriverAsAccessor())\n $marathon.context_handles.clear\n $marathon.context_handles.push( Proc.new { \n $marathon.current_search_context = $webdriver\n $marathon.namingStrategy.setTopLevelComponent($marathon.getDriverAsAccessor())\n } )\nend",
"def window_icons\n # Load them\n load_window_icons\n @gtk_window_icons.freeze\n # Once loaded, we only need a reader\n self.class.send(:define_method, :window_icons) do\n @gtk_window_icons\n end\n # Return the value\n window_icons\n end",
"def available_spaces\n open_spaces = []\n @board.first.each_with_index do |element, index|\n open_spaces << index if element == \"\\u26b3\" \n end\n open_spaces\n end",
"def window_icons\n # Load them\n load_window_icons\n @gtk_window_icons.freeze\n # Once loaded, we only need a reader\n self.class.send(:define_method, :window_icons) do\n @gtk_window_icons\n end\n # Return the value\n window_icons\n end",
"def displayed_widgets\n list = []\n self.div(:class=>\"fl-container-flex widget-content\").divs(:class=>\"s3d-contentpage-title\").each do |div|\n list << div.text\n end\n return list\n end",
"def try_windows\n m_GetStdHandle =\n Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')\n m_GetConsoleScreenBufferInfo =\n Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L')\n format = 'SSSSSssssSS'\n buf = ([0] * format.size).pack(format)\n stdout_handle = m_GetStdHandle.call(STDOUT_HANDLE)\n\n m_GetConsoleScreenBufferInfo.call(stdout_handle, buf)\n\n (bufx, bufy, curx, cury, wattr,\n left, top, right, bottom, maxx, maxy) = buf.unpack(format)\n\n return bottom - top + 1, right - left + 1\n rescue NameError # No Win32API\n end",
"def size\r\n @browsers.size\r\n end",
"def get_window_bounds(window_id:)\n {\n method: \"Browser.getWindowBounds\",\n params: { windowId: window_id }.compact\n }\n end",
"def windows_width\n Graphics.width / 2 + 10 # + 64\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 windowed_page_numbers\n inner_window, outer_window = @options[:inner_window].to_i, @options[:outer_window].to_i\n\n # override inner window -VS\n # we want to always display all the pages\n inner_window = total_pages.to_i\n\n window_from = current_page - inner_window\n window_to = current_page + inner_window\n\n # adjust lower or upper limit if other is out of bounds\n if window_to > total_pages\n window_from -= window_to - total_pages\n window_to = total_pages\n end\n if window_from < 1\n window_to += 1 - window_from\n window_from = 1\n window_to = total_pages if window_to > total_pages\n end\n\n # these are always visible\n middle = window_from..window_to\n\n # left window\n if outer_window + 3 < middle.first # there's a gap\n left = (1..(outer_window + 1)).to_a\n left << :gap\n else # runs into visible pages\n left = 1...middle.first\n end\n\n # right window\n if total_pages - outer_window - 2 > middle.last # again, gap\n right = ((total_pages - outer_window)..total_pages).to_a\n right.unshift :gap\n else # runs into visible pages\n right = (middle.last + 1)..total_pages\n end\n\n left.to_a + middle.to_a + right.to_a\n end",
"def border_windows\n borders = {\n score: Curses::Window.new(6, 16, 3, 2),\n lvl: Curses::Window.new(5, 7, 10, 2),\n lines: Curses::Window.new(5, 9, 10, 9),\n highscores: Curses::Window.new(26, 16, 16, 2),\n tetris: Curses::Window.new(42, 22, 3, 19),\n next: Curses::Window.new(12, 16, 3, 42),\n controls: Curses::Window.new(26, 16, 16, 42)\n }\n\n # For each window in the hash, setup borders\n borders.each do |name, window|\n setup_border_windows(name, window)\n end\n borders\nend",
"def page_window window_number=0\n get_page source_window window_number\n nil\n end",
"def getMonitors(monArray)\n\t\t@product = @html.xpath(X_PATH_MON)\n\t\t@product.each do |tagcloud_element|\n\t\t\tmonitor = Monitor.new\n\t\t\tmonitor.monitors = tagcloud_element.text\n\t\t\tmonArray.push(monitor)\n\t\t\t\n \t\t\t\n\t\t\t\n\t\tend\n\t\n\tend",
"def browser\r\n @web_browser\r\n end",
"def window\n Window\n end",
"def browser_width\n @browser_width\n end",
"def window name, cwd, cmd\n tab name, cwd, cmd\n end",
"def CreateBrowser()\r\n ret = @dispatch._invoke(1610743828, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def show_frames\r\n jssh_command = \"var frameset = #{WINDOW_VAR}.frames;\r\n var elements_frames = new Array();\r\n for(var i = 0; i < frameset.length; i++)\r\n {\r\n var frames = frameset[i].frames;\r\n for(var j = 0; j < frames.length; j++)\r\n {\r\n elements_frames.push(frames[j].frameElement); \r\n }\r\n }\r\n elements_frames.length;\"\r\n \r\n jssh_command.gsub!(\"\\n\", \"\")\r\n $jssh_socket.send(\"#{jssh_command};\\n\", 0)\r\n length = read_socket().to_i \r\n \r\n puts \"There are #{length} frames\"\r\n \r\n frames = Array.new(length)\r\n for i in 0..length - 1 do\r\n frames[i] = Frame.new(self, :jssh_name, \"elements_frames[#{i}]\")\r\n end\r\n \r\n for i in 0..length - 1 do\r\n puts \"frame: name: #{frames[i].name}\"\r\n puts \" index: #{i+1}\"\r\n end\r\n end",
"def _ps_browser(pat)\n x = `ps -ocomm,pcpu,rss -xwwc | grep -i #{pat}`\n\n if x.length > 0\n cpu = Float(/\\d+\\.\\d+/.match(x)[0])\n mem = Float(/\\d+$/.match(x)[0])*1024.0\n else\n cpu = -1.0\n mem = -1.0\n end\n \n return [cpu, mem]\n end",
"def index\n @browser_readers = BrowserReader.all\n end",
"def find_window(how, what)\r\n jssh_command = \"getWindows().length;\";\r\n $jssh_socket.send(\"#{jssh_command}\\n\", 0)\r\n @@total_windows = read_socket()\r\n #puts \"total windows are : \" + @@total_windows.to_s\r\n\r\n jssh_command = \"var windows = getWindows(); var window_number = 0;var found = false;\r\n for(var i = 0; i < windows.length; i++)\r\n {\r\n var attribute = '';\r\n if(\\\"#{how}\\\" == \\\"url\\\")\r\n {\r\n attribute = windows[i].getBrowser().contentDocument.URL;\r\n }\r\n if(\\\"#{how}\\\" == \\\"title\\\")\r\n {\r\n attribute = windows[i].getBrowser().contentDocument.title;\r\n }\"\r\n if(what.class == Regexp) \r\n # Construct the regular expression because we can't use it directly by converting it to string.\r\n # If reg ex is /Google/i then its string conversion will be (?i-mx:Google) so we can't use it.\r\n # Construct the regular expression again from the string conversion.\r\n oldRegExp = what.to_s\r\n newRegExp = \"/\" + what.source + \"/\"\r\n flags = oldRegExp.slice(2, oldRegExp.index(':') - 2)\r\n\r\n for i in 0..flags.length do\r\n flag = flags[i, 1]\r\n if(flag == '-')\r\n break;\r\n else\r\n newRegExp << flag\r\n end\r\n end\r\n \r\n jssh_command += \"var regExp = new RegExp(#{newRegExp});\r\n found = regExp.test(attribute);\"\r\n else\r\n jssh_command += \"found = (attribute == \\\"#{what}\\\");\"\r\n end\r\n \r\n jssh_command += \"if(found)\r\n {\r\n window_number = i;\r\n break;\r\n }\r\n }\r\n window_number;\"\r\n \r\n jssh_command.gsub!(/\\n/, \"\")\r\n #puts \"jssh_command is : #{jssh_command}\"\r\n $jssh_socket.send(\"#{jssh_command}\\n\", 0)\r\n window_number = read_socket()\r\n #puts \"window number is : \" + window_number.to_s\r\n\r\n return window_number.to_i\r\n end",
"def create_popup_windows\n @popups = {}\n opt = H87Options.option_list\n y = @help_window.height\n for i in 0..opt.size-1\n if opt[i].popup\n popup = opt[i].popup.new(y, opt[i])\n popup.visible = false\n popup.set_handler(:cancel, method(:close_popup))\n popup.set_handler(:ok, method(:item_selected))\n @popups[i] = popup\n end\n end\n end"
] | [
"0.80504346",
"0.7693145",
"0.74637604",
"0.7219841",
"0.69462866",
"0.6905145",
"0.6712737",
"0.638947",
"0.62823224",
"0.6171416",
"0.61342996",
"0.6094918",
"0.60554004",
"0.6004392",
"0.5973957",
"0.58912444",
"0.58742243",
"0.5839404",
"0.5808513",
"0.57563937",
"0.57413113",
"0.5718264",
"0.57001597",
"0.56806767",
"0.56697494",
"0.56543285",
"0.5636476",
"0.562986",
"0.5598912",
"0.55983496",
"0.55807346",
"0.55786705",
"0.55769485",
"0.5529779",
"0.55243057",
"0.55243057",
"0.5495742",
"0.54865676",
"0.54426676",
"0.54385436",
"0.5416997",
"0.54133886",
"0.5408645",
"0.54081476",
"0.54081476",
"0.5395761",
"0.53950953",
"0.53950953",
"0.5394709",
"0.5380718",
"0.5373262",
"0.53727204",
"0.53663087",
"0.53334755",
"0.53244764",
"0.5324308",
"0.53217167",
"0.5285129",
"0.52784824",
"0.5275866",
"0.5268121",
"0.526768",
"0.5237736",
"0.5226988",
"0.52079815",
"0.51720065",
"0.5156804",
"0.5156741",
"0.5150779",
"0.5143398",
"0.5120164",
"0.5105858",
"0.5096154",
"0.50877005",
"0.50864226",
"0.5082261",
"0.50774074",
"0.50773823",
"0.5077003",
"0.50766075",
"0.50762916",
"0.5066268",
"0.506484",
"0.5057803",
"0.50536376",
"0.5045654",
"0.5043472",
"0.5041723",
"0.50353837",
"0.50333256",
"0.50255346",
"0.5022817",
"0.50226474",
"0.5016031",
"0.50123644",
"0.5009459",
"0.49987054",
"0.49909088",
"0.49898484",
"0.49887416"
] | 0.59955376 | 14 |
Returns original window if defined, current window if not See Windowuse | def original_window
@original_window ||= window
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_window; @window; end",
"def window\r\n return $window\r\n end",
"def window\n @session.request(:vim_get_current_window)\n end",
"def window\n @win\n end",
"def usable_window\n window = @windows.last\n window if window.loaded?\n end",
"def active_window\n window_pointer = FFI::MemoryPointer.new :ulong, 1\n XDo::FFILib.xdo_window_get_active @_pointer, window_pointer\n XDo::Window.new self, window_pointer.read_ulong\n end",
"def current_window\n @driver.window_handle\n rescue Selenium::WebDriver::Error::NoSuchWindowError\n nil\n end",
"def window\n Window\n end",
"def current_window_builder\n return UI::Window.window_builder(current_windowskin)\n end",
"def current_window_builder\n return UI::Window.window_builder(current_windowskin)\n end",
"def window\n Window_Base.new(0, 0, 0, 0)\n end",
"def current_window\n case current_action\n when :buy\n @goods_window\n when :sell\n @sell_window\n when :rebuy\n @rebuy_window\n else\n nil\n end\n end",
"def active_window\n if File.exists?(wmii_namespace)\n 'wmiir cat /client/sel/ctl | sed 1q'\n else\n %q[xprop -root _NET_ACTIVE_WINDOW | awk '/#/ { print $(NF) ; exit } END { exit 1 }' || xdotool getwindowfocus]\n end\nend",
"def window\n @window || create_window\n end",
"def window\n self\n end",
"def current_windowskin_settings\n if $game_variables != nil\n winvar = YE::SYSTEM::WINDOW_VARIABLE\n if $game_variables[winvar] == 0\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n elsif !MENU_CONFIG::WINDOW_HASH.include?($game_variables[winvar])\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n end\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[$game_variables[winvar]]\n else\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[YE::SYSTEM::DEFAULT_WINDOW]\n end\n return mso_windowskin\n end",
"def current_windowskin_settings\n if $game_variables != nil\n winvar = YE::SYSTEM::WINDOW_VARIABLE\n if $game_variables[winvar] == 0\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n elsif !MENU_CONFIG::WINDOW_HASH.include?($game_variables[winvar])\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n end\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[$game_variables[winvar]]\n else\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[YE::SYSTEM::DEFAULT_WINDOW]\n end\n return mso_windowskin\n end",
"def switch_window\n current_window = window\n wins = windows\n wait_until { (wins = windows) && wins.size > 1 } if wins.size == 1\n raise StandardError, 'Unable to determine which window to switch to' if wins.size > 2\n\n wins.find { |w| w != current_window }.use\n window\n end",
"def active_window\n current_terminal.current_session\n end",
"def win\n @win\n end",
"def overwrite_window\n return @window.overwrite(@otherwin.get_window)\n end",
"def active_window\n return @active_members_window if @last_window == :active_members_window\n return @reserve_members_window if @last_window == :reserve_members_window\n nil\n end",
"def focused_window\n window_pointer = FFI::MemoryPointer.new :ulong, 1\n XDo::FFILib.xdo_window_get_focus @_pointer, window_pointer\n XDo::Window.new self, window_pointer.read_ulong\n end",
"def current_name_window_builder\n return UI::Window.window_builder(current_name_windowskin)\n end",
"def active_window\n windows = @terminal.windows.get\n windows.detect do |window|\n window.properties_.get[:frontmost] rescue false\n end\n end",
"def active_window\n windows = @terminal.windows.get\n windows.detect do |window|\n window.properties_.get[:frontmost] rescue false\n end\n end",
"def get_window_number()\r\n $jssh_socket.send(\"getWindows().length;\\n\", 0)\r\n @@current_window = read_socket().to_i - 1\r\n \r\n # Derek Berner 5/16/08 \r\n # If at any time a non-browser window like the \"Downloads\" window \r\n # pops up, it will become the topmost window, so make sure we \r\n # ignore it.\r\n @@current_window = js_eval(\"getWindows().length\").to_i - 1\r\n while js_eval(\"getWindows()[#{@@current_window}].getBrowser\") == ''\r\n @@current_window -= 1;\r\n end\r\n\r\n # This will store the information about the window.\r\n #@@window_stack.push(@@current_window)\r\n #puts \"here in get_window_number window number is #{@@current_window}\"\r\n return @@current_window\r\n end",
"def real_focused_window\n window_pointer = FFI::MemoryPointer.new :ulong, 1\n XDo::FFILib.xdo_window_sane_get_focus @_pointer, window_pointer\n XDo::Window.new self, window_pointer.read_ulong\n end",
"def selected_window\n list_windows[@command_window.item]\n end",
"def window_handle; end",
"def current_windowskin\n current_layout.windowskin || $game_system.windowskin_name\n end",
"def current_windowskin\n @windowskin_overwrite || current_layout.windowskin || $game_system.windowskin_name\n end",
"def windows?; end",
"def get_window_area()\n get_children_area(\"WINDOW\")\n end",
"def get_window_area()\n get_children_area(\"WINDOW\")\n end",
"def page_window window_number=0\n get_page source_window window_number\n nil\n end",
"def switch_to_previous_window\n @window_id -= 1\n if @window_id < 0\n # wrap back to the last\n @window_id = @browser.windows.count - 1\n end\n\n @browser.windows[@window_id].use\n end",
"def window_id(window)\n window.id_.get\n end",
"def window_id(window)\n window.id_.get\n end",
"def window_id(window)\n window.id_.get\n end",
"def current?\n current_window == handle\n end",
"def window_handle\n bridge.window_handle\n end",
"def current_window_builder(skin)\n Window.window_builder(skin)\n end",
"def window\n @window ||= UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)\n end",
"def preferred_backup_window\n @dbi.preferred_backup_window\n end",
"def preferred_backup_window\n @dbi.preferred_backup_window\n end",
"def select_previous_window(num = 1)\n @server.invoke_command \"select-window -t:-#{num}\"\n current_window\n end",
"def preferred_backup_window\n data[:preferred_backup_window]\n end",
"def preferred_backup_window\n data[:preferred_backup_window]\n end",
"def window(name_or_handle)\n logger.info 'EyesTargetLocator.window()'\n logger.info 'Making preparaions...'\n on_will_switch.will_switch_to_window name_or_handle\n logger.info 'Done! Switching to window..'\n __getobj__.window name_or_handle\n logger.info 'Done!'\n driver\n end",
"def get_status_window\n return @status_window if @status_window.is_a?(Window_BattleStatus)\n return nil\n end",
"def set_backing_window win\n @otherwin = win\n # XX should we extract the coordinates and use for printing ??\n # or for setting maxrow and maxcol\n end",
"def current_pick_window\n pick_windows.where(\"window_start < '#{DateTime.now}' AND window_end > '#{DateTime.now}'\").first\n end",
"def window_id\n -1\n end",
"def window_id\n -1\n end",
"def customWindowsToEnterFullScreenForWindow(window)\n\t\t[window]\n\tend",
"def hwnd\n Functions.control_hwnd(@window.hwnd, @locators)\n end",
"def window name, cwd, cmd\n raise NotImplementedError.new(\n \"window should be implemented to open new window\")\n end",
"def window\n\n\t#TODO Make this more robust to handle multiple configuration files\n\tunless ARGV[1].nil?\n\t\t@this_window ||= AnalysisWindowImport.new(config: ARGV[1]) #Pass the configuration in\n\telse\n\t\traise ArgumentError.new(\"A valid configuration file must be defined\")\n\tend\n\n\treturn @this_window\nend",
"def getwin(file)\n Ncurses.getwin(file)\n end",
"def window_id\n return (env = to_i!(ENV['WINDOWID'])) if env\n \n curr_pid = Process.pid\n until curr_pid.to_i < 2\n file = environ_file(curr_pid)\n if file and (xid = to_i!(file.read.scan(/(?<=WINDOWID=)\\d+/)[0]))\n return xid\n else\n curr_pid = ppid_of(curr_pid)\n end\n end\n \n end",
"def window_rect\n manage.window.rect\n end",
"def window_rect\n manage.window.rect\n end",
"def window_rect\n manage.window.rect\n end",
"def isMainWindow\n true\n end",
"def new_window\n @manifest_options[:new_window]\n end",
"def current_item\n current_window.item\n end",
"def window(name)\n Tk.execute_only(:tkwait, :window, name)\n end",
"def eq_window\n IITWindow.new(@ole.EQWindow)\n end",
"def active_quick_window_id\n driver.getActiveQuickWindowID()\n end",
"def bring_current_window_to_front\n @fox_driver.switch_to.window(@fox_driver.window_handles.first)\n end",
"def panel_window\n Panel.panel_window(pointer)\n end",
"def window\n WIN[:find].call 'ConsoleWindowClass', title\n end",
"def window\n WIN[:find].call 'ConsoleWindowClass', title\n end",
"def window name, cwd, cmd\n tab name, cwd, cmd\n end",
"def get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def switch_to_other_window\n @window_id = (@window_id - 1).abs\n if @window_id != 0 and @window_id !=1\n puts @window_id\n raise(Exception::WindowMatchError, \"You cannot use this keyword when more than 2 windows are open; you must use 'Switch To Window', 'Switch to Next Window', or 'Switch to Previous Window'\")\n end\n\n @browser.windows[@window_id].use\n end",
"def select_window window_id\r\n command 'selectWindow', window_id||'null'\r\n end",
"def select_window window_id\r\n command 'selectWindow', window_id||'null'\r\n end",
"def window(name, opts)\n clone(:window=>((@opts[:window]||EMPTY_ARRAY) + [[name, SQL::Window.new(opts)].freeze]).freeze)\n end",
"def gold_window; @gold_window; end",
"def switch_to_main_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.first)\nend",
"def window_handle\n driver.window_handle\n end",
"def main_window\r\n super\r\n # Make windows\r\n @left_window = Window_DebugLeft.new\r\n @right_window = Window_DebugRight.new\r\n @help_window = Window_Base.new(192, 352, 448, 128)\r\n @help_window.contents = Bitmap.new(406, 96)\r\n # Restore previously selected item\r\n @left_window.top_row = $game_temp.debug_top_row\r\n @left_window.index = $game_temp.debug_index\r\n @right_window.mode = @left_window.mode\r\n @right_window.top_id = @left_window.top_id\r\n end",
"def get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def current_name_windowskin\n @nameskin_overwrite || current_layout.name_windowskin || NAME_SKIN\n end",
"def activate_current_window\n if @item_window.index > -1\n @item_window.activate\n else\n @category_window.activate\n end\n end",
"def window_by_id(id)\n @windows.ID(id)\n end",
"def window_by_id(id)\n @windows.ID(id)\n end",
"def window_by_id(id)\n @windows.ID(id)\n end",
"def scan_window\n return nil unless scan_windows\n scan_windows.first\n end",
"def window_style\n case @link.WindowStyle\n when SHOWNORMAL\n 'normal'\n when SHOWMAXIMIZED\n 'maximized'\n when SHOWMINNOACTIVE\n 'minimized'\n else\n 'unknown' # Should never reach here\n end\n end",
"def get_window_object()\n driver.manage.window\nend",
"def switch_to_new_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.last)\nend",
"def main_window\r\n super\r\n # Make help window, item window\r\n @help_window = Window_Help.new\r\n @item_window = Window_Item.new\r\n # Associate help window\r\n @item_window.help_window = @help_window\r\n # Make target window (set to invisible / inactive)\r\n @target_window = Window_Target.new\r\n @target_window.visible = false\r\n @target_window.active = false\r\n end",
"def preferred_maintenance_window\n @dbi.preferred_maintenance_window\n end",
"def preferred_maintenance_window\n @dbi.preferred_maintenance_window\n end",
"def window_focus window_name\r\n command 'windowFocus', window_name\r\n end",
"def get_window_object()\n driver.manage.window\nend",
"def new_window(type); end"
] | [
"0.787422",
"0.7749725",
"0.7462729",
"0.7365655",
"0.73364246",
"0.7200005",
"0.7185287",
"0.7107227",
"0.7069621",
"0.7069621",
"0.7031164",
"0.69700843",
"0.695627",
"0.6947236",
"0.69061977",
"0.6901702",
"0.6901667",
"0.68819124",
"0.68757325",
"0.6871016",
"0.68509674",
"0.67669237",
"0.6752168",
"0.6696656",
"0.66760147",
"0.66760147",
"0.6655991",
"0.66300064",
"0.6613878",
"0.66078645",
"0.66018456",
"0.66008633",
"0.65747094",
"0.64982635",
"0.6482641",
"0.64654505",
"0.6451854",
"0.6407821",
"0.6407821",
"0.6407821",
"0.6397751",
"0.6391097",
"0.6353378",
"0.63417",
"0.63056767",
"0.63056767",
"0.62814826",
"0.62712806",
"0.62712806",
"0.6259397",
"0.6252293",
"0.62186384",
"0.62164307",
"0.6192256",
"0.6192256",
"0.61829937",
"0.6177472",
"0.617483",
"0.6174504",
"0.61479956",
"0.6121051",
"0.6105501",
"0.6105501",
"0.6105501",
"0.610298",
"0.60969853",
"0.60927325",
"0.6074109",
"0.60413",
"0.6033346",
"0.6030142",
"0.6029877",
"0.6022653",
"0.6022653",
"0.60214186",
"0.60054326",
"0.6002585",
"0.5999351",
"0.5999351",
"0.5996473",
"0.5994478",
"0.59918606",
"0.59915733",
"0.59565663",
"0.5953314",
"0.59525234",
"0.5945777",
"0.5938629",
"0.5938629",
"0.5938629",
"0.591485",
"0.590844",
"0.58760095",
"0.5872104",
"0.58658004",
"0.586008",
"0.586008",
"0.58571947",
"0.58528054",
"0.58490527"
] | 0.82171977 | 0 |
Waits for and returns second window if present See Windowuse | def switch_window
current_window = window
wins = windows
wait_until { (wins = windows) && wins.size > 1 } if wins.size == 1
raise StandardError, 'Unable to determine which window to switch to' if wins.size > 2
wins.find { |w| w != current_window }.use
window
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window(title, timeout = 0)\n timeout = 30 if timeout == 0\n $webdriver.switch_to.default_content \n if not $marathon.windowMatchingTitle(title)\n bmark = MyBenchMark.new\n bmark.report(\"Waiting for window '\" + title + \"'\") {\n wait = Wait.new(:timeout => timeout, :message => \"Waiting for window '\" + title + \"'\")\n begin\n wait.until {\n waitSucceeded = false\n $webdriver.window_handles.each { |h|\n $webdriver.switch_to.window(h) unless waitSucceeded\n waitSucceeded = true if $marathon.windowMatchingTitle(title)\n }\n waitSucceeded\n }\n ensure\n bmark.close\n end\n }\n end\n $marathon.current_search_context = $webdriver\n $marathon.namingStrategy.setTopLevelComponent($marathon.getDriverAsAccessor())\n $marathon.context_handles.clear\n $marathon.context_handles.push( Proc.new { \n $marathon.current_search_context = $webdriver\n $marathon.namingStrategy.setTopLevelComponent($marathon.getDriverAsAccessor())\n } )\nend",
"def wait_until_present(context=nil)\n adapter.window.wait_until_present context\n end",
"def window(name)\n Tk.execute_only(:tkwait, :window, name)\n end",
"def usable_window\n window = @windows.last\n window if window.loaded?\n end",
"def wait_for_popup window_id, timeout\r\n command 'waitForPopUp', window_id||'null', timeout\r\n end",
"def wait_for_popup window_id, timeout\r\n command 'waitForPopUp', window_id||'null', timeout\r\n end",
"def switch_to_other_window\n @window_id = (@window_id - 1).abs\n if @window_id != 0 and @window_id !=1\n puts @window_id\n raise(Exception::WindowMatchError, \"You cannot use this keyword when more than 2 windows are open; you must use 'Switch To Window', 'Switch to Next Window', or 'Switch to Previous Window'\")\n end\n\n @browser.windows[@window_id].use\n end",
"def get_window; @window; end",
"def dialog( title, seconds=3 )\n\t\td = begin\n\t\t\t\tw = Window.top_level(title, seconds)\n\t\t\t\tyield(w) ? w : nil\n\t\trescue TimeoutError\n\t\tend\n\n\t\td.wait_for_close if d\n\t\treturn d\n\tend",
"def get_window_object()\n driver.manage.window\nend",
"def get_window_object()\n driver.manage.window\nend",
"def use\n wait_for_exists\n cache_current = current_window\n @browser.original_window ||= cache_current\n restore_to = unless cache_current == handle\n @driver.switch_to.window(handle)\n cache_current\n end\n if block_given?\n begin\n yield\n ensure\n @driver.switch_to.window(restore_to) if restore_to\n end\n end\n self\n end",
"def switch_to_next_window\n @window_id += 1\n if @window_id >= @browser.windows.count\n # wrap back to the first\n @window_id = 0\n end\n\n @browser.windows[@window_id].use\n end",
"def window(name_or_handle)\n logger.info 'EyesTargetLocator.window()'\n logger.info 'Making preparaions...'\n on_will_switch.will_switch_to_window name_or_handle\n logger.info 'Done! Switching to window..'\n __getobj__.window name_or_handle\n logger.info 'Done!'\n driver\n end",
"def switch_to_window_by_title window_title\n $previous_window = $driver.window_handle\n window_found = false\n $driver.window_handles.each{ |handle|\n $driver.switch_to.window handle\n if $driver.title == window_title\n window_found = true\n break\n end\n }\n raise \"Window having title \\\"#{window_title}\\\" not found\" if not window_found\nend",
"def XOselectWindow(tag, tvalue)\n\t\tres= OK\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# default is OK\n\t\t$pfd.tstart( @wwBrws.url.to_s)\n\t\tbegin\n\t\t\tself.setPageTimer()\t\t\t\t\t\t\t\t\t \t\t\t\t# set or clear the page timer\n\t\t\t$pfd.tstart( @wwBrws.url.to_s)\n\t\t\ttimedOut= false\n\n @winHandles.checkHandle (self) \t\t\t\t\t\t# add/ delete any new window\n\t\t\t$alog.lwrite(('There are '+@wwBrws.windows.size.to_s+' active windows.'), 'DEBG')\n\t\t\tcase tag\n\t\t\t\twhen :index\n\t\t\t\t\tuntil ((timedOut=self.getPageTimer()) || @wwBrws.window(:index => tvalue).exists?)\n\t\t\t\t\t\tsleep TIMETICK\n\t\t\t\t\tend\n\t\t\t\t\t$alog.lwrite(('2nd. Found. There are '+@wwBrws.windows.size.to_s+' active windows.'), 'DEBG')\n\t\t\t\t\tif timedOut\n\t\t\t\t\t\tres= CRITICAL\n\t\t\t\t\telse\n\t\t\t\t\t\t$alog.lwrite(('3nd. Activating. There are '+@wwBrws.windows.size.to_s+' active windows.'), 'DEBG')\n \t\t\tres= @winHandles.activateHandle(self, tvalue)\n\t\t\t\t\tend\n\t\t\t\twhen :url\n\t\t\t\t\tuntil ((timedOut=self.getPageTimer()) || @wwBrws.window(:url => /#{tvalue}/).exists?)\n\t\t\t\t\t\tsleep TIMETICK\n\t\t\t\t\tend\n\t\t\t\t\tif timedOut\n\t\t\t\t\t\tres= CRITICAL\n\t\t\t\t\telse\n\t\t\t\t\t\t@wwBrws.window(:url => /#{tvalue}/).use\n\t\t\t\t\tend\n\t\t\t\twhen :title\n\t\t\t\t\tuntil ((timedOut=self.getPageTimer()) || @wwBrws.window(:title => /#{tvalue}/).exists?)\n\t\t\t\t\t\tsleep TIMETICK\n\t\t\t\t\tend\n\t\t\t\t\tif timedOut\n\t\t\t\t\t\tres= CRITICAL\n\t\t\t\t\telse\n\t\t\t\t\t\t@wwBrws.window(:title => /#{tvalue}/).use\n\t\t\t\t\tend\n\t\t\tend\n\t\t\tif(res==CRITICAL)\n\t\t\t\tres= setResCritical('CANnot switch to window: /'+tvalue.to_s+'/ :'+$!.to_s)\n\t\t\telse\n\t\t\t\t$alog.lwrite(('Now using Windows w/title '+@wwBrws.window.title.to_s+' '), 'DEBG')\n\t\t\tend\n\t\trescue\n\t\t\tres= setResCritical('CANnot switch to window: /'+tvalue.to_s+'/ :'+$!.to_s) \t\t\t\t#\n\t\tend\n\t\treturnRes (res )\n\tend",
"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 get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def switch_to_new_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.last)\nend",
"def switch_to_main_window\n $previous_window = $driver.window_handle\n $driver.switch_to.window($driver.window_handles.first)\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 current_window\n @driver.window_handle\n rescue Selenium::WebDriver::Error::NoSuchWindowError\n nil\n end",
"def get_window()\n begin\n driver.title\n rescue\n nil\n end\nend",
"def scan_window\n return nil unless scan_windows\n scan_windows.first\n end",
"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 receive_next_window\n @window += 1\n receive_window\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 select_next_window(num = 1)\n @server.invoke_command \"select-window -t #{identifier}:+#{num}\"\n current_window\n end",
"def secondTestWindows\n puts \"Let's steer away from computational tests\"\n sleep(1)\n puts \"And do something a little bit easier\"\n sleep(1)\n puts \"Imagine you are standing beside some tram tracks. In the distance, you spot a runaway trolley hurtling down the tracks towards five workers who cannot hear it coming. Even if they do spot it, they won’t be able to move out of the way in time.\n As this disaster looms, you glance down and see a lever connected to the tracks. You realise that if you pull the lever, the tram will be diverted down a second set of tracks away from the five unsuspecting workers.\n However, down this side track is one lone worker, just as oblivious as his colleagues.\n So, would you pull the lever, leading to one death but saving five?\"\n sleep(7)\n end",
"def customWindowsToEnterFullScreenForWindow(window)\n\t\t[window]\n\tend",
"def test_039\n test_000\n login(\"root\",\"root\")\n create_2nd_user\n sleep WAIT_TIME\n abc = @selenium.get_attribute(\"//body/div[2]@style\")\n # if there is a piece of text \"display: none\", this subwindow will be fade out\n result = (abc.to_s =~ /display: none/ )\n # 'result' is nill demonstrates that the subwindow still available\n assert_equal result, nil\n logout\n end",
"def window(windowTitle, timeout = 0)\n $marathon.window(windowTitle, timeout)\n return true\nend",
"def windows?; end",
"def load_window(waittime, window)\n begin\n Timeout::timeout(waittime) do\n time = Time.new\n yield\n end\n rescue Exception => e\n time = Time.new\n if window.exists?\n puts \"#{time.strftime('%Y.%m.%d %H:%M:%S')} - Exception occurred:\\n window.title = #{window.title}\\n #{e}\\n\"\n else\n puts \"#{time.strftime('%Y.%m.%d %H:%M:%S')} - Exception occurred:\\n #{e}\\n\"\n end\n retries ||= 0\n puts \"#{time.strftime('%Y.%m.%d %H:%M:%S')} - Exception: retries = #{retries}\\n\"\n if retries < @max_retries\n retries += 1\n time_to_wait = (Float(waittime) / @max_retries).round\n puts \"#{time.strftime('%Y.%m.%d %H:%M:%S')} - Exception: time_to_wait = #{time_to_wait}\\n\"\n sleep time_to_wait\n retry\n else\n puts \"#{time.strftime('%Y.%m.%d %H:%M:%S')} - Exception: raise Exception\\n\"\n raise e\n end\n end\n end",
"def wait_for_pdf_window(string)\n Timeout.timeout(Nenv.browser_timeout) do\n loading = true\n while loading\n check = url_match(string, RouteHelper.browser.windows.last.use.url)\n loading = false if check\n sleep(1)\n end\n return true\n end\n rescue Timeout::Error => e\n raise \"Timeout waiting for window to load - #{e}\"\n exit\n end",
"def window\n @window || create_window\n end",
"def window\n @win\n end",
"def preview_project(&blk)\n within_frame(\"authorfrm\") do\n click_on(\"Preview Project\")\n end\n \n page.driver.browser.window_handles.length.should == 2\n \n within_window(page.driver.browser.window_handles.last) do\n current_path.should be_start_with('/webapp/vle/preview.html')\n yield blk\n end\nend",
"def window(id)\n if block_given?\n original = begin\n @bridge.window_handle\n rescue Error::NoSuchWindowError\n nil\n end\n\n unless @bridge.window_handles.include? id\n raise Error::NoSuchWindowError, \"The specified identifier '#{id}' is not found in the window handle list\"\n end\n\n @bridge.switch_to_window id\n\n begin\n returned = yield\n ensure\n current_handles = @bridge.window_handles\n original = current_handles.first unless current_handles.include? original\n @bridge.switch_to_window original\n returned\n end\n else\n @bridge.switch_to_window id\n end\n end",
"def get_status_window\n return @status_window if @status_window.is_a?(Window_BattleStatus)\n return nil\n end",
"def active_window\n if File.exists?(wmii_namespace)\n 'wmiir cat /client/sel/ctl | sed 1q'\n else\n %q[xprop -root _NET_ACTIVE_WINDOW | awk '/#/ { print $(NF) ; exit } END { exit 1 }' || xdotool getwindowfocus]\n end\nend",
"def switch_to_previous_window\n $driver.switch_to.window $previous_window\nend",
"def check_for_window(name, error=true)\n name = name.to_s.dup\n name.slice!(0) if name.start_with?('#')\n window_setup\n if(name.blank?)\n self << \"if(window.window_rails_windows.length > 0){\"\n else\n self << \"if(window.window_rails_windows['#{name}']){\"\n end\n yield if block_given?\n self << \"}\"\n self << \"else { alert('Unexpected error. Failed to locate window for output.'); }\" if error\n nil\n end",
"def clickWindowsButton (windowCaption , buttonCaption , maxWaitTime=30 )\n\n sleep 1\n\n hwnd = -1\n begin \n timeout(maxWaitTime) do\n\n hwnd = getWindowHandle(windowCaption)\n\n while hwnd == -1 \n hwnd = getWindowHandle(windowCaption)\n sleep 0.5\n end\n makeWindowActive(hwnd)\n end\n rescue\n puts \"clickWindowsButton: Cant make window active in specified time ( \" + maxWaitTime.to_s + \") - no handle\"\n return false\n end\n\n puts ' Window handle is : ' + hwnd.to_s\n if hwnd != -1 \n puts \"clickWindowsButton: Handle for window: \" + windowCaption + \" is: \" + hwnd.to_s\n makeWindowActive(hwnd)\n else\n end\n\n d = getChildHandle( hwnd , buttonCaption )\n puts (\"clickWindowsButton: handle for button: \" + buttonCaption + \" is \" + d.to_s )\n\n if d != -1 \n makeWindowActive(hwnd)\n clickButtonWithHandle (d)\n else\n return false\n end\n\n return true\n\n end",
"def with_window(windowTitle, timeout = 0)\n endTime = System.currentTimeMillis + (timeout * 1000)\n begin\n window(windowTitle, timeout)\n rescue Exception => e\n if System.currentTimeMillis < endTime\n retry\n else\n raise e\n end\n end\n yield\n $marathon.close\n return true\nend",
"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 test_032\n test_000\n login(\"root\",\"root\")\n create_1st_user\n sleep WAIT_TIME\n attribute = @selenium.get_attribute(\"//body/div[2]@style\")\n # if there is a piece of text \"display: none\", this subwindow will be fade out\n result = (attribute.to_s =~ /display: none/ )\n # 'result' is nill demonstrates that the subwindow still available\n assert_equal result, nil\n logout\n end",
"def win\n @win\n end",
"def window\r\n return $window\r\n end",
"def bring_current_window_to_front\n @fox_driver.switch_to.window(@fox_driver.window_handles.first)\n end",
"def send_next_window\n @window += 1\n send_window\n end",
"def get_window_number()\r\n $jssh_socket.send(\"getWindows().length;\\n\", 0)\r\n @@current_window = read_socket().to_i - 1\r\n \r\n # Derek Berner 5/16/08 \r\n # If at any time a non-browser window like the \"Downloads\" window \r\n # pops up, it will become the topmost window, so make sure we \r\n # ignore it.\r\n @@current_window = js_eval(\"getWindows().length\").to_i - 1\r\n while js_eval(\"getWindows()[#{@@current_window}].getBrowser\") == ''\r\n @@current_window -= 1;\r\n end\r\n\r\n # This will store the information about the window.\r\n #@@window_stack.push(@@current_window)\r\n #puts \"here in get_window_number window number is #{@@current_window}\"\r\n return @@current_window\r\n end",
"def current_pick_window\n pick_windows.where(\"window_start < '#{DateTime.now}' AND window_end > '#{DateTime.now}'\").first\n end",
"def switch_to_previous_window\n @window_id -= 1\n if @window_id < 0\n # wrap back to the last\n @window_id = @browser.windows.count - 1\n end\n\n @browser.windows[@window_id].use\n end",
"def next_window\n return unless peek_event\n\n window = History::Window.new\n\n while event = next_event\n window.add(event)\n\n break if event.type == 'DecisionTaskCompleted'\n end\n\n # Find the end of the window by exhausting all the commands\n window.add(next_event) while command?(peek_event)\n\n window.freeze\n end",
"def win\n process_result 1.0\n end",
"def ensure_open_window\n window_handles = @selenium.window_handles\n\n if window_handles.size == 0\n @javascript.run( 'window.open()' )\n @selenium.switch_to.window( @selenium.window_handles.last )\n else\n if window_handles.size > 1\n # Keep the first\n window_handles[1..-1].each do |handle|\n @selenium.switch_to.window( handle )\n @selenium.close\n end\n\n @selenium.switch_to.window( @selenium.window_handles.first )\n end\n\n @selenium.navigate.to 'about:blank'\n end\n\n @selenium.manage.window.resize_to( @width, @height )\n end",
"def wait\r\n Ragweed::Wrap32::wait_for_single_object @h\r\n end",
"def move_first_window_or_create_new(window)\n if window == windows.first\n move_window(window.index)\n else\n new_window(window)\n end\n end",
"def window_handle\n driver.window_handle\n end",
"def wait_for_browser\r\n # NOTE: no need any more\r\n end",
"def full_screen\n use { @driver.manage.window.full_screen }\n end",
"def window_handle; end",
"def window\n Window\n end",
"def close()\r\n #puts \"current window number is : #{@@current_window}\"\r\n # Derek Berner 5/16/08\r\n # Try to join thread only if there is exactly one open window\r\n if js_eval(\"getWindows().length\").to_i == 1\r\n $jssh_socket.send(\" getWindows()[0].close(); \\n\", 0)\r\n @t.join if @t != nil\r\n #sleep 5\r\n else\r\n # Check if window exists, because there may be the case that it has been closed by click event on some element.\r\n # For e.g: Close Button, Close this Window link etc.\r\n window_number = find_window(\"url\", @window_url)\r\n\r\n # If matching window found. Close the window.\r\n if(window_number > 0)\r\n $jssh_socket.send(\" getWindows()[#{window_number}].close();\\n\", 0)\r\n read_socket();\r\n end \r\n \r\n #Get the parent window url from the stack and return that window.\r\n #@@current_window = @@window_stack.pop()\r\n @window_url = @@window_stack.pop()\r\n @window_title = @@window_stack.pop()\r\n # Find window with this url.\r\n window_number = find_window(\"url\", @window_url)\r\n @@current_window = window_number\r\n set_browser_document()\r\n end\r\n end",
"def overwrite_window\n return @window.overwrite(@otherwin.get_window)\n end",
"def within_window(locator, &block)\n identifier = { locator.keys.first => /#{Regexp.escape(locator.values.first)}/ }\n browser.window(identifier).use(&block)\n end",
"def select_previous_window(num = 1)\n @server.invoke_command \"select-window -t:-#{num}\"\n current_window\n end",
"def show_window\n end",
"def window_exists?\n @window.exists?\n end",
"def new_window(type); end",
"def full_screen\n driver.manage.window.full_screen\n end",
"def window\n self\n end",
"def wait_for_others(w, orig_heading)\n loop do\n return if orig_heading != heading_for(w)\n sleep 1\n end\n end",
"def exist?\n !closed? && window.present?\n end",
"def next_two_adjacent_windows\n windows = `tmux list-windows`.lines.map(&:to_i)\n\n # Start from the beginning (if I have [1,2,9], give me [3,4])\n windows.each_cons(2) do |i,j|\n if j-i >= 2\n return i+1, i+2\n end\n end\n\n # If that failed, and there's room, put the next two at the end\n if (i = windows.max) < 9\n return i+1, i+2\n end\n\n # Out of single-digit windows? Silly human. Take a break.\n puts <<-EOF\n Unable to locate two adjacent windows. (In use: #{windows.inspect})\n Reminder: humans don't multitask well. Step away from the computer.\n EOF\n exit\nend",
"def wait_for_message\n @message_window.update\n while $game_message.visible \n update_basic\n end\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 check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)\n target = Applitools::Selenium::Target.window.tap do |t|\n t.timeout(match_timeout)\n t.fully if force_full_page_screenshot\n end\n check(tag, target)\n end",
"def close_other_window\n @window_id = (@window_id - 1).abs\n if @window_id != 0 and @window_id !=1\n raise(Exception::WindowMatchError, \"You cannot use this keyword when more than 2 windows are open; you must use 'Switch To Window', 'Switch to Next Window', or 'Switch to Previous Window'\")\n end\n\n @browser.windows[@window_id].close\n end",
"def show_window\r\n if visible?\r\n bring_to_front()\r\n else\r\n show_modal()\r\n end\r\n end",
"def present?\n adapter.window.present?\n end",
"def page_window window_number=0\n get_page source_window window_number\n nil\n end",
"def active_window\n windows = @terminal.windows.get\n windows.detect do |window|\n window.properties_.get[:frontmost] rescue false\n end\n end",
"def active_window\n windows = @terminal.windows.get\n windows.detect do |window|\n window.properties_.get[:frontmost] rescue false\n end\n end",
"def active_window\n window_pointer = FFI::MemoryPointer.new :ulong, 1\n XDo::FFILib.xdo_window_get_active @_pointer, window_pointer\n XDo::Window.new self, window_pointer.read_ulong\n end",
"def secondRealDeviceLaunch\n\tcapabilities1 =\n \t\t{\n \t\t'browserName' => '',\n \t\t'platform' => 'Mac',\n \t\t'version' => '8.0.2',\n \t\t'deviceName' => \"17006b330e705035909a2e1b33b6ebbdb5b86893\",\n \t\t'platformName' => 'iOS', \n \t\t#'app' => '/Users/360_macmini/Documents/WoowTalk/Cucumber-Appium/YowWowMe/WowApp.ipa',\n \t\t'app' => '/Users/yosovm1/Documents/Cucumber-Appium/YowWowMe/WowApp.ipa',\n \t\t'newCommandTimeout' => '600',\n \t\t'udid' => \"17006b330e705035909a2e1b33b6ebbdb5b86893\",\n \t\t'launchTimeout' => '600000',\n \t\t#'autoAcceptAlerts' => 'true',\n \t\t}\n\t\tbegin\n \t\t\t@driverSecond ||= Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities1, :url => server_url1)\t\n\t\trescue \n\t\t\tsleep(60)\n \t\t\t @driverSecond ||= Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities1, :url => server_url1)\n \t\t\t puts \"Second Driver launch after time out\"\n\t\tend\nend",
"def open_status_window(battler)\n Sound.play_decision\n @windows[Win_Detail].refresh(battler)\n @windows[Win_Detail].activate\n @windows[Win_Detail].show\n @windows[Menu_Actor].hide\n @windows[Win_Help].hide\n @windows[Win_Status].hide\n end",
"def test_default\n w = Window_Confirmation.new(0,0,320,nil)\n @windows.push(w)\n return true\n end",
"def test_default\n w = Window_ItemDetails.new(0,0,640,96,nil)\n @windows.push(w)\n return true\n end",
"def wait_for_input\n wait_for_input_core = lambda do\n text = %x{#{TM_DIALOG} -w #{@dialog_token} }\n raise WindowNotFound if $CHILD_STATUS == 54528 # -43\n raise \"Error (#{text})\" if $CHILD_STATUS != 0\n\n OSX::PropertyList::load(text)\n end\n\n if block_given? then\n loop do\n should_continue = yield(wait_for_input_core.call)\n break unless should_continue\n end\n else\n wait_for_input_core.call\n end\n end",
"def wait_active(timeout = 0)\n Window.functions[__method__] ||= AU3_Function.new(\"WinWaitActive\", 'SSL', 'L')\n Window.functions[__method__].call(@title.wide, @text.wide, timeout) != 0\n end",
"def switch_to_window(id)\n driver.switch_to.window(id)\n end",
"def switch_to_frame\n wait.until { wrapper_element.attribute('class').include?('modal_open') }\n @browser.switch_to.frame(@browser.find_element(Selectors::FAST_SEARCH_MODAL[:iframe]))\n end",
"def win; end",
"def wait(title, text = \"\", timeout = 0)\n @functions[__method__] ||= AU3_Function.new(\"WinWait\", 'SSL', 'L')\n @functions[__method__].call(title.wide, text.wide, timeout) != 0\n end",
"def wait_for\n wait = Selenium::WebDriver::Wait.new(:timeout => 1000)\n wait.until { yield(@session) }\n end",
"def status_window aconfig={}, &block\n sw = StatusWindow.new aconfig\n sw.win.name = \"WINDOW::status_window\"\n return sw unless block_given?\n begin\n yield sw\n ensure\n sw.destroy if sw\n end\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 test_document_server(url)\n test_name = \"Test Document Server Connection\"\n puts test_name\n get_website(url)\n login_as_guest_test\n if @browser.find_element(:css=>'.focus') #Dismisses the splashscreen if present\n @wait.until{@browser.find_element(:css=>'.focus')}.click\n end\n login_toolshelf_button_test\n login_test\nend"
] | [
"0.68915147",
"0.6578523",
"0.65782666",
"0.6577984",
"0.6564619",
"0.6564619",
"0.64832425",
"0.63045776",
"0.61994475",
"0.6193892",
"0.6170813",
"0.611071",
"0.6102286",
"0.6099346",
"0.60870767",
"0.6080209",
"0.59825706",
"0.59752125",
"0.59729826",
"0.5947358",
"0.5930566",
"0.5919489",
"0.5911548",
"0.5898632",
"0.5896768",
"0.5889362",
"0.586736",
"0.5863414",
"0.58618796",
"0.5853434",
"0.5848581",
"0.5829452",
"0.5826606",
"0.5816195",
"0.5808919",
"0.5802272",
"0.579616",
"0.5778609",
"0.5773082",
"0.5757777",
"0.5731251",
"0.5729638",
"0.57244134",
"0.5713771",
"0.5698676",
"0.5687495",
"0.5673959",
"0.56557524",
"0.5647873",
"0.56314224",
"0.56219995",
"0.56191736",
"0.56180334",
"0.55802697",
"0.5574049",
"0.5556053",
"0.5542186",
"0.55336976",
"0.5531749",
"0.55033606",
"0.5500106",
"0.54974955",
"0.54973257",
"0.54877007",
"0.54730177",
"0.54650617",
"0.5455101",
"0.54524016",
"0.5449745",
"0.54418004",
"0.5437118",
"0.5432306",
"0.5430934",
"0.5430188",
"0.5401027",
"0.53945667",
"0.53797925",
"0.5379019",
"0.5363129",
"0.5358779",
"0.53509307",
"0.53419626",
"0.5340754",
"0.5337982",
"0.5337982",
"0.53378284",
"0.5336895",
"0.53246766",
"0.53225833",
"0.5322191",
"0.53154325",
"0.5309606",
"0.5308132",
"0.52907753",
"0.5287235",
"0.52849895",
"0.5283085",
"0.5281927",
"0.52565014",
"0.525555"
] | 0.6465405 | 7 |
copied from Learnco lab | def get_programs
uri = URI.parse(URL)
response = Net::HTTP.get_response(uri)
response.body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notes_from_training\n end",
"def nn\n end",
"def no_learn\n 8\n end",
"def probers; end",
"def operations; end",
"def operations; end",
"def labels; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def samples; end",
"def samples; end",
"def private; end",
"def intensifier; end",
"def scientist; end",
"def alg; end",
"def spe_training\n\tend",
"def schumann; end",
"def train\n raise NotImplementedError\n end",
"def terpene; end",
"def\n \nend\n\n\n# 6. sentence_maker refactored solution",
"def getKnowledge\n\t\t\n\tend",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def learn_more\n end",
"def desc() summary; end",
"def schubert; end",
"def fit; end",
"def villian; end",
"def suivre; end",
"def label; end",
"def label; end",
"def p15\n\t\nend",
"def wagner; end",
"def label() @positive end",
"def op; end",
"def silly_adjective; end",
"def train\r\n return @train\r\n end",
"def ismn; end",
"def titan; end",
"def alternatives; end",
"def explain\n \n end",
"def analyze_component_breakdown\n\n end",
"def how_it_works\r\n end",
"def tld; end",
"def tld; end",
"def formation; end",
"def berlioz; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def operation; end",
"def learn!\n parse_ngrams!\n parse_lexicon!\n compute_interpolations! if interpolations.nil?\n end",
"def malts; end",
"def passes; end",
"def passes; end",
"def transformations; end",
"def loaded_features; end",
"def ca; end",
"def verdi; end",
"def confidence; end",
"def term; end",
"def code_of_conduct; end",
"def desc; end",
"def weight; end",
"def king_richard_iii; end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def explore\n end",
"def spouse; end",
"def trd; end",
"def emotional_adjective; end",
"def stderrs; end",
"def expert(data)\nend",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def completed_text_extraction\n end",
"def codepoints()\n #This is a stub, used for indexing\n end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def masterwork_prob_bonus; 0; end",
"def instructions\n \n end",
"def jack_handey; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def summary; end",
"def in_law; end",
"def relatorios\n end",
"def romeo_and_juliet; end",
"def find_labels(t)\n # puts \"Inside find_labels\"\n unTaggedString = t.split(\" \")\n t = StanfordCoreNLP::Text.new(t)\n @pipeline.annotate(t)\n #for each sentence identify theparsed form of the sentence\n sentence = t.get(:sentences).toArray\n parsed_sentence = sentence[0].get(:collapsed_c_c_processed_dependencies) \n labels = Array.new\n labelCounter = 0\n govDep = parsed_sentence.typedDependencies.toArray\n #for each untagged token\n for j in (0..unTaggedString.length - 1)\n unTaggedString[j].gsub!(\".\", \"\")\n unTaggedString[j].gsub!(\",\", \"\")\n #puts \"Label for #{unTaggedString[j]}\"\n #identify its corresponding position in govDep and fetch its label\n for k in (0..govDep.length - 1)\n #puts \"Comparing with #{govDep[k].dep.value()}\"\n if(govDep[k].dep.value() == unTaggedString[j])\n labels[j] = govDep[k].reln.getShortName()\n #puts labels[j]\n labelCounter+=1\n break\n end\n end\n end\n return labels\nend",
"def sld; end"
] | [
"0.61483425",
"0.6135703",
"0.59213567",
"0.58859855",
"0.5854494",
"0.5854494",
"0.58193946",
"0.5817524",
"0.5817524",
"0.5817524",
"0.5776534",
"0.5776534",
"0.575989",
"0.5726117",
"0.57078665",
"0.5706091",
"0.56539047",
"0.564158",
"0.5598436",
"0.558321",
"0.5569446",
"0.556753",
"0.5533377",
"0.5533377",
"0.5533377",
"0.5533377",
"0.55301",
"0.5525626",
"0.5523628",
"0.55207086",
"0.55109173",
"0.55066574",
"0.55049896",
"0.55049896",
"0.54981345",
"0.548445",
"0.5470191",
"0.5452165",
"0.5433625",
"0.54231125",
"0.5417037",
"0.5409409",
"0.54012156",
"0.5396045",
"0.5391576",
"0.5380297",
"0.53774863",
"0.53774863",
"0.53711325",
"0.5360277",
"0.53592926",
"0.53592926",
"0.53592926",
"0.53592926",
"0.53592926",
"0.5358315",
"0.5356436",
"0.5350907",
"0.5335426",
"0.5335426",
"0.53354037",
"0.53326064",
"0.53089213",
"0.53063023",
"0.530159",
"0.5295099",
"0.52812153",
"0.52710366",
"0.526115",
"0.52603143",
"0.5256994",
"0.5256994",
"0.5256994",
"0.5256994",
"0.5256994",
"0.5254346",
"0.52519935",
"0.524916",
"0.52395636",
"0.5225762",
"0.52201873",
"0.52201873",
"0.5217824",
"0.52127695",
"0.5212664",
"0.52088207",
"0.52016854",
"0.52013695",
"0.52012193",
"0.52012193",
"0.52012193",
"0.52012193",
"0.51966053",
"0.51966053",
"0.51966053",
"0.51966053",
"0.5183651",
"0.51800644",
"0.51772034",
"0.5174953",
"0.51687014"
] | 0.0 | -1 |
Returns estimated effort for a ProjectPhase by calculating the sum of the estimated effort for each StockDeliverableType and CustomDeliverableType | def estimated_effort
total_estimated_effort = 0
self.project_phase_deliverables.each do |deliverable|
total_estimated_effort += deliverable.estimated_effort.to_f unless deliverable.nil?
end
return total_estimated_effort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_phase_actual_effort(project_id, phase)\n @hours = 0\n @dataset = Deliverable.find_all_by_phase_and_project_id(phase, project_id)\n puts @dataset\n if @dataset.nil?\n return 0\n else\n @dataset.each do |d|\n @hours += d.hours_logged\n end\n return @hours\n end\n end",
"def logged_effort\n total_logged_effort = 0\n\n self.project_phase_deliverables.each do |deliverable|\n total_logged_effort += deliverable.logged_effort.to_f unless deliverable.nil?\n end\n\n return total_logged_effort\n end",
"def project_phase_deliverables\n project_phase_deliverables = []\n stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n project_phase_deliverables << d\n end\n end\n\n custom_deliverable_types.each do |custom|\n custom.deliverables.each do |d|\n project_phase_deliverables << d\n end\n end\n project_phase_deliverables\n end",
"def amount_missing_on_deliverables\n # Bisect the issues because NOT IN isn't reliable\n all_issues = self.project.issues.all\n return 0 if all_issues.empty?\n\n deliverable_issues = self.project.issues.find(:all, :conditions => [\"deliverable_id IN (?)\", self.deliverables.collect(&:id)])\n\n missing_issues = all_issues - deliverable_issues\n\n time_logs = missing_issues.collect(&:time_entries).flatten\n \n return time_logs.collect(&:cost).sum\n end",
"def hours_spent\n hours_spent = 0\n project_tasks.each do |project_task|\n hours_spent += project_task.hours_spent\n end\n hours_spent\n end",
"def hours_planned\n hours_planned = 0\n project_tasks.each do |project_task|\n hours_planned += project_task.hours_planned\n end\n hours_planned\n end",
"def spent\n self.deliverables.collect(&:spent).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end",
"def expense_by_party_and_line_item_subtype party, line_item_sub_type, invoiced=nil, document_id=nil\n sub_total = expense_subtotal_by_party(party)\n accum = Money.new(0)\n\n filter_invoiced(line_items, invoiced, document_id).select{|li| li.line_item_sub_type == line_item_sub_type}.each do |li|\n if li.after_subtotal\n\n if li.billable_party == party\n accum -= li.percentage_of_subtotal ? li.revenue_total_with_percentage(sub_total) : li.revenue_total\n end\n\n if li.payable_party == party\n accum += li.percentage_of_subtotal ? li.expense_total_with_percentage(sub_total) : li.expense_total\n end\n\n else\n\n if li.billable_party == party\n accum -= li.revenue_total\n end\n\n if li.payable_party == party\n accum += li.expense_total\n end\n \n end\n\n end\n accum\n end",
"def project_costs(proj)\n Issue.cross_project_scope(proj, 'descendants')\n .select('spent_on, SUM(hours) AS sum_hours')\n .where(\"#{SQL_COM}\")\n .joins(:time_entries)\n .group(:spent_on)\n .collect { |issue| [issue.spent_on.to_date, issue.sum_hours] }\n end",
"def amount_spent_on(project)\n self.expenses.where(:project_id => project.id).sum(:amount)\n end",
"def profit\n return 0.0 unless self.deliverables.size > 0\n \n # Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types\n return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end",
"def show\n @project_phase = ProjectPhase.find(params[:id])\n @lifecycle_phase = @project_phase.lifecycle_phase\n @project_phase_deliverables = []\n @project_phase.stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n @project_phase.custom_deliverable_types.each do |custom|\n custom.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n respond_to do |format|\n format.json { render :json => { :lifecycle_phase_container => @lifecycle_phase,\n :deliverables_container => @project_phase_deliverables,\n :project_phase_estimated_effort => @project_phase.estimated_effort,\n :project_phase_logged_effort => @project_phase.logged_effort} }\n end\n end",
"def estimated_profit\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_client(id)\n days_tracked = (mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n task_estimate_mins = Task.total_estimated_minutes_for_client(id)\n task_estimate_days = (task_estimate_mins.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n ((task_estimate_days * day_rate.to_s.to_d) - (days_tracked * day_rate.to_s.to_d)).round(2)\n end",
"def charged_so_far\n charges = stages.collect{ |pr| pr.charged_so_far }.sum\n invoices.collect{ |inv| inv.total }.sum + charges\n end",
"def revenue_by_party_and_line_item_subtype party, line_item_sub_type, invoiced=nil, document_id=nil\n sub_total = revenue_subtotal_by_party(party)\n accum = Money.new(0)\n\n filter_invoiced(line_items, invoiced, document_id).select{|li| li.line_item_sub_type == line_item_sub_type}.each do |li|\n if li.after_subtotal\n\n if li.billable_party == party\n accum += li.percentage_of_subtotal ? li.revenue_total_with_percentage(sub_total) : li.revenue_total\n end\n\n if li.payable_party == party\n accum -= li.percentage_of_subtotal ? -li.expense_total_with_percentage(sub_total) : li.expense_total\n end\n\n else\n\n if li.billable_party == party\n accum += li.revenue_total\n end\n\n if li.payable_party == party\n accum -= li.expense_total\n end\n \n end\n\n end\n accum\n end",
"def timesheet_total_price(paied_actions = [])\n paied_actions.reject!(&:blank?)\n total_price = 0\n paied_actions.each do |paied_action|\n if paied_action.is_a? Numeric\n total_price += paied_action\n else\n paied_action.each do |act|\n total_price += price_sum(act)\n end\n end\n end\n total_price\n end",
"def total_initial_investment\n fetch(:total_initial_investment) do\n if initial_investment.nil? && ccs_investment.nil? && cost_of_installing.nil? &&\n storage_costs&.zero? && capacity_costs&.zero?\n nil\n else\n (initial_investment || 0.0) +\n (ccs_investment || 0.0) +\n (cost_of_installing || 0.0) +\n (storage_costs || 0.0) +\n (capacity_costs || 0.0)\n end\n end\n end",
"def invested(domain)\n #binding.pry\n funding_rounds.select{|fr| fr.startup.domain == domain}.map{|fr| fr.investment}.sum\n end",
"def budget\n return self.deliverables.collect(&:budget).delete_if { |d| d.blank?}.inject { |sum, n| sum + n} || 0.0\n end",
"def progress\n return 100 unless self.deliverables.size > 0\n return 100 if self.budget == 0.0\n \n balance = 0.0\n \n self.deliverables.each do |deliverable|\n balance += deliverable.budget * deliverable.progress\n end\n \n return (balance / self.budget).round\n end",
"def consolidate_phase_trays(plans)\n tray_plans = []\n plans.each do |p|\n tp = tray_plans.detect { |x| x[:phase] == p[:phase] }\n if tp.present?\n tp[:quantity] += p[:quantity]\n tp[:trays] += p[:trays]\n else\n tray_plans << p\n end\n end\n tray_plans\n end",
"def amount_missing_on_issues\n time_logs = TimeEntry.where(project_id: self.project.id)\n\n return time_logs.collect(&:cost).sum\n end",
"def find_team_values\n #sets the total investments as an empty hash\n team_investments = {}\n #iterates through every team\n @teams.each do |team, value|\n #initializes the value for the team\n investment_values = 0\n #finds every investment for the team\n Investment.where(team_id: team.id).each do |i|\n #only adds the investment if it is in the selected quarter\n Feature.find(i.feature_id).quater == @quater ? investment_values += i.investment : a=0\n end\n team_investments[team.id] = investment_values\n end\n return team_investments\n end",
"def update_invested\n self.invested_amount = self.investments.map(&:amount).sum\n self.goal_investment = 0 unless self.goal_investment\n self.equity_offered = 0 unless self.equity_offered\n self.save\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def calculate_total_money_spent\n return @trips.inject(0.0) { |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.cost }\n end",
"def equip\n @project = Project.find(params[:id])\n @totprice=0\n @totsize=0\n @project.baskets.each do |p|\n if not p.equipment.price.nil? #if the basket equipment price is not nil\n @totprice=@totprice+(p.equipment.price*p.quantity) #add to the running total\n end\n if (not p.equipment.width.nil?) and (not p.equipment.depth.nil?) #if width and depth are not nil\n @totsize=@totsize+ (p.equipment.width*p.equipment.depth*p.quantity) #calculate total surface area and add to the running total\n end\n end\n \n @totprice=@totprice.round(2)\n @totprice=sprintf \"%.02f\", @totprice #display total price in currency format to 2 dp\n \n respond_to do |format|\n format.html # equip.html.erb\n format.json { render json: @project }\n \n end\n end",
"def total_funds\n #binding.pry\n funding_rounds.map{|fr| fr.investment}.sum\n end",
"def calc_need(assets)\n\n a = {}\n assets.find_each do |asset|\n # see if this asset sub type has been seen yet\n if a.has_key?(asset.asset_subtype)\n report_row = a[asset.asset_subtype]\n else\n report_row = AssetSubtypeReportRow.new(asset.asset_subtype)\n a[asset.asset_subtype] = report_row\n end\n # get the replacement cost for this item based on the current policy\n report_row.add(asset)\n end \n\n return a \n end",
"def getDeveloperTaskEffort\r\n effortHash = {}\r\n\t#Read in the developers from theexcel sheet\r\n\tdevelopers = getUniqueColumnItems $ws1,$columnNumbers1[\"Developer\"],2,$validRow\r\n developers.each do |name|\r\n criterion = {$columnNumbers1[\"Effort\"] => /^\\s*\\d/i, $columnNumbers1[\"Developer\"] => /^\\s*#{name}/i, $columnNumbers1[\"Acceptence\"] => /^\\s*Yes/i}\r\n efforts = readColumnsCrieteria $ws1,$columnNumbers1[\"Normalised Effort\"],criterion,$validRow\r\n #Store the result in the hash\r\n\t\ttotalEffort = efforts.inject{|result,element| result + element} \r\n\t\t#Default values of zero\r\n\t\ttotalEffort = 0 unless totalEffort\r\n effortHash[name] = totalEffort\r\n end\r\n effortHash\r\nend",
"def total_cost\n [executor_cost, team_lead_cost, account_manager_cost].compact.inject(&:+)\n end",
"def total_funds\n my_rounds.map{|rounds| rounds.investment}.sum\n end",
"def _calc_delivered_cost task, opts\n if task.work_finished_at <= task.delivered_at\n _to_hours(task.delivered_at - task.work_started_at, opts)\n else\n _to_hours(task.delivered_at - task.work_started_at + 5 * (task.work_finished_at - task.delivered_at), opts)\n end\n end",
"def total_impact\n component_total(components)\n end",
"def invested(domain)\n FundingRound.all.inject(0) do |sum, funding_round|\n if (funding_round.venture_capitalist == self && funding_round.startup.domain == domain)\n sum += funding_round.investment\n else\n sum\n end\n end\n end",
"def total_sum()\n return self.work_packets.sum( :worked_hours )\n end",
"def hours_sold_for\n @project.hours_sold_for\n end",
"def total_demand_for_electricity\n final_demand_for_electricity +\n non_final_demand_for_electricity +\n electricity_losses_if_export_is_zero\n end",
"def total_costs\n fixed_costs + variable_costs\n end",
"def invoiced_for_superficie_presentation_unit_type_measurement\n finished_products.each do |finished_product|\n finished_product.products.each do |product|\n product.product_by_invoices.each do |product_by_invoice|\n total_presentation_unit_type_to_use = product_by_invoice.total_presentation_unit_type_to_use\n finished_product.presentation_unit_type.presentation_unit_type_conversions.each do |presentation_unit_type_conversion|\n if packing_material.presentation_unit_type_id.eql?(presentation_unit_type_conversion.presentation_unit_type_to_id)\n invoiced += (total_presentation_unit_type_to_use*presentation_unit_type_conversion.proportion).to_i\n end\n end\n end\n end\n end\n end",
"def total_funds\n investments = self.funding_rounds.map do |funding_round|\n funding_round.investment\n end\n investments.sum\n end",
"def per_trip_total\n (per_ticket_cost + checked_bag_cost + per_trip_accom)\n end",
"def prepaid_liabilities_total\n voucher_groups.inject(Money.new(0)) { |sum, vg| sum + ( vg.cogs * vg.quantity ) }\n end",
"def version_costs(proj_id, version_id)\n proj = Project.find(proj_id)\n Issue.cross_project_scope(proj, 'descendants')\n .select('spent_on, SUM(hours) AS sum_hours')\n .where(\"#{SQL_COM} AND fixed_version_id = ? \", version_id)\n .joins(:time_entries)\n .group(:spent_on)\n .collect { |issue| [issue.spent_on.to_date, issue.sum_hours] }\n end",
"def total(day, project_id)\n sum = 0\n Array.wrap(day[project_id]).each do |story|\n sum += story['estimate'].to_i\n end\n sum\nend",
"def schedule_impact\n if self.time_added?\n self.hours\n elsif time_removed?\n self.hours * -1.0\n else\n 0.0\n end\n end",
"def CPI\n if self.spent_hours>0 and self.estimated_hours>0\n earned_value= (self.completed_percent * self.estimated_hours)/100\n actual_cost=self.spent_hours\n return (earned_value/actual_cost)\n else\n return 0\n end\n\n rescue\n return 0\n end",
"def tasks_progress\n total_done = 0\n total_tasks = 0\n self.stories.each do |story|\n story.issues.each do |issue|\n total_tasks += 1\n total_done += issue.done\n end\n end\n total_tasks > 0 ? total_done / total_tasks : 100\n end",
"def project_totals(from=7.days.ago, to=Date.today)\n @pt = []\n projects.each do |p|\n hrs = total_project_hours(p.id, from, to)\n @pt << [p.name, hrs] if hrs > 0\n end\n @pt\n end",
"def SPI\n\n #byebug\n if self.estimated_hours>0 and !self.start_date.nil? and !self.due_date.nil?\n hoxe_dias=(Date.parse(Time.now.to_s) - self.start_date).to_f\n total_dias=(self.due_date-self.start_date).to_f\n earned_value= (completed_percent * estimated_hours)/100 # Podria ser tambien las spent_hours\n planned_value=(hoxe_dias/total_dias)*estimated_hours\n return (earned_value/planned_value)\n else\n return 0\n end\n\n rescue\n return 0\n\n end",
"def total_points\n filtered_records.limit(nil).approved.sum('completed_tasks.points * COALESCE(completed_tasks.quantity, 1)')\n end",
"def total_income\n _result = 0\n budget_items.each do |i|\n _flow = i.charge_account.charge_group.flow rescue 0\n if (_flow == 1 || _flow == 3) && !i.annual.blank?\n _result += i.annual\n end\n end\n _result\n end",
"def total_cost_items\n line_items.sum(&:total_cost_line_item)\n end",
"def total_paid_amount(facility)\n eobs = InsurancePaymentEob.select(\"SUM(total_amount_paid_for_claim) AS total_payment, \\\n SUM(claim_interest) AS total_interest, \\\n SUM(late_filing_charge) AS total_filing_charge, \\\n SUM(fund) AS total_fund, \\\n SUM(over_payment_recovery) AS total_over_payment_recovery\").\n where(\"check_information_id = #{id}\")\n eob = eobs.first if !eobs.blank?\n if !eob.blank?\n total_over_payment_recovery = facility.details[:over_payment_recovery] ? eob.total_over_payment_recovery : 0\n payment_amount = eob.total_payment.to_f\n net_payment_amount = payment_amount.to_f - total_over_payment_recovery.to_f\n total_paid_amount = net_payment_amount.to_f + eob.total_filing_charge.to_f + eob.total_fund.to_f\n if !facility.details[:interest_in_service_line]\n total_paid_amount += eob.total_interest.to_f\n end\n else\n total_paid_amount = PatientPayEob.where(\"check_information_id = #{id}\").sum('stub_amount')\n end\n job_ids = job.job_ids_for_check\n if !job_ids.blank?\n total_provider_amount = ProviderAdjustment.where(\"job_id in (#{job_ids.join(',')})\").sum('amount')\n end\n total_paid_amount += total_provider_amount.to_f\n total_paid_amount.to_f.round(2)\n end",
"def total_cost\n line_items.to_a.sum {|item| item.total_cost}\n end",
"def total_costs\n fetch(:total_costs) do\n fixed_costs + variable_costs if fixed_costs && variable_costs\n end\n end",
"def parts_cost\n asset_event_asset_subsystems.map(&:parts_cost).compact.reduce(0, :+)\n end",
"def _calc_inProgress_cost task, opts\n if task.terminated_at\n _to_hours(5 * (task.terminated_at - task.work_started_at), opts)\n elsif task.delivered_at.nil?\n _to_hours(Time.now - task.work_started_at, opts) \n else\n _to_hours(task.delivered_at - task.work_started_at + 5 * (task.work_finished_at - task.delivered_at), opts)\n end\n end",
"def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end",
"def find_company_projects_sum\n \t\t# returns a mapping [project name, client info, sum of hours, id]\n \t\tmy_company.projects.map{\n \t\t\t|p|[p.name, p.client, p.entries.reduce(0) do |sum, entry| \n \t\t\t\t\tsum = sum + entry.hours \n \t\t\t\tend, p.id\n \t\t\t]\n \t\t}\n \tend",
"def total_funds\n self.funding_rounds.sum {|fr| fr.investment}\n end",
"def total_asset_cost\n val = 0\n if assets.count > 0\n policy = Policy.find_by(organization_id: assets.first.organization_id)\n\n # this is to calculate the total ALI cost for a rehabilitation ALI\n # right now rehabilitation cost is taken from the policy\n # though a calculator should be used this is a TODO for a later time\n # reference .calculate_estimated_rehabilitation_cost in Asset model for same TODO\n if assets.where('disposition_date IS NOT NULL').count == 0\n\n if rehabilitation_ali?\n val = PolicyAssetSubtypeRule.find_by(policy_id: policy.id, asset_subtype_id: assets.first.asset_subtype_id).total_rehabilitation_cost * assets.count\n else\n if self.notional?\n asset_policy_analyzer = assets.first.policy_analyzer\n if asset_policy_analyzer.get_replace_asset_subtype_id.present? && asset_policy_analyzer.get_replacement_cost_calculation_type == CostCalculationType.find_by(class_name: 'PurchasePricePlusInterestCalculator')\n policy_replacement_calculator = CostCalculationType.find_by(class_name: 'ReplacementCostPlusInterestCalculator')\n else\n policy_replacement_calculator = assets.first.policy_analyzer.get_replacement_cost_calculation_type\n end\n assets.each do |a|\n cost = replacement_cost(a, policy_replacement_calculator)\n val += cost.to_i\n end\n else\n val = assets.sum(:scheduled_replacement_cost)\n end\n end\n end\n end\n\n val\n end",
"def real_effort_now(date = Date.today)\n return 0 unless !real_hours.blank? && real_hours > 0\n self.task_progresses.where(\"working_day <= ?\", date).sum(:effort)\n end",
"def total_timesheet\n if self.shifts.any?\n hours = self.shifts.sum(:time_worked)\n if hours > 40\n self.reg_hours = 40\n self.ot_hours = hours - 40\n ot_rate = job.pay_rate * 1.5\n self.gross_pay = job.pay_rate * self.reg_hours + self.ot_hours * ot_rate\n else\n pay = job.pay_rate * hours\n self.reg_hours = hours\n self.ot_hours = 0\n self.gross_pay = pay\n self.total_bill = pay * job.mark_up\n \n end\n end\n end",
"def total_investment_over_lifetime\n fetch(:total_investment_over_lifetime) do\n total_initial_investment + decommissioning_costs\n end\n end",
"def sum(overtime: nil)\n (self.hour || 0) +\n (self.piecework_hours || 0) +\n (self.overtime_50 || 0) +\n (self.overtime_100 || 0)\n end",
"def campaign_totals\n @campaign_totals ||= advertiser_report_items.inject({}) do |memory, advertiser_report_item|\n advertiser_report_item.to_h.each do |key, value|\n memory[key] ||= 0.0\n memory[key] += value.to_f\n end\n\n memory\n end\n end",
"def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend",
"def get_cout_total_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_total_parcelle(self)\n end\n end\n sum\n end",
"def getDeliverableTypes\n @projectPhase = ProjectPhase.find(@project_phase_id)\n @deliverableTypes = DeliverableType.find_all_by_lifecycle_phase_id(@projectPhase.lifecycle_phase_id)\n @deliverableTypesArray = []\n @deliverableTypes.each do |type|\n @deliverableTypesArray.append([type.name,type.id])\n end\n end",
"def total_pay\n total_pay = self.employees.map do |employee|\n employee.pay\n end\n total_pay.inject(:+)\n end",
"def total\n count = 0\n self.total_time_exercise_workouts.each do |ex|\n count += ex.duration\n end\n count\n end",
"def total_funds\n sum_funds = 0\n self.funding_rounds.each do |funding_round|\n sum_funds += funding_round.investment\n end \n sum_funds\nend",
"def get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def hours_spent\n \thours_spent = 0\n \tinputs.each do |input|\n \t\thours_spent += input.hours\n \tend\n \thours_spent\n end",
"def invested(domain)\n rounds_by_domain = funding_rounds.select{|fr| fr.startup.domain == domain}\n rounds_by_domain.sum(&:investment)\n end",
"def total_revenue\n costs = @driven_trips.reject {|trip| trip.cost.nil?}.map {|item| item.cost}\n calculated_costs = costs.sum {|item| (item - 1.65) * 0.8.round(2)}\n return calculated_costs\n end",
"def move_assets\n\n get_planning_years\n\n @job_finished = false\n\n @activity_line_item = ActivityLineItem.find_by(:object_key => params[:ali])\n\n @fy_year = params[:year].to_i\n if @activity_line_item.present? and @fy_year > 0\n assets = @activity_line_item.assets.where(object_key: params[:targets].split(','))\n\n if assets.count > 25\n Delayed::Job.enqueue MoveAssetYearJob.new(@activity_line_item, @fy_year, params[:targets], current_user, params[:early_replacement_reason]), :priority => 0\n\n notify_user :notice, \"Assets are being moved. You will be notified when the process is complete.\"\n else\n assets_touched = @activity_line_item.assets.pluck(:object_key)\n\n @capital_project = @activity_line_item.capital_project\n @ali_cost = assets.sum(:scheduled_replacement_cost)\n\n service = CapitalProjectBuilder.new\n assets_count = assets.count\n Rails.logger.debug \"Found #{assets_count} assets to process\"\n @deleted_alis = []\n assets.each do |a|\n # Replace or Rehab?\n if @activity_line_item.rehabilitation_ali?\n a.scheduled_rehabilitation_year = @fy_year\n else\n a.scheduled_replacement_year = @fy_year\n a.update_early_replacement_reason(params[:early_replacement_reason])\n end\n\n a.save(:validate => false)\n a.reload\n @deleted_alis += service.update_asset_schedule(a)[:deleted_alis]\n a.reload\n end\n\n # update the original ALI's estimated cost for its assets\n updated_ali = ActivityLineItem.find_by(id: @activity_line_item.id)\n if updated_ali.present?\n updated_ali.update_estimated_cost\n Rails.logger.debug(\"NEW COST::: #{updated_ali.estimated_cost}\")\n end\n\n @alis_touched = Rails.application.config.asset_base_class_name.constantize.where(object_key: assets_touched).very_specific.map{|asset| asset.activity_line_items.where('fy_year <= ?', @years.last)}.flatten!.uniq\n\n @job_finished = true\n notify_user :notice, \"Moved #{assets_count} assets to #{fiscal_year(@fy_year)}\"\n end\n\n else\n notify_user :alert, \"Missing ALI or fy_year. Can't perform update.\"\n end\n\n end",
"def total_hours\n approved_flights.sum(:duration)\n end",
"def labor_budget\n return self.deliverables.collect(&:labor_budget).delete_if { |d| d.blank?}.inject { |sum, n| sum + n} || 0.0\n end",
"def total_worth\n find_amount = funding_rounds.map{|funding| funding.investment}\n find_amount.inject{|sum, el| sum + el}\n end",
"def index\n @projects = Project.find(:all, :conditions => \"status = 'Active'\")\n @phases = ProjectPhase.find(:all, :conditions => {:projects => {:status => \"Active\"}}, :joins => [:project])\n @deliverables = Deliverable.find(:all, :conditions => {:project_phases => {:projects => {:status => \"Active\"}}}, :joins => [:project_phase => :project])\n\n if is_developer\n @efforts = Effort.find(:all, :conditions => ['user_id = ?', current_user.id])\n else\n @efforts = Effort.find(:all)\n end\n @efforts.sort! { |a,b| b.effort_date <=> a.effort_date }\n @effort = Effort.new\n\n respond_to do |format|\n format.html\n end\n end",
"def sum_produits_used\n sum = 0\n self.protofactures.each { |p| sum += p.prix_unit * (p.quantite - p.stock) }\n sum\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def ppptotal\n pppquantity + pppquality + pppontime + pppeffective + \n pppknowledge + ppprules + pppcommunication +\n pppleader + pppmanage + pppdiscipline + pppproactive + ppprelate + \n pppparttwo\n end",
"def total_funds\n total = 0\n num_funding_rounds.each do |round| \n total += round.investment\n end\n total\n end",
"def estimate_to_complete\n estimate_at_completion_cost - project.actual_cost(self)\n end",
"def get_total_review_effort(issue)\n issue['fields']['customfield_10029'].to_f + issue['fields']['customfield_10034'].to_f + issue['fields']['customfield_10038'].to_f + issue['fields']['customfield_10105'].to_f + issue['fields']['customfield_10106'].to_f\n end",
"def total_price\n total = total_price_without_installments\n if promotions.any?\n adjustment = adjustments.eligible.map(&:amount).sum\n\n (total += adjustment).to_f\n end\n if line_items.any? { |li| li.request_installments == true }\n total = total / 5\n end\n total\n end",
"def invested(web)\n arr = []\n funding_rounds.select do |s|\n if s.startup.domain == web\n arr << s.investment\n end\n end\n arr.sum\n end",
"def total_funds #YES\n startup_arr = FundingRound.all.select do |f|\n f.startup == self\n end\n startup_arr.collect do |s|\n s.investment\n end.sum \n end",
"def score\n total = 0\n achievements.each do |a|\n total += a.task.score\n end\n total\n end",
"def total_cost\n # binding.pry\n self.memberships.map{|membership| membership.cost }.sum\n end",
"def variable_operation_and_maintenance_costs_per_typical_input\n fetch(:variable_operation_and_maintenance_costs_per_typical_input) do\n return 0.0 if input_capacity.zero?\n return 0.0 if variable_operation_and_maintenance_costs_per_full_load_hour.nil?\n return 0.0 if variable_operation_and_maintenance_costs_for_ccs_per_full_load_hour.nil?\n\n (variable_operation_and_maintenance_costs_per_full_load_hour +\n variable_operation_and_maintenance_costs_for_ccs_per_full_load_hour) / # highlighting\n (input_capacity * 3600.0)\n end\n end",
"def calculate_score(team)\n scores.includes(:wattball_player).where(:wattball_players => {:team_id => team}).sum(:amount) \n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def getDeveloperNonTaskEffort\r\n effortHash = {}\r\n\tmaxRow = getMaxRow $ws_nonCSCRM, $columnNumbers_nonCSCRM[\"Task Name\"]\r\n\t#Read in the developers from the excel sheet\r\n\tdevelopers = getUniqueColumnItems $ws_nonCSCRM,$columnNumbers_nonCSCRM[\"Developer\"],2,maxRow\r\n developers.each do |name|\r\n\t\tcriterion = {$columnNumbers_nonCSCRM[\"Effort(hrs)\"] => /^\\s*\\d/i, $columnNumbers_nonCSCRM[\"Developer\"] => /^\\s*#{name}/i}\r\n efforts = readColumnsCrieteria $ws_nonCSCRM,$columnNumbers_nonCSCRM[\"Effort(hrs)\"],criterion,maxRow\r\n #Store the result in the hash\r\n\t\ttotalEffort = efforts.inject{|result,element| result + element} \r\n\t\t#Default values of zero\r\n\t\ttotalEffort = 0 unless totalEffort\r\n\t\t#Convert to days\r\n\t\ttotalEffort = (totalEffort / 8.5)\r\n\t\t#Round to 1 decimal position\r\n\t\ttotalEffort = (totalEffort * 10).round() / 10.0\r\n effortHash[name] = totalEffort\r\n end\r\n effortHash\r\nend",
"def total_amount_passed_to_field_worker\n # it is assumed that the setup fee is deducted from loan disbursement \n total_amount_passed = BigDecimal(\"0\")\n self.membership_to_receive_loan_disbursement.each do |glm|\n glp = glm.group_loan_product \n total_amount_passed += glp.loan_amount - glp.setup_payment_amount\n end\n \n return total_amount_passed\n end",
"def update_investments investment_type\n if self.investment_type.nil?\n self.create_investments investment_type\n else\n self.investment_type.update!(:fix_income => investment_type[:fix_income], :equity=> investment_type[:equity], :gold=> investment_type[:gold], :land_and_estate=> investment_type[:land_and_estate])\n end\n end",
"def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end"
] | [
"0.6394787",
"0.62272865",
"0.5798721",
"0.56754416",
"0.5484788",
"0.5387674",
"0.536942",
"0.53105897",
"0.52936953",
"0.5292658",
"0.52565676",
"0.5237736",
"0.51657087",
"0.51464784",
"0.51193655",
"0.5102273",
"0.50990856",
"0.5075204",
"0.5070166",
"0.5062832",
"0.50492275",
"0.50472766",
"0.5015658",
"0.50116754",
"0.5005082",
"0.49914458",
"0.49834132",
"0.4958452",
"0.49563697",
"0.4953459",
"0.49534035",
"0.4952138",
"0.4933557",
"0.4924134",
"0.49213037",
"0.49188843",
"0.49051887",
"0.48929378",
"0.48822552",
"0.48766807",
"0.48762882",
"0.48622337",
"0.48551494",
"0.48379144",
"0.4833828",
"0.48299938",
"0.4828164",
"0.4823248",
"0.48174682",
"0.48145",
"0.48022908",
"0.48019218",
"0.48014495",
"0.4785117",
"0.47785425",
"0.4765762",
"0.47657433",
"0.47578344",
"0.47451627",
"0.4745141",
"0.47373423",
"0.47358486",
"0.47324222",
"0.4711384",
"0.47065994",
"0.47056547",
"0.4702873",
"0.46981394",
"0.46938884",
"0.46816826",
"0.46762696",
"0.46723297",
"0.46695745",
"0.4666709",
"0.4664913",
"0.46626252",
"0.46601468",
"0.46577826",
"0.46575636",
"0.46560118",
"0.46532372",
"0.46519947",
"0.4649409",
"0.46480596",
"0.46480596",
"0.46451196",
"0.46374115",
"0.4637049",
"0.46361095",
"0.46299386",
"0.46294174",
"0.46273965",
"0.46272895",
"0.46267483",
"0.46148798",
"0.4611944",
"0.4605969",
"0.46023384",
"0.45973334",
"0.4584568"
] | 0.7271085 | 0 |
function to get the total logged effort for this deliverable | def logged_effort
total_logged_effort = 0
self.project_phase_deliverables.each do |deliverable|
total_logged_effort += deliverable.logged_effort.to_f unless deliverable.nil?
end
return total_logged_effort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimated_effort\n total_estimated_effort = 0\n\n self.project_phase_deliverables.each do |deliverable|\n total_estimated_effort += deliverable.estimated_effort.to_f unless deliverable.nil?\n end\n\n return total_estimated_effort\n end",
"def total\n count = 0\n self.total_time_exercise_workouts.each do |ex|\n count += ex.duration\n end\n count\n end",
"def amount_missing_on_deliverables\n # Bisect the issues because NOT IN isn't reliable\n all_issues = self.project.issues.all\n return 0 if all_issues.empty?\n\n deliverable_issues = self.project.issues.find(:all, :conditions => [\"deliverable_id IN (?)\", self.deliverables.collect(&:id)])\n\n missing_issues = all_issues - deliverable_issues\n\n time_logs = missing_issues.collect(&:time_entries).flatten\n \n return time_logs.collect(&:cost).sum\n end",
"def total_sum()\n return self.work_packets.sum( :worked_hours )\n end",
"def avarage_calories_burned\n total_workout_calories / set_sport_by_user.count\n rescue\n 0\n end",
"def calculate_phase_actual_effort(project_id, phase)\n @hours = 0\n @dataset = Deliverable.find_all_by_phase_and_project_id(phase, project_id)\n puts @dataset\n if @dataset.nil?\n return 0\n else\n @dataset.each do |d|\n @hours += d.hours_logged\n end\n return @hours\n end\n end",
"def total_workout_calories\n set_sport_by_user.sum(:burned_calories) || 0\n end",
"def get_total_review_effort(issue)\n issue['fields']['customfield_10029'].to_f + issue['fields']['customfield_10034'].to_f + issue['fields']['customfield_10038'].to_f + issue['fields']['customfield_10105'].to_f + issue['fields']['customfield_10106'].to_f\n end",
"def hours_planned\n hours_planned = 0\n project_tasks.each do |project_task|\n hours_planned += project_task.hours_planned\n end\n hours_planned\n end",
"def estimated_profit\n day_rate = avg_rate_card_amount_cents.round(2)\n mins_tracked = Timing.minute_duration_submitted_for_client(id)\n days_tracked = (mins_tracked.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n task_estimate_mins = Task.total_estimated_minutes_for_client(id)\n task_estimate_days = (task_estimate_mins.to_s.to_d / account.account_setting.working_day_duration_minutes).round(2)\n\n ((task_estimate_days * day_rate.to_s.to_d) - (days_tracked * day_rate.to_s.to_d)).round(2)\n end",
"def amount_missing_on_issues\n time_logs = TimeEntry.where(project_id: self.project.id)\n\n return time_logs.collect(&:cost).sum\n end",
"def attack\n total_for(:attack) \n end",
"def total_demand\n info[:total_demand]\n end",
"def total_hours\n approved_flights.sum(:duration)\n end",
"def budget\n return self.deliverables.collect(&:budget).delete_if { |d| d.blank?}.inject { |sum, n| sum + n} || 0.0\n end",
"def total_impact\n component_total(components)\n end",
"def spent\n self.deliverables.collect(&:spent).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end",
"def total_charged\n return self.trips.sum(&:cost)\n end",
"def recent_goal_qty\n @recent_goal.stake_qty\n end",
"def total_wait\n if cart.delivers\n if !cart.delivery_duration.blank?\n response = estimated_wait + cart.delivery_duration\n else\n response = estimated_wait + 20\n end\n else\n response = estimated_wait\n end\n\n return response\n end",
"def progress\n return 100 unless self.deliverables.size > 0\n return 100 if self.budget == 0.0\n \n balance = 0.0\n \n self.deliverables.each do |deliverable|\n balance += deliverable.budget * deliverable.progress\n end\n \n return (balance / self.budget).round\n end",
"def dps\n self.total_damage.to_f / self.encounter.duration_in_seconds\n end",
"def last_workout_calories\n set_sport_by_user.last.try(:burned_calories) || 0\n end",
"def total_owed\n self.appointments.sum(:cost)\n end",
"def real_effort_now(date = Date.today)\n return 0 unless !real_hours.blank? && real_hours > 0\n self.task_progresses.where(\"working_day <= ?\", date).sum(:effort)\n end",
"def display_total_calories_per_workout\n puts \"This workout will burn an average of #{self.total_calories} calories.\"\n end",
"def get_total_duration\n @sport_duration = Sport.where(user_id: current_user.id).sum(:duration)\n end",
"def labor_budget\n return self.deliverables.collect(&:labor_budget).delete_if { |d| d.blank?}.inject { |sum, n| sum + n} || 0.0\n end",
"def daily_goals\n goals\n end",
"def calculate_total_money_spent\n return @trips.inject(0.0) { |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.cost }\n end",
"def level\n # attended = Commitment.where(\"user_id = ? AND fulfilled = ?\", id, true)\n # ((attended.map { |commitment| Post.where(id: commitment.post_id).first }.map { |post| post.pace }.inject { |memo, n| memo + n })/attended.length).round\n 5\n end",
"def report_person_effort_for_course(person, course)\n person_effort_log_lines = EffortLog.find_by_sql([\"SELECT effort_logs.week_number, effort_log_line_items.sum FROM effort_log_line_items inner join effort_logs on effort_log_line_items.effort_log_id = effort_logs.id where effort_log_line_items.course_id = ? and effort_logs.person_id = ? order by effort_logs.week_number\", course.id, person.id])\n\n person_result = []\n @course.course_length.times do\n person_result << 0\n end\n if !person_effort_log_lines.nil? && person_effort_log_lines.size != 0 then\n person_effort_log_lines.each do |line|\n week = line.week_number.to_i\n if week >= @course.course_start && week <= @course.course_end then\n person_result[week - @course.course_start + 0] += line.sum.to_i #add two to skip the team and person label at the front of the array\n end\n\n end\n\n end\n return person_result\n end",
"def hours_spent\n hours_spent = 0\n project_tasks.each do |project_task|\n hours_spent += project_task.hours_spent\n end\n hours_spent\n end",
"def total_cost\n# Get the total cost of a specific lifter's gym memberships\n membs_cost = memberships.map{|membership|membership.cost}\n cost_total = membs_cost.inject(:+)\n end",
"def total_time_exercise_workouts\n self.exercise_workouts.select do |ex|\n ex.duration\n end\n end",
"def total_time\n minutes_to_human_readable_time(entries.internal.sum(:duration) + expected_remaining_work * 60)\n end",
"def total_investment_over_lifetime\n fetch(:total_investment_over_lifetime) do\n total_initial_investment + decommissioning_costs\n end\n end",
"def pri_tclear\n team_stats.offensive_clear_rate\n end",
"def per_ticket_cost\n flight_cost\n end",
"def actual_travel\n actual_travel = travel_expenses.reduce(0) {|sum, expense| sum += expense.amount }\n end",
"def sum_charges\n return (self.sum_produits_used)\n end",
"def score\n total = 0\n achievements.each do |a|\n total += a.task.score\n end\n total\n end",
"def profit\n return 0.0 unless self.deliverables.size > 0\n \n # Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types\n return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end",
"def delivery\n 50\n end",
"def hps\n self.total_healing.to_f / self.encounter.duration_in_seconds\n end",
"def planned_duration\n planned_value_by_week.count - 1 \n end",
"def total_amount_passed_to_field_worker\n # it is assumed that the setup fee is deducted from loan disbursement \n total_amount_passed = BigDecimal(\"0\")\n self.membership_to_receive_loan_disbursement.each do |glm|\n glp = glm.group_loan_product \n total_amount_passed += glp.loan_amount - glp.setup_payment_amount\n end\n \n return total_amount_passed\n end",
"def amount_spent_on(project)\n self.expenses.where(:project_id => project.id).sum(:amount)\n end",
"def invest_in_the_system\r\n @profit_from_crash += msg.value\r\n end",
"def invest_in_the_system\r\n @profit_from_crash += msg.value\r\n end",
"def total_amount_due_to_retailer\n shipping = self.retailer.reimburse_shipping_cost ? self.ship_total : 0.0\n product_cost = (self.line_items.collect {|line_item| line_item.product_cost_for_retailer }).sum\n self.tax_total + shipping + product_cost\n end",
"def daily_print_usage_by_user\n return @daily_print_usage_by_user\n end",
"def get_total_billable_time_amount\n @total_amount = 0.0\n @billed_time = 0.0\n unless @saved_time_entries.empty?\n @total_amount = @saved_time_entries.map(&:final_billed_amount).inject(0) do |total,amount|\n total + amount\n end\n @billed_time = @saved_time_entries.inject(0) do | total, time_entry|\n actual_duration = @dur_setng_is_one100th ? one_hundredth_timediffernce(time_entry.actual_duration) : one_tenth_timediffernce(time_entry.actual_duration)\n time_entry.is_billable ? total + actual_duration : total\n end\n @total_amount = @total_amount.to_f.roundf2(2)\n end\n @total_amount || 0.0 \n end",
"def average_completion_time\n respond_with Commit.average_completion_time\n end",
"def total_workout_with_km_calories\n set_sport_by_user.sum(:distance)\n end",
"def total_time; end",
"def pdf_total_time\n runs.sum(:finish)\n end",
"def total_duration\n self.inject(0) do |accum,trip|\n accum += trip.duration\n accum\n end\n end",
"def tot_current_benefit\n if self != nil && self.current_package != nil && self.current_package.calc_hourly_benefit != nil\n (self.calc_tot_hours * self.current_package.calc_hourly_benefit * 100.0).round / 100.0\n else\n 0.00\n end\n # check ?\n # ( @employee_benefit[\"deposit\"] -\n # ( @employee_benefit[\"monthly_benefit\"] - @employee_benefit[\"tot_deposits_made\"] )\n # ) > 0.005\n end",
"def achievements_percentage\n achievements_done.to_f / @achievements.size\n end",
"def hours_sold_for\n @project.hours_sold_for\n end",
"def total_time_spent\n return trips.sum {|trip| trip.duration}\n end",
"def average_calories\n total = 0\n self.desserts.each do |dessert|\n total + dessert.calories / dessert.ingreidents.length\n end\n total\n end",
"def total_paid_amount(facility)\n eobs = InsurancePaymentEob.select(\"SUM(total_amount_paid_for_claim) AS total_payment, \\\n SUM(claim_interest) AS total_interest, \\\n SUM(late_filing_charge) AS total_filing_charge, \\\n SUM(fund) AS total_fund, \\\n SUM(over_payment_recovery) AS total_over_payment_recovery\").\n where(\"check_information_id = #{id}\")\n eob = eobs.first if !eobs.blank?\n if !eob.blank?\n total_over_payment_recovery = facility.details[:over_payment_recovery] ? eob.total_over_payment_recovery : 0\n payment_amount = eob.total_payment.to_f\n net_payment_amount = payment_amount.to_f - total_over_payment_recovery.to_f\n total_paid_amount = net_payment_amount.to_f + eob.total_filing_charge.to_f + eob.total_fund.to_f\n if !facility.details[:interest_in_service_line]\n total_paid_amount += eob.total_interest.to_f\n end\n else\n total_paid_amount = PatientPayEob.where(\"check_information_id = #{id}\").sum('stub_amount')\n end\n job_ids = job.job_ids_for_check\n if !job_ids.blank?\n total_provider_amount = ProviderAdjustment.where(\"job_id in (#{job_ids.join(',')})\").sum('amount')\n end\n total_paid_amount += total_provider_amount.to_f\n total_paid_amount.to_f.round(2)\n end",
"def total_cost\n # binding.pry\n self.memberships.map{|membership| membership.cost }.sum\n end",
"def tot_deposits_made\n Rails.logger.debug(\"*** tot_deposits_made\")\n # note cannot use database sum because big_deposit is not native to database\n dep_result = 0.0\n EmployeeBenefit.where(\n \"employee_id = ? and eff_month = ? and eff_year = ? and deposited_at IS NOT NULL\",\n self.employee_id.to_s,\n self.eff_month.to_s,\n self.eff_year.to_s\n ).each do |eb|\n dep_result += round_money(eb.deposit)\n end\n Rails.logger.debug(\"*** dep_result: #{dep_result.inspect}\")\n return dep_result\n end",
"def took\n response['took']\n end",
"def total_paid\n self.user_expenses.reduce(0) { |sum, user_expense| user_expense.paid + sum }\n end",
"def undeliverable_percent\n total, fails = total_count, messages_given_up_on_count\n if total == 0\n return 0\n elsif fails == 0\n return 0\n else\n return (fails / total) * 100\n end\n end",
"def total_spent_hours\n @total_spent_hours ||= TimeEntry.where(:meeting_id => id).sum(:hours).to_f\n end",
"def total_cost\n total_cost = 0\n trips.each do |trip|\n total_cost += trip.cost\n end\n return \"$ #{total_cost/100.round(2)}\"\n end",
"def total_timesheet\n if self.shifts.any?\n hours = self.shifts.sum(:time_worked)\n if hours > 40\n self.reg_hours = 40\n self.ot_hours = hours - 40\n ot_rate = job.pay_rate * 1.5\n self.gross_pay = job.pay_rate * self.reg_hours + self.ot_hours * ot_rate\n else\n pay = job.pay_rate * hours\n self.reg_hours = hours\n self.ot_hours = 0\n self.gross_pay = pay\n self.total_bill = pay * job.mark_up\n \n end\n end\n end",
"def invested(domain)\n #binding.pry\n funding_rounds.select{|fr| fr.startup.domain == domain}.map{|fr| fr.investment}.sum\n end",
"def total_expenses\n self.expenses.sum(\"amount\")\n end",
"def overall_KDR\n overall_deaths = 0\n overall_kills = 0\n @player_champs_list.each do |champ|\n overall_deaths += champ.total_deaths\n overall_kills += champ.total_kills\n end\n overall_deaths > 0 ? (overall_kills.to_f / overall_deaths).round(2) : overall_kills.to_f\n end",
"def total_duration_over_70\n self.inject(0) do |accum,trip|\n accum += trip.duration_over_70\n accum\n end\n end",
"def print_report\n sum = 0.0\n puts \"\\nSummary:\"\n puts '-'*8\n @days.each do |day|\n puts \"#{day[:day].strftime(\"%m/%d/%y\")}, %.2f hours\" % day[:hours]\n sum += day[:hours]\n end\n puts \"\\nTotal hours = %.2f\" % sum\n days = elapsed_days(@days[0][:day])\n puts \"Elapsed days = %d\" % days\n puts \"Average hrs per week = %.2f\" % (sum / (days / 7.0))\n puts\n end",
"def goals(player_id)\n Stat.where(player_id: player_id).sum(:goals)\n end",
"def goals_for()\n\t self.as_regular_contestants.select{|c| c.score}.collect{|c| c.score}.inject{|gf, c| gf + c} || 0\n\tend",
"def per_trip_total\n (per_ticket_cost + checked_bag_cost + per_trip_accom)\n end",
"def direct_costs_for_visit_based_service\n total = 0\n self.line_items_visits.each do |line_items_visit|\n total += line_items_visit.subject_count * self.direct_costs_for_visit_based_service_single_subject(line_items_visit)\n end\n total\n end",
"def total_funds\n #binding.pry\n funding_rounds.map{|fr| fr.investment}.sum\n end",
"def expense_total\n self.expenses.sum(:amount).to_f\n end",
"def get_total_wages\n self.get_base_wages + self.get_manager_wages\n end",
"def total_working_hours_balance\n @total_working_hours_balance\n end",
"def total_time_spent\n\n time_spent = Trip.total_time(trips)\n\n return time_spent\n end",
"def get_works_total_hours\n res_hours =0\n self.works.each do |w|\n res_hours+=w.workhours unless w.workhours.nil?\n end\n return res_hours\n end",
"def complete_percent\n if learner\n # check if this is a reportable thing, if not then base the percent on the existance of the learner\n if offering_reportable?\n learner.report_learner.complete_percent || 0\n else\n # Offering is not reportable, but it has been started. Return 100%.\n 100\n end\n else\n 0\n end\n end",
"def total_funds\n self.funding_rounds.sum {|fr| fr.investment}\n end",
"def cost\n return @cost\n end",
"def cost\n return @cost\n end",
"def total_visit\n pet_histories.count\n end",
"def get_total_expense\n\t\tbills.pluck(:amount).inject(:+) rescue 0\n\tend",
"def remaining_production_total\n return productions_total - allotment_total_of_production_queue - allotment_total_of_research\n end",
"def get_logged_ratio(logged_hours, estimated_hours)\n Integer(logged_hours.to_f/estimated_hours.to_f*100)\n end",
"def total_exp_level\n lvl = self.lvl\n return (100 * (1 - @@exp_mul ** (lvl - 1)) / (1 - @@exp_mul))\n end",
"def total_spent\n total_cost = 0\n trips.each do |trip|\n total_cost += trip.cost\n end\n return total_cost\n end",
"def wealth\n @gold + inventory_worth\n end",
"def per_trip_accom\n accom_cost\n end",
"def donated_amount\n self.fees.purchased.sum(:amount).to_f\n end"
] | [
"0.7250742",
"0.6434303",
"0.6432553",
"0.6411589",
"0.64055353",
"0.6349569",
"0.6248869",
"0.6048537",
"0.6018238",
"0.5975668",
"0.5954886",
"0.5953312",
"0.5903224",
"0.5894547",
"0.58932376",
"0.58912987",
"0.588154",
"0.585457",
"0.58411676",
"0.583361",
"0.58333963",
"0.58215415",
"0.58159196",
"0.58124363",
"0.580242",
"0.57540727",
"0.5741179",
"0.57389295",
"0.57388026",
"0.5703248",
"0.5695362",
"0.56929255",
"0.5691097",
"0.5687229",
"0.56857723",
"0.5682179",
"0.56795835",
"0.56773716",
"0.56770986",
"0.56707925",
"0.5670409",
"0.5669191",
"0.566798",
"0.5658995",
"0.5654045",
"0.5650114",
"0.5642207",
"0.564127",
"0.56282663",
"0.56282663",
"0.5623977",
"0.5596693",
"0.55934435",
"0.5591205",
"0.5584777",
"0.55841947",
"0.557439",
"0.5566058",
"0.55638856",
"0.5563491",
"0.55603456",
"0.5550789",
"0.5547675",
"0.5545644",
"0.5540804",
"0.5538881",
"0.55356514",
"0.55305797",
"0.5527557",
"0.552637",
"0.55189997",
"0.5513704",
"0.55133563",
"0.5510628",
"0.5505513",
"0.5500477",
"0.5493523",
"0.5487451",
"0.5478866",
"0.54761624",
"0.54740846",
"0.5472455",
"0.54679304",
"0.5461845",
"0.54601485",
"0.5459921",
"0.54570854",
"0.54528326",
"0.5452115",
"0.5450746",
"0.5450746",
"0.54504085",
"0.54479575",
"0.54399747",
"0.5439171",
"0.5434244",
"0.5434077",
"0.54340094",
"0.5433491",
"0.54272443"
] | 0.82118356 | 0 |
function to return the aggregated project phase deliverables with both stock and custom | def project_phase_deliverables
project_phase_deliverables = []
stock_deliverable_types.each do |stock|
stock.deliverables.each do |d|
project_phase_deliverables << d
end
end
custom_deliverable_types.each do |custom|
custom.deliverables.each do |d|
project_phase_deliverables << d
end
end
project_phase_deliverables
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliverables\n return Deliverable.where(project_id: @project.id)\n end",
"def getDeliverableTypes\n @projectPhase = ProjectPhase.find(@project_phase_id)\n @deliverableTypes = DeliverableType.find_all_by_lifecycle_phase_id(@projectPhase.lifecycle_phase_id)\n @deliverableTypesArray = []\n @deliverableTypes.each do |type|\n @deliverableTypesArray.append([type.name,type.id])\n end\n end",
"def all_deliverables\n deliverables = self.deliverables.order(\"name ASC\")\n result = []\n deliverables.each do |deliverable|\n if deliverable.has_sub_item == true \n result << [ \"#{deliverable.name} -- SubItem: #{deliverable.sub_item_name} \"+\n \"-- Default SubItem Quantity: #{deliverable.sub_item_quantity} \"+\n \"-- Additional Extra SubItem Price: #{deliverable.independent_sub_item_price}\" , \n deliverable.id ]\n else\n result << [ \"#{deliverable.name}\" , \n deliverable.id ]\n end\n \n end\n return result\n end",
"def all_deliverable_projects\n all_digest_projects\n end",
"def pending_refund_payments_projects\n pending_refund_payments.map(&:project)\n end",
"def portfolio\n funding_rounds.map{|fr| fr.startup}.uniq\n #binding.pry\n end",
"def portfolio\n self.funding_rounds.map do |round|\n round.startup.uniq \n end\n end",
"def portfolio\n funding_rounds.map{|funding| funding.startup}.uniq\n end",
"def show\n @project_phase = ProjectPhase.find(params[:id])\n @lifecycle_phase = @project_phase.lifecycle_phase\n @project_phase_deliverables = []\n @project_phase.stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n @project_phase.custom_deliverable_types.each do |custom|\n custom.deliverables.each do |d|\n @project_phase_deliverables << d\n end\n end\n\n respond_to do |format|\n format.json { render :json => { :lifecycle_phase_container => @lifecycle_phase,\n :deliverables_container => @project_phase_deliverables,\n :project_phase_estimated_effort => @project_phase.estimated_effort,\n :project_phase_logged_effort => @project_phase.logged_effort} }\n end\n end",
"def portfolio()\n # uniq_funding = self.funding_rounds().uniq\n # uniq_funding.map {|funding| funding.startup}\n startups = self.funding_rounds().map { |funding| funding.startup}\n startups.uniq \n end",
"def portfolio\n funding_rounds.map {|funding_round| funding_round.startup}.uniq\n end",
"def porfolio\n self.funding_rounds.collect do |funding_round|\n funding.round.startup\n end.uniq\nend",
"def project_totals(from=7.days.ago, to=Date.today)\n @pt = []\n projects.each do |p|\n hrs = total_project_hours(p.id, from, to)\n @pt << [p.name, hrs] if hrs > 0\n end\n @pt\n end",
"def projects_supported\n @pledges = Pledge.all\n project_list = {}\n @pledges.each do |pledge|\n if pledge.user_id == self.id\n if project_list.has_key?(pledge.project_id)\n project_list[pledge.project_id] += pledge.dollar_amount\n else\n project_list[pledge.project_id] = pledge.dollar_amount\n end\n end\n end\n return project_list\n end",
"def portfolio\n arr = []\n FundingRound.all.select do |s|\n if s.venture_capitalist == self\n arr << s.startup.name\n end\n end\n arr.uniq\n end",
"def project_all\n prj = { '_id' => 0 }\n prj.merge!(make_grp_prj_periods[1])\n prj.merge!(make_grp_prj_nodes[1])\n prj.merge!(project_bookingnet)\n prj.merge!(project_baselist) unless @sensitivity >= 2\n prj.merge!(project_standardcost) unless @sensitivity >= 1\n { '$project' => prj }\n end",
"def products_billing_summary_by_stock(year)\n\n current_year = DateTime.now.year\n\n # Build the result holder\n total_cost = 0\n stock_items = if current_year == year\n ::Yito::Model::Booking::BookingItem.all(conditions: {active: true},\n fields: [:reference, :cost],\n order: [:category_code, :reference])\n else\n BookingDataSystem::Booking.historic_stock(year).map do |item|\n OpenStruct.new({reference: item.item_reference, cost: 0})\n end\n end\n\n summary = stock_items.inject({}) do |result, item|\n data_holder = {}\n (1..12).each { |item| data_holder.store(item, 0) }\n data_holder.store(:total, 0)\n data_holder.store(:cost, item.cost || 0)\n data_holder.store(:percentage, 0)\n total_cost = total_cost + item.cost unless item.cost.nil?\n result.store(item.reference, data_holder)\n result\n end\n data_holder = {}\n (1..12).each { |item| data_holder.store(item, 0) }\n data_holder.store(:total, 0)\n data_holder.store(:cost, 0)\n data_holder.store(:percentage, 0)\n summary.store(:TOTAL, data_holder)\n # Fill the data\n data = query_strategy.products_billing_summary_by_stock(year)\n data.each do |data_item|\n if summary.has_key?(data_item.reference)\n # stock\n summary[data_item.reference][data_item.period.to_i] = data_item.total_item_cost\n summary[data_item.reference][:total] += data_item.total_item_cost\n if summary[data_item.reference][:cost] and summary[data_item.reference][:cost] > 0\n summary[data_item.reference][:percentage] = summary[data_item.reference][:total] /\n summary[data_item.reference][:cost] * 100\n end\n # total\n summary[:TOTAL][data_item.period.to_i] += data_item.total_item_cost\n summary[:TOTAL][:total] += data_item.total_item_cost\n summary[:TOTAL][:cost] = total_cost\n if summary[:TOTAL][:cost] and summary[:TOTAL][:cost] > 0\n summary[:TOTAL][:percentage] = summary[:TOTAL][:total] /\n summary[:TOTAL][:cost] * 100\n end\n end\n end\n\n return summary\n end",
"def find_company_projects_sum\n \t\t# returns a mapping [project name, client info, sum of hours, id]\n \t\tmy_company.projects.map{\n \t\t\t|p|[p.name, p.client, p.entries.reduce(0) do |sum, entry| \n \t\t\t\t\tsum = sum + entry.hours \n \t\t\t\tend, p.id\n \t\t\t]\n \t\t}\n \tend",
"def combined_projects\n self.projects + self.owned_projects + self.all_teams.map(&:projects).flatten(1)\n end",
"def get_pending_bucks\n\t\t\t jobcode = self.job_id\n\t\t\t approve_for = ::Department.where('bucks_approve1 = \\'' + jobcode + '\\' OR bucks_approve2 = \\'' + jobcode + '\\'')\n\t\t\t bucks = Array.new\n\t\t\t approve_for.each { |d| Buck.joins('INNER JOIN employees ON bucks_bucks.issuer_id = employees.IDnum WHERE employees.department_id = ' + d.id.to_s + ' AND bucks_bucks.status = \"Pending\"').each { |b| bucks.push(b) }}\n\t\t\t return bucks\n\t\t\t end",
"def investors\n funds = []\n num_funding_rounds.each do |round| \n funds << round.venture_capitalist\n end\n funds.uniq\n end",
"def project_costs(proj)\n Issue.cross_project_scope(proj, 'descendants')\n .select('spent_on, SUM(hours) AS sum_hours')\n .where(\"#{SQL_COM}\")\n .joins(:time_entries)\n .group(:spent_on)\n .collect { |issue| [issue.spent_on.to_date, issue.sum_hours] }\n end",
"def consolidate_phase_trays(plans)\n tray_plans = []\n plans.each do |p|\n tp = tray_plans.detect { |x| x[:phase] == p[:phase] }\n if tp.present?\n tp[:quantity] += p[:quantity]\n tp[:trays] += p[:trays]\n else\n tray_plans << p\n end\n end\n tray_plans\n end",
"def index\n @project_phase_deliverables = ProjectPhaseDeliverable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @project_phase_deliverables }\n end\n end",
"def investors\n array = FundingRound.all.select do |element|\n element.startup == self\n end\n array2 = array.map do |element|\n element.venture_capitalist\n end\n array2.uniq\n end",
"def investors \n #traverse through all the rounds and identify the rounds related to this startup\n #traverse through the rounds and identify the investors \n #return a unique array \n funding_rounds = FundingRound.all.select do |round|\n round.startup == self \n end\n our_investors = funding_rounds.map do |round| \n round.venture_capitalist\n end\n our_investors.uniq\n end",
"def index\n @project_phases = ProjectPhase.all\n end",
"def display_pending_refund_payments_projects_name\n source.pending_refund_payments_projects.map(&:name).uniq\n end",
"def all_expense_items\n owing_expense_items + paid_expense_items\n end",
"def invested(domain)\n get_total_funds = portfolio.map do |startup| \n if startup.domain == domain\n startup.total_funds\n end\n end\n final_fund = get_total_funds.compact\n final_fund.inject{|sum, el| sum + el}\n end",
"def projects_charge_accounts(_projects)\n _array = []\n _ret = nil\n\n # Adding charge accounts belonging to current projects\n _ret = ChargeAccount.expenditures.where(project_id: _projects)\n ret_array(_array, _ret, 'id')\n # _projects.each do |i|\n # _ret = ChargeAccount.expenditures.where(project_id: i.id)\n # ret_array(_array, _ret, 'id')\n # end\n\n # Adding global charge accounts belonging to projects organizations\n _sort_projects_by_organization = _projects.sort { |a,b| a.organization_id <=> b.organization_id }\n _previous_organization = _sort_projects_by_organization.first.organization_id\n _sort_projects_by_organization.each do |i|\n if _previous_organization != i.organization_id\n # when organization changes, process previous\n _ret = ChargeAccount.expenditures.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n _previous_organization = i.organization_id\n end\n end\n # last organization, process previous\n _ret = ChargeAccount.expenditures.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n\n # Returning founded charge accounts\n _ret = ChargeAccount.where(id: _array).order(:account_code)\n end",
"def projects_charge_accounts(_projects)\n _array = []\n _ret = nil\n\n # Adding charge accounts belonging to current projects\n _ret = ChargeAccount.expenditures.where(project_id: _projects)\n ret_array(_array, _ret, 'id')\n # _projects.each do |i|\n # _ret = ChargeAccount.expenditures.where(project_id: i.id)\n # ret_array(_array, _ret, 'id')\n # end\n\n # Adding global charge accounts belonging to projects organizations\n _sort_projects_by_organization = _projects.sort { |a,b| a.organization_id <=> b.organization_id }\n _previous_organization = _sort_projects_by_organization.first.organization_id\n _sort_projects_by_organization.each do |i|\n if _previous_organization != i.organization_id\n # when organization changes, process previous\n _ret = ChargeAccount.expenditures.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n _previous_organization = i.organization_id\n end\n end\n # last organization, process previous\n _ret = ChargeAccount.expenditures.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n\n # Returning founded charge accounts\n _ret = ChargeAccount.where(id: _array).order(:account_code)\n end",
"def get_same_stock_deliverable_types\n StockDeliverableType.find_all_by_deliverable_type_id(self.deliverable_type_id)\n end",
"def completed_transfer_items\n transfer_items.joins(transfer: :shipment).merge(Shipment.complete)\n end",
"def project_stores(_project)\n _array = []\n _stores = nil\n\n # Adding global stores, not JIT, belonging to current project's company\n if !_project.company.blank?\n _stores = Store.where(\"company_id = ? AND office_id IS NULL AND supplier_id IS NULL\", _project.company_id)\n elsif session[:company] != '0'\n _stores = Store.where(\"company_id = ? AND office_id IS NULL AND supplier_id IS NULL\", session[:company].to_i)\n else\n _stores = session[:organization] != '0' ? Store.where(\"organization_id = ? AND office_id IS NULL AND supplier_id IS NULL\", session[:organization].to_i) : Store.all\n end\n ret_array(_array, _stores)\n # Adding stores belonging to current project\n if !_project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(company_id = ? AND office_id = ?)\", _project.company.id, _project.office.id)\n elsif !_project.company.blank? && _project.office.blank?\n _stores = Store.where(\"(company_id = ?)\", _project.company.id)\n elsif _project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(office_id = ?)\", _project.office.id)\n else\n _stores = stores_dropdown\n end\n ret_array(_array, _stores)\n # Adding JIT stores\n _ret = session[:organization] != '0' ? Store.where(\"organization_id = ? AND company_id IS NULL AND NOT supplier_id IS NULL\", session[:organization].to_i) : Store.where(\"(company_id IS NULL AND NOT supplier_id IS NULL)\")\n ret_array(_array, _ret)\n # Returning founded stores\n _stores = Store.where(id: _array).order(:name)\n end",
"def investors #YAS\n arr = FundingRound.all.select do |f|\n f.startup == self\n # binding.pry\n end\n arr.collect do |f|\n f.venture_capitalist.name\n end.uniq\n end",
"def investors\n test1 = FundingRound.all.select {|round| round.startup == self.name}.map do |name|\n name.venture_capitalist\n end\n test1.uniq\n\n #longer method using .each *not recommend \n # test1 = [] #test1 is the new array that will store the return values\n # @array1.each do |name| \n # test1.push(name.venture_capitalist) #we have to push it somewhere.. since .each will not push anything for us by default... \n # end\n # test1.uniq \n end",
"def portfolio\n FundingRound.all.map do |funding_round| \n if funding_round.venture_capitalist == self\n funding_round\n end\n end\n end",
"def export_project(project)\n return [\n project.id,\n project.name,\n project.description,\n project.homepage,\n project.is_public ? 1 : 0,\n project.parent ? project.parent.identifier : nil,\n project.created_on ? project.created_on.strftime('%Y-%m-%d %H:%M:%S') : nil,\n project.updated_on ? project.updated_on.strftime('%Y-%m-%d %H:%M:%S') : nil,\n project.identifier,\n project.status,\n project.enabled_module_names * ',',\n project.trackers.collect(&:name) * ',',\n project.issue_custom_fields.collect(&:name) * ',',\n ]\n end",
"def check_by_project\n _r = false\n # global_project_breakdown returns multidimensional array containing different project in each line\n # Each line contains 5 elements: Project Id, max_order_total, max_order_price, Net amount sum by project & Item net price\n a = global_project_breakdown(purchase_order_items.order(:project_id))\n d = a.detect { |f| (f[1] > 0 && (f[3] > f[1])) || (f[2] > 0 && (f[4] > f[2])) }\n _r = d.nil? ? false : true\n end",
"def charged_so_far\n charges = stages.collect{ |pr| pr.charged_so_far }.sum\n invoices.collect{ |inv| inv.total }.sum + charges\n end",
"def investors\n funding_rounds.map{|fr| fr.venture_capitalist}.uniq\n end",
"def available_missions\n budget_missions - contracts.independent.includes(:mission).inject([]) do |m, c|\n (c.mission.repeatable? or c.status.to_sym == :failed)? m : m.push(c.mission)\n end.flatten\n end",
"def ring_projects\n @ring_projects ||= [\n ObsProject.new(\"#{name}#{RINGS_PREFIX}0-Bootstrap\", '0'),\n ObsProject.new(\"#{name}#{RINGS_PREFIX}1-MinimalX\", '1'),\n ObsProject.new(\"#{name}#{RINGS_PREFIX}2-TestDVD\", '2') ]\n end",
"def delivered_products\n @delivered_products ||= begin\n products = order['OrderDetails']['OrderRows']\n products.each do |ol|\n if ol['OrderRowId'].to_s == line_id.to_s\n ol['QuantityToDeliver'] = quantity\n ol['PackageId'] = track_and_trace_reference\n end\n\n if ol['ProductId'] == 'Postage'\n ol['QuantityToDeliver'] = 1\n ol['PackageId'] = track_and_trace_reference\n end\n end\n products.collect do |pr|\n pr.slice 'OrderRowId', 'QuantityToDeliver', 'PackageId'\n end\n end\n end",
"def get_projected_accounts\n\t\t #@projected_accounts_info = Hash[ACCOUNT_INFO.dup.find_all{|k,v| v[:discretionary]}]\n\t\t #@projected_accounts_info = accounts_with_projections(@projected_accounts_info)\n\t\t #@projected_accounts_info = @accounts.find_all{|acc| info = ACCOUNT_INFO[acc.name] and info[:discretionary]} \n projected_accounts = @accounts.find_all{|acc| acc.info and acc.info[:discretionary]}\n @projected_accounts_info = accounts_with_projections(projected_accounts)\n\tend",
"def subtotals\n x = {}\n charges.each do |r|\n x[r.product_code] ||= 0.to_f\n x[r.product_code] += r.total_cost.to_f\n end\n return x\n end",
"def orders_completed\n # TODO:\n # How about service ?\n result = Array.new\n self.jobs.unscoped.each do |j|\n j.orders.each do |o|\n if !o.workspace.blank?\n result << o if o.workspace.completed?\n end\n end\n end\n result\n end",
"def crew_booking_job_request_package \n \n \n job_requests_package = {}\n self.crews.each do |crew|\n job_requests_package[crew.id] = JobRequest.joins(:project).where(\n :user_id => crew.id, :is_canceled => false ,\n :project => {:is_finished => false })\n end\n \n return job_requests_package\n end",
"def total_funds #YES\n startup_arr = FundingRound.all.select do |f|\n f.startup == self\n end\n startup_arr.collect do |s|\n s.investment\n end.sum \n end",
"def investors\n self.funding_rounds.map {|fr| fr.venture_capitalist}.uniq\n end",
"def show\n @project_promises = ProjectPromise.where(\"project_id= ?\",@project.id)\n @project_fundings = ProjectFunding.where(\"project_id= ?\",@project.id)\n @sum = ProjectFunding.where(\"project_id= ?\",@project.id).where(\"accepted= ?\", true).sum(:amount)\n end",
"def projects\n investigation.try(:projects) || []\n end",
"def cross_project\n []\n end",
"def projects_charge_accounts(_projects)\n _array = []\n _ret = nil\n\n # Adding charge accounts belonging to current projects\n _ret = ChargeAccount.incomes.where(project_id: _projects)\n ret_array(_array, _ret, 'id')\n\n # Adding global charge accounts belonging to projects organizations\n _sort_projects_by_organization = _projects.sort { |a,b| a.organization_id <=> b.organization_id }\n _previous_organization = _sort_projects_by_organization.first.organization_id\n _sort_projects_by_organization.each do |i|\n if _previous_organization != i.organization_id\n # when organization changes, process previous\n _ret = ChargeAccount.incomes.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n _previous_organization = i.organization_id\n end\n end\n # last organization, process previous\n _ret = ChargeAccount.incomes.where('(project_id IS NULL AND charge_accounts.organization_id = ?)', _previous_organization)\n ret_array(_array, _ret, 'id')\n\n # Returning founded charge accounts\n _ret = ChargeAccount.where(id: _array).order(:account_code)\n end",
"def service_orders_completed\n result = Array.new\n self.services.each do |s|\n s.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end",
"def packages_with_advisories\n @packages_with_advisories ||= ReleaseComponent.includes(:package)\\\n .where('errata_id != ? AND errata_id IN (?)', @errata, @errata.release.errata)\\\n .map{|m| [m.package.name, m.package.id]}\\\n .flatten.uniq\n end",
"def get_products_bought\n res = []\n\n @data.product_qty.each do |prd_id, qty|\n qty = qty.to_i\n if qty > 0\n res << [ qty, @data.products.with_id(prd_id) ]\n end\n end\n\n res\n end",
"def active_projects\n self.projects.where(:is_canceled => false, :is_finished => false )\n end",
"def big_investors\n self.investors.select {|vc| vc.tres_commas_club}\n end",
"def work_packages\n @work_packages ||= {\n '1' => FacilitiesManagement::RM6232::WorkPackage.selectable.map { |work_package| work_package.supplier_services.where(total: true, core: false) }.reject(&:empty?),\n '2' => FacilitiesManagement::RM6232::WorkPackage.selectable.map { |work_package| work_package.supplier_services.where(hard: true, core: false) }.reject(&:empty?),\n '3' => FacilitiesManagement::RM6232::WorkPackage.selectable.map { |work_package| work_package.supplier_services.where(soft: true, core: false) }.reject(&:empty?)\n }\n end",
"def vendor\n @shipments = Spree::Shipment.where(stock_location_id: current_spree_user.stock_locations.first.id, state: \"pending\").joins(:order).where(spree_orders: {state: 'complete'}).order(created_at: :asc)\n end",
"def index\n @projects = (Project.includes(:users).includes(:owner).includes(:errands).where(owner: current_user.id) + current_user.projects.includes(:owner).includes(:users).includes(:errands)).uniq\n end",
"def game_companies\n comps = []\n add_entities(comps, UNIT1_COMPANIES) if @units[1]\n add_entities(comps, UNIT3_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[3]\n add_entities(comps, UNIT2_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[2]\n comps\n end",
"def projects_stores(_projects)\n _array = []\n _ret = nil\n\n # Adding global stores, not JIT, belonging to current company\n if session[:company] != '0'\n _ret = Store.where(\"company_id = ? AND office_id IS NULL AND supplier_id IS NULL\", session[:company].to_i)\n else\n _ret = session[:organization] != '0' ? Store.where(\"organization_id = ? AND office_id IS NULL AND supplier_id IS NULL\", session[:organization].to_i) : Store.all\n end\n ret_array(_array, _ret)\n\n # Adding stores belonging to current projects (projects have company and office)\n _projects.each do |i|\n if !i.company.blank? && !i.office.blank?\n _ret = Store.where(\"(company_id = ? AND office_id = ?)\", i.company_id, i.office_id)\n elsif !i.company.blank? && i.office.blank?\n _ret = Store.where(\"(company_id = ?)\", i.company_id)\n elsif i.company.blank? && !i.office.blank?\n _ret = Store.where(\"(office_id = ?)\", i.office_id)\n end\n ret_array(_array, _ret)\n end\n\n # Adding JIT stores\n _ret = session[:organization] != '0' ? Store.where(\"organization_id = ? AND company_id IS NULL AND NOT supplier_id IS NULL\", session[:organization].to_i) : Store.where(\"(company_id IS NULL AND NOT supplier_id IS NULL)\")\n ret_array(_array, _ret)\n\n # Returning founded stores\n _ret = Store.where(id: _array).order(:name)\n end",
"def find_team_values\n #sets the total investments as an empty hash\n team_investments = {}\n #iterates through every team\n @teams.each do |team, value|\n #initializes the value for the team\n investment_values = 0\n #finds every investment for the team\n Investment.where(team_id: team.id).each do |i|\n #only adds the investment if it is in the selected quarter\n Feature.find(i.feature_id).quater == @quater ? investment_values += i.investment : a=0\n end\n team_investments[team.id] = investment_values\n end\n return team_investments\n end",
"def dump_projects_harvest\n projects = pull_projects_harvest()\n projects.each do |project|\n same_project = FetchData.where(resource_original_id: project[\"id\"], source: 'harvest', resource: 'project').to_a\n if same_project.length == 0\n FetchData.create!(user_id: user_id, source_user_id: get_user_id_harvest(), resource_original_id: project[\"id\"], payload: project, source: 'harvest', resource: 'project')\n else\n FetchData.where(resource_original_id: project[\"id\"], source: 'harvest', resource: 'project').update(payload: project)\n end\n end\n end",
"def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end",
"def invested(domain)\n #binding.pry\n funding_rounds.select{|fr| fr.startup.domain == domain}.map{|fr| fr.investment}.sum\n end",
"def available_delivery_services\n delivery_service_prices.map(&:delivery_service).uniq\n end",
"def pending_start_projects\n self.projects.where(:is_canceled => false, :is_started => false ).order(\"shoot_date ASC\")\n end",
"def projects_charge_accounts(_projects)\n _array = []\n _ret = nil\n\n # Adding charge accounts belonging to current projects\n _ret = ChargeAccount.where(project_id: _projects)\n ret_array(_array, _ret)\n # _projects.each do |i|\n # _ret = ChargeAccount.where(project_id: i.id)\n # ret_array(_array, _ret)\n # end\n\n # Adding global charge accounts\n _ret = ChargeAccount.where('project_id IS NULL')\n ret_array(_array, _ret)\n\n # Returning founded charge accounts\n _ret = ChargeAccount.where(id: _array).order(:account_code)\n end",
"def projects_charge_accounts(_projects)\n _array = []\n _ret = nil\n\n # Adding charge accounts belonging to current projects\n _ret = ChargeAccount.where(project_id: _projects)\n ret_array(_array, _ret)\n # _projects.each do |i|\n # _ret = ChargeAccount.where(project_id: i.id)\n # ret_array(_array, _ret)\n # end\n\n # Adding global charge accounts\n _ret = ChargeAccount.where('project_id IS NULL')\n ret_array(_array, _ret)\n\n # Returning founded charge accounts\n _ret = ChargeAccount.where(id: _array).order(:account_code)\n end",
"def get_portfolio\n return self.total_value_in_stocks + self.balance\n end",
"def bi_total_date(_project, _from, _to, _group)\n if _group.nil?\n budget_items.joins(:budget).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ?\",_project,_from,_to).select('SUM(budget_items.amount) bi_t')\n else\n budget_items.joins(:budget,:charge_account).where(\"budgets.project_id in (?) AND budgets.approval_date >= ? AND budgets.approval_date <= ? AND charge_accounts.charge_group_id = ?\",_project,_from,_to, _group).select('SUM(budget_items.amount) bi_t')\n end\n end",
"def index\n @projects = Project.find(:all, :conditions => \"status = 'Active'\")\n @phases = ProjectPhase.find(:all, :conditions => {:projects => {:status => \"Active\"}}, :joins => [:project])\n @deliverables = Deliverable.find(:all, :conditions => {:project_phases => {:projects => {:status => \"Active\"}}}, :joins => [:project_phase => :project])\n\n if is_developer\n @efforts = Effort.find(:all, :conditions => ['user_id = ?', current_user.id])\n else\n @efforts = Effort.find(:all)\n end\n @efforts.sort! { |a,b| b.effort_date <=> a.effort_date }\n @effort = Effort.new\n\n respond_to do |format|\n format.html\n end\n end",
"def financialReport\n result = []\n channels = ActiveRecord::Base.connection.execute(\"select distinct purchase_channel from orders;\")\n channels.each do |channel|\n orders_per_channel = Order.where([\"purchase_channel = ?\", channel['purchase_channel']])\n sum_total_value = orders_per_channel.inject(0) {|sum, hash| sum + hash[:total_value]}\n result << {purchase_channel: channel['purchase_channel'], orders_count: orders_per_channel.count, sum_total_value: sum_total_value}\n end\n render json: result, status: :ok\n end",
"def item_totals_for_inventories\n\t\tresult = []\n\t\tInventory.includes(:items).all.each do |i|\n\t\t\tentry = { :name => i.name, :data => { } }\n\t\t\ti.holdings.each { |h| entry[:data] = entry[:data].merge({ h.item.name => h.quantity }) }\n\t\t\tresult << entry\n\t\tend\n\t\tresult\n\tend",
"def invested(web)\n arr = []\n funding_rounds.select do |s|\n if s.startup.domain == web\n arr << s.investment\n end\n end\n arr.sum\n end",
"def project_stores(_project)\n _array = []\n _stores = nil\n\n # Adding stores belonging to current project only\n # Stores with exclusive office\n if !_project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(company_id = ? AND office_id = ?)\", _project.company.id, _project.office.id)\n elsif !_project.company.blank? && _project.office.blank?\n _stores = Store.where(\"(company_id = ?)\", _project.company.id)\n elsif _project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(office_id = ?)\", _project.office.id)\n else\n _stores = nil\n end\n ret_array(_array, _stores, 'id')\n # Stores with multiple offices\n if !_project.office.blank?\n _stores = StoreOffice.where(\"office_id = ?\", _project.office.id)\n ret_array(_array, _stores, 'store_id')\n end\n\n # Returning founded stores\n _stores = Store.where(id: _array).order(:name)\n end",
"def project_stores(_project)\n _array = []\n _stores = nil\n\n # Adding stores belonging to current project only\n # Stores with exclusive office\n if !_project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(company_id = ? AND office_id = ?)\", _project.company.id, _project.office.id)\n elsif !_project.company.blank? && _project.office.blank?\n _stores = Store.where(\"(company_id = ?)\", _project.company.id)\n elsif _project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(office_id = ?)\", _project.office.id)\n else\n _stores = nil\n end\n ret_array(_array, _stores, 'id')\n # Stores with multiple offices\n if !_project.office.blank?\n _stores = StoreOffice.where(\"office_id = ?\", _project.office.id)\n ret_array(_array, _stores, 'store_id')\n end\n\n # Returning founded stores\n _stores = Store.where(id: _array).order(:name)\n end",
"def project_stores(_project)\n _array = []\n _stores = nil\n\n # Adding stores belonging to current project only\n # Stores with exclusive office\n if !_project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(company_id = ? AND office_id = ?)\", _project.company.id, _project.office.id)\n elsif !_project.company.blank? && _project.office.blank?\n _stores = Store.where(\"(company_id = ?)\", _project.company.id)\n elsif _project.company.blank? && !_project.office.blank?\n _stores = Store.where(\"(office_id = ?)\", _project.office.id)\n else\n _stores = nil\n end\n ret_array(_array, _stores, 'id')\n # Stores with multiple offices\n if !_project.office.blank?\n _stores = StoreOffice.where(\"office_id = ?\", _project.office.id)\n ret_array(_array, _stores, 'store_id')\n end\n\n # Returning founded stores\n _stores = Store.where(id: _array).order(:name)\n end",
"def investors\n array = FundingRound.all.select {|round| round.startup == self.name}\n test1 = array.map do |name|\n name.venture_capitalist\n end\n test1.uniq #output only the unique names *takes account for duplicate funding_round ppl\n\n #longer method using .each *not recommend \n # test1 = [] #test1 is the new array that will store the return values\n # @array1.each do |name| \n # test1.push(name.venture_capitalist) #we have to push it somewhere.. since .each will not push anything for us by default... \n # end\n # test1.uniq \n end",
"def display_pending_refund_payments_projects_name\n object.pending_refund_payments_projects.map(&:name).uniq\n end",
"def index\n @incomplete_carts = Cart.where( purchase_completed: false )\n @completed_carts = Cart.where( purchase_completed: true )\n end",
"def investors\n self.funding_rounds.collect do |funding_round|\n funding_round.venture_capitalist\n end.uniq\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def gather_releases_by_subgenre(subgenre)\n check = self.releases \n collected = [] \n self.releases.each do |release|\n collected << release if release.subgenre == subgenre\n end\n collected \n end",
"def sum_produits_stock\n sum = 0\n self.protofactures.each { |p| sum += p.prix_unit * p.stock }\n sum\n end",
"def get_projects\n\n @user_activity_line_item_filter = current_user.user_activity_line_item_filter\n\n # Start to set up the query\n conditions = []\n values = []\n\n #-----------------------------------------------------------------------------\n #\n # Steps\n #\n #\n # 1. parameters on assets within ALIs\n # 2. parameters on ALIs within projects\n # 3. parameters on projects\n #\n # 1. Search for assets that meet given parameters (type, subtype, etc.) Returns all ALIs with those assets.\n # 2. Given ALIs from above, return subset that meet ALI parameters. Get projects from that subset.\n # 3. Given projects from above return all projects that meet project parameters.\n #\n #-----------------------------------------------------------------------------\n\n # Use ALI as the base relation to deal with asset & ALI filters\n @alis = ActivityLineItem.active.distinct\n no_ali_or_asset_params_exist = true\n\n #-----------------------------------------------------------------------------\n # Asset parameters\n #-----------------------------------------------------------------------------\n\n # Filter by asset type and subtype. Requires joining across CP <- ALI <- ALI-Assets <- Assets\n asset_search = Hash.new\n asset_table = Rails.application.config.asset_base_class_name.constantize.table_name\n asset_search[asset_table.to_sym] = Hash.new\n\n if @user_activity_line_item_filter.try(:asset_subtypes).present?\n @asset_subtype_filter = @user_activity_line_item_filter.asset_subtypes.split(',')\n\n asset_search[asset_table.to_sym][:asset_subtype_id] = @asset_subtype_filter\n no_ali_or_asset_params_exist = false\n elsif @user_activity_line_item_filter.try(:asset_types).present? && (Rails.application.config.asset_base_class_name.constantize.column_names.include? :asset_type_id)\n @asset_subtype_filter = AssetSubtype.where(asset_type_id: @user_activity_line_item_filter.asset_types.split(',')).pluck(:id)\n asset_search[asset_table.to_sym][:asset_subtype_id] = @asset_subtype_filter\n no_ali_or_asset_params_exist = false\n end\n\n if @user_activity_line_item_filter.try(:fta_asset_classes).present?\n asset_search[:transit_assets] = {fta_asset_class_id: @user_activity_line_item_filter.fta_asset_classes.split(',')}\n no_ali_or_asset_params_exist = false\n end\n\n # filter by backlog\n if @user_activity_line_item_filter.try(:in_backlog)\n asset_search[asset_table.to_sym][:in_backlog] = true\n no_ali_or_asset_params_exist = false\n end\n\n if @user_activity_line_item_filter.try(:asset_query_string)\n asset_search[asset_table.to_sym][:object_key] = Rails.application.config.asset_base_class_name.constantize.find_by_sql(@user_activity_line_item_filter.asset_query_string).map{|x| x.object_key}\n no_ali_or_asset_params_exist = false\n end\n\n unless asset_search[asset_table.to_sym].empty? && asset_search.keys.count == 1\n\n asset_search[asset_table.to_sym][:organization_id] = @organization_list\n\n @alis = @alis.joins(:assets).where(asset_search)\n\n if Rails.application.config.asset_base_class_name == 'TransamAsset'\n @alis = @alis.joins(\"INNER JOIN `transit_assets` ON `transam_assets`.`transam_assetible_id` = `transit_assets`.`id` AND `transam_assets`.`transam_assetible_type` = 'TransitAsset'\")\n end\n end\n #-----------------------------------------------------------------------------\n\n\n #-----------------------------------------------------------------------------\n # CapitalProject specific\n #-----------------------------------------------------------------------------\n # get the projects based on filtered ALIs\n\n # dont impose ALI/asset conditions unless they were in the params\n @projects = CapitalProject.active.includes(:capital_project_type,:team_ali_code)\n unless no_ali_or_asset_params_exist\n @projects = CapitalProject.includes(:capital_project_type,:team_ali_code).where(id: @alis.distinct(:capital_project_id).pluck(:capital_project_id))\n end\n\n # org id is not tied to ALI filter\n # org id is used in scheduler though not necessary but all links specify looking at a single org at a time\n # other functionality like planning does not require\n if params[:org_id].blank?\n conditions << 'capital_projects.organization_id IN (?)'\n values << @organization_list\n else\n @org_id = params[:org_id].to_i\n conditions << 'capital_projects.organization_id = ?'\n values << @org_id\n end\n\n @capital_project_flag_filter = []\n\n capital_project_types = (@user_activity_line_item_filter.try(:capital_project_type_id).blank? ? [] : [@user_activity_line_item_filter.capital_project_type_id] )\n sogr_types = []\n if @user_activity_line_item_filter.try(:sogr_type) == 'SOGR'\n sogr_types = [CapitalProjectType.find_by(name: 'Replacement').id]\n conditions << 'capital_projects.sogr = ?'\n values << true\n elsif @user_activity_line_item_filter.try(:sogr_type) == 'Non-SOGR'\n conditions << 'capital_projects.sogr = ?'\n values << false\n end\n\n @capital_project_type_filter = (capital_project_types & sogr_types)\n unless @capital_project_type_filter.empty?\n conditions << 'capital_projects.capital_project_type_id IN (?)'\n values << @capital_project_type_filter\n end\n\n # TEAM ALI code\n if @user_activity_line_item_filter.try(:team_ali_codes).blank?\n @team_ali_code_filter = []\n else\n @team_ali_code_filter = @user_activity_line_item_filter.team_ali_codes.split(',')\n\n conditions << 'capital_projects.team_ali_code_id IN (?)'\n values << @team_ali_code_filter\n end\n\n if @user_activity_line_item_filter.try(:planning_year)\n @fy_year_filter = [current_planning_year_year]\n\n conditions << 'capital_projects.fy_year IN (?)'\n values << @fy_year_filter\n else\n @fy_year_filter = []\n end\n\n # District\n if @user_activity_line_item_filter.try(:districts).blank?\n @district_filter = []\n else\n @district_filter = @user_activity_line_item_filter.districts.split(',')\n conditions << 'capital_projects.id IN (SELECT DISTINCT capital_projects_districts.capital_project_id FROM capital_projects_districts WHERE capital_projects_districts.district_id IN (?))'\n values << @district_filter\n end\n\n #-----------------------------------------------------------------------------\n\n\n #-----------------------------------------------------------------------------\n # Parse non-common filters\n # filter values come from request params\n\n @fiscal_year_filter = params[:fiscal_year_filter]\n\n if @fiscal_year_filter.blank?\n @fiscal_year_filter = []\n else\n conditions << 'capital_projects.fy_year IN (?)'\n values << @fiscal_year_filter\n end\n #-----------------------------------------------------------------------------\n\n # final results\n @projects = @projects.joins(:organization).where(conditions.join(' AND '), *values).order('organizations.short_name', :fy_year, :project_number)\n\n @alis = ActivityLineItem.where(capital_project_id: @projects.ids)\n end",
"def backed_projects \n self.project_backers.map do |projectbacker| \n projectbacker.project\n end\n end",
"def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end",
"def getDeliverableTypeList(lifecycle_phase)\n return DeliverableType.find_all_by_lifecycle_phase_id(lifecycle_phase)\n end",
"def projects\n return [] unless basecamp\n @projects ||= basecamp.projects\n end",
"def invoice_items_report\n detailed = params[:detailed]\n project = params[:project]\n @from = params[:from]\n @to = params[:to]\n supplier = params[:supplier]\n order = params[:order]\n account = params[:account]\n product = params[:product]\n\n if project.blank?\n init_oco if !session[:organization]\n # Initialize select_tags\n @projects = projects_dropdown if @projects.nil?\n # Arrays for search\n current_projects = @projects.blank? ? [0] : current_projects_for_index(@projects)\n project = current_projects.to_a\n end\n\n # Dates are mandatory\n if @from.blank? || @to.blank?\n return\n end\n\n # Format dates\n from = Time.parse(@from).strftime(\"%Y-%m-%d\")\n to = Time.parse(@to).strftime(\"%Y-%m-%d\")\n\n #SupplierInvoice.joins(:supplier_invoice_approvals,:supplier_invoice_items)\n\n if !project.blank? && !supplier.blank? && !order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.work_order_id = ? AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,order,account,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && !order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.work_order_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,order,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && !order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.work_order_id = ? AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,order,account,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,account,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && !order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.work_order_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,order,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && !order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.work_order_id = ? AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,order,account,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && !order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.work_order_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,order,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,account,from,to).order(:invoice_date)\n elsif !project.blank? && !supplier.blank? && order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.supplier_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,supplier,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && !order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.work_order_id = ? AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,order,account,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && !order.blank? && account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.work_order_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,order,from,to).order(:invoice_date)\n elsif !project.blank? && supplier.blank? && order.blank? && !account.blank?\n @invoice_items_report = SupplierInvoiceItem.joins(:supplier_invoice).where(\"supplier_invoices.project_id in (?) AND supplier_invoices.charge_account_id = ? AND supplier_invoices.invoice_date >= ? AND supplier_invoices.invoice_date <= ?\",project,account,from,to).order(:invoice_date)\n end\n\n\n # Setup filename\n title = t(\"activerecord.models.supplier_invoice.few\") + \"_#{from}_#{to}.pdf\"\n\n respond_to do |format|\n # Render PDF\n if !@invoice_items_report.blank?\n format.pdf { send_data render_to_string,\n filename: \"#{title}.pdf\",\n type: 'application/pdf',\n disposition: 'inline' }\n format.csv { send_data SupplierInvoiceItem.to_report_invoices_csv(@invoice_items_report),\n filename: \"#{title}.csv\",\n type: 'application/csv',\n disposition: 'inline' }\n else\n format.csv { redirect_to ag2_purchase_track_url, alert: I18n.t(\"ag2_purchase.ag2_purchase_track.index.error_report\") }\n format.pdf { redirect_to ag2_purchase_track_url, alert: I18n.t(\"ag2_purchase.ag2_purchase_track.index.error_report\") }\n end\n end\n end",
"def projects\n PivotalTracker::Project.all\n end",
"def ring_projects\n @ring_projects ||= strategy.rings.each_with_index.map do |r,idx|\n ObsProject.new(\"#{rings_project_name}:#{idx}-#{r}\", \"#{idx}-#{r}\")\n end\n end",
"def known_omnibus_projects\n # iterate through min/max versions for all product names\n # and collect the name for both versions\n projects = %w{ 0.0.0 1000.1000.1000 }.collect do |v|\n @version = v\n omnibus_project\n end\n # remove duplicates and return multiple known names or return the single\n # project name\n projects.uniq || projects\n end",
"def show\n\t@projects = Array.new\n @statusreport = current_user.organization.statusreports.find(params[:id])\n # @projects = @statusreport.projects(:order=>'priority ASC').with_deleted\n @project_id = @statusreport.projects(:order=>'priority').with_deleted\n\n\t@project_id.each do |id|\n @projects << LineItem.find_by_project_id_and_statusreport_id(id,@statusreport)\n\n @projects.sort! { |a,b| b.priority.to_s <=> a.priority.to_s }\n\tend\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @statusreport }\n end\n end",
"def get_data_from_result_list(capital_project_list)\n\n # Capital Needs by year\n a = []\n labels = [get_fiscal_year_label]\n labels << \"Capital Needs\"\n\n # Get a unique list of capital project ids\n capital_project_ids = capital_project_list.pluck(:id).uniq\n\n (current_planning_year_year..last_fiscal_year_year).each do |year|\n row = []\n row << fiscal_year(year)\n # get the capital projects for this analysis year and state\n alis = ActivityLineItem.where('fy_year = ? AND capital_project_id IN (?)', year, capital_project_ids)\n total = alis.sum(ActivityLineItem::COST_SUM_SQL_CLAUSE)\n row << total\n a << row\n end\n\n return {:labels => labels, :data => a, table_labels: labels, table_data: a, chart_labels: labels, chart_data: a} \n\n end"
] | [
"0.65836674",
"0.6328863",
"0.6298275",
"0.60927415",
"0.60913974",
"0.60671175",
"0.6051786",
"0.60024947",
"0.59516114",
"0.58622426",
"0.5858245",
"0.58278084",
"0.57256776",
"0.5671447",
"0.56512403",
"0.55656505",
"0.554246",
"0.5535978",
"0.55007213",
"0.54706866",
"0.54595196",
"0.54362434",
"0.54050815",
"0.5373351",
"0.53617066",
"0.5353884",
"0.5347255",
"0.53424895",
"0.53227526",
"0.5317603",
"0.531582",
"0.531582",
"0.5305006",
"0.5304631",
"0.5299778",
"0.52967167",
"0.528657",
"0.52854025",
"0.52833086",
"0.52760905",
"0.5251683",
"0.52407444",
"0.5238632",
"0.5237849",
"0.52120006",
"0.52093905",
"0.52066034",
"0.5203461",
"0.52025247",
"0.5199386",
"0.5189831",
"0.5189629",
"0.5185034",
"0.5171231",
"0.5169723",
"0.5161192",
"0.5158947",
"0.5143626",
"0.5137103",
"0.51342434",
"0.513133",
"0.5127608",
"0.51217353",
"0.51165694",
"0.5111463",
"0.5107545",
"0.5103365",
"0.51015013",
"0.50950783",
"0.5094199",
"0.50897986",
"0.50834113",
"0.50834113",
"0.50831103",
"0.50792515",
"0.507776",
"0.50735813",
"0.50687355",
"0.5064828",
"0.50615704",
"0.50615704",
"0.50615704",
"0.5060545",
"0.50589657",
"0.50520355",
"0.5037862",
"0.5031386",
"0.5030314",
"0.5028471",
"0.5028283",
"0.50162554",
"0.50089335",
"0.5007334",
"0.5001834",
"0.49966338",
"0.4995508",
"0.4989407",
"0.49877355",
"0.49838844",
"0.4983632"
] | 0.806633 | 0 |
gets the current theme or returns default if it comes back blank | def get_theme
use_theme = Preference.get_setting('CURRENT_THEME')
(use_theme == '' ? 'default' : use_theme).downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_theme\n nil\n end",
"def get_theme\n\t\tif @current_user and @current_user.theme\n\t\t\t@current_theme = @current_user.theme.css_class\n\t\telse\n\t\t\t@current_theme = \"pond\"\n\t\tend\n\tend",
"def theme\n @theme || 'plastik'\n end",
"def current_theme(passed_theme = nil)\n theme_name = unless passed_theme .blank?\n passed_theme\n else\n current_blog_user ? current_blog_user.blog_config.theme_name : ''\n end\n Theme.find(theme_name)\n end",
"def theme\n return @theme\n end",
"def current_theme(passed_theme = nil)\n @current_theme ||= get_current_theme(passed_theme)\n end",
"def theme\n Design::Theme.array.find_by_name(self.theme_name) || site.theme\n end",
"def current_theme\n account_prefix\n end",
"def theme\n @theme\n end",
"def current_theme(passed_theme=nil)\n theme = passed_theme || self.class.read_inheritable_attribute(\"theme\")\n \n @active_theme = case theme\n when Symbol then send(theme)\n when Proc then theme.call(self)\n when String then theme\n end\n end",
"def theme\n options.fetch(:theme, nil)\n end",
"def theme\n @theme ||= resource.cache.theme(theme_id)\n end",
"def parent_theme\n ThemesForRails.config.parent_theme(current_theme)\n end",
"def for_user(user)\n if user\n by_id(user.theme_id)\n else\n default\n end\n end",
"def theme_name\n if params[:action] == \"home\"\n @theme_name = ThemeOption.where(user_id: current_user.id).first.template.downcase\n else\n \"application\"\n end\n end",
"def theme_settings\n (settings_data ? settings_data['general'].presence : nil) || {}\n end",
"def theme_name\n \n if params[:action] == \"home\"\n @theme_name = ThemeOption.where(user_id: current_user.id).first.template.downcase\n else\n \"application\"\n end\n end",
"def theme; end",
"def theme; end",
"def theme; end",
"def theme_resolver\n theme(current_account.account_prefix) if DmCore.config.enable_themes\n end",
"def get_default\n if self.current_defaults\n self.current_defaults.first\n else\n raise \"Cette instance ne possède de #{self.class.name} par default\"\n end\n end",
"def default_windowskin\n DEFAULT_SKIN\n end",
"def theme=(_arg0); end",
"def get_theme\n @theme = Broadcaster::Theme.find(params[:theme_id])\n end",
"def get_theme\n @theme = Broadcaster::Theme.find(params[:theme_id])\n end",
"def get_theme\n @theme = Broadcaster::Theme.find(params[:theme_id])\n end",
"def by_id(id)\n THEMES.detect { |t| t.id == id } || default\n end",
"def theme=(value)\n @theme = value\n end",
"def theme_path\n \"#{ThemesForRails.config.themes_path}/#{current_theme}\"\n end",
"def theme_name\n if request.subdomain != \"www\" && request.subdomain.present?\n @subdomain = request.subdomain\n @site = Site.where(subdomain: request.subdomain).first\n @user = User.where(id: @site.user_id).first\n @theme_name = ThemeOption.where(site_id: @site.id).first.template\n @theme = ThemeName.where(id: @theme_name).first.name.downcase\n if params[:action] == \"home\"\n @theme\n elsif params[:action] == \"leasing\"\n @theme + \"leasing\"\n end\n else\n \"test\"\n end\n end",
"def get_box_theme(id)\n return @themes[id]\n end",
"def current_windowskin_settings\n if $game_variables != nil\n winvar = YE::SYSTEM::WINDOW_VARIABLE\n if $game_variables[winvar] == 0\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n elsif !MENU_CONFIG::WINDOW_HASH.include?($game_variables[winvar])\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n end\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[$game_variables[winvar]]\n else\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[YE::SYSTEM::DEFAULT_WINDOW]\n end\n return mso_windowskin\n end",
"def current_windowskin_settings\n if $game_variables != nil\n winvar = YE::SYSTEM::WINDOW_VARIABLE\n if $game_variables[winvar] == 0\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n elsif !MENU_CONFIG::WINDOW_HASH.include?($game_variables[winvar])\n $game_variables[winvar] = YE::SYSTEM::DEFAULT_WINDOW\n end\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[$game_variables[winvar]]\n else\n mso_windowskin = MENU_CONFIG::WINDOW_HASH[YE::SYSTEM::DEFAULT_WINDOW]\n end\n return mso_windowskin\n end",
"def name\n theme.name\n end",
"def theme\n @theme ||= Theme.unscoped.find(params[:id])\n halt 404 unless @theme\n @theme\n end",
"def theme_selector themed_object\n unless themed_object.blank?\n @stpl_theme = themed_object.current_theme || StplTheme.new\n render 'stpl_themes/select_theme', :themed_object => themed_object\n else\n raise \"Themed object not found. Please provide object to be themed.\"\n end\n end",
"def initialize(theme = nil)\n @current_theme = theme\n end",
"def default_tab\n if logged_in?\n self.all_tabs[TabConstants::HOME]\n else\n self.all_tabs[TabConstants::ABOUT]\n end\n end",
"def default_color\n return current_layout.default_color\n end",
"def set_theme\n # @theme = Theme.find(params[:id])\n @theme = Theme.current_theme\n end",
"def theme\n {\n variant: {\n name: cookies[:themeVariantName],\n hue: cookies[:themeVariantHue]\n },\n mode: cookies[:themeMode] || \"light\"\n }\n end",
"def get_template\n # Filters the name of the current theme.\n apply_filters('template', get_option('template'))\n end",
"def switch_theme(stylesheet)\n # TS_INFO: Manage themes not implemented\n end",
"def get_raw_theme_root(stylesheet_or_template, skip_cache = false)\n if !Railspress.GLOBAL.wp_theme_directories.kind_of?(Array) || Railspress.GLOBAL.wp_theme_directories.size <= 1\n return '/themes'\n end\n\n theme_root = false\n\n # If requesting the root for the current theme, consult options to avoid calling get_theme_roots()\n if !skip_cache\n if get_option( 'stylesheet' ) == stylesheet_or_template\n theme_root = get_option( 'stylesheet_root' )\n elsif get_option( 'template' ) == stylesheet_or_template\n theme_root = get_option( 'template_root' )\n end\n end\n\n if theme_root.blank?\n theme_roots = get_theme_roots\n if !theme_roots[ stylesheet_or_template ].blank?\n theme_root = theme_roots[ stylesheet_or_template ]\n end\n end\n\n theme_root\n end",
"def theme_data(options = {})\n if options[:parent]\n ThemesForRails.config.themes_data(parent_theme) || {}\n else\n ThemesForRails.config.themes_data(current_theme) || {}\n end\n end",
"def style_default\n lock(:s) do\n @cache[:s][:default] ||= style_new\n end\n end",
"def get_theme\n @theme = Theme.find(params[:theme_id])\n end",
"def select_theme\n theme = nil\n #response.headers['Cache-Control']='private'\n response.headers['Vary'] = 'User-Agent'\n ua = request.user_agent\n force_mobile_format if ua.blank?\n response.headers['Cache-Control'] = 'no-cache' if is_mobile_device?\n @group ||= Group.find(Setting.default_group) if Setting.default_group.present?\n theme = @group.options[:theme] if @group.present? and @group.options.present? and @group.options.include?(:theme)\n end",
"def get_theme_root(stylesheet_or_template = false )\n if stylesheet_or_template && theme_root = get_raw_theme_root(stylesheet_or_template)\n # Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.\n # This gives relative theme roots the benefit of the doubt when things go haywire.\n theme_root = Railspress.WP_CONTENT_DIR + theme_root unless Railspress.GLOBAL.wp_theme_directories.include?(theme_root)\n else\n theme_root = Railspress.WP_CONTENT_DIR + '/themes'\n end\n\n # Filters the absolute path to the themes directory.\n apply_filters( 'theme_root', theme_root )\n end",
"def current_windowskin\n current_layout.windowskin || $game_system.windowskin_name\n end",
"def fetch_random_theme\n url = build_url( :type => :random, :limit => 1 )\n xml = Nokogiri::XML( open(url) ).at( \"//kuler:themeItem\" )\n return Kuler::Theme.new( xml )\n end",
"def theme(theme)\n case theme\n when :dark\n @methods[:theme] = MIDNIGHT\n when :deep\n @methods[:theme] = SUBMARINE\n when :light\n @methods[:theme] = BLUESCALE\n else\n throw ArgumentError.new('Not a valid theme')\n end\n end",
"def update_current_theme(name, options = {})\n self.class.renders_theme(name, options)\n Rails.application.config.theme.name = current_theme_name\n Rails.application.config.theme.layout = current_theme_layout\n ShinyThemes::Engine.theme_config.save unless options[:dont_save]\n self.class.theme # return current theme object\n end",
"def default_color\n return translate_color(current_layout.default_color)\n end",
"def current_windowskin\n @windowskin_overwrite || current_layout.windowskin || $game_system.windowskin_name\n end",
"def default\n on_current_site.find_by(default: true)\n end",
"def get_theme(name, slide_index, password = nil, folder = nil, storage = nil)\n data, _status_code, _headers = get_theme_with_http_info(name, slide_index, password, folder, storage)\n data\n end",
"def default\n find(\"Default\")\n end",
"def fetch_random_theme\n fetch_themes(:type => :random, :limit => 1).first\n end",
"def theme(name)\n @current_theme = name\n path = ThemePark.resolve_views_path(name)\n prepend_view_path path\n end",
"def theme_path\n Rails.root.join('themes', account_prefix)\n end",
"def in_theme?(theme_name=nil)\n File.file? theme_path(theme_name)\n end",
"def theme_path\n File.join(themes_path, theme)\n end",
"def get_theme_root_uri( stylesheet_or_template = false, theme_root = false )\n theme_root = get_raw_theme_root(stylesheet_or_template) if stylesheet_or_template && ! theme_root\n\n if ( stylesheet_or_template && theme_root )\n if Railspress.GLOBAL.wp_theme_directories.nil?\n p \"get_theme_root_uri(#{stylesheet_or_template}, #{theme_root})\"\n end\n if Railspress.GLOBAL.wp_theme_directories.include?(theme_root)\n # Absolute path. Make an educated guess. YMMV -- but note the filter below.\n if theme_root.start_with?(Railspress.WP_CONTENT_DIR)\n theme_root_uri = content_url( theme_root.gsub( WP_CONTENT_DIR, '') )\n elsif theme_root.start_with?(Railspress.ABSPATH)\n theme_root_uri = site_url(theme_root.gsub(Railspress.ABSPATH, ''))\n elsif theme_root.start_with?(Railspress.WP_PLUGIN_DIR) || theme_root.start_with?(Railspress.WPMU_PLUGIN_DIR)\n theme_root_uri = plugins_url( basename( theme_root ), theme_root )\n else\n theme_root_uri = theme_root\n end\n else\n theme_root_uri = content_url( theme_root )\n end\n else\n theme_root_uri = content_url( 'themes' )\n end\n\n # Filters the URI for themes directory.\n apply_filters( 'theme_root_uri', theme_root_uri, get_option( 'siteurl' ), stylesheet_or_template )\n end",
"def default_editor\n # Visual = Advanced editor\n return ENV['VISUAL'] if ENV['VISUAL'] && !ENV['VISUAL'].empty?\n # Editor = basic editor\n return ENV['EDITOR'] if ENV['EDITOR'] && !ENV['EDITOR'].empty?\n if windows?\n 'notepad'\n else\n %w(editor nano vi).find do |editor|\n system(\"which #{editor} > /dev/null 2>&1\")\n end\n end\n end",
"def color_themes # :nologin:\n end",
"def set_theme\n @theme = params[:id].to_i.zero? ? Theme.new : Theme.find(params[:id])\n end",
"def default_template\n @default_template ||= \"application\"\n end",
"def get_theme\n respond theme, 200, {'Content-Type' => 'text/plain'}\n end",
"def themes_menu(user)\n pastel = Pastel.new\n puts \" \"\n puts pastel.white.inverse.bold(\"Here are a list of themes, please select one.\") \n puts \"*********************\"\n Joke.all_themes \n puts \"*********************\"\n user_theme = gets.chomp\n if Joke.find_by_theme(user_theme) == []\n puts \"*********************\"\n puts pastel.white.inverse.bold(\"No such theme, please try again.\")\n puts \"*********************\"\n self.return_to_menu(user)\n else Joke.puts_user_theme_jokes(user_theme)\n puts \" \"\n self.return_to_menu(user)\n end\n end",
"def default_color_profile\n self.default_options[:color_profile].presence\n end",
"def theme_css(name)\n \"themes/#{name}/style\"\n end",
"def original_template_theme\n #duplicated_from 有自己的page_layouts\n has_native_layout? ? self : duplicated_from\n #self.class.where(:page_layout_root_id=>self.page_layout_root_id).first\n end",
"def get_theme val\n case action_name\n when 'index'\n val == 1 ? 'b' : 'd'\n when 'sent'\n val == 2 ? 'b' : 'd'\n when 'seller'\n val == 1 ? 'b' : 'd'\n when 'unposted'\n val == 2 ? 'b' : 'd'\n when 'sold'\n val == 3 ? 'b' : 'd'\n when 'received'\n val == 2 ? 'b' : 'd'\n when 'new'\n val == 3 ? 'b' : 'd'\n when 'contact'\n val == 2 ? 'b' : 'd'\n when 'password'\n val == 3 ? 'b' : 'd'\n end\n end",
"def current_name_windowskin\n @nameskin_overwrite || current_layout.name_windowskin || NAME_SKIN\n end",
"def default_layout\n 'default' if html?\n end",
"def theme_file\n @theme_file ||= File.join(\n Rails.root, 'app', 'assets', 'stylesheets', 'themes',\n \"#{theme}.scss\"\n )\n end",
"def find_theme\n @theme = Theme.find(params[:theme_id])\n end",
"def default_layout\n @default_layout ||= (\n IO.read(LIBDIR + \"/templates/layouts/page.mustache\")\n )\n end",
"def default_design\n designs.select { |d| d.default? }.first\n end",
"def get_default\n list.each do |plan|\n return plan if plan['default']\n end\n nil\n end",
"def get_default\n list.each do |plan|\n return plan if plan['default']\n end\n nil\n end",
"def theme_finder_method #:nodoc:\n return @theme_finder_method if @theme_finder_method\n return self.superclass.theme_finder_method if self.superclass.respond_to? :theme_finder_method\n \"\"\n end",
"def default_layout\n nil\n end",
"def themes_path\n File.join(RAILS_ROOT, 'themes')\n end",
"def use_default_style?\n return @use_default_style\n end",
"def get_theme_mods\n theme_slug = get_option( 'stylesheet' )\n mods = get_option( \"theme_mods_#{theme_slug}\" )\n if mods\n theme_name = get_option( 'current_theme' )\n unless theme_name\n theme_name = wp_get_theme.get( 'Name' )\n end\n # mods = get_option( \"mods_#{theme_name}\" ) # Deprecated location.\n # if is_admin() && false != mods\n # update_option( \"theme_mods_#{theme_slug}\", mods )\n # delete_option( \"mods_#{theme_name}\" )\n # end\n else\n mods = {}\n end\n mods\n end",
"def themes_path\n \"#{Rails.root}/app/themes\"\n end",
"def current_layout\n @site_layout ||= SiteLayout.first\n end",
"def applied?\n SpreeTheme.site_class.current.template_theme ==self \n end",
"def theme_keynote\n self.theme = Themes::KEYNOTE\n end",
"def default_current_status\n current_status ||= 'Active'\n end",
"def is_child_theme\n TEMPLATEPATH != STYLESHEETPATH\n end",
"def choose_layout\n Rails.configuration.blog.layout\n end",
"def current_layout\n config = PSDK_CONFIG.layout.choices\n return config[$scene.class.to_s] || config[:any]\n end",
"def loadconf\n\n @conf = YAML.load_file(File.join($path, \"config.yaml\"))\n return @conf['theme']\n end",
"def theme_option(option_name)\n theme_data(parent: true).merge(theme_data)[option_name.to_s]\n end",
"def applied?\n Spree::Store.current.template_theme ==self\n end",
"def set_cms_theme\n @cms_theme = current_portal.themes.friendly.find(params[:id])\n end"
] | [
"0.83288646",
"0.79230934",
"0.7906802",
"0.78816706",
"0.77404493",
"0.7739274",
"0.7630222",
"0.75294083",
"0.74879324",
"0.73766637",
"0.7246554",
"0.70597017",
"0.70159614",
"0.67778724",
"0.6729735",
"0.65933573",
"0.65707153",
"0.6463578",
"0.6463578",
"0.6463578",
"0.64244497",
"0.6390925",
"0.6381777",
"0.63547724",
"0.63489467",
"0.63489467",
"0.63489467",
"0.63127965",
"0.62844527",
"0.62776816",
"0.6265333",
"0.6222385",
"0.6222073",
"0.6221701",
"0.6212653",
"0.6212588",
"0.6209732",
"0.6204903",
"0.6183214",
"0.6152267",
"0.61468136",
"0.6130421",
"0.60317713",
"0.60283655",
"0.5992306",
"0.5991303",
"0.5978095",
"0.5974602",
"0.5953772",
"0.5942646",
"0.5928032",
"0.5878834",
"0.58725506",
"0.586044",
"0.5854647",
"0.58473325",
"0.5828812",
"0.5801525",
"0.5791014",
"0.5766901",
"0.5755037",
"0.5734951",
"0.57259256",
"0.5725745",
"0.57040995",
"0.5690092",
"0.5681977",
"0.56801",
"0.565974",
"0.5647684",
"0.56304187",
"0.56154215",
"0.5614376",
"0.5605049",
"0.56043863",
"0.5601746",
"0.55988234",
"0.55693054",
"0.5557371",
"0.55534536",
"0.5551282",
"0.5545741",
"0.5545741",
"0.5539954",
"0.55159336",
"0.5514478",
"0.55020505",
"0.55002046",
"0.5494697",
"0.5493644",
"0.5485327",
"0.5480743",
"0.54769015",
"0.5473916",
"0.54519314",
"0.54489017",
"0.54459304",
"0.5444129",
"0.54431105",
"0.5428294"
] | 0.85378844 | 0 |
in the case of an http error | def handle_unknown_request
$params = request.request_uri # the requested URI
# we're still going to build the 'about' block, so let's get that data
@posts = Post.find_current
@tags = Post.tag_counts(:order => 'name asc')
$page_title = Preference.get_setting('ERROR_PAGE_TITLE')
@error = true # for use later
render :template => 'errors/unknown_request'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_error(http)\n error = http.error\n fail(error, *@deferrable_args)\n end",
"def on_error(http)\n error = http.error\n fail(error, *@deferrable_args)\n end",
"def error(url); end",
"def http_error?\n http_error.present?\n end",
"def handle_http_failure(method:, http_response:)\n content = http_response.inspect\n msg = \"received a #{http_response&.code} response with: #{content}!\"\n log_error(method: method, error: ExternalApiError.new(msg))\n end",
"def http_error?(code)\n http_status?(:error, code)\n end",
"def handle_error (url, res)\n puts \"#{url} was not found\" if res.code.to_i == 404\n puts \"#{url} requires authorization\" if res.code.to_i == 401\n puts \"#{url} returns an application error\" if res.code.to_i == 500\nend",
"def error!(url); end",
"def error?\n http_status >= 400 && http_status <= 599\n end",
"def http_error?\n !(200..299).include?(http_code)\n end",
"def server_error?; end",
"def handle_request_error(exception)\n end",
"def server_error\n\n end",
"def errback(http)\n raise \"Web API rtm.start failed: #{http.error}\"\n end",
"def server_error_status_code\n _undefined\n end",
"def display_http_error(error)\n display_error(\"\\e[33;1m#{error[:code]} #{Rack::Utils::HTTP_STATUS_CODES[error[:code].to_i]\n }\\e[0m for \\e[34;1m#{error[:url]}\\e[0m\")\n end",
"def error\n @error_response\n end",
"def api_error; end",
"def http_client_error?(code)\n http_status?(:client_error, code)\n end",
"def server_errors; end",
"def http_err_code\n http_codes[@http_err]\n end",
"def http_server_error?(code)\n http_status?(:server_error, code)\n end",
"def client_error?; end",
"def request_failure(packet); end",
"def client_error_status_code\n _undefined\n end",
"def validate_http_status\n return true if @http.code.to_i == 200\n DomainTools::Exceptions::raise_by_code(@http.code)\n end",
"def error(x, status:200, type:\"request\", title:\"An error occurred\", message:\"\", args: [])\n x.res.status = status\n if App[:app_error][type.to_sym]\n App[:app_error][type.to_sym][:get][x, title, message, *args]\n else\n x << \"ERROR: #{title} - #{message}\"\n end\n end",
"def net_http_res; end",
"def check_error(json)\n if json[\"nyplAPI\"][\"response\"][\"headers\"][\"status\"] == \"error\"\n msg = \"NYPL Repo API Error: \" + json[\"nyplAPI\"][\"response\"][\"headers\"][\"code\"] + \" \"+ json[\"nyplAPI\"][\"response\"][\"headers\"][\"message\"]\n raise msg\n end\n\n end",
"def handle_http_error(res)\n if res.code == \"202\" # retry\n self.call\n else\n raise \"Error in FoodTruckApiClient: Call to API failed, returning the HTTP status code #{res.code} and the following error message: #{error}\"\n end\n end",
"def status_bad_request\n respond_to do |format|\n format.any { head :bad_request }\n end\n end",
"def validate_response(response) # :nodoc:\n code = response.code.to_i\n raise HttpError, \"#{code} #{response.msg}\" if code < 200 || code > 299\n end",
"def check_error(response)\n raise NotImplementedError\n end",
"def status_error\n @status = 500\n end",
"def failure(response)\n catch_throttling_error(response)\n parsed_response = JSON.parse(response.body.to_s)\n raise RequestError, parsed_response['detail']\n rescue JSON::ParserError\n raise RequestError, response.status\n end",
"def error\n expires_in 1.month, public: true\n set_metadata({ 'title' => translate('errors.error') })\n render status: request.env['PATH_INFO'][1, 3].to_i\n end",
"def error\n expires_in 1.month, public: true\n set_metadata({ 'title' => translate('errors.error') })\n render status: request.env['PATH_INFO'][1, 3].to_i\n end",
"def error!(status, message)\n response.status = status\n response[\"Content-Type\"] = \"application/json\"\n response.write({error: message}.to_json)\n request.halt\n end",
"def throw_error(error)\n render json: error, status: :bad_request\n end",
"def respond_bad_request; make_response(nil, false, 400, \"Bad Request\") end",
"def failure?\n self.kind_of?(Net::HTTPClientError) || self.kind_of?(Net::HTTPServerError)\n end",
"def parse_error(error, req); end",
"def check_for_errors\n info = MultiJson.load(self.body).first\n\n if info['result'] && info['result'] != 0\n if info['result'] == 500\n raise Webceo::Api::ServerError.new(self.status.to_i, self.body)\n else\n raise Webceo::Api::ClientError.new(self.status.to_i, self.body)\n end\n end\n end",
"def http_error(e)\n msg = e.message\n if e.is_a?(RestClient::Exception)\n msg = e.response.body if e.response.is_a?(RestClient::Response)\n end\n msg\n end",
"def error_message\n return '' if url.nil? || status_code == 200\n\n case status_code\n when 400\n 'The URL was not entered correctly. Be sure to use http:// or https:// to start all URLS'\n when 401\n 'The URL was not authorized for download.'\n when 403..404\n 'The URL was not found.'\n when 410\n 'The requested URL is no longer available.'\n when 411\n 'URL cannot be downloaded, please link directly to data file'\n when 414\n \"The server will not accept the request, because the URL #{url} is too long.\"\n when 408, 499\n 'The server timed out waiting for the request to complete.'\n when 409\n \"You've already added this URL in this version.\"\n when 500..511\n 'Encountered a remote server error while retrieving the request.'\n else\n 'The given URL is invalid. Please check the URL and resubmit.'\n end\n end",
"def before_server_error(exception); end",
"def check_for_error(res)\n body = res.parsed_response\n raise ValidationError.new(body), \"Authentication failed\\n status code: \\\"#{res.code}\\\"\\n message: \\\"#{body['error']}\\\"\" if res.code != 200\n end",
"def robots_error(url); end",
"def error\n response_json.fetch(\"error\", \"\")\n end",
"def json_error err, status = 400, headers = {}\n\t\t\tjson_resp({'error' => err}, status, headers)\n\t\tend",
"def handle_request_exception(exception)\n # puts \"ERROR: #{exception}\\n\" + exception.backtrace.join(\"\\n\")\n handle_error_response(exception.kind_of?(CAHTTPError) ? JSON.parse(exception.response) : {})\n end",
"def error_manager(uri, response)\n case response\n when Net::HTTPSuccess then\n # This covers cases where the response may not validate as JSON.\n begin\n return JSON.parse(response.body)\n rescue\n return {}\n end\n when Net::HTTPBadRequest\n raise Ropenstack::MalformedRequestError, response.body\n when Net::HTTPNotFound\n raise Ropenstack::NotFoundError, \"URI: #{uri} \\n\" + response.body\t\n when Net::HTTPUnauthorized\n raise Ropenstack::UnauthorisedError, response.body\n else\n raise Ropenstack::RopenstackError, response.body\n end\n end",
"def _error(message,code) \n status code\n response.headers['Content-Type'] = 'application/json'\n body({:error=>{:message=>message}}.to_json)\n end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def handle_errors(err)\n unless err && err.kind_of?(Google::Apis::Error)\n print \"Unknown error: #{err}\"\n exit\n end\n body_json = MultiJson.load(err.body)\n if body_json['error']\n puts \"Error(s) when performing request:\"\n body_json['error']['errors'].each do |error|\n puts \" - [#{error['reason']}] #{error['message']}\"\n end\n else\n puts \"Unknown error when performing request, details below:\"\n puts\n puts \"Response headers:\"\n puts \"-----------------\"\n err.header.each do |key, value|\n puts \"#{key}: #{value}\"\n end\n puts\n puts \"Response body:\"\n puts \"--------------\"\n puts err.body\n end\nend",
"def check_conn_error(conn)\n return nil if conn.code == 200\n\n @errors.push(\n time: Time.now.strftime('%d.%m.%Y-%H:%M:%S:%L'),\n code: conn.code,\n message: conn.msg,\n request: conn.request.path.to_s\n )\n end",
"def check_url(path, url)\n res = http_client.get(url, follow_redirect: true)\n return if res.status == 200\n raise(nil) unless res.status.to_s.match(/50\\d|403/)\n\n puts \"::warning file=#{path}:: Unexpected response from #{url} (#{res.status})\"\nrescue StandardError => e\n puts \"::warning file=#{path}:: Unable to reach #{url} #{res.respond_to?('status') ? res.status : nil}\"\n puts e.full_message unless e.instance_of?(TypeError)\n 1\nend",
"def bad_request(error)\n json_response({ message: error.message }, :bad_request)\n end",
"def error\n end",
"def handleHTTPStatus(code)\n case code\n when 200 # Ok\n puts \"HTTP request successful\"\n return true\n when 204\n puts \"HTTP Error: No Content\"\n return false\n when 401\n puts \"HTTP Error: Server rejected authentication.\"\n return false\n else\n puts \"Unhandled HTTP status: #{code}\"\n return false\n end # case code\n end",
"def error!(status, message)\n request.halt status, {error: message}.to_json\n end",
"def error!(status, message)\n request.halt status, {error: message}.to_json\n end",
"def error?(res)\n res.code >= 400 || JSON.parse(res.body)[\"error\"]\n end",
"def handle_error(errors, status, content_type)\n if defined?(Rails)\n Rails.logger.warn \"RESPONSE STATUS: #{status}\"\n Rails.logger.warn errors\n end\n\n OpenStruct.new(success?: false, status: status, body: { errors: errors }, content_type: content_type)\n end",
"def serve_exception(_exception); end",
"def status_code; end",
"def requestFailed(request)\n error = request.error\n puts \"Error parsing the users API call\"\n # should do something better...\n end",
"def http_error(code, message = nil, headers = {})\n [code, {'Content-Type' => 'text/plain; charset=utf-8'}.merge(headers),\n [http_status(code) + (message.nil? ? \"\\n\" : \" (#{message})\\n\")]]\n end",
"def error\n end",
"def connection_error(error, req, text = T.unsafe(nil)); end",
"def client_error?\n @status.between?(400, 499) if @status\n end",
"def robots_error!(url); end",
"def routing_error\n head 400\n end",
"def response_error(response)\n trace = \"Response \\n\\nbody : #{response.body}\\n\\ncode: #{response.code}\\n\\nmessage: #{response.message}\"\n case @base_url\n when BASE_URLS[:quote]\n raise InterfaceError, \"Error :: Could not get stock data \\n\\n#{trace}\"\n when BASE_URLS[:history]\n raise InterfaceError, \"Error :: Could not get historical data \\n\\n#{trace}\"\n when BASE_URLS[:scrip_symbol]\n raise InterfaceError, \"Error :: Could not get stock symbol \\n\\n#{trace}\"\n else\n raise InterfaceError, \"Error connecting to #{@base_url} \\n\\n#{trace}\"\n end\n end",
"def bad_request_response(env)\n if head_request?(env)\n [ 400, { \"content-type\" => \"text/plain\", \"content-length\" => \"0\" }, [] ]\n else\n [ 400, { \"content-type\" => \"text/plain\", \"content-length\" => \"11\" }, [ \"Bad Request\" ] ]\n end\n end",
"def http_get_direct(url)\n log(\"http get : #{url}\") if $opt[\"debug\"]\n begin\n html = Net::HTTP.get_response(URI.parse(url)).body\n # XXX must fix the rescue its not working\n rescue => err\n log(\"Error: #{err}\")\n exit 2\n end\n html\nend",
"def errorhandling\n end",
"def auth_error(e)\n json_response({ message: e.message }, :unprocessable_entity)\n end",
"def _check_error(resp)\r\n\t\tif resp.error\r\n\t\t\traise VoldemortException.new(resp.error.error_message, resp.error.error_code)\r\n end\r\n end",
"def on_error error\n raise error\n end",
"def error?(response)\n response.key?('errorcode')\n end",
"def render_error(err)\n json_response({ message: err }, :unprocessable_entity)\n end",
"def internal_error\n\t\tself.status = 500\n\t\tself.headers = {}\n\t\tself.content = [\"Internal error\"]\n\t\tself\n\tend",
"def check_error(response) #:nodoc:\n case response.code\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{response.code}\"\n end\n end",
"def bad_request\n render :json => {:success=>false, :error_code=> 400, :error_msg=>\"Bad Request\"}\n end",
"def error?\n (500..599).include?(status)\n end",
"def __raise_transport_error(response)\n error = ERRORS[response.status] || ServerError\n raise error.new \"[#{response.status}] #{response.body}\"\n end",
"def bad_request_status\n status_message(400)\n end",
"def rescue_http_error(exception)\n status, headers, body = exception.to_response\n if self.respond_to?(:render_http_error)\n [status, headers, self.render_http_error(exception)]\n else\n [status, headers, body]\n end\n end",
"def foreign_server_failure\n [ 503, {'Content-Type'=>'text/plain', 'Content-Length' => '23'},\n ['Foreign server failure.'] ]\n end",
"def rescue_bad_request(error)\n render status: :bad_request, json: { code: 400, error: \"#{error.class}: #{error}\" }\n end",
"def check_error(response) #:nodoc:\n case response.status\n when \"OK\" then # ignore, ok\n when \"ZERO_RESULTS\" then\n raise AddressError, 'unknown address'\n when \"OVER_QUERY_LIMIT\"\n raise CredentialsError, 'over query limit'\n when \"REQUEST_DENIED\"\n raise CredentialsError, 'request denied'\n when \"INVALID_REQUEST\"\n raise AddressError, 'missing address'\n when \"UNKNOWN_ERROR\"\n raise Error, \"unknown server error. Try again.\"\n else\n raise Error, \"unkown error #{response.status}\"\n end\n end",
"def render_error(msg, status)\n render_403\n end",
"def hastur_error!(code=501, message=\"FAIL\", bt=[])\n error = {\n :status => code,\n :message => message,\n :backtrace => bt.kind_of?(Array) ? bt[0..10] : bt\n }\n\n # remove this after getting the loggers to do the right thing\n STDERR.puts MultiJson.dump(error, :pretty => true)\n\n if self.is_a? Grape::API\n throw :error, error\n elsif self.is_a? Sinatra::Base\n error[:url] = request.url\n halt serialize(error, {})\n else\n abort \"BUG: not a Grape::API or Sinatra::Base\"\n end\n end",
"def error\n render plain: '500 Internal Server Error', status: :internal_server_error\n end"
] | [
"0.79031616",
"0.79031616",
"0.7682189",
"0.7532429",
"0.74699533",
"0.7452467",
"0.73794985",
"0.73670566",
"0.7354882",
"0.73332906",
"0.729328",
"0.72313225",
"0.7132746",
"0.71001506",
"0.70032364",
"0.699925",
"0.699735",
"0.6958664",
"0.69418263",
"0.693496",
"0.6896912",
"0.68931353",
"0.6855444",
"0.6840379",
"0.6837175",
"0.68343633",
"0.6833287",
"0.6800588",
"0.6794274",
"0.6785327",
"0.6774801",
"0.6753768",
"0.6742158",
"0.6735629",
"0.6719685",
"0.671258",
"0.67122406",
"0.67114794",
"0.6707769",
"0.6698329",
"0.66835344",
"0.6678314",
"0.6668966",
"0.66649693",
"0.6655549",
"0.6638534",
"0.6619666",
"0.66105074",
"0.6606007",
"0.65980595",
"0.6588879",
"0.6583713",
"0.6583096",
"0.65771866",
"0.65771866",
"0.65771866",
"0.65771866",
"0.65771866",
"0.65771866",
"0.65771866",
"0.6576231",
"0.6570025",
"0.6560832",
"0.65585303",
"0.6549192",
"0.6530608",
"0.6522829",
"0.6522829",
"0.65066594",
"0.6495804",
"0.6492006",
"0.6488303",
"0.6486749",
"0.6486601",
"0.6484975",
"0.64796907",
"0.647721",
"0.6465997",
"0.6462362",
"0.6461223",
"0.64575434",
"0.64567745",
"0.6445056",
"0.6444853",
"0.64353806",
"0.6430955",
"0.6426036",
"0.6425923",
"0.64233387",
"0.6422145",
"0.6421553",
"0.6417419",
"0.6396259",
"0.63911194",
"0.6389682",
"0.63860285",
"0.63847023",
"0.63814676",
"0.6373866",
"0.6372968",
"0.6361355"
] | 0.0 | -1 |
implement BFS method, this is shortest path problem with unweighted graph, BFS is best solution | def bradth_first_search_colors(start_vertex, stop_vertex)
queue = Array.new()
queue << search_vertex(start_vertex)
until queue.empty?
temp_vertex = queue.shift()
break if temp_vertex.value == stop_vertex #found stop condition
vertex_edges = temp_vertex.edges.head
until vertex_edges == nil
current_vertex = search_vertex(vertex_edges.value)
if current_vertex.color == 'white'
current_vertex.color = 'gray' #indicates that shorter path is available if found again
current_vertex.distance = temp_vertex.distance + 1
current_vertex.parent = temp_vertex.value
queue << current_vertex
end
vertex_edges = vertex_edges.link
end
temp_vertex.color = 'black' #completly explored tree
end
graph_traversal(start_vertex, stop_vertex)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs(graph, s)\n queue = [s]\n @visited[s] = true\n @dist[s] = 0\n w = nil\n while not queue.empty?\n w = queue.delete_at(0)\n graph.adj(v).each do |edge|\n w = edge.to\n if not @visited[w]\n @path[w] = v\n @dist[w] = @dist[v] + 1\n @visited[w] = true\n queue << w\n end\n end\n end\n end",
"def bfs(graph, s)\n queue = [s]\n @visited[s] = true\n @dist[s] = 0\n w = nil\n while not queue.empty?\n w = queue.delete_at(0)\n graph.adj(v).each do |edge|\n w = edge.other(v)\n if not @visited[w]\n @path[w] = v\n @dist[w] = @dist[v] + 1\n @visited[w] = true\n queue << w\n end\n end\n end\n end",
"def bfs(graph, starting_point)\n q = Queue.new()\n q.enq(starting_point)\n visited = [] \n loop do \n node = q.deq\n visited.push(node) unless visited.include?(node) \n graph.values[node].each{ |x| q.enq(x) }\n break if visited.length == graph.length\n end \n visited\n end",
"def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend",
"def bfs(start, goal = :goalNode?)\n require 'set'\n visited = Set.new\n frontier = []\n frontier << start\n\n until frontier.empty?\n current = frontier.shift\n\n next if visited.include? current\n visited << current\n\n found = false\n found = if block_given?\n yield(current)\n else\n send(goal, current)\n end\n\n if !found\n current.connections.each do |node|\n frontier << node\n end\n else\n return current\n end\n end\n :goal_node_not_found\nend",
"def do_bfs(graph, source)\n\tbfs_info = []\n\n\t# Initialize all of our vertices to have nil values\n\tgraph.each_with_index {|v, i| bfs_info[i] = BFS_Vertex_Info.new(nil, nil)}\n\n\t# Set our initial (starting) vertex to have a distance of 0\n\t# since it is the origin of our search\n\tbfs_info[source].distance = 0\n\n\tqueue = Queue.new\n\tqueue.enqueue(source)\n\n\t# Traverse the graph\n\twhile !queue.is_empty?\n\t\tvertex = queue.dequeue();\n\n\t\t# Look at each vertex that is a neighbor of our \n\t\t# current vertex; if its distance is nil, we\n\t\t# haven't visited it yet.\n\t\tgraph[vertex].each do |v|\n\t\t\tif bfs_info[v].distance.nil?\n\t\t\t\tbfs_info[v].distance = bfs_info[vertex].distance + 1\n\t\t\t\tbfs_info[v].predecessor = vertex\n\t\t\t\tqueue.enqueue(v)\n\t\t\tend\n\t\tend\n\tend\n\n\t# Return a list of vertices, their distances, and\n\t# predecessors\n\tbfs_info\nend",
"def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend",
"def bfs(starting_node, target_value)\n return starting_node if starting_node.value == target_value\n queue = [starting_node]\n until queue.empty?\n queue += starting_node.neighbors\n queue.each { |neighbor| bfs(neighbor, tar) }\n end\n nil\nend",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n checked_nodes = Set.new\n\n until queue.empty?\n current = queue.shift\n unless checked_nodes.include?(current)\n checked_nodes.add(current)\n return current if current.value == target_value\n queue += current.neighbors\n end\n end\n nil\nend",
"def bfs_graph(graph, target, visited = Set.new)\n graph.graph.each do |g|\n val = bfs_helper(g, target, visited)\n if (!val.nil?)\n return val\n end\n end\n nil\nend",
"def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def bfs( start, &block )\n start.distance = 0\n start.predecessor = nil\n start.gray!\n vq = Queue.new()\n vq.enqueue(start)\n while vq.size > 0\n current = vq.dequeue()\n current.get_connections.each do |nbr|\n if nbr.white?\n nbr.gray!\n nbr.distance = current.distance + 1\n nbr.predecessor = current\n vq.enqueue(nbr)\n end\n end\n current.black!\n yield current if block_given?\n end\n # clean up vertices attributes set during bfs\n @vertices.keys.each do |key|\n @vertices[key].distance = nil\n @vertices[key].predecessor = nil\n @vertices[key].color = nil\n end\n end",
"def bfs_adj_list(queue, item)\n @checked_edges = []\n @current_node = start\n queue.add(@current_node)\n until current_node == item || current_node.nil?\n @current_node.linked_list.each do |next_node|\n queue.add(next_node)\n end\n current_node = queue.pop\n end\n return @current_node\n end",
"def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end",
"def bfs(v)\n raise ArgumentError, \"No such vertex\" if v < 0 or vertices <= v\n queue = LinkedQueue.new\n is_visited = []\n queue.enter(Edge.new(-1,v))\n while !queue.empty? do\n edge = queue.leave\n next if is_visited[edge.w]\n yield edge.v,edge.w\n is_visited[edge.w] = true\n each_edge(edge.w) do |w,x|\n queue.enter(Edge.new(w,x)) if !is_visited[x]\n end\n end\n end",
"def bfs(start_node_num)\n node = find_node(start_node_num)\n _clear_visited\n ret_list = [node.value]\n # Your code here\n q = Queue.new\n q << node\n node.visited = true\n\n until q.empty?\n current = q.pop\n current.edges.each do |edge|\n next if edge.node_to.visited\n q << edge.node_to\n edge.node_to.visited = true\n ret_list << edge.node_to.value\n end\n end\n\n return ret_list\n end",
"def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end",
"def breadth_first_search(graph, source, target = nil)\n # queue: first-in, first-out (FIFO). keeps track of which vertices have already\n # been visited but have not yet been visited from, so we know where to search.\n queue = Queue.new\n\n # a `Set` instance is a collection of unordered values with no duplicates\n # maintain a list of visited nodes and prevent checking a node more than once\n visited = Set.new\n\n # shortest path information, if applicable\n meta = {}\n\n # enqueue the source key (push it to the empty queue)\n queue.enq(source)\n\n until queue.empty?\n # current node, which we `shift` from the queue\n current = queue.deq\n\n # print the shortest path if it was found\n return path(source, current, meta) if target && current == target\n\n # we don't have to keep track of distance here, since we have a method\n # to access each of the node's neighbors. the neighbors are stored in a set.\n # process each neighboring vertex of the current node,\n # i.e. traverse all outgoing edges from the current node.\n current.neighbors.each do |neighbor|\n # if the neighbor node is unvisited, we ignore this edge\n unless visited.include?(neighbor)\n queue.enq(neighbor)\n visited.add(neighbor) # we just enqueued this node, so mark it as visited\n meta[neighbor] = current # record the path (only done once, b/c of `unless`)\n end\n end\n end\nend",
"def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend",
"def bfs(source)\n color = {}\n prev = {}\n dist = {}\n @vertices.each do |v|\n color[v] = \"white\"\n prev[v] = nil\n dist[v] = -1\n end\n color[source] = \"grey\"\n dist[source] = 0\n queue = []\n queue.push source\n while !queue.empty?\n v = queue.pop\n (@edges[v] || []).each do |edge|\n adj = edge.to\n if color[adj] == \"white\"\n color[adj] = \"grey\"\n dist[adj] = dist[v] + 1\n prev[adj] = v\n queue.push adj\n end\n end\n color[v] = \"black\"\n end\n [prev, dist]\n end",
"def dijkstras(start=@vertices.keys.sort[0],goal=nil)\n\t\t# Set of visited nodes\n\t\tvisited = []\n\n\t\t# Step 1 \n\t\t# - Start node weighs 0\n\t\t# - Set all other to infinity its done in constructor already\n\t\t@vertices[start] = 0\n\n\t\t# Step 2 \n\t\t# - Set initial node as current\n\t\t# - Mark all nodes unvisited except start node\n\t\tunvisited = @vertices.keys - [start]\n\t\tcurrent = start\n\n\t\twhile(!unvisited.empty?)\n\t\t\t# Step 3\n\t\t\t# - Consider all neighbors of current node\n\t\t\t# - Calculate distance cost: current path weight + edge weight\n\t\t\t# - Update distance if this distance is less than recorded distance\n\t\t\t\n\t\t\t@map[current].each do |neighbor|\n\t\t\t\tnext if visited.include?(neighbor.to)\n\t\t\t\tweight = @vertices[current] + neighbor.weight.to_i\n\t\t\t\tif weight < @vertices[neighbor.to]\n\t\t\t\t\t@vertices[neighbor.to] = weight\n\t\t\t\t\t@prev[neighbor.to] = current\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 4\n\t\t\t# - Add current node to visited\n\t\t\t# - Remove current node from unvisited\n\t\t\tvisited << current\n\t\t\tunvisited -= [current]\n\n\t\t\t# Find the smallest weighted node, could use a PQueue instead\n\t\t\tsmallest = @infinity\n\t\t\tcurrent = @infinity\n\t\t\tunvisited.each do |node|\n\t\t\t\tif @vertices[node] < smallest\n\t\t\t\t\tsmallest = @vertices[node]\n\t\t\t\t\t# Step 6\n\t\t\t\t\t# - Set smallest weighted node as current node, continue\n\t\t\t\t\tcurrent = node\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 5\n\t\t\t# - If goal is in visited, stop\n\t\t\t# - If full traversal without a goal? \n\t\t\t# \tCheck for infinity weighted node\n\t\t\tif visited.include? goal\t\t\n\t\t\t\tpath(goal)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tbreak if current == @infinity\n\t\tend\n\t\t\n\t\t# Print all shortest paths\n\t\tputs \"Initial Node: #{start}\"\n\t\tvisited.each do |x|\n\t\t\tpath(x)\n\t\t\tputs\n\t\tend\n\tend",
"def djikstra(graph, start_node, end_node)\n path_weights = {}\n previous_shortest_path = {}\n remaining = graph.nodes\n\n # Begin by setting weight of start node to 0, others to infinity\n graph.nodes.each do |node|\n if node == start_node\n path_weights[node] = 0\n else\n path_weights[node] = Float::INFINITY\n end\n end\n\n #TODO: can stop when we reach destination\n\n # pluck the node in remaining with lowest path weight. this will always be the start node to begin\n while remaining.length > 0\n min_index = nil\n lowest_score = Float::INFINITY\n remaining.each_with_index do |remaining_node, i|\n if path_weights[remaining_node] < lowest_score\n min_index = i\n lowest_score = path_weights[remaining_node]\n end\n end\n node = remaining.delete_at(min_index)\n\n # Update path_weight/previous of neighboring nodes based on shortest path\n # Also notice how we consider there may be no connections for the min_node.\n (node.connections || []).each do |neighbor, weight|\n if path_weights[neighbor] > (path_weights[node] + weight)\n path_weights[neighbor] = path_weights[node] + weight\n previous_shortest_path[neighbor] = node\n end\n end\n end\n\n node = end_node\n shortest_path = []\n\n while node\n shortest_path.unshift(node)\n node = previous_shortest_path[node]\n end\n\n puts path_weights[end_node]\n shortest_path.map{|node| node.value}\nend",
"def bfs\n closed = []\n fringe = initialize_fringe\n\n loop do\n return nil if fringe.empty? # No solution\n current = fringe.pop\n city = current[:city]\n return current if done? city # Found the solution?\n unless closed.include? city # Expand if we haven't visited the city\n closed.push city\n expand(current).each do |c|\n fringe.unshift(c) # Add to front to ensure FIFO\n end\n end\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 bfs\n\n\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 bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def bfs\n # raise NotImplementedError\n end",
"def bfs\n bfs_queue = []\n curr = @root\n node_list = []\n while curr\n visit(curr, node_list)\n bfs_queue << curr.left if curr.left\n bfs_queue << curr.right if curr.right\n curr = bfs_queue.shift\n end\n return node_list\n end",
"def bfs(g,s)\r\n q = []\r\n dists = Hash.new(Float::INFINITY)\r\n curr = s\r\n dists[curr] = 0\r\n \r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n while q.size > 0\r\n \tprev,curr = q.shift\r\n dists[curr] = [6 + dists[prev],dists[curr]].min\r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n #prev,curr = q.shift\r\n end\r\n \r\n return dists\r\nend",
"def bfs(char, the_set)\n q = [char]\n @visited[char] = true\n while ! q.empty?\n x = q.shift\n the_set.add(x)\n @map[x] = the_set\n @h[x].keys.each do |y|\n next if @visited[y]\n @visited[y] = true\n q.push(y)\n end\n end\nend",
"def dijkstras(start=@vertices.keys.sort[0],goal=nil)\n\t\t# Set of visited nodes\n\t\tvisited = []\n\n\t\t# Step 1 \n\t\t# - Start node weighs 0\n\t\t# - Set all other to infinity its done in constructor already\n\t\t@vertices[start] = 0\n\n\t\t# Step 2 \n\t\t# - Set initial node as current\n\t\t# - Mark all nodes unvisited except start node\n\t\tunvisited = @vertices.keys - [start]\n\t\tcurrent = start\n\n\t\twhile(!unvisited.empty?)\n\t\t\t# Step 3\n\t\t\t# - Consider all neighbors of current node\n\t\t\t# - Calculate distance cost: current path weight + edge weight\n\t\t\t# - Update distance if this distance is less than recorded distance\n\t\t\t\n\t\t\t@map[current].each do |neighbor|\n\t\t\t\tnext if visited.include?(neighbor.to)\n\t\t\t\tweight = @vertices[current] + neighbor.weight.to_i\n\t\t\t\tif weight < @vertices[neighbor.to]\n\t\t\t\t\t@vertices[neighbor.to] = weight\n\t\t\t\t\t@prev[neighbor.to] = current\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 4\n\t\t\t# - Add current node to visited\n\t\t\t# - Remove current node from unvisited\n\t\t\tvisited << current\n\t\t\tunvisited -= [current]\n\n\t\t\t# Find the smallest weighted node\n\t\t\tcurrent = unvisited.collect { |node| [@vertices[node],node] }\n\t\t\tcurrent.empty? ? current = @infinity : current = current.min[1]\n\n\t\t\t# Step 5\n\t\t\t# - If goal is in visited, stop\n\t\t\t# - If full traversal without a goal? \n\t\t\t# \tCheck for infinity weighted node\n\t\t\tif visited.include? goal\t\t\n\t\t\t\tpath(goal)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tbreak if current == @infinity\n\t\tend\n\t\t\n\t\t# Print all shortest paths\n\t\tputs \"Initial Node: #{start}\"\n\t\tvisited.each do |x|\n\t\t\tpath(x)\n\t\t\tputs\n\t\tend\n\tend",
"def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end",
"def bfs(root, target)\n queue = []\n queue << root\n\n until queue.empty?\n current = queue.shift\n\n next if current.nil?\n return true if current.val == target\n\n queue << current.left\n queue << current.right\n end\n\n return false\nend",
"def bfs(target)\n queue = [self]\n until queue.empty?\n return queue.first if queue.first.position == target\n queue += queue.first.children\n queue.shift\n end \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 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 bfs(v)\n curr = v\n queue = []\n distances = Hash.new(0)\n queue.push(curr)\n distances[curr] = 0\n while !queue.empty?\n curr = queue.shift\n dst = distances[curr] + 1\n if @hypernyms.include?(curr)\n queue += @hypernyms[curr]\n end\n queue.each do |v|\n \n distances[v] = dst if !distances.include?(v)\n end\n end\n distances\n end",
"def breadth_first_search?(graph, start, goal)\n visited = Hash.new(false)\n queue = Queue.new\n queue.push(start)\n visited[start] = true\n until queue.empty? do\n node = queue.pop\n return true if node == goal\n add_to_queue(graph, queue, node, visited)\n end\n false\n end",
"def bfs_tree_from_vertex(start)\n tree_from_vertex(start, :bfs)\n end",
"def bfs_shortest_path(node1, node2)\n distance, route = breadth_first_search(node1)\n step = distance[node2]\n node = node2\n path = [ node2 ]\n while node != node1 and route[node]\n node = route[node]\n path.unshift(node)\n end\n return step, path\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bfs\n raise NotImplementedError\n end",
"def bradth_first_search(start_vertex, stop_vertex)\n queue = Array.new()\n queue << search_vertex(start_vertex)\n until queue.empty?\n temp_vertex = queue.shift()\n break if temp_vertex.value == stop_vertex\n vertex_edges = temp_vertex.edges.head\n until vertex_edges == nil\n current = search_vertex(vertex_edges.value)\n if current.visited == false\n current.visited = true\n current.parent = temp_vertex.value\n queue << current\n end\n vertex_edges = vertex_edges.link\n end\n temp_vertex.visited = true\n end\n graph_traversal(start_vertex, stop_vertex)\n end",
"def breadth_first_search_winston(goal_vertex)\n return [self] if self == goal_vertex\n @queue = []\n @explored = {}\n @queue << [self]\n @explored[self.label] = true\n while @queue\n path = @queue.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) : @queue.unshift(new_path)\n end\n }\n end\n end",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end",
"def bfs\n\n end",
"def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end",
"def breadth_first_traverse(s)\n a = []\n # marking visited nodes\n visited = Array.new(@vertices)\n # create a queue for BFS\n queue = Queue.new\n\n # mark the current node as visited and enqueue it\n visited[s] = true\n queue.enqueue(s)\n\n until queue.empty?\n\n # Dequeue a vertex from queue and print it or push it into 'a' array\n s = queue.poll\n\n # print \"#{s} \"\n a.push(s)\n\n # get all adjacent vertices of the dequeued vertex s\n # if a adjacent has not been visited, then mark it\n # visited and dequeue it\n adjacent_vertices = @adjList[s]\n\n i = 0\n while i < adjacent_vertices.length\n\n n = adjacent_vertices[i]\n\n unless visited[n]\n visited[n] = true\n queue.enqueue(n)\n end\n\n i += 1\n end\n\n end\n # returning the list on BFS order\n a\n end",
"def bfs_iterative(target)\n queue = [self]\n\n until queue.empty?\n node = queue.shift\n\n return node if node.value == target\n\n node.children.each do |child|\n queue << child\n end\n end\n\n nil\n end",
"def dijkstra(graph, source)\n # number of vertices in graph\n n = graph.vertices.count\n # O(V)\n # a hash of vertex_states for each vertex in graph\n vertex_states = Hash.new{ |hash,key| hash[key] = VertexState.new(key)}\n graph.each_vertex do |vertex|\n vertex_states[vertex]\n end\n \n # init rules for priority queue\n pqueue = PQueue.new(){|u,v| vertex_states[u].shortest_distance < vertex_states[v].shortest_distance }\n # handle the source node\n vertex_states[source].shortest_distance = 0\n vertex_states[source].visited = true\n pqueue.push(source)\n \n # O(VlogV + E)\n # main loop of algo\n while pqueue.size != 0\n # O(logV)\n u = pqueue.pop\n # set vertex state to visited\n vertex_states[u].visited = true\n # check adjacent vertices\n # O(E)\n graph.each_adjacent(u) do |v|\n relax(graph,u,v,vertex_states) {pqueue.push(v)}\n end\n end\n vertex_states\n end",
"def findShortest(graph_nodes, graph_from, graph_to, ids, val)\n return -1 if ids.count(val)<=1 # no two nodes with color val\n dmin = graph_nodes\n num_edges = graph_from.length\n neighbors = {}\n 0.upto(num_edges-1) do |i|\n if neighbors[graph_from[i]]\n neighbors[graph_from[i]] << graph_to[i]\n else\n neighbors[graph_from[i]] = [graph_to[i]]\n end\n if neighbors[graph_to[i]]\n neighbors[graph_to[i]] << graph_from[i]\n else\n neighbors[graph_to[i]] = [graph_from[i]]\n end\n end\n p neighbors\n ids.each_with_index do |v,i|\n if v == val\n # zero-base index to one-base index \n source_node = i+1\n # look for others using bfs (stop looking if distance > dmin)\n queue = []\n visited = []\n backtrace = {}\n queue << source_node\n while !(queue.empty?)\n current_node = queue.shift\n visited << current_node\n if (current_node!=source_node) && (ids[current_node-1]==val)\n puts \"we are here!\"\n # how did I get here? backtrace\n hops = 0\n trace_node = current_node\n while (trace_node!=source_node)\n trace_node = backtrace[trace_node]\n hops +=1\n end\n if hops < dmin\n dmin = hops\n end\n break\n end\n neighbors[current_node].each do |xnode|\n if !(visited.include?(xnode))\n queue << xnode\n backtrace[xnode] = current_node\n end\n end\n end\n p visited\n end\n end\n if dmin == graph_nodes\n return -1\n else\n return dmin\n end\nend",
"def breadth_first_search(start_node, target_value)\n\t\tvisited = [start_node]\t\t\t\n\t\tqueue = [start_node]\n\t\n\t\twhile ( queue.length > 0 )\t\n\n\t\t\t# dequeue\n\t\t\tvertex = queue.shift\n\t\t\treturn vertex if target_value.name == vertex.name\n\t\n\t\t\t# visit all adjacent unvisited vertexes, mark visited, enqueue\n\t\t\tNode.childPointers.each do |child|\n\t\t\t\tif !eval(\"vertex.#{child}.nil?\")\n\t\t\t\t\tif !eval(\"visited.include?vertex.#{child}\")\n\t\t\t\t\t\tvisited << eval(\"vertex.#{child}\")\n\t\t\t\t\t\teval(\"vertex.#{child}.prev = vertex\")\n\t\t\t\t\t\tqueue << eval(\"vertex.#{child}\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tnil\n\tend",
"def shortest_path(v,w)\n raise ArgumentError unless path?(v,w) \n to_edge = []\n bfs(w) { |v1,v2| to_edge[v2] = v1 }\n result = []\n x = v\n while x != w\n result << x\n x = to_edge[x]\n end\n result << x\n end",
"def compute_shortest_path\n update_distance_of_all_edges_to(Float::INFINITY)\n @distance_to[@source_node] = 0\n\n # The prioriy queue holds a node and its distance from the source node.\n @pq.insert(@source_node, 0)\n while @pq.any?\n node = @pq.remove_min\n node.adjacent_edges.each do |adj_edge|\n relax(adj_edge)\n end\n end\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 bfs(current = @root, array = [])\n if current == nil\n return array\n else\n bfs(current.left, array)\n array << { key: current.key, value: current.value }\n bfs(current.right, array)\n end\n end",
"def bfs(target)\n q = [self]\n until q.empty?\n shifted = q.shift\n return shifted if shifted.value == target\n q += shifted.children\n # debugger\n end\n nil\n end",
"def shortest_path\n dist, previous = Hash.new(Infinity), {}\n dist[@source] = 0.0\n queue = @graph.vertex_set.dup\n\n until queue.empty?\n u = queue.min { |a,b| dist[a.name] <=> dist[b.name] }\n break if dist[u.name].infinite?\n queue.delete(u)\n\n u.each_edge do |e, v|\n alt = dist[u.name] + e.weight\n if alt < dist[v.name]\n dist[v.name] = alt\n previous[v.name] = u.name\n end\n end\n end\n\n path = []\n u = @dest\n until previous[u].nil?\n path.unshift(u)\n u = previous[u]\n end\n\n path.unshift(@source)\n end",
"def 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 shortest_path(start, finish)\n queue << [start, 0]\n loop do\n break if queue.empty?\n vertex, d = queue.pop\n graph[*vertex] = d\n break if vertex == finish\n enqueue_neighbours(*vertex, d + 1)\n end\n queue.clear\n !blank?(finish) ? build_path(start, finish) : []\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 bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end",
"def bfs(val) \n queue = [self] \n\n until queue.empty? \n if queue.first.value == val\n return queue.first\n else\n queue.concat(queue.shift.children) #you add [] + children's children\n end\n end\n nil #if noting == val\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def find_route(adj, i, f)\n return false unless adj[i] && adj[f]\n return true if i == f\n bfs_queue = []\n visited = {}\n visited[i] = true\n bfs_queue << adj[i].first\n\n while !bfs_queue.empty?\n current = bfs_queue.shift\n return true if current == f\n visited[current] ? break : visited[current] = true\n adj[current].each { |n| bfs_queue << n }\n end\n\n return false\nend",
"def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end",
"def dijkstra(src, target = nil)\n frontier = PriorityQueue.new\n shortest_paths = {src => 0}\n frontier[src] = 0\n\n until frontier.empty?\n v, c = frontier.pop_min # much faster\n\n return c if target == v\n shortest_paths[v] = c\n\n v.outer_edges.each do |e|\n v2, c2 = e.to, e.cost\n next if shortest_paths[v2]\n\n frontier.insert([v2, c + c2]) # faster\n end\n end\n\n shortest_paths\nend",
"def dijkstra(source, destination, calcweight)\n\tvisited = Hash.new\t\t\t\t#hash of airports and booleans\n\tshortest_distances = Hash.new\t#hash of airports and the cost of reaching that airport from source\n\tprevious = Hash.new\t\t\t\t#hash of airports and their predecessor in the dijkstra algorithm -- the values are tuples of airports and flights\n\t@airports.each do |a|\n\t\tvisited[a] = false\t\t\t#initially no airports are visited\n\t\tshortest_distances[a]=@INFINITY\t\t#the cost to reach every airport is infinite\n\t\tprevious[a]= [nil,nil]\t\t\t#no airport has been reached yet\n\tend\n\n\t#info about priority queue: http://www.math.kobe-u.ac.jp/~kodama/tips-ruby-pqueue.html\n\tpq = PQueue.new(proc {|x,y| shortest_distances[x[0]] < shortest_distances[y[0]]})\n\n\tpq.push([source,@date]) \t\t#the priority queue contains a tuple of airports and the arrival time in that airport\n\tvisited[source] = true\n\tshortest_distances[source] = 0\n\n\n\n\twhile pq.size!=0\t\t\t#If the priority queue is empty, the algorithm is finished\n\t\tnode = pq.pop\n\t\tvisited[node[0]] = true\t\t#(node[0] contains the airport code)\n\n\t\t#if edges[v]\n\t\t\tnode[0].connections.each do |w|\t\n\n\t\t\t\tif visited[w]==false\n\t\t\t\t\tf = getFlights(node[0],w,node[1])\t#for each connection from that airport\n\t\t\t\t\tif(not f.nil? and f.length!=0)\t\t#get the suitable flights\n\t\t\t\t\t\tweight = @INFINITY\t\t#and find the most optimal of this array of flights\n\t\t\t\t\t\tflight = nil\n\n\t\t\t\t\t\tf.each do |fl|\t\t\t\n\t\t\t\t\t\t\tt = calcweight.call(fl,shortest_distances[node[0]])\n\t\t\t\t\t\t\tif t<weight then \n\t\t\t\t\t\t\t\tweight = t \n\t\t\t\t\t\t\t\tflight = fl\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t#continue regular dijkstra algorithm\n\t\t\t\t\t\tif shortest_distances[w] > weight\n\t\t\t\t\t\t\tshortest_distances[w] = weight\n\t\t\t\t\t\t\tprevious[w] = [node[0],flight]\n\t\t\t\t\t\t\tarrdate = Date.new(flight.date.to_s,flight.departureTime.to_s) #calculate the arrival time/date \n\t\t\t\t\t\t\tarrdate.addTimeToDate(flight.flightDuration)\t\t\t#of this flight\n\t\t\t\t\t\t\tpq.push([w,arrdate])\t\t\t\t#and put it with the airport in the priority queue\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\tend\n\n\tret = []\n\t#get the list of flights form the 'previous' hash\n\twhile destination != source\n\t\tif destination.nil? then \n\t\tp \"No flights available, try an other day...\"\n\t\treturn nil\n\t\tend\n\t\tf = previous[destination][1]\n\n\t\tret.push(f)\n\t\tdestination = previous[destination][0]\n\n\n\tend\n\t#ret now holds the flights in reversed order, so we need to reverse the array before returning it.\n\treturn ret.reverse\nend",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def bfs_search(queue, item)\n root = @tree.root\n queue.add(root)\n current_node = queue.pop\n until current_node == item || current_node.nil?\n queue.add(current_node.left_child)\n queue.add(current_node.add_child)\n current_node = queue.pop\n end\n return current_node\nend",
"def dijkstra(adjacency_matrix, start_node) \n shortest_distances = Array.new(adjacency_matrix[0].length){Float::INFINITY}\n parent_list = Array.new(shortest_distances.length){nil} \n tracking_q = Queue.new\n visited_nodes = Set.new\n\n # start with start node\n # start node has no previous node, marked as 0\n visited_nodes.add(start_node)\n shortest_distances[start_node] = 0\n\n adjacency_matrix[start_node].each_with_index do |weight, i|\n if weight > 0 && i != start_node\n parent_list[i] = start_node\n shortest_distances[i] = weight\n tracking_q.push(i)\n end\n end\n\n until (tracking_q.empty?) \n cur_node = tracking_q.pop\n # skip already visited nodes\n next if visited_nodes.include?(cur_node)\n # check all adjacent nodes\n visited_nodes.add(cur_node)\n\n # check for adjacent nodes\n adjacency_matrix[cur_node].each_with_index do |weight, i|\n # ignore those with no weight\n if weight > 0 && i != cur_node\n if shortest_distances[cur_node] + weight < shortest_distances[i]\n shortest_distances[i] = shortest_distances[cur_node] + weight\n parent_list[i] = cur_node\n end\n tracking_q.push(i)\n end\n end\n end\n\n return {start_node: start_node, \n parent_list: parent_list, \n shortest_distances: shortest_distances}\nend",
"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 solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend",
"def calc_dijkstra\n # The initial values for the Dijkstra search\n dijkstra_search.frontier << [state.star, 0]\n dijkstra_search.came_from[state.star] = nil\n dijkstra_search.cost_so_far[state.star] = 0\n\n # Until their are no more cells to be explored\n until dijkstra_search.frontier.empty?\n # Get the next cell to be explored from\n # We get the first element of the array which is the cell. The second element is the priority.\n current = dijkstra_search.frontier.shift[0]\n\n # Stop the search if we found the target\n return if current == state.target\n\n # For each of the neighbors\n adjacent_neighbors(current).each do | neighbor |\n # Unless this cell is a wall or has already been explored.\n unless dijkstra_search.came_from.key?(neighbor) or state.walls.key?(neighbor)\n # Calculate the movement cost of getting to this cell and memo\n new_cost = dijkstra_search.cost_so_far[current] + cost(neighbor)\n dijkstra_search.cost_so_far[neighbor] = new_cost\n\n # Add this neighbor to the cells too be explored\n dijkstra_search.frontier << [neighbor, new_cost]\n dijkstra_search.came_from[neighbor] = current\n end\n end\n\n # Sort the frontier so exploration occurs that have a low cost so far.\n # My implementation of a priority queue\n dijkstra_search.frontier = dijkstra_search.frontier.sort_by {|cell, priority| priority}\n end\n end",
"def breadth_first_search(target)\n queue = [@root]\n visited = []\n\n until queue.empty?\n node = queue[0]\n visited << node\n return \"Found target: #{target} at node #{node}\" if node.value == target\n if node.left && !visited.include?(node.left)\n queue << node.left\n end\n if node.right && !visited.include?(node.right)\n queue << node.right\n end\n queue.shift\n end\n end",
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend",
"def plan(s1, s2)\r\n if s1 == s2\r\n return []\r\n end\r\n\r\n condensed_path = Array.new\r\n full_path = Array.new\r\n temp = BFS.new(graph, find_node(s1)).shortest_path_to(find_node(s2))\r\n\r\n temp.each {|x| full_path.push(x.to_s)}\r\n condensed_path.push(full_path.first)\r\n condensed_path = condensed_path + transfer_stations(full_path)\r\n \r\n if condensed_path.last != full_path.last #need to test this more\r\n condensed_path << full_path.last\r\n end\r\n\r\n return condensed_path\r\n end",
"def floyd_warshall(weight=nil, zero=0)\r\n c = Hash.new {|h,k| h[k] = Hash.new}\r\n path = Hash.new {|h,k| h[k] = Hash.new}\r\n delta = Hash.new {|h,k| h[k] = 0}\r\n edges.each do |e| \r\n delta[e.source] += 1\r\n delta[e.target] -= 1\r\n path[e.source][e.target] = e.target \r\n c[e.source][e.target] = cost(e, weight)\r\n end\r\n vertices.each do |k|\r\n vertices.each do |i|\r\n if c[i][k]\r\n vertices.each do |j|\r\n if c[k][j] && \r\n (c[i][j].nil? or c[i][j] > (c[i][k] + c[k][j]))\r\n path[i][j] = path[i][k]\r\n c[i][j] = c[i][k] + c[k][j]\r\n return nil if i == j and c[i][j] < zero\r\n end\r\n end\r\n end \r\n end\r\n end\r\n [c, path, delta]\r\n end",
"def bfs(target_value)\n queue = [self]\n\n until queue.empty?\n head = queue.shift\n return head if head.value == target_value\n\n head.children.each { |child| queue << child }\n end\n end",
"def bfs(target_value)\n child_arr = [self]\n # children.each {|child| children_arr << child }\n while child_arr.length > 0\n node_to_check = child_arr.shift\n return node_to_check if node_to_check.value == target_value\n node_to_check.children.each { |child| child_arr << child }\n end\n nil\n end",
"def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n next unless @graph[from]\n @graph[from].each_key do |to|\n unless visited[to]\n visited[to] = true\n distance[to] = distance[from] + 1\n predecessor[to] = from\n queue.push(to)\n end\n end\n end\n return distance, predecessor\n end",
"def bfs(target_value)\n queue = []\n queue << self\n\n while queue.empty? == false\n check = queue.pop\n \n if check.value == target_value\n return check.value\n else\n queue.unshift(*check.children)\n end\n end\n \n false\n end",
"def bfs_search_tree_from(v)\n unless defined?(DirectedAdjacencyGraph)\n require 'rgl/adjacency'\n end\n bfs = bfs_iterator(v)\n tree = DirectedAdjacencyGraph.new\n\n bfs.set_tree_edge_event_handler do |from, to|\n tree.add_edge(from, to)\n end\n\n bfs.set_to_end # does the search\n tree\n end"
] | [
"0.7821317",
"0.7783775",
"0.7655907",
"0.7561982",
"0.74678147",
"0.7439531",
"0.7432345",
"0.7280656",
"0.72553843",
"0.717093",
"0.7112583",
"0.7100397",
"0.7040671",
"0.69938123",
"0.6933733",
"0.692333",
"0.6912769",
"0.68775815",
"0.6867509",
"0.67230695",
"0.67045087",
"0.6689002",
"0.6685421",
"0.66621196",
"0.66397756",
"0.6629706",
"0.6611054",
"0.6597863",
"0.65727854",
"0.6565225",
"0.6561917",
"0.6532831",
"0.6522583",
"0.6501382",
"0.64606357",
"0.6412505",
"0.6411429",
"0.640154",
"0.639616",
"0.6389675",
"0.63625467",
"0.6349766",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6345858",
"0.6339391",
"0.63325906",
"0.6310693",
"0.6291469",
"0.62696946",
"0.62527764",
"0.62487036",
"0.62374276",
"0.6234196",
"0.6215499",
"0.61992306",
"0.6180172",
"0.6178453",
"0.61755157",
"0.6174355",
"0.6152028",
"0.6136305",
"0.612936",
"0.6124173",
"0.6121196",
"0.60856277",
"0.6074655",
"0.60732377",
"0.6033668",
"0.60184157",
"0.6005734",
"0.60039973",
"0.59936583",
"0.59864724",
"0.5982297",
"0.59748745",
"0.596974",
"0.59688145",
"0.59681535",
"0.5964773",
"0.5953158",
"0.5934091",
"0.5931707",
"0.592661",
"0.5916429",
"0.5914786",
"0.5911356"
] | 0.0 | -1 |
Public: Determines if this scenario can be loaded. | def loadable?
Api::Area.code_exists?(area_code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadable?\n %w(test development).include?(Rails.env) || !loaded?\n end",
"def loaded?\n true\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n !!self.loaded\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?(resource)\n resource.instance_variable_defined?(instance_variable_name)\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n return @loaded\n end",
"def loading?\n !load_stack.empty?\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?(resource)\n assert_kind_of 'resource', resource, source_model\n\n resource.instance_variable_defined?(instance_variable_name)\n end",
"def loaded?(feature)\n $LOADED_FEATURES.include? feature\n end",
"def loaded?\n @loaded ||= false\n end",
"def loaded?\n @loaded ||= false\n end",
"def is_loaded\n\t\tend",
"def loaded?\n self.load_error = nil\n\n return true if loaded\n\n load_validations_pass?\n end",
"def system_load_ok?\n true\n end",
"def loaded?\n not @hash.nil?\n end",
"def loaded?\n not @hash.nil?\n end",
"def loaded? feature\n $LOADED_FEATURES.any? do |path|\n path =~ /^#{feature}#{SUFFIX_RE}$/\n end\n end",
"def loaded?\n Spotify.image_is_loaded(@pointer)\n end",
"def loaded_correctly?\n !!@module\n end",
"def loaded_correctly?\n !!@module\n end",
"def loaded?\n self.response_data.present?\n end",
"def loaded?\n browser.title.include?('PHPTRAVELS')\n end",
"def loaded?(constant)\n return loaded.include?(constant)\n end",
"def loaded?\n Spotify.album_is_loaded(pointer)\n end",
"def loadable?(path)\n return false unless File.exists? path\n\n @stat = File.stat path\n @stat.file? and @stat.readable?\n end",
"def loaded?\n\t\treturn @entry ? true : false\n\tend",
"def loaded?\n !@all.nil?\n end",
"def should_load?\n test_framework? || trace_observer_configured?\n end",
"def loaded?\n @data\n end",
"def loaded?\n @data\n end",
"def loaded?\n !! @data\n end",
"def loaded?\n !! @data\n end",
"def loaded?\n !!@data\n end",
"def is_chain_loaded?\n loaded = self.loader_status\n if loaded[\"success\"]\n return loaded[\"loaded\"]\n else\n return nil\n end\n end",
"def instance_loading?(type)\n defined?(@autoloaders) and @autoloaders.include?(type.intern)\n end",
"def has_included_resources?\n !self.included_resources.empty?\n end",
"def can_start_instance?\n if maint_mode?\n return false unless Instance.running_for_profile(self).empty? or\n Instance.running_maint_for_laboratory?(laboratory)\n else\n return false if !active? or \n laboratory.max_instances <= laboratory.active_instances.size\n end\n true\n end",
"def loaded?\n Unit.units.has_key? @label\n end",
"def preload_required?\n %w[start restart reload run].include?(@action)\n end",
"def load_current_resource\n true\n end",
"def loaded?\n Thread.current[:padrino_loaded]\n end",
"def ability?\n self.__ability.present?\n end",
"def content_loaded?\n @content.to_bool\n end",
"def conditions_met?\n class_name = SceneManager.scene.class.name.to_sym\n return false unless scene_whitelist.empty? || scene_whitelist.include?(class_name)\n return false if scene_blacklist.include?(class_name)\n return false unless $game_switches[@event.switch_id]\n return true\n end",
"def training_required?\n return training_required\n end",
"def has_included_resources?\n @has_included_resources ||= included_resources.any?\n end",
"def loaded?\n @images.size > 0\n end",
"def initiative_started?\n find_init.present?\n end",
"def autoload?\n\n return true unless defined? @autoload\n return @autoload \n\n end",
"def load_from_classloader?\n !!@resource_prefix\n end",
"def loaded?(*how)\n pageTitle_element.present?\n end",
"def autoload?\n !!@autoload\n end",
"def readyable?\n readyable\n end",
"def loaded?\n !!@collection\n end",
"def loaded?\n !! last_request_time\n end",
"def loaded?\n !! last_request_time\n end",
"def loading_revision?\n !load_revision_stack.empty?\n end",
"def guard_usable?\r\n usable?($data_skills[guard_skill_id])\r\n end",
"def loading?(path)\n while thread = load_map[path]\n return true if thread == Thread.current\n thread.join\n end\n\n return false\n end",
"def static_boot_eligible?\n provider.static_boot_eligible?\n end",
"def ready?\n\t if @controller and @controller.respond_to?(:ready?)\n\t\t@controller.ready?\n\t else\n\t\ttrue\n\t end\n\tend",
"def config_file_loaded?\n @config_file_loaded\n end",
"def loading_context?\n validation_context == :loading\n end",
"def loading_context?\n validation_context == :loading\n end",
"def loading_context?\n validation_context == :loading\n end",
"def has_custom_attack?\n custom_attack_skill_features.any?\n end",
"def extension_loaded?\n !!extension_loaded\n end",
"def extension_loaded?\n !!extension_loaded\n end",
"def can_import?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def scenario\n unless @scenarios_loaded\n scenario_file = File.expand_path(\"./scenarios/#{self.class.name.underscore}.scenario\", @@current_dir)\n if File.exists?(scenario_file)\n self.instance_eval File.read(scenario_file), __FILE__, __LINE__ + 1\n else\n raise ScenarioFileNotFoundError.new(\"File #{scenario_file} not found\")\n end \n @scenarios_loaded = true\n end\n end",
"def state_loaded?(state_class)\n @states.include?(state_class)\n end",
"def startable?\n\t\treturn false if self.key_name.blank? || self.instance_type.blank? || self.image_id.blank? || self.security_groups.nil?\n\t\treturn true\n\tend",
"def has_included_resources?\n # Check nill\n if @include_param.nil?\n has_included_resources_is_false_when_nil\n else\n check_has_included_resources_is_true_or_false_with_wildcard_and_non_params_or_both\n end\n\n end",
"def module_loaded?\n /^#{new_resource.modname}/.match?(::File.read(\"/proc/modules\"))\n end",
"def ready?\n state == RUNNABLE_STATE\n end",
"def provisional?\n registered? && @provisional\n end",
"def attributes_loaded?\n @attributes_loaded\n end",
"def options_valid?\n loaded_config? &&\n output_base_valid? &&\n have_sample_ids? &&\n sample_ids_in_config?\nend",
"def estimable?\n story_type == 'feature' && !estimated?\n end",
"def dom_loaded?\n !@dom_loaded.empty?\n end",
"def available?\n true\n end",
"def partially_instanciated?\n !fully_instanciated?\n end",
"def use_placeholder_loader?\n !self[:instance_specific] && !self[:eager_graph]\n end",
"def has_a_wizard?\n @wizard != nil\n end",
"def ready_to_start?\n\t\tenabled_players = @entries.select do |entry|\n\t\t\tentry.enabled\n\t\tend\n\t\tenabled_players.size() >= Constants::MIN_PLAYERS &&\n\t\t\tnames_are_unique?(enabled_players)\n\tend",
"def ready?\n return _ready?\n rescue\n return false\n end",
"def on_page?\n begin\n rcd_trait\n @trait = rcd_trait\n #consider adding a URL check here\n Watir::Wait.until { @trait.exists? && @trait.present? }\n return true\n rescue\n return false\n end\n end",
"def verify_load_path(path, loading=false)\n path = File.expand_path path if home_path? path\n\n @feature = path\n\n if qualified_path? path\n return false unless loadable? path\n else\n return false unless path = search_load_path(path, loading)\n path = \"./#{path}\" unless qualified_path? path\n end\n\n @file_path = path\n @load_path = File.expand_path path\n\n return true\n end",
"def ready?\n `#@native.readyState === \"complete\" || #@native.readyState === \"interactive\"`\n end"
] | [
"0.7016242",
"0.6803629",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.67440385",
"0.6740174",
"0.6740174",
"0.6701838",
"0.6697548",
"0.6697176",
"0.669248",
"0.6688106",
"0.6674858",
"0.6674858",
"0.6666693",
"0.65276355",
"0.65257347",
"0.6502418",
"0.6487232",
"0.6482193",
"0.634612",
"0.6344512",
"0.6344512",
"0.6294609",
"0.62756187",
"0.62535053",
"0.62535053",
"0.6185436",
"0.61042064",
"0.6062381",
"0.60524094",
"0.6030005",
"0.60073805",
"0.59998435",
"0.5995064",
"0.5946048",
"0.5946048",
"0.5932176",
"0.5932176",
"0.59193933",
"0.59193546",
"0.59162605",
"0.5905827",
"0.5901099",
"0.58979946",
"0.5889657",
"0.5880142",
"0.58759725",
"0.58424395",
"0.5823547",
"0.5823373",
"0.5820309",
"0.5802133",
"0.57924575",
"0.5783343",
"0.5782986",
"0.57729524",
"0.5771309",
"0.57704383",
"0.5766721",
"0.57461125",
"0.5741257",
"0.5741257",
"0.5739801",
"0.57201695",
"0.57199115",
"0.5714592",
"0.56902206",
"0.56873333",
"0.5678866",
"0.5678866",
"0.5678866",
"0.56776243",
"0.5667389",
"0.5667389",
"0.5662809",
"0.5650283",
"0.56457925",
"0.56443584",
"0.5639749",
"0.5638793",
"0.56344944",
"0.56233585",
"0.5622299",
"0.5612973",
"0.56024885",
"0.5595485",
"0.55901086",
"0.5588157",
"0.55776143",
"0.5572858",
"0.5571398",
"0.55709267",
"0.556414",
"0.55569476",
"0.55522424"
] | 0.62746537 | 29 |
The JSON request returns a string. Let's make it a DateTime object | def parsed_created_at
DateTime.parse(created_at) if created_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_date\n start_time.to_i\n end",
"def date\n Date.parse(@obj['date'])\n end",
"def to_datetime\n @_to_datetime = proc do |dt|\n begin\n DateTime.iso8601(dt.to_s)\n rescue ArgumentError\n raise Intermodal::BadRequest\n end\n end\n end",
"def date\n Date.parse(@data['date'])\n end",
"def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end",
"def datetime\n return \"\" if self.date.nil?\n self.date.iso8601\n end",
"def httpdate\n utc.httpdate\n end",
"def get_datetime\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/datetime'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the response\n _response = @http_client.execute_as_string(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n return DateTime.iso8601(_response.raw_body)\n end",
"def get_date\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/date'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n Date.iso8601(_response.raw_body)\n end",
"def time\n Time.parse(@data['date'])\n end",
"def api_date; utc.strftime(API_TIME_FORMAT); end",
"def created\n DateTime.parse(@json['project']['meta']['created'])\n end",
"def api_date\n utc.strftime(MO.api_time_format)\n end",
"def test_sending_datetime_as_optional_in_plain_text_body()\n # Parameters for the API call\n body = DateTimeHelper.from_rfc3339('1994-02-13T14:01:54.9571247Z')\n\n # Perform the API call through the SDK function\n result = @controller.send_datetime_optional_in_endpoint(body: body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_sending_datetime_as_optional_in_plain_text_body()\n # Parameters for the API call\n body = DateTimeHelper.from_rfc3339('1994-02-13T14:01:54.9571247Z')\n\n # Perform the API call through the SDK function\n result = @controller.send_datetime_optional_in_endpoint(body: body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def systemdate\n response = CreateSend.get('/systemdate.json')\n Hashie::Mash.new(response)\n end",
"def test_send_optional_datetime_in_model_as_body()\n # Parameters for the API call\n body = ModelWithOptionalRfc3339DateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":\"1994-02-13T14:01:54.9571247Z\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_datetime_in_model(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_optional_datetime_in_model_as_body()\n # Parameters for the API call\n body = ModelWithOptionalRfc3339DateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":\"1994-02-13T14:01:54.9571247Z\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_datetime_in_model(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_rfc3339_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_rfc3339('1994-02-13T14:01:54.9571247Z')\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc3339_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_rfc3339_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_rfc3339('1994-02-13T14:01:54.9571247Z')\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc3339_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def json\n {\"creation_date\" => @creation_date}\n end",
"def set_time\n @tDate = Time.now\n respond_to do |format|\n format.html\n format.json {render json: @tDate}\n end\n end",
"def open_datetime\n Time.parse(data.fetch('openDate'))\n end",
"def get_3339_datetime\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/3339datetime'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n DateTimeHelper.from_rfc3339(_response.raw_body)\n end",
"def created_at\n data['creationDate'].to_date\n end",
"def test_date_as_optional()\n # Parameters for the API call\n body = DateAsOptional.from_hash(APIHelper.json_deserialize(\n '{\"date\":\"1994-02-13\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.date_as_optional(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_date_as_optional()\n # Parameters for the API call\n body = DateAsOptional.from_hash(APIHelper.json_deserialize(\n '{\"date\":\"1994-02-13\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.date_as_optional(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def datetime_data(object)\n return object unless object.present?\n\n DateTime.strptime(object, '%Y-%m-%d').to_s\n rescue ArgumentError => e\n rescue_and_retry_datetime(object, e)\n end",
"def get_arrival_time\n DateTime.new(\n params[:date][:year].to_i,\n params[:date][:month].to_i,\n params[:date][:day].to_i,\n params[:date][:hour].to_i,\n params[:date][:minute].to_i\n )\n end",
"def to_datetime()\n #This is a stub, used for indexing\n end",
"def httpdate\n getutc.strftime('%a, %d %b %Y %T GMT')\n end",
"def created_at\n Time.at(response[\"createdAt\"]) if response[\"createdAt\"]\n end",
"def date\n request Net::NNTP::Date.new\n end",
"def request_timestamp\n request_time.strftime(\"%Y%m%dT%H%M%SZ\")\n end",
"def get_1123_date_time\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/1123datetime'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n DateTimeHelper.from_rfc1123(_response.raw_body)\n end",
"def date_published_iso8601\n date_published.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n end",
"def result\n DateTime.iso8601(value).utc\n end",
"def created\n Time.parse(@json['user']['meta']['created'])\n end",
"def date\n if date = headers['Date']\n Time.httpdate(date)\n else\n headers['Date'] = now.httpdate unless headers.frozen?\n now\n end\n rescue ArgumentError\n headers['Date'] = now.httpdate unless headers.frozen?\n now\n end",
"def date_parsed\n if created_at?\n Date.parse(valid_params[\"created_at\"])\n elsif updated_at?\n Date.parse(valid_params[\"updated_at\"])\n end\n end",
"def test_send_unix_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_unix_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_unix_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_unix(1484719381)\n\n # Perform the API call through the SDK function\n result = @controller.send_unix_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def system_datetime\r\n request(HTTPMethods::GET, PATH_SYSTEMDATETIME)\r\n end",
"def date_time\n @message[:date_time]\n end",
"def getWeatherData\n @tempModel = Temp\n current_date = Date.today.strftime \"%Y-%m-%d\"\n \n response = RestClient.get(\"http://api.worldweatheronline.com/premium/v1/past-weather.ashx?key=#{ENV['WEATHER_API_KEY']}&q=30.404251,-97.849442&date=2020-06-05&enddate=#{current_date}&format=json\n \", headers={})\n jsonified_response = JSON.parse(response)\n \n # API response is parsed and inserted into DB by the model method postWeatherData\n @tempModel.postWeatherData(jsonified_response);\n puts current_date\n end",
"def to_soap_value\n return to_s unless respond_to? :to_datetime\n to_datetime.to_soap_value\n end",
"def request_timestamp\n auth_info[\"date\"] || \"\"\n end",
"def generate_iso_8601_date\n date = self.to_formatted_s(:response_format)\n iso8601_date = Time.parse(date).utc.iso8601\n\n return iso8601_date\n end",
"def received_at\n params['date'] + params['time']\n end",
"def safe_datetime_string\n safe_date = nil\n if self =~ US_DATE_REGEX\n safe_date = us_date_to_iso_str\n elsif self =~ JSON_DATE_REGEX\n safe_date = json_date_to_time.to_s\n else\n safe_date = self\n end\n safe_date\n end",
"def created_at\n Time.parse @gapi.creation_time\n rescue StandardError\n nil\n end",
"def http_date\n tp = Time.now.gmtime.to_s.split\n \"#{tp[0]}, #{tp[2]} #{tp[1]} #{tp[5]} #{tp[3]} GMT\"\n end",
"def date\n if value = self['date']\n begin\n # Rely on Ruby's standard time.rb to parse the time.\n (Time.rfc2822(value) rescue Time.parse(value)).localtime\n rescue\n # Exceptions during time parsing just cause nil to be\n # returned.\n end\n end\n end",
"def get_unix_date_time\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/response/unixdatetime'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n DateTimeHelper.from_unix(_response.raw_body)\n end",
"def created_at\n return DateTime.parse(@created_at) if @created_at\n\n @created_at\n end",
"def api_time; utc.strftime(API_TIME_FORMAT); end",
"def updated\n DateTime.parse(@json['project']['meta']['updated'])\n end",
"def test_send_rfc1123_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_rfc1123('Sun, 06 Nov 1994 08:49:37 GMT')\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc1123_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_rfc1123_date_time()\n # Parameters for the API call\n datetime = DateTimeHelper.from_rfc1123('Sun, 06 Nov 1994 08:49:37 GMT')\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc1123_date_time(datetime)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def parse_datetime_date(type, resource)\n year = resource[\"#{type}(1i)\"].to_i\n month = resource[\"#{type}(2i)\"].to_i\n day = resource[\"#{type}(3i)\"].to_i\n hour = resource[\"#{type}(4i)\"].to_i\n minute = resource[\"#{type}(5i)\"].to_i\n DateTime.new(year, month, day, hour, minute)\n end",
"def date\n parse!\n @date\n end",
"def ruby_value\n ::Date.parse(@date_time_value.strftime(\"%Y%m%d\"))\n end",
"def get_date(property, data, uri = nil, single: true)\n get_property(property, data, uri, single: single) { |value, type| DateTime.parse(value) }\n end",
"def httpdate\n Time.now.httpdate\n end",
"def get_datetime_array\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/datetime'\n\n # process optional query parameters\n _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {\n 'array' => true\n }\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK',\n 'accept' => 'application/json'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the response\n _response = @http_client.execute_as_string(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Endpoint error handling using HTTP status codes.\n if _response.status_code == 404\n return nil\n end\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n\n # Return appropriate response type\n decoded = APIHelper.json_deserialize(_response.raw_body)\n return decoded.map{|element| DateTime.iso8601(element)}\n end",
"def updated\n DateTime.parse(@json['user']['meta']['updated'])\n end",
"def result\n DateTime.parse(value.sub(/^datetime-/, '')).utc\n end",
"def date \n params['date']\n end",
"def status_effective_at\n object.status_effective_at.as_json\n end",
"def date_time()\n\t\t@data.inspect\n\t\tif !@data.key?(:time) || @data[:time].empty? || !@data.key?(:date) || @data[:date].empty?\n\t\t\treturn nil\n\t\tend\n\n\t\ttime = @data[:time]\n\t\tdate = @data[:date]\n\t\ttime.gsub!(/\\.[0-9]*$/, \"\") # remove decimals\n\t\tdatetime = \"#{date} #{time} UTC\"\n\n\t\tdate = DateTime.strptime(datetime, \"%d%m%y %H%M%S %Z\")\n\t\tdate\n\tend",
"def ruby_value\n to_datetime\n end",
"def request_datestamp\n request_time.strftime(\"%Y%m%d\")\n end",
"def datetime(date)\n if date.class == String\n date = Time.parse(date)\n end\n date\n end",
"def test_send_date()\n # Parameters for the API call\n date = Date.parse('1994-02-13')\n\n # Perform the API call through the SDK function\n result = @controller.send_date(date)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_date()\n # Parameters for the API call\n date = Date.parse('1994-02-13')\n\n # Perform the API call through the SDK function\n result = @controller.send_date(date)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def get_requested_at_smart_str\n if Time.current.to_date == self.requested_at.to_date\n get_formatted_time(self.requested_at)\n else\n get_formatted_datetime(self.requested_at)\n end\n end",
"def test_send_optional_rfc1123_date_time_in_model_body()\n # Parameters for the API call\n date_time = ModelWithOptionalRfc1123DateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":\"Sun, 06 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc1123_date_time_in_model(date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_optional_rfc1123_date_time_in_model_body()\n # Parameters for the API call\n date_time = ModelWithOptionalRfc1123DateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":\"Sun, 06 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_rfc1123_date_time_in_model(date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def created_at_datetime\n @created_at_datetime ||= DateTime.parse(@created_at)\n end",
"def posted\n # Will interpret the stored date as being in the timezone set in Time.zone\n Time.zone.parse(posted_before_type_cast)\n end",
"def httpdate\n return \"#{self.day_name[0, 3]}, #{@t_day} #{self.month_name[0, 3]} #{@t_year} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec} GMT\"\n end",
"def rfc_date(datetime)\n datetime.strftime(\"%Y-%m-%dT%H:%M:%SZ\") # 2003-12-13T18:30:02Z\n end",
"def result\n map_value(converted_value: RDF::Literal.new(\n value.value,\n datatype: PermissiveSchema.valkyrie_datetime\n ))\n end",
"def date\n success ? { 'datesent' => sent } : {}\n end",
"def get_server_date\n response = get_root\n response[\"Date\"]\n end",
"def rfc3339_datetime_as_optional(date_time,\n date_time1: nil)\n # Validate required parameters.\n validate_parameters(\n 'date_time' => date_time\n )\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/query/rfc3339dateTimeAsOptional'\n _query_builder = APIHelper.append_url_with_query_parameters(\n _query_builder,\n 'dateTime' => date_time,\n 'dateTime1' => date_time1\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n _response = execute_request(_request)\n\n # Validate response against endpoint and global error codes.\n return nil if _response.status_code == 404\n validate_response(_response)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n ServerResponse.from_hash(decoded)\n end",
"def received_at\n params['_raw_orderCreatedDatetime']\n end",
"def test_send_optional_unix_time_stamp_in_model_body()\n # Parameters for the API call\n date_time = UnixDateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":1484719381}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_unix_time_stamp_in_model_body(date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def test_send_optional_unix_time_stamp_in_model_body()\n # Parameters for the API call\n date_time = UnixDateTime.from_hash(APIHelper.json_deserialize(\n '{\"dateTime\":1484719381}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_optional_unix_time_stamp_in_model_body(date_time)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def parse_date_time\n self.each do |review|\n review['date_created'] = DateTime.parse(review['date_created'])\n end\n end",
"def get_date()\n @time\n end",
"def created_time\n Time.parse(object[\"created_time\"]) if object[\"created_time\"]\n end",
"def fetch_date_time(response)\n\tbegin\t\t\t\n\t\tdate_time_val = response.string_between_markers(\"tweet-timestamp\",\"\\\\u003E\").strip\n\t\tdate_time_val = date_time_val.string_between_markers(\"js-permalink js-nav\\\\\\\" title=\\\\\\\"\",\"\\\\\\\"\")\n\t\tif date_time_val != nil and date_time_val.to_s != \"\"\n\t\t\tset_date_time(date_time_val)\t\t\n\t\t\tLogWriter.debug(\"date_time:\"+date_time_val)\t\n\t\t\treturn date_time_val\n\t\telse\t\t\t\n\t\t\tLogWriter.debug(\"date_time: UNKNOWN\")\n\t\t\treturn \"UNKNOWN\"\n\t\tend\n\trescue Exception => e#do not log the exception, since data time parsing breaks often.\n\t\t#LogWriter.error(\"DATE TIME PARSING EXCEPTION\"+e.to_s)#given that this often breaks, it is better to throw this more specific error message\n\t\treturn \"UNKNOWN\"\n\tend\n\tend",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def received_at\n\tTime.parse params['payment_date']\n end",
"def get_date()\n @date\n end",
"def get_date()\n @date\n end",
"def api_time\n utc.strftime(MO.api_time_format)\n end",
"def creation_date\n data[:creation_date]\n end",
"def get_request_timestamp\n\t\treturn @transport.get_path(\"meta\",\"datetime\")\n\tend"
] | [
"0.7441295",
"0.6730717",
"0.6662277",
"0.65524375",
"0.6502525",
"0.6502525",
"0.6448631",
"0.64075744",
"0.63948345",
"0.6387967",
"0.6386055",
"0.6363418",
"0.6275118",
"0.6251853",
"0.6251853",
"0.62270695",
"0.62264305",
"0.62264305",
"0.6211145",
"0.6211145",
"0.6187502",
"0.61790824",
"0.61200404",
"0.6096618",
"0.6086011",
"0.6078881",
"0.6078881",
"0.6075439",
"0.60585684",
"0.6054702",
"0.60244024",
"0.60215133",
"0.6020518",
"0.5991471",
"0.5985004",
"0.5943442",
"0.5922251",
"0.5914599",
"0.5914519",
"0.5913551",
"0.5913432",
"0.5913432",
"0.5911142",
"0.58709735",
"0.58678955",
"0.5866568",
"0.58455604",
"0.58430654",
"0.5839031",
"0.5836995",
"0.58363175",
"0.5830312",
"0.58276474",
"0.5814037",
"0.5812074",
"0.5799986",
"0.57938844",
"0.578859",
"0.578859",
"0.5783577",
"0.57698554",
"0.5766046",
"0.5764158",
"0.5761226",
"0.5760272",
"0.57481253",
"0.5745848",
"0.57367754",
"0.57347316",
"0.57266617",
"0.5719571",
"0.5714702",
"0.5703358",
"0.56992644",
"0.56992644",
"0.5695564",
"0.56913483",
"0.56913483",
"0.56866044",
"0.56742793",
"0.565851",
"0.56537944",
"0.5651115",
"0.5644806",
"0.5640886",
"0.56353605",
"0.5635155",
"0.5631255",
"0.5631255",
"0.56274426",
"0.56153077",
"0.56143844",
"0.56039786",
"0.5598159",
"0.5585662",
"0.5581436",
"0.5581436",
"0.55813026",
"0.5580131",
"0.5577173"
] | 0.6120484 | 22 |
Returns an HTTParty::Reponse object with a hash of the scenario user_values | def all_inputs
HTTParty.get(self.class.url_to("#{ id }/inputs"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_response_data\n {\n user: @user.get_hash\n }\n end",
"def success_response_data_for_client\n {\n user: user_data,\n user_kyc_data: user_kyc_data\n }\n end",
"def user_hash\n response_hash.key?(:user) ? response_hash[:user] : {}\n end",
"def make_response(user)\n res = {email: user.email, wallets:[]}\n user.wallets.each{|wallet| res[:wallets] << { id: wallet.id, balance: wallet.display_balance, currency: wallet.balance_currency}}\n res\n end",
"def to_response\n slice(:id, :username, :cash, :referrals).to_json\n end",
"def getValues\n return {\n :clientID => @clientID,\n :clientSecret => @clientSecret,\n :accessToken => @options[:accessToken]\n }\n end",
"def handle_response_json\n assigns = {}\n if instance_variables.include? :@errors\n assigned_variables = [ :@errors ]\n else\n assigned_variables = instance_variables.reject do |variable|\n variable.to_s.starts_with?('@_') or variable.in? Gatekeeper.response_ignored_variables\n end\n end\n assigned_variables.each do |variable|\n variable_value = instance_variable_get(variable)\n assigns[variable.to_s.gsub('@', '').camelize(:lower)] =\n if variable_value.respond_to? :info\n variable_value.info(@current_user, keys: :camelized)\n else\n variable_value.as_json\n end\n end\n render json: assigns\n end",
"def user_hash\n @user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)\n end",
"def payload(user)\n\t\treturn nil unless user and user.id\n\t\t{\n\t\t\tauth_token: JsonWebToken.encode({user_id: user.id, login: user.login}),\n\t\t\tuser: {login: user.login, fio: user.fio}\n\t\t}\n\tend",
"def get_sample_user\n user = case params[:type]\n when \"registered\"; User.registered.sample\n when \"pending\"; User.pending.sample\n when \"active\"; Participation.active.sample.user\n when \"unregistered\"; User.initialized.sample\n else User.order(\"RAND()\").first\n end\n render :json => user.attributes_for_app\n end",
"def login_data\n tbcreds = UserTestbedCredential.where(:user_id => user.id, :testbed_id => testbed.id).first\n logindata = {\n \"authenticationData\" => [\n {\n \"urnPrefix\" => tbcreds.testbed.urn_prefix_list,\n \"username\" => tbcreds.username,\n \"password\" => tbcreds.password\n }\n ]\n }\n logindata\n end",
"def render_authentication_payload(user)\n cookies[:cmm_jwt] = create_jwt_cookie(user.id)\n render json: { user: UserSerializer.new(user) }, status: :ok\n end",
"def to_api\n\n results = {\n 'nation_name' => nation_name,\n 'client_app_id' => client_app_id,\n 'client_secret' => client_secret,\n 'redirect_uri' => redirect_uri\n }\n \n end",
"def to_h\n temp_data = clean @data\n temp_custom_data = clean @custom_data\n temp_data['CustomFieldResponses'] = temp_custom_data\n temp_data\n end",
"def user\n hash = {\n provider: 'josh_id',\n id: current_user.id.to_s,\n info: {\n email: current_user.email,\n username: current_user.username,\n #first_name: current_user.first_name,\n }\n }\n\n render json: hash.to_json\n end",
"def as_json(*)\n serializer = ScenarioSerializer.new(@controller, @updater.scenario)\n { scenario: serializer, gqueries: @results }\n end",
"def user_app_data\n\t\tuser = current_user\n\t\tsurgery_locations = SurgeryLocation.all.count\n\t\tif user.present?\n\t\t# response to the JSON\n \t render json: { success: true, response: {my_surgeries: user.surgeries.count, my_diagnose: user.diagnose.count, manage_assistants: user.manage_assistants.count,surgery_locations: surgery_locations} },:status=> 200\n\t else\n\t render :json=> { success: false, message: \"User App data are not present\" },:status=> 203\n\t end \n\tend",
"def service_response_data\n {\n webhook: @client_webhook_setting.get_hash,\n test_send_id: lock_id\n }\n end",
"def success_response_data\n {\n api_key: @client.api_key,\n api_secret: @client_api_secret_d\n }\n end",
"def success_response\n {\n is_token_invalid: @token_invalid.to_i,\n account_activated: @account_activated.to_i,\n has_double_opt_in: @has_double_opt_in.to_i,\n user: user_data\n }.merge(@client_setting_data)\n end",
"def user_values\n value_of(:user_values, method(:nice_yaml))\n end",
"def set_api_response_data\n users_list = []\n @users.each do |u|\n ukd = @user_kyc_details[u.id]\n ukd_present = ukd.present?\n users_list << {\n user_id: u.id,\n case_id: ukd_present ? @user_kyc_details[u.id].id : 0,\n email: u.email,\n registration_timestamp: u.created_at.to_i,\n is_kyc_submitted: ukd_present.to_i,\n whitelist_status: ukd_present ? @user_kyc_details[u.id].whitelist_status : nil,\n action_to_perform: action_to_perform(ukd)\n }\n end\n\n meta = {\n page_number: @page_number,\n total_records: @total_filtered_users,\n page_payload: {\n },\n page_size: @page_size,\n filters: @allowed_filters,\n sortings: @sortings,\n }\n\n data = {\n meta: meta,\n result_set: 'users_list',\n users_list: users_list\n }\n\n @api_response_data = data\n\n end",
"def get_body(secret_value)\n { 'value' => secret_value }.to_json\n end",
"def service_response_data\n {\n user_extended_detail: @user_extended_detail\n }\n end",
"def index\n\t\trender json: {\n\t\t\terror: nil,\n\t\t\tdata: @current_user.api_hash\n\t\t}\n\tend",
"def api_user_headers\n user = create(:user)\n headers = api_user_login(user.email, user.password)\n request.headers['access-token'] = headers['access-token']\n request.headers['client'] = headers['client']\n request.headers['uid'] = headers['uid']\n end",
"def userReponses\n user=User.find(params[:userId])\n render :json=> user.response\n end",
"def summary_json(user)\n return {} unless user.admin? || user.ta?\n\n if user.admin?\n groupings = self.groupings\n graders = groupings.joins(:tas)\n .pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')\n .group_by { |x| x[:id] }\n assigned_criteria = nil\n else\n groupings = self.groupings\n .joins(:memberships)\n .where('memberships.user_id': user.id)\n graders = {}\n if self.assign_graders_to_criteria\n assigned_criteria = user.criterion_ta_associations\n .where(assessment_id: self.id)\n .pluck(:criterion_id)\n else\n assigned_criteria = nil\n end\n end\n\n grouping_data = groupings.joins(:group)\n .left_outer_joins(inviter: :section)\n .pluck_to_hash(:id, 'groups.group_name', 'sections.name')\n .group_by { |x| x[:id] }\n members = groupings.joins(:accepted_students)\n .pluck_to_hash(:id, 'users.user_name', 'users.first_name', 'users.last_name')\n .group_by { |x| x[:id] }\n tag_data = groupings\n .joins(:tags)\n .pluck_to_hash(:id, 'tags.name')\n .group_by { |h| h[:id] }\n groupings_with_results = groupings.includes(current_result: :marks).includes(:submitted_remark, :extension)\n result_ids = groupings_with_results.pluck('results.id').uniq.compact\n extra_marks_hash = Result.get_total_extra_marks(result_ids, max_mark: max_mark)\n\n hide_unassigned = user.ta? && hide_unassigned_criteria\n\n criteria_shown = Set.new\n max_mark = 0\n\n selected_criteria = user.admin? ? self.criteria : self.ta_criteria\n criteria_columns = selected_criteria.map do |crit|\n unassigned = !assigned_criteria.nil? && !assigned_criteria.include?(crit.id)\n next if hide_unassigned && unassigned\n\n max_mark += crit.max_mark unless crit.bonus?\n accessor = crit.id\n criteria_shown << accessor\n {\n Header: crit.bonus? ? \"#{crit.name} (#{Criterion.human_attribute_name(:bonus)})\" : crit.name,\n accessor: \"criteria.#{accessor}\",\n className: 'number ' + (unassigned ? 'unassigned' : ''),\n headerClassName: unassigned ? 'unassigned' : ''\n }\n end.compact\n\n final_data = groupings_with_results.map do |g|\n result = g.current_result\n has_remark = g.current_submission_used&.submitted_remark.present?\n if user.ta? && anonymize_groups\n group_name = \"#{Group.model_name.human} #{g.id}\"\n section = ''\n group_members = []\n else\n group_name = grouping_data[g.id][0]['groups.group_name']\n section = grouping_data[g.id][0]['sections.name']\n group_members = members.fetch(g.id, [])\n .map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] }\n end\n\n tag_info = tag_data.fetch(g.id, [])\n .map { |a| a['tags.name'] }\n criteria = result.nil? ? {} : result.mark_hash.select { |key, _| criteria_shown.include?(key) }\n extra_mark = extra_marks_hash[result&.id]\n {\n group_name: group_name,\n section: section,\n members: group_members,\n tags: tag_info,\n graders: graders.fetch(g.id, [])\n .map { |s| [s['users.user_name'], s['users.first_name'], s['users.last_name']] },\n marking_state: marking_state(has_remark,\n result&.marking_state,\n result&.released_to_students,\n g.collection_date),\n final_grade: [criteria.values.compact.sum + (extra_mark || 0), 0].max,\n criteria: criteria,\n max_mark: max_mark,\n result_id: result&.id,\n submission_id: result&.submission_id,\n total_extra_marks: extra_mark\n }\n end\n\n { data: final_data,\n criteriaColumns: criteria_columns,\n numAssigned: self.get_num_assigned(user.admin? ? nil : user.id),\n numMarked: self.get_num_marked(user.admin? ? nil : user.id) }\n end",
"def user_data\n @user_data ||= opts[:questionnaire_response]&.user_demographics_data\n end",
"def user_details\n\t\t@user_data = Hash.new\n\t\t@user_data[\"first_name\"] = @first_name\n\t\t@user_data[\"username\"] = @username\n\t\t@user_data[\"password\"] = @password\n\t\t@user_data[\"balance\"] = @balance\n\tend",
"def mv_request(user, lp)\n\turl = lp + \"/mvs/\"\n\n\tidentifying_factors = {}\n\tauthenticating_factors = {}\n\n authenticating_factors = Hash.new.tap do |h|\n h['password'] = user['password'] if user['password']\n end\n\n identifying_factors = Hash.new.tap do |h|\n h[\"firstName\"] = user[\"firstName\"] if user[\"firstName\"]\n h[\"lastName\"] = user[\"lastName\"] if user[\"lastName\"]\n h[\"email\"] = user[\"email\"] if user[\"email\"]\n h[\"memberId\"] = user[\"memberId\"] if user[\"memberId\"]\n end\n\n\tbody = {\"identifyingFactors\" => identifying_factors}.to_json\n\n\trequest = {\"url\" => url, \"body\" => body}\n\n\treturn request\nend",
"def json_response(method = '', value = '')\n response = {\n status: 'success',\n version: 1,\n method: method,\n data: value\n }\n response\n end",
"def mock_auth_hash(user)\n return {\n provider: user.oauth_provider,\n uid: user.oauth_uid,\n info: {\n name: user.name,\n email: user.email\n },\n credentials: {\n token: SecureRandom.base64(128),\n refresh_token: SecureRandom.base64(64),\n expires_at: Time.now + 8.hours\n }\n }\n end",
"def mock_auth_hash(user)\n return {\n provider: user.oauth_provider,\n uid: user.oauth_uid,\n info: {\n name: user.name,\n email: user.email\n },\n credentials: {\n token: SecureRandom.base64(128),\n refresh_token: SecureRandom.base64(64),\n expires_at: Time.now + 8.hours\n }\n }\n end",
"def user_show_data\n user = User.find(params[:user])\n\n @data = {\n name: user.full_name,\n email: user.email,\n title: user.title,\n school_name: user.organization.name,\n logo_link: user.organization.logo_link,\n points: user.points,\n reviews: reviews_from_user(user),\n protips: protips_from_user(user),\n receives_weekly_digest: user.receives_weekly_digest,\n active: user.active\n }\n\n render json: @data\n end",
"def serialise_http(user)\n Spontaneous.serialise_http(shallow_export(user))\n end",
"def get_session\n if session[:user_id].present? && session[:user_name].present?\n @result = {flag:true , session_id: session[:user_id] , :user_name=> session[:user_name]}\n render :json=>@result\n else \n @result = {flag:false}\n render :json=>@result\n end\n end",
"def usage_data\n usage_data = User.all.select(:time_fetched, :twitter_handle).to_json\n render json: {status: 200, success: true, message: 'Success', data: usage_data}\n rescue => e\n Rails.logger.error \"account_controller#usage_data - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def values(params = {})\n @client.get(\"#{path}/values\", params)\n end",
"def user_data\n {\n id: @user.id,\n email: @user.email,\n user_token_sale_state: @user_token_sale_state,\n bt_name: @user.bt_name.to_s\n }\n end",
"def hash\n [custom_headers, encode_as, name, payload, url].hash\n end",
"def create\n json authentication_response, :status => authentication_response_status\n end",
"def summarize\n {\n id: id,\n name: name,\n username: username,\n email: email,\n hashed_email: hashed_email,\n user_type: user_type,\n gender: gender,\n birthday: birthday,\n total_lines: total_lines,\n secret_words: secret_words,\n secret_picture_name: secret_picture.name,\n secret_picture_path: secret_picture.path,\n location: \"/v2/users/#{id}\",\n age: age,\n sharing_disabled: sharing_disabled?,\n }\n end",
"def success_response_data\n {\n client_setting: @client_setting\n }\n end",
"def construct_attribs_payload( orcid, oauth_access, oauth_renew, oauth_scope, user_types )\n h = {}\n\n h['orcid'] = orcid\n h['oauth_access_token'] = oauth_access\n h['oauth_refresh_token'] = oauth_renew\n h['user_types'] = user_types\n h['scope'] = oauth_scope\n\n #puts \"==> #{h.to_json}\"\n return h.to_json\n end",
"def service_response_data\n {\n webhook: @client_webhook_setting.get_hash\n }\n end",
"def create_washington_auth_request(scope)\n post user_session_path, params: {user: { \n email: users(:washington).email,\n password: \"georgepass\"\n }}\n \n context = {}\n context[\"scope\"] = scope\n context[\"state\"] = SecureRandom.urlsafe_base64(10)\n context[\"code_verifier\"] = SecureRandom.urlsafe_base64(10)\n context[\"client_id\"] = \"http://localhost:12345\"\n context[\"redirect_uri\"] = \"http://localhost:12345/redirect\"\n\n approval_params = {}\n scope.split(\" \").each {|s| approval_params[s] = 1}\n approval_params[\"code_challenge\"] = \n Base64.urlsafe_encode64(\n Digest::SHA256.digest(\n context[\"code_verifier\"])).chomp(\"=\")\n approval_params[\"commit\"] = \"Approve\"\n [\"state\", \"client_id\", \"redirect_uri\"].each do |p|\n approval_params[p] = context[p]\n end\n\n\n post indie_auth_approval_path, params: approval_params\n return context\n end",
"def profile_hash(details, creds)\n params = {}\n params[:api_type] = details[:api_type]\n params[:license_key] = creds[:license_key]\n params[:login_id] = creds[:login_id]\n params[:version] = details[:version]\n params\n end",
"def session_hash(user)\n {\n username: user.username,\n authentication_token: user.authentication_token\n }\n end",
"def payload(id, username)\n {\n exp: (Time.now + 30.minutes).to_i,\n iat: Time.now.to_i,\n iss: ENV['JWT_ISSUER'],\n user: {\n id: id,\n username: username\n }\n }\n end",
"def payload(id, username)\n {\n exp: (Time.now + 30.minutes).to_i,\n iat: Time.now.to_i,\n iss: ENV['JWT_ISSUER'],\n user: {\n id: id,\n username: username\n }\n }\n end",
"def expected_response(http_method, uri, credentials, password, password_is_ha1 = T.unsafe(nil)); end",
"def idp_build_user_assertions(user,group)\n hash = {}\n hash[:attributes] = {}\n reseller = Reseller.new\n\n # Populate the session information\n hash[:name_id] = user.uid\n hash[:attributes][:mno_session] = user.sso_session\n hash[:attributes][:mno_session_recheck] = 3.minutes.from_now.utc.iso8601\n\n # Add group metadata\n hash[:attributes][:group_uid] = group.uid\n hash[:attributes][:group_name] = group.name\n hash[:attributes][:group_end_free_trial] = group.free_trial_end_at.utc.iso8601\n hash[:attributes][:group_role] = nil\n hash[:attributes][:group_has_credit_card] = false\n hash[:attributes][:group_email] = \"#{group.uid}@example.com\"\n hash[:attributes][:group_currency] = 'USD'\n hash[:attributes][:group_timezone] = 'America/Los_Angeles'\n hash[:attributes][:group_country] = 'US'\n hash[:attributes][:group_city] = 'Los Angeles'\n hash[:attributes][:group_reseller_id] = reseller.uid\n\n # Add reseller metadata\n if session.delete(:reseller_sso)\n hash[:attributes][:reseller_id] = reseller.uid\n hash[:attributes][:reseller_name] = reseller.name\n hash[:attributes][:reseller_country] = reseller.country\n end\n\n # Add user metadata\n hash[:attributes][:uid] = user.uid\n hash[:attributes][:virtual_uid] = user.virtual_uid(group)\n hash[:attributes][:email] = user.email\n hash[:attributes][:virtual_email] = user.virtual_email(group)\n hash[:attributes][:name] = user.name\n hash[:attributes][:surname] = user.surname\n hash[:attributes][:country] = user.geo_country_code\n hash[:attributes][:company_name] = user.company\n\n # Permissions\n hash[:attributes][:group_role] = (user.role(group) || 'Guest')\n hash[:attributes][:app_owner] = true\n hash[:attributes][:organizations] = {}\n\n # Return the hash\n return hash\n end",
"def index\n unless access_token\n redirect_to controller: 'oauths', action: 'welcome'\n return\n end\n \n @drivers = [:chrome, :ff, :ie, :safari]\n @scenarios = Scenario.where(user_id: current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scenarios }\n end\n end",
"def get_user_session_data_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicySecurityEastWestSecurityDistributedFirewallSettingsFirewallIdentityStoreApi.get_user_session_data ...'\n end\n # resource path\n local_var_path = '/global-infra/settings/firewall/idfw/user-session-data'\n\n # query parameters\n query_params = {}\n query_params[:'enforcement_point_path'] = opts[:'enforcement_point_path'] if !opts[:'enforcement_point_path'].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 = ['BasicAuth']\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 => 'IdfwUserSessionDataAndMappings')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicySecurityEastWestSecurityDistributedFirewallSettingsFirewallIdentityStoreApi#get_user_session_data\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def rest_identity_values\n data = {}\n\n rest_identity_map.each do |rfc_template, property|\n property_value = new_resource.send(property)\n data.merge! bury(rfc_template, property_value)\n end\n\n data\n end",
"def hash_details\n hash_value = params[:value]\n sql = VerificationHash.where(hash_value: hash_value).select(:email).select(\"CASE WHEN entity_type='PropertyBuyer' THEN 'Buyer' WHEN entity_type='Agents::Branches::AssignedAgent' THEN 'Agent' WHEN entity_type='Developer' THEN 'Developer' ELSE 'Vendor' END as entity_type \").to_sql\n details = ActiveRecord::Base.connection.execute(sql)\n if details.first['entity_type'] == 'Agent'\n is_agent = Agents::Branches::AssignedAgent.unscope(where: :is_developer).where(is_developer: true, email: details.first['email']).last.nil?\n details.first['entity_type'] = 'Developer' if !is_agent\n end\n render json: { hash_details: details }, status: 200\n end",
"def index\n users = policy_scope(User)\n render json: { users: users }\n end",
"def set_user_info\n response = Request.send_request_action(action: \"index\", cookie: @cookie)\n @authkey = response[:response][\"authkey\"]\n @passkey = response[:response][\"passkey\"]\n @user_id = response[:response][\"id\"]\n end",
"def get_hamper_data\n hamper_data = convert_session_hamper_into_hash(\"hamper0\") if(!customer_signed_in?)\n # hamper_data = Hamper.where('customer_id = ?', current_customer.id).to_json(:include => { :hamper_items => { :include => { :product => {:only => :name } } } }) if(customer_signed_in?)\n hamper_data = Hamper.where('customer_id = ? AND ordered = ?', current_customer.id, false).to_json(:include => { :hamper_items => { :include => { :product => {:only => :name } } } }) if(customer_signed_in?)\n head :ok, hampers: hamper_data, format: :json\n end",
"def user_data\n {\n user_id: @user.id,\n email: @user.email\n }\n end",
"def get_response(user_input)\n response_string = RestClient.get(\"https://www.metaweather.com/api/location/#{@cities_selector[user_input]}/\")\n response_hash = JSON.parse(response_string)\n end",
"def user_response_params\n params.require(:user_responses)\n end",
"def values\n request.values.flatten\n end",
"def parse_response(context) \n @user_context = {\n :cobrand_id => context[:cobrand_id],\n :channel_id => context[:channel_id],\n :locale => { \n :country => context[:locale][:country], \n :language => context[:locale][:language], \n :variant => context[:locale][:variant] \n },\n :tnc_version => context[:tnc_version],\n :application_id => context[:application_id],\n :cobrand_conversation_credentials => {\n :session_token => context[:cobrand_conversation_credentials][:session_token]\n }, \n :preference_info => {\n :currency_code => context[:preference_info][:currency_code],\n :time_zone => context[:preference_info][:time_zone],\n :date_format => context[:preference_info][:date_format],\n :currency_notation_type => context[:preference_info][:currency_notation_type],\n :number_format => {\n :decimal_separator => context[:preference_info][:number_format][:decimal_separator],\n :grouping_separator => context[:preference_info][:number_format][:grouping_separator],\n :group_pattern => context[:preference_info][:number_format][:group_pattern]\n }\n },\n :conversation_credentials => {\n :session_token => context[:conversation_credentials][:session_token]\n }, \n :valid => context[:valid],\n :is_password_expired => context[:is_password_expired],\n :attributes! => {\n :conversation_credentials => {\"xsi:type\" => \"login:SessionCredentials\"},\n :cobrand_conversation_credentials => { \"xsi:type\" => \"login:SessionCredentials\"}\n }\n }\n end",
"def parse_response(context) \n @user_context = {\n :cobrand_id => context[:cobrand_id],\n :channel_id => context[:channel_id],\n :locale => { \n :country => context[:locale][:country], \n :language => context[:locale][:language], \n :variant => context[:locale][:variant] \n },\n :tnc_version => context[:tnc_version],\n :application_id => context[:application_id],\n :cobrand_conversation_credentials => {\n :session_token => context[:cobrand_conversation_credentials][:session_token]\n }, \n :preference_info => {\n :currency_code => context[:preference_info][:currency_code],\n :time_zone => context[:preference_info][:time_zone],\n :date_format => context[:preference_info][:date_format],\n :currency_notation_type => context[:preference_info][:currency_notation_type],\n :number_format => {\n :decimal_separator => context[:preference_info][:number_format][:decimal_separator],\n :grouping_separator => context[:preference_info][:number_format][:grouping_separator],\n :group_pattern => context[:preference_info][:number_format][:group_pattern]\n }\n },\n :conversation_credentials => {\n :session_token => context[:conversation_credentials][:session_token]\n }, \n :valid => context[:valid],\n :is_password_expired => context[:is_password_expired],\n :attributes! => {\n :conversation_credentials => {\"xsi:type\" => \"login:SessionCredentials\"},\n :cobrand_conversation_credentials => { \"xsi:type\" => \"login:SessionCredentials\"}\n }\n }\n end",
"def response_for_inauthentic_request(env)\n handle_head(env) do\n body = { 'errors' => { 'mauth' => ['Unauthorized'] } }\n [401, { 'Content-Type' => 'application/json' }, [JSON.pretty_generate(body)]]\n end\n end",
"def request_headers(user = nil)\n return {} unless user\n { 'REMOTE_USER' => user.login }\n end",
"def user_kyc_data\n @user_kyc_detail.present? ?\n {\n kyc_status: kyc_status,\n admin_action_types: @user_kyc_detail.admin_action_types_array,\n whitelist_status: @user_kyc_detail.whitelist_status\n }\n :\n {}\n end",
"def user_information\n { \"username\": @user.username, \"email\": @user.email, \"id\": @user.id }\n end",
"def find\n user = getUserByAuthToken(request)\n theResponse = { :id => user.id, :email => user.email, :authentication_token => user.authentication_token}\n render :status => 200, :json => theResponse\n end",
"def expected_filtered_response(spec)\n spec.inject({}) do |body, kv|\n cookbook, allowed_versions = kv\n body[cookbook] = {\n \"url\" => api_url(\"/cookbooks/#{cookbook}\"),\n \"versions\" => allowed_versions.map do |version|\n {\n \"url\" => api_url(\"/cookbooks/#{cookbook}/#{version}\"),\n \"version\" => version\n }\n end\n }\n body\n end\n end",
"def call\n if user\n {access_token:JsonWebToken.encode(user_id: user.id),\n user_role: user.role}\n end \n end",
"def users\n\n @response = CompanyApi::Request::Economy.new(\n CompanyApi::Response::Formatter::Economy,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_user_details\n\n # Check if error present or not?\n unless @response.success?\n render_error_response(@response)\n return\n end\n\n @presenter_obj = ::WebPresenter::Economy::User.new(@response, params)\n unless @presenter_obj.client_token.step_three_done?\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect\n return\n end\n\n end",
"def credentials\n { :user => @user, :password => @password }\n end",
"def with_authentication_hash(auth_type, auth_values); end",
"def to_h\n JSON.parse(body)\n end",
"def build_response\n { status: :success, data: {} }\n end",
"def user_variables_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: UserVariableApi#user_variables_get ...\"\n end\n \n # resource path\n path = \"/userVariables\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'client_id'] = opts[:'client_id'] if opts[:'client_id']\n query_params[:'parent_id'] = opts[:'parent_id'] if opts[:'parent_id']\n query_params[:'variable_id'] = opts[:'variable_id'] if opts[:'variable_id']\n query_params[:'user_id'] = opts[:'user_id'] if opts[:'user_id']\n query_params[:'default_unit_id'] = opts[:'default_unit_id'] if opts[:'default_unit_id']\n query_params[:'minimum_allowed_value'] = opts[:'minimum_allowed_value'] if opts[:'minimum_allowed_value']\n query_params[:'maximum_allowed_value'] = opts[:'maximum_allowed_value'] if opts[:'maximum_allowed_value']\n query_params[:'filling_value'] = opts[:'filling_value'] if opts[:'filling_value']\n query_params[:'join_with'] = opts[:'join_with'] if opts[:'join_with']\n query_params[:'onset_delay'] = opts[:'onset_delay'] if opts[:'onset_delay']\n query_params[:'duration_of_action'] = opts[:'duration_of_action'] if opts[:'duration_of_action']\n query_params[:'variable_category_id'] = opts[:'variable_category_id'] if opts[:'variable_category_id']\n query_params[:'updated'] = opts[:'updated'] if opts[:'updated']\n query_params[:'public'] = opts[:'public'] if opts[:'public']\n query_params[:'cause_only'] = opts[:'cause_only'] if opts[:'cause_only']\n query_params[:'filling_type'] = opts[:'filling_type'] if opts[:'filling_type']\n query_params[:'number_of_measurements'] = opts[:'number_of_measurements'] if opts[:'number_of_measurements']\n query_params[:'number_of_processed_measurements'] = opts[:'number_of_processed_measurements'] if opts[:'number_of_processed_measurements']\n query_params[:'measurements_at_last_analysis'] = opts[:'measurements_at_last_analysis'] if opts[:'measurements_at_last_analysis']\n query_params[:'last_unit_id'] = opts[:'last_unit_id'] if opts[:'last_unit_id']\n query_params[:'last_original_unit_id'] = opts[:'last_original_unit_id'] if opts[:'last_original_unit_id']\n query_params[:'last_original_value'] = opts[:'last_original_value'] if opts[:'last_original_value']\n query_params[:'last_value'] = opts[:'last_value'] if opts[:'last_value']\n query_params[:'last_original_value'] = opts[:'last_original_value2'] if opts[:'last_original_value2']\n query_params[:'last_source_id'] = opts[:'last_source_id'] if opts[:'last_source_id']\n query_params[:'number_of_correlations'] = opts[:'number_of_correlations'] if opts[:'number_of_correlations']\n query_params[:'status'] = opts[:'status'] if opts[:'status']\n query_params[:'error_message'] = opts[:'error_message'] if opts[:'error_message']\n query_params[:'last_successful_update_time'] = opts[:'last_successful_update_time'] if opts[:'last_successful_update_time']\n query_params[:'standard_deviation'] = opts[:'standard_deviation'] if opts[:'standard_deviation']\n query_params[:'variance'] = opts[:'variance'] if opts[:'variance']\n query_params[:'minimum_recorded_value'] = opts[:'minimum_recorded_value'] if opts[:'minimum_recorded_value']\n query_params[:'maximum_recorded_value'] = opts[:'maximum_recorded_value'] if opts[:'maximum_recorded_value']\n query_params[:'mean'] = opts[:'mean'] if opts[:'mean']\n query_params[:'median'] = opts[:'median'] if opts[:'median']\n query_params[:'most_common_unit_id'] = opts[:'most_common_unit_id'] if opts[:'most_common_unit_id']\n query_params[:'most_common_value'] = opts[:'most_common_value'] if opts[:'most_common_value']\n query_params[:'number_of_unique_daily_values'] = opts[:'number_of_unique_daily_values'] if opts[:'number_of_unique_daily_values']\n query_params[:'number_of_changes'] = opts[:'number_of_changes'] if opts[:'number_of_changes']\n query_params[:'skewness'] = opts[:'skewness'] if opts[:'skewness']\n query_params[:'kurtosis'] = opts[:'kurtosis'] if opts[:'kurtosis']\n query_params[:'latitude'] = opts[:'latitude'] if opts[:'latitude']\n query_params[:'longitude'] = opts[:'longitude'] if opts[:'longitude']\n query_params[:'location'] = opts[:'location'] if opts[:'location']\n query_params[:'created_at'] = opts[:'created_at'] if opts[:'created_at']\n query_params[:'updated_at'] = opts[:'updated_at'] if opts[:'updated_at']\n query_params[:'outcome'] = opts[:'outcome'] if opts[:'outcome']\n query_params[:'sources'] = opts[:'sources'] if opts[:'sources']\n query_params[:'earliest_source_time'] = opts[:'earliest_source_time'] if opts[:'earliest_source_time']\n query_params[:'latest_source_time'] = opts[:'latest_source_time'] if opts[:'latest_source_time']\n query_params[:'earliest_measurement_time'] = opts[:'earliest_measurement_time'] if opts[:'earliest_measurement_time']\n query_params[:'latest_measurement_time'] = opts[:'latest_measurement_time'] if opts[:'latest_measurement_time']\n query_params[:'earliest_filling_time'] = opts[:'earliest_filling_time'] if opts[:'earliest_filling_time']\n query_params[:'latest_filling_time'] = opts[:'latest_filling_time'] if opts[:'latest_filling_time']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:GET, 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 => 'inline_response_200_25')\n if Configuration.debugging\n Configuration.logger.debug \"API called: UserVariableApi#user_variables_get. Result: #{result.inspect}\"\n end\n return result\n end",
"def agent_details\n authenticate_request\n if @current_user && !@current_user.is_developer\n details = @current_user.details\n render json: details, status: 200\n end\n end",
"def json_data\n { id: self.id, membership_id: self.membership_id, amount: self.amount.round(2), paid_by: self.user.full_name, description: self.description, vendor: self.vendor, group_id: self.group.id }\n end",
"def response\n rsp = {}\n rsp[:version] = @version\n rsp[:reqId] = @params[:reqId] if @params.key?(:reqId)\n if valid?\n rsp[:status] = \"ok\"\n rsp[:table] = datatable unless data.nil? \n else\n rsp[:status] = \"error\"\n rsp[:errors] = @errors.values.map do |error|\n { :reason => \"invalid_request\" , :message => error }\n end\n end\n \"#{@params[:responseHandler] || @responseHandler}(#{rsp.to_json})\" \n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:name] = @name\n to_return[:identifier] = @identifier\n to_return[:cloudkit_identifier] = @user_record_name\n to_return[:cloudkit_last_modified_device] = @cloudkit_last_modified_device\n to_return[:html] = generate_html\n\n to_return\n end",
"def questionnaire_report_by_users\r\n\r\n range = @when_start .. @when_end\r\n activity_id = Activity.get_activity('submit questionnaire_answer').id\r\n\r\n user_activities = UserActivity.where(:activity_id => activity_id).where(:created_at => range).joins(:user).all\r\n users = {}\r\n user_activities.each do |au|\r\n unless users[au.user.email]\r\n users[au.user.email] = {:user => \"#{au.user.email} #{au.user.first_name} #{au.user.last_name}\", attendance: {}}\r\n end\r\n users[au.user.email][:attendance][au.created_at.to_date] = true\r\n end\r\n\r\n users\r\n end",
"def get_user_session_data_0_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicySecurityEastWestSecurityDistributedFirewallSettingsFirewallIdentityStoreApi.get_user_session_data_0 ...'\n end\n # resource path\n local_var_path = '/infra/settings/firewall/idfw/user-session-data'\n\n # query parameters\n query_params = {}\n query_params[:'enforcement_point_path'] = opts[:'enforcement_point_path'] if !opts[:'enforcement_point_path'].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 = ['BasicAuth']\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 => 'IdfwUserSessionDataAndMappings')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicySecurityEastWestSecurityDistributedFirewallSettingsFirewallIdentityStoreApi#get_user_session_data_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def user_holds opts= {}\n path, opts = build_user_path(\"holds\", opts)\n JSON.parse(get path, opts)\n end",
"def show\n render json: @user_page_setting\n end",
"def response_data\n @_response_data ||= Hash.new.with_indifferent_access\n end",
"def rest_headers\n { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => \"Token token=#{@user[:authentication_token]}\" }\n end",
"def intitiate_response_object \n response_object = Hash.new\n response_object[:status] = \"failure\"\n response_object[:statusCode] = 500\n response_object[:response] = \"\"\n response_object[:message] = \"The server encountered an unexpected condition which prevented it from fulfilling the request\"\n return response_object\n end",
"def url_verification\n render json: { challenge: params[:challenge] }\n end",
"def as_json(ops={})\n {\n id: id,\n email: email,\n token: authentication_token,\n }\n end",
"def user_earnings_total(ga_user_id, startDate, endDate)\n\n request = {report_requests:[\n {metrics:[{expression:\"ga:metric2\"}],\n dimensions:[{name:\"ga:dimension1\"}],\n date_ranges:[{start_date: startDate, end_date: endDate}],\n view_id:\"ga:141580290\",\n filters_expression: \"ga:dimension1==#{ga_user_id}\"\n }]}\n\n results = ga_request(request)\n\n json = JSON.parse(results.to_json)[\"reports\"][0][\"data\"][\"totals\"][0][\"values\"][0]\n\n return json\n\n end",
"def controller()\n\n # Create a Sinatra isntance\n $sinatra_instance = Sinatra.new()\n\n # Get a localhost/data url defined (used by ajax)\n $sinatra_instance.get '/data' do\n\n # we need to turn the data object into a json response at the end\n data = {}\n\n # This is the array of data for each scenario for the graph\n data['graph_data'] = []\n\n # The array for the erros\n data['error_log'] = $error_log\n\n # Define the graph data objects\n for i in 0..10\n data['graph_data'][i] = []\n end\n\n # Work out the xmax and ymax\n data['graph_xmax'] = (($graph_time || 0) * 1.05).ceil.to_s\n data['graph_ymax'] = (($amount_of_users || 0) * 1.2).ceil.to_s\n\n # Sets the graph data for [0] (vusers) to 0, stops an error\n data['graph_data'][0][0] = 0\n\n if (!$starttime.nil?) then\n\n # Loops through each second to get the graph data\n for i in 0..((Time.new.to_i - $starttime ))\n\n # The [0] is for v users\n data['graph_data'][0][i] = $results_vusers[i + 1]\n\n num = 0\n # Anthing above [0] is for the running tests\n $results_scenarios_graph.each do |key, results2|\n num = num + 1\n if (results2[i + 1].nil? == false) then\n\n sum = 0\n results2[i + 1].each { |a| sum+=a }\n\n # Add the results to the json object\n data['graph_data'][num][i] = ((sum / results2[i + 1].size.to_f) / 1000).round(2)\n\n if (data['graph_data'][num][i] > $max_x) then\n $max_x = data['graph_data'][num][i]\n end\n\n end\n end\n end\n end\n\n data['graph_y2max'] = ($max_x * 1.1)\n\n # Define the objects for the overview of the cucumber scenarios (table below graph)\n data['graph_details_name'] = []\n data['graph_details_min'] = []\n data['graph_details_max'] = []\n data['graph_details_avg'] = []\n data['graph_details_err'] = []\n data['graph_details_ite'] = []\n data['graph_details_per'] = []\n\n data['graph_details_name'][0] = 'Vusers'\n\n # If the data exists then use it, otherwise set it to 0\n if (!data['graph_data'].nil?) then\n\n if (data['graph_data'][0].nil?) then\n data['graph_data'][0] = []\n end\n\n if (data['graph_data'][0].count > 1)\n data['graph_details_avg'][0] = (data['graph_data'][0].inject{ |sum, el| sum + el }.to_f / data['graph_data'][0].size).round(2)\n data['graph_details_min'][0] = data['graph_data'][0].min.round(2)\n data['graph_details_max'][0] = data['graph_data'][0].max.round(2)\n else\n data['graph_details_avg'][0] = 0\n data['graph_details_min'][0] = 0\n data['graph_details_max'][0] = 0\n end\n\n data['graph_details_err'][0] = 0\n data['graph_details_ite'][0] = 0\n data['graph_details_per'][0] = 0\n\n else\n data['graph_details_min'][0] = 0\n data['graph_details_max'][0] = 0\n data['graph_details_avg'][0] = 0\n data['graph_details_err'][0] = 0\n data['graph_details_ite'][0] = 0\n data['graph_details_per'][0] = 0\n\n end\n\n i = 0\n #puts $results_scenarios_graph.count\n # This is the same as above, but for tests, not the vusers\n $results_scenarios_graph.each do |key, results2|\n\n i += 1\n data['graph_details_name'][i] = key\n\n if (!$results_scenarios[key].nil?) then\n\n if ($results_scenarios[key].count > 1)\n data['graph_details_avg'][i] = (($results_scenarios[key].inject{ |sum, el| sum + el }.to_f / $results_scenarios[key].size) / 1000).round(2)\n data['graph_details_min'][i] = ($results_scenarios[key].min / 1000).round(2)\n data['graph_details_max'][i] = ($results_scenarios[key].max / 1000).round(2)\n data['graph_details_per'][i] = (percentile($results_scenarios[key], 0.9) / 1000).round(2)\n else\n data['graph_details_avg'][i] = 0\n data['graph_details_min'][i] = 0\n data['graph_details_max'][i] = 0\n data['graph_details_per'][i] = 0\n end\n else\n\n data['graph_details_min'][i] = 0\n data['graph_details_max'][i] = 0\n data['graph_details_avg'][i] = 0\n data['graph_details_per'][i] = 0\n\n end\n\n data['graph_details_err'][i] = $scenario_errors[key]\n data['graph_details_ite'][i] = $scenario_iterations[key]\n\n\n end\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n # This is the array of data for each scenario for the graph\n data['trans_graph_data'] = []\n\n # Define the graph data objects\n for i in 0..30\n data['trans_graph_data'][i] = []\n end\n\n # Work out the xmax and ymax\n data['trans_graph_xmax'] = (($graph_time || 0) * 1.05).ceil.to_s\n\n # Sets the graph data for [0] (vusers) to 0, stops an error\n\n #$stdout.puts $results_transactions_graph\n\n if (!$starttime.nil?) then\n\n # Loops through each second to get the graph data\n for i in 0..((Time.new.to_i - $starttime ))\n\n num = 0\n # Anthing above [0] is for the running tests\n $results_transactions_graph.each do |key, results2|\n if (results2[i + 1].nil? == false) then\n\n sum = 0\n results2[i + 1].each { |a| sum+=a }\n\n # Add the results to the json object\n data['trans_graph_data'][num][i] = ((sum / results2[i + 1].size.to_f) / 1000).round(2)\n if (data['trans_graph_data'][num][i] > $trans_max_x) then\n $trans_max_x = data['trans_graph_data'][num][i]\n end\n\n end\n num = num + 1\n end\n end\n end\n\n data['trans_graph_ymax'] = ($trans_max_x * 1.1)\n\n data['trans_graph_details_name'] = []\n data['trans_graph_details_min'] = []\n data['trans_graph_details_max'] = []\n data['trans_graph_details_avg'] = []\n data['trans_graph_details_err'] = []\n data['trans_graph_details_ite'] = []\n data['trans_graph_details_per'] = []\n\n i = 0\n #puts $results_transactions_graph.count\n # This is the same as above, but for tests, not the vusers\n $results_transactions_graph.each do |key, results2|\n\n\n data['trans_graph_details_name'][i] = key\n\n if (!$results_transactions[key].nil?) then\n\n if ($results_transactions[key].count > 1)\n data['trans_graph_details_avg'][i] = (($results_transactions[key].inject{ |sum, el| sum + el }.to_f / $results_transactions[key].size) / 1000).round(2)\n data['trans_graph_details_min'][i] = ($results_transactions[key].min / 1000).round(2)\n data['trans_graph_details_max'][i] = ($results_transactions[key].max / 1000).round(2)\n data['trans_graph_details_per'][i] = (percentile($results_transactions[key], 0.9) / 1000).round(2)\n else\n data['trans_graph_details_avg'][i] = 0\n data['trans_graph_details_min'][i] = 0\n data['trans_graph_details_max'][i] = 0\n data['trans_graph_details_per'][i] = 0\n end\n else\n\n data['trans_graph_details_min'][i] = 0\n data['trans_graph_details_max'][i] = 0\n data['trans_graph_details_avg'][i] = 0\n data['trans_graph_details_per'][i] = 0\n\n end\n\n if (!$transactions_iterations[key].nil?)\n data['trans_graph_details_ite'][i] = $transactions_iterations[key]\n else\n data['trans_graph_details_ite'][i] = 0\n end\n i += 1\n end\n\n\n\n # Print the output as a json string\n return data.to_json\n end\n\n # Get a localhost url defined (main page)\n $sinatra_instance.get '/' do\n\n erb :'index.html'\n\n end\n\n # run sinatra on the default url/port\n $sinatra_instance.run!\n\nend",
"def get_user_report\n service_response = AdminManagement::Report::User.new(params).perform\n render_api_response(service_response)\n end",
"def operational_values\n\t\treturn super.merge(\n\t\t\turi: self.uri,\n\t\t\thttp_method: self.http_method,\n\t\t\texpected_status: self.expected_status,\n\t\t\tbody: self.body,\n\t\t\tbody_mimetype: self.body_mimetype\n\t\t)\n\tend",
"def getUser\n render json: @current_user, status: 200\n end",
"def execute request_context\n raise \"You gotta implement this method and return a hash like => {:status => <integer>, :body => <string>, :headers => <hash>}\"\n end",
"def as_json\n hash = super\n hash['controller'] = controller\n hash['action'] = action\n\n hash\n end",
"def return_value(response)\n value = response[:value].is_a?(String) ? response[:value] : ''\n { :value => value, :default_flag => response[:default_flag].to_s }\n end",
"def check_sign\n user = @current_user\n render :json => { login:true , admin: user.admin, user: {login:user.login, type:user.user_type, id: user.id}}\n end"
] | [
"0.5917605",
"0.5801616",
"0.5529489",
"0.5388547",
"0.5348963",
"0.533305",
"0.53063893",
"0.52115864",
"0.5190619",
"0.5175631",
"0.51479566",
"0.51427794",
"0.5064472",
"0.5058336",
"0.50544626",
"0.5039075",
"0.50381523",
"0.5016776",
"0.49970564",
"0.49776086",
"0.49757028",
"0.49703038",
"0.49366295",
"0.49361828",
"0.49352887",
"0.4920999",
"0.49132693",
"0.49070966",
"0.49058634",
"0.48938897",
"0.4890253",
"0.48778182",
"0.48718837",
"0.48718837",
"0.48661765",
"0.48565537",
"0.4847335",
"0.48436818",
"0.48433402",
"0.48331055",
"0.4828305",
"0.48241007",
"0.48183915",
"0.48165247",
"0.48150107",
"0.481414",
"0.48132086",
"0.48077375",
"0.48050892",
"0.48037073",
"0.48037073",
"0.47959897",
"0.47942975",
"0.4792688",
"0.47907442",
"0.4787752",
"0.47736764",
"0.47712666",
"0.47639412",
"0.47625774",
"0.47613388",
"0.47610247",
"0.47585082",
"0.47571337",
"0.47569525",
"0.47569525",
"0.47530854",
"0.47463918",
"0.4739331",
"0.4734527",
"0.47227702",
"0.47218016",
"0.47211397",
"0.47123948",
"0.47116432",
"0.47085705",
"0.47061163",
"0.4704204",
"0.46878088",
"0.46875265",
"0.4685131",
"0.46800599",
"0.46757063",
"0.4674529",
"0.46733338",
"0.46722472",
"0.46717945",
"0.4667932",
"0.4662406",
"0.46590224",
"0.46507147",
"0.4646895",
"0.46432793",
"0.4639215",
"0.4638611",
"0.46321145",
"0.4631117",
"0.4630328",
"0.46299645",
"0.4629127",
"0.462684"
] | 0.0 | -1 |
The value which is used for sorting. Used on the preset scenario list | def sorting_value
respond_to?(:ordering) ? ordering : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valueOrder(obj)\n if obj.tutors.exists?\n obj.tutors.sort_by {|t| t.pname }.first.pname\n else\n \"_\"\n end\n end",
"def default_sort_attribute\n ::Mincer.config.sorting.sort_attribute\n end",
"def calculate_sort_value options\n dummy_time = dummy_time_for_day opening_hash(options['contract.default'])\n options['model'].sort_value = (dummy_time.to_f * 100).to_i\n end",
"def sort_value_from_arg(arg) # :nodoc:\n case arg\n when /^asc/i\n arg = 1\n when /^desc/i\n arg = -1\n when Number\n arg.to_i >= 0 ? 1 : -1\n else\n arg ? 1 : -1\n end\n end",
"def sort_key(value)\n @sort = value\n end",
"def sort_by_default\n 1\n end",
"def ordered_values; end",
"def default_sort_order\n ::Mincer.config.sorting.order_attribute\n end",
"def comparison_value\n return @comparison_value\n end",
"def validate_sort_field( value )\n if [ 'title', 'code', 'created_at' ].include?( value )\n return value\n else\n return 'title'\n end\n end",
"def sort\n self[:sort]\n end",
"def default_sort_option\n\t\t'name'\n\tend",
"def variant_column\n \"option_value_#{ order_in_good }\"\n end",
"def sort\n return @sort\n end",
"def sort_code()\n return @sort_code\n end",
"def sort_order\n 0\n end",
"def sort_option\n ['Best match', 'Level', 'Provider(s)']\n end",
"def order\n @num\n end",
"def calculate_sort_value\n return nil unless day\n dummy_time = dummy_time_for_day DAYS.index(day) + 1\n self.sort_value = (dummy_time.to_f * 100).to_i\n end",
"def calculate_sort_value\n return nil unless day\n dummy_time = dummy_time_for_day DAYS.index(day) + 1\n self.sort_value = (dummy_time.to_f * 100).to_i\n end",
"def order\n @order || \"99_99\"\n end",
"def lbSortByValue _args\n \"lbSortByValue _args;\" \n end",
"def current_sort_field_selected\n sort_field_from_response || # as in original\n sort_field_from_params || # sort param specified\n sort_field_from_list || # sort param not specified\n default_sort_field # falls back on 'relevance'\n end",
"def sort_value(value)\n val = value.to_s.downcase\n return 1 if ASCENDING_CONVERSION.include?(val)\n return -1 if DESCENDING_CONVERSION.include?(val)\n raise InvalidSortValueError.new(\n \"#{self} was supplied as a sort direction when acceptable values are: \" +\n \"EM::Mongo::ASCENDING, 'ascending', 'asc', :ascending, :asc, 1, EM::Mongo::DESCENDING, \" +\n \"'descending', 'desc', :descending, :desc, -1.\")\n end",
"def sort_text\n attributes.fetch(:sortText)\n end",
"def value_index\n return nil unless self.value\n VALUES.index(self.value.downcase)\n end",
"def sort_field(val = nil)\n if val == nil\n @sort_field || name\n else\n @sort_field = val\n end\n end",
"def key_for_min_value\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def values\n cards.map(&:value).sort\n end",
"def priority_sorting_metric\n [-1 * (measurement.priority.presence || (Measurement::MIN_PRIORITY - 1)), open_from]\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def sort_show(value)\n @ole.SortShow = value\n nil\n end",
"def sort_by\n if valid_column?(@sort_by)\n @sort_by\n else\n self.class.sortable_attributes.first\n end\n end",
"def describe_value(value)\r\n\t\t\tvalues.find(value.to_i).value\r\n\t\tend",
"def sort=(value)\n @sort = value\n end",
"def sort_field\n @view_column[:sort_field] || field\n end",
"def get_sort_cat\n \t\tif @sort == 'data'\n \t\t\treturn 'created_at'\n \t\telsif @sort == 'cheapest'\n \t\t\treturn 'price'\n \t\telse\n \t\t\treturn 'price desc' \t\t\n \t\tend\n \tend",
"def tvSortByValue _args\n \"tvSortByValue _args;\" \n end",
"def describe_value(value)\r\n\t\tvalues.find(value.to_i).value\r\n\tend",
"def describe_value(value)\r\n\t\tvalues.find(value.to_i).value\r\n\tend",
"def sort_field\n @view_column.fetch(:sort_field, field)\n end",
"def value\n self['value']\n end",
"def order_by_value\n @hand = @hand.sort_by{|card| card.point }\n end",
"def sort_code\n @sort_code ||= %w(issue_id project_id user_id user_type).map{ |a| self[a].present? ? 1 : 0 }.join\n end",
"def sort_name(value)\n @ole.SortName = value\n nil\n end",
"def sort_column\n nil\n end",
"def get_value\n if @value == 'A'\n 11\n elsif @value == 'J' || @value == 'Q' || @value == 'K'\n 10\n else\n @value\n end\n end",
"def default\n @default ||= \"#{fields.first.sql} ASC\"\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def describe_value(value)\r\n\t\t\tvalue\r\n\t\tend",
"def get_current_ranking\r\n self.bid = self.bid.sort { |a, b| a.value <=> b.value }\r\n end",
"def sort_by_value(ascending=true, num_partitions=nil)\n self.sort_by('lambda{|(_, value)| value}')\n end",
"def sort_using_rank\n score[1]\n end",
"def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end",
"def sortable_sort\n @sortable_sort\n end",
"def priority\n return data.priority\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def __sort_option__\n { name => operator }\n end",
"def first_value\r\n get(@first_index)\r\n end",
"def cur_ordering\r\n @orderings\r\n end",
"def reference_attribute\n\t\t\tsorted_attributes.first\n\t\tend",
"def value\n return 10 if [\"J\", \"K\"].include?(@value)\n return 1 if \"A\" == @value\n return 0 if [\"Q\", \"JOKER\"].include?(@value)\n return @value\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def set_SortBy(value)\n set_input(\"SortBy\", value)\n end",
"def default_sort\n 'name asc'\n end"
] | [
"0.6464138",
"0.63776237",
"0.63436735",
"0.6317916",
"0.6288007",
"0.6167908",
"0.61620027",
"0.61186767",
"0.6088003",
"0.59630585",
"0.5926655",
"0.59065783",
"0.58935887",
"0.5840346",
"0.58377767",
"0.5814039",
"0.5781655",
"0.57744765",
"0.57550967",
"0.57550967",
"0.5734756",
"0.57306904",
"0.5682885",
"0.56593966",
"0.56262475",
"0.5620908",
"0.5619797",
"0.5618192",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56097305",
"0.56054145",
"0.56049",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.56030434",
"0.55982727",
"0.5575521",
"0.5570149",
"0.5556305",
"0.5545032",
"0.55433804",
"0.55305517",
"0.55004126",
"0.55004126",
"0.5487298",
"0.5486541",
"0.54819095",
"0.54750943",
"0.5473178",
"0.54701376",
"0.54642147",
"0.545935",
"0.54562837",
"0.54403025",
"0.5440036",
"0.5438538",
"0.5433318",
"0.5430778",
"0.54306585",
"0.54251766",
"0.540536",
"0.540536",
"0.53993535",
"0.5398896",
"0.5394266",
"0.5392025",
"0.5384725",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53705937",
"0.53683615"
] | 0.65542465 | 0 |
GET /tweets GET /tweets.json | def index
@tweets = current_user.tweets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def list\r\n #page = params[:page].nil? ? 0 : params[:page]\r\n tweets = Tweet.all\r\n render json: tweets\r\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def list_tweets\n tweets\n end",
"def show\n user = user_from_token\n @tweet = user.tweets.where(:id => params[:id])\n render :json => @tweet\n end",
"def get_timeline\n HTTParty.post(\"#{@api_path}/tweets/#{@handle}/#{@password}\")\n end",
"def tweets(opts={})\n params = {\n :screen_name => NAME,\n :trim_user => true,\n :include_entities => true\n }.merge(opts)\n get(\"/statuses/user_timeline.json\",params)\n end",
"def latest_tweets\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n end\n\n count = params[:count] || 10\n time_line = client.user_timeline(current_user.twitter_handle, {count: count})\n current_user.update(time_fetched: current_user.time_fetched+1)\n if time_line.class == Twitter::Error::NotFound\n render json: {status: 400, success: false, message: 'Twitter handle or id not valid'}\n else\n render json: {status: 200, success: true, message: 'Success', data: time_line.map{|a| a.text}.as_json}\n end\n\n rescue => e\n Rails.logger.error \"account_controller#latest_tweets - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def index\n chain = Tweet\n chain = chain.since_id(params[:since_id]) if params[:since_id]\n @tweets = chain.all(:order => 'msg_twid ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def get_tweets\n # TODO-JW: look into -- respond_to :json\n @card = Card.find(params[:id])\n @api = Twitter.user_timeline(@card.twitter_handle, options={count: 10})\n if @api\n tweets = []\n @api.each_with_index do |tweet,i|\n tweets[i] = {}\n tweets[i][:tweet_id] = String(tweet.id)\n tweets[i][:text] = auto_link(tweet.text)\n tweets[i][:created] = tweet.created_at\n tweets[i][:user_id] = tweet.user.screen_name\n end\n render json: tweets \n else\n [].to_json\n end\n end",
"def index\n if params[:page] && current_user\n render json: current_user, scope: {page: params[:page]}, serializer: UserWithTweetsSerializer, meta: {total_pages: current_user.timeline_tweets.count/25}\n elsif current_user\n render json: current_user, serializer: UserWithTweetsSerializer\n elsif params[:page]\n @tweets = Tweet.all.page(params[:page])\n render json: @tweets\n else\n @tweets = Tweet.all\n render json: @tweets\n end\n end",
"def getTweets\n\t\tputs 'in getTweets'\n\t\t@client.on_timeline_status do |tweet|\n\t\t\tputs 'getTweets: ' + tweet.text\n\n\t\t\t#binding.pry\n\t\t\tpopPlayQueue(tweet)\n\t\tend\n\tend",
"def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end",
"def getThreeTweets\n\t\trender json: TwitterAPI.get_top_3_tweets(params[:twitter_id])\n\tend",
"def tweets\n @tweets = @user.tweets.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5) # order OWN tweets according to when they were created, with the most recent tweet at the top.\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n #Array of all tweets. Used for index html page\n @tweets = Tweet.all\n end",
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users you follow.\", data: tweets}\n\t\telse\n\t\t\trender json: {:status=>\"failure\", :message=>\"User is not present.\", data: tweets}\n\t\tend\n\tend",
"def index\n @tweets = Tweetaro.all\n end",
"def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end",
"def index\n @tweets = Tweet.all\n end",
"def print_tweet(tweets)\ngets tweets.each do |tweet| puts tweet[\"text\"]\nend\nend",
"def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end",
"def tweet(postids)\n handle_response(get(\"/content/tweet.json\", :query => {:postids => postids}))\n end",
"def twitter\n @user = User.find(session[:user_id])\n t = @user.twitter\n unless t.present?\n redirect_to @user, :notice => \"Please add your twitter account!\"\n return\n end\n @tweets = t.home_timeline\n @posts = []\n @tweets.each do |tweet|\n if Post.exists?(:tweet_id => tweet[:id])\n @posts.push(Post.find_by_tweet_id(tweet[:id]))\n else\n p = Post.new\n p.tweet_id = tweet[:id]\n p.tweeter_twitter_id = tweet[:user][:id]\n if User.exists?(:twitter_id => tweet[:user][:id])\n p.user_id = User.find_by_twitter_id(tweet[:user][:id]).id\n else\n p.user_id = -1\n end\n p.post_type = 3\n p.created_at = tweet[:created_at].to_datetime\n url = \"https://api.twitter.com/1/statuses/oembed.json?id=#{tweet[:id]}&omit_script=true\"\n begin\n tweet_page = open(URI.parse(url))\n p.body = JSON.parse(tweet_page.read)['html']\n if p.save!\n @posts.push(p)\n end\n rescue\n # Tried to access a protected tweet, just skip it\n end\n end\n end\n\n @body_class = 'twitter-background'\n respond_to do |format|\n format.html # twitter.html.erb\n format.json { render json: @posts }\n end\n end",
"def get_tweet(search,since_id = 0, throtle = 20)\n\turl = 'http://search.twitter.com/search.json?q='+search+'&rpp='+throtle.to_s+'&since_id='+since_id.to_s\n\tprint \"Asking with this url \" + url+ \"\\n\"\n\tresp = Net::HTTP.get_response(URI.parse(url))\n\tresponse_array = JSON.parse(resp.body)\nend",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { @tweets_url = query ? \"/tweets.json?q=#{query}\" : '/tweets.json' }\n format.json do\n tweets, has_more =\n if query\n search_result =\n Tweet.search(\n query,\n page: params[:page] || 1,\n per_page: 20,\n includes: [\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n ],\n )\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets =\n pagy Tweet\n .includes(\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n )\n .order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: { has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n end\n end\n end",
"def user_tweet\n get_tweets params[:Enter_what_you_want_to_search]\n respond_to do |format|\n format.html \n format.json \n end\n \nend",
"def show\r\n tweet = Tweet.find(params[:id])\r\n render json: tweet\r\n end",
"def user_timeline(query={})\n\t\t# La fonction user_timeline est disponible à partir de l'API REST mais pas à partir de l'API \"twitter\", j'ai refait la fonction à la main \n\t\tHTTParty.get('http://twitter.com/statuses/user_timeline.json', :query => query)\n end",
"def tweets\n @_tweets ||= client.filter_tweets(screen_names)\n end",
"def show\n render json: @tweet\n end",
"def print_twitter_search(tweets)\n #puts JSON.pretty_generate(tweet)\n tweets.each do |tweet|\n puts tweet[\"text\"] \n end \n end",
"def user_tweets(user_id)\n twitter.user_timeline(user_id)\n end",
"def show\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n config.access_token = ENV[\"TWITTER_ACCESS_TOKEN\"]\n config.access_token_secret = ENV[\"TWITTER_ACCESS_TOKEN_SECRET\"]\n end\n\n begin\n timelines = client.user_timeline(@club.twitter_id)\n @tweets = []\n rescue\n end\n\n if timelines.present?\n timelines.each do |timeline_tweet|\n tweet = client.status(timeline_tweet.id)\n @tweets << tweet.text\n end\n end\n end",
"def print_timeline(tweets)\n \n puts tweets [0][\"user\"][\"screen_name\"]\n puts tweets [0][\"text\"]\n\n \n\nend",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end",
"def index\n @actor_tweets = ActorTweet.all\n end",
"def index\n respond_with RawTweet.all\n end",
"def index\n reader = inject( Java::pl.goldmann.confitura.beans.TweetReader )\n \n @tweets = reader.read\n @total = reader.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tweets }\n end\n end",
"def index\n authenticate\n @tweets = Tweet.where(\n user_id: current_user.id,\n stat: nil\n ).order(:id)\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def show\r\n @tweets = Tweet.all\r\n @tweet = Tweet.find(params[:id])\r\n end",
"def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { \n if query\n @tweets_url = \"/tweets.json?q=#{query}\"\n else\n @tweets_url = \"/tweets.json\" \n end\n }\n format.json { \n tweets, has_more = if query\n search_result = Tweet.search(query, \n page: params[:page] || 1, \n per_page: 20, \n includes: [\n {user: {avatar_attachment: [:blob]}},\n :likes, {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}\n ])\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets = pagy Tweet.includes({user: {avatar_attachment: [:blob]}},\n :likes, \n {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}).order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: {has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n }\n end\n end",
"def all_tweets\n Tweet.all\n end",
"def get_latest_tweets(num_of_tweets)\n client = configure_authentication\n latest = client.home_timeline({:count => num_of_tweets})\n client.end_session\n info = latest.to_json\n end",
"def show\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:get, params[:id])\n format.html # show.rhtml\n format.json { render :json => @tweet.to_json }\n format.xml { render :xml => @tweet.to_xml }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format)\n end\n end\n end",
"def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n []\n end\nend",
"def show\n @tweets = @usuario.tweets\n end",
"def by_user\r\n tweets = Tweet.where(user_id: params[:user_id])\r\n render json: tweets\r\n end",
"def index\n @following_user_ids = @user.following.pluck(:id)\n\n @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user)\n json_response(@tweets)\n end",
"def show\n @all_tweets = set_tweet_collection.tweets\n end",
"def index\n @tweets = Tweet.all.reverse\n respond_with(@tweets)\n end",
"def index\n # binding.pry\n @tweet = Tweet.new\n if current_user\n friend_ids = Friend.where(user_id: current_user).pluck(:friends_id) \n @tweets = Tweet.where(user_id: friend_ids)\n else\n @tweets = Tweet.includes([:user]).all\n end\n\n @tweets = @tweets.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def status_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::StatusTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::StatusTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::StatusTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Status.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def news\n #creamos el hash para mostrar los datos en la api\n @tweet = Tweet.includes(:likes)\n\n #User.includes(:posts)\n api = []\n @tweet.each do |tweet|\n api << Hash[:id => tweet.id, :content => tweet.content, :user_id => tweet.user_id, :likes_count => tweet.likes.count,:retweets_count => tweet.count_tweet,:rewtitted_from => tweet.tweet_id]\n end\n @tweets = api.last(50)#ultimos50 tweets\n render json: @tweets \n end",
"def tweet_from_api\n @tweet_api = User.find(2).tweets.create(tweet_params)\n render json: @tweet_api\n end",
"def print_timeline(response)\n \n tweets = response[\"statuses\"]\n \n for tweet in tweets\n puts tweet[\"user\"][\"screen_name\"]\n puts tweet[\"text\"]\n end\n \nend",
"def index\n @new_tweets = NewTweet.all\n end",
"def index\n @tweets = Tweet.all.order(created_at: :desc).page(params[:page]).per(25)\n @tweet = Tweet.new\n end",
"def index\n timeline = Tweet.where(user_id: User.find(@current_user_id).follows).or(Tweet.where(user_id: @current_user_id))\n render json: {timeline: timeline}\n end",
"def index\r\n @tweets = Tweet.all\r\n @tweet = Tweet.new\r\n end",
"def tweets(options={})\n\n @tweets=(@tweets.empty? || (@last_tweets_options!=options)) ? @tweets=read_tweets(self.id, options) : @tweets\n @last_tweets_options=options\n @tweets\n end",
"def fetch_user_timeline(n=200)\n tweets.destroy_all if n == 200\n statuses = Twitter.user_timeline(screen_name, count: n)\n Tweet.many_from_twitter(statuses)\n end",
"def latest_tweets(k=5)\n\n # Get the tweets\n response = make_response(\"statuses\",\"user_timeline\")\n timeline = JSON.parse(response.body)\n tweets = timeline[0..k-1]\n\nend",
"def get_tweets(screen_name, num_tweets)\n\t\n\tresult = \"\"\n #Query num_tweets tweets from screen_name and create the HTML\n Twitter.user_timeline(screen_name, {\"count\" => num_tweets}).each do |tweet|\n \tlinkified = linkifyTweet(tweet.text)\n \tresult = result + \"<li class=\\\"tweet\\\">\n <span class=\\\"gentle\\\">#{linkified}</span>\n </li>\"\n end\n return result\nend",
"def show\n @tweetsandwich = Tweetsandwich.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweetsandwich }\n end\n end",
"def default\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = \"0EOMlVsBuU0VNShIxBpoobxhk\"\n config.consumer_secret = \"e2JDYCId5uucBtgsCV5epvu5GO7vjSVrnFI1Lj0Z3SkWK0KJrV\"\n config.access_token = \"429379668-BgRseD5d6XHjZ3cZIE8KP21QCO3aqBp5sTsysXtr\"\n config.access_token_secret = \"SAJXh81CWxHM6N8WmYo6OgVdKjAoJSdBkFq7zGEjUlIM3\"\n end\n\n timeline = client.user_timeline(twitter_id)\n tweets = timeline.map { |tweet| tweet.text }\n content = { title: 'Tweets del Diario Hoy', body: strip_urls(tweets) }\n\n respond content, { type: 'list' }\n end",
"def index\n @tweeters = Tweeter.all\n end",
"def show\n @tag = Tag.find(params[:id])\n\n @tweets = @tag.tweets.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tag }\n end\n end",
"def show\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_list }\n end\n end",
"def friends_timeline(params = {})\n get \"statuses/friends_timeline\", params\n end",
"def index\n\n @tweets = Tweet.limit(50)\n @no_authorized = false\n\n\n if params[:code]\n session[:code] = params[:code]\n end\n \n #Get access_token\n if session[:access_token].nil? || params[:code]\n if authorize_redbooth == ERROR\n @no_authorized = true\n end\n end\n\n begin\n args = {:access_token => session[:access_token]}\n response = get_redbooth_projects (args)\n @projects = response.map{|x| [x[\"name\"],x[\"id\"]]} if response\n response = get_redbooth_task_lists (args) \n @task_lists = response.map{|x| [x[\"name\"],x[\"id\"]]} if response\n rescue RestClient::Unauthorized => exception\n if authorize_redbooth == ERROR \n @no_authorized = true\n end\n end\n\n\n if @no_authorized\n redirect_to :controller => 'oauth', :action => 'index' and return\n else\n redishelper = RedisHandlerQueue.new\n @handlers = redishelper.get_handlers\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end\n \n end",
"def tweet_objects\n tweet_json = JSON.parse(File.read(tweet_filepath))['tweets']\n tweet_json.map { |tweet| Twitter::Tweet.new(tweet.deep_symbolize_keys) }\n end",
"def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end",
"def print_timeline(tweets)\n # ADD CODE TO ITERATE THROUGH EACH TWEET AND PRINT ITS TEXT\n tweets.each do |tweet| puts tweet['text'] end\n \n\nend",
"def get_tweets(list)\n unless list.authorized(@user)\n raise AuthorizationException.new\n end\n list.tweets\nend",
"def fetch_tweets(criteria)\n @client.filter(track: criteria.theme) do |object|\n puts object.text if object.is_a?(Twitter::Tweet)\n end\n end",
"def search_twitter()\n search_call = \"#{@api_endpoint_twitter}?ors=#{@search_term}&result_type=#{@result_type}&rpp=#{@results_per_page}\"\n @response = http_get search_call\n end",
"def index\n @tweets = current_user.feed_tweets.order(id: :desc).page(params[:page])\n @tweet = current_user.tweets.build\n end",
"def show\n @user = User.find_by!(username: params[:username])\n #This saves user tweets in desc order.\n @tweets = @user.tweets.order(created_at: :desc)\n end",
"def index\r\n @users = User.where.not(id: current_user&.id)\r\n @tweet = Tweet.new\r\n @tweets = Tweet.all.page(params[:page])\r\n\r\n \r\n if params[:q]\r\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").page(params[:page])\r\n if @tweets.nil?\r\n @tweets = Tweet.all.page(params[:page])\r\n end\r\n else\r\n @tweets = Tweet.all.page(params[:page])\r\n end\r\n \r\n #SCOPE comentado para evitar conflicto con buscador\r\n if signed_in?\r\n @tweets = Tweet.tweets_for_me(current_user).page(params[:page])\r\n else\r\n @tweets = Tweet.all.order(\"created_at DESC\").page(params[:page])\r\n end\r\n\r\n if params[:tweetsearch].present?\r\n @tweets = Tweet.search_my_tweets(params[:tweetsearch]).page(params[:page]).order(\"created_at DESC\")\r\n elsif params[:hashtag].present?\r\n @tweets = Tweet.search_my_tweets(\"##{params[:hashtag]}\").page(params[:page]).order(\"created_at DESC\")\r\n end\r\n\r\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n format.xml { render xml: @tweet }\n end\n end",
"def index\n @tweets = Tweet.all\n @user = current_user\n @recent_tweets = Tweet.order(created_at: :desc).limit(10)\n @pop_tweets = Tweet.order(likes_count: :desc).limit(10)\n @tweet = Tweet.new\n #@users # 基於測試規格,必須講定變數名稱,請用此變數中存放關注人數 Top 10 的使用者資料\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def get_tweet(id)\n\n\t\t# tweet = Tweet.where({:tweet_id => id})\n\n\n\tend",
"def url\n \"http://twitter.com/#{self.username}/statuses/#{self.twitter_id}\"\n end",
"def search_hashtag tag\r\n response = RestClient.get 'https://api.twitter.com/1.1/search/tweets.json', params: {q: tag, count: 100}, Authorization: 'Bearer AAAAAAAAAAAAAAAAAAAAAJr1YQAAAAAAHA%2FAKcuAEPhPSJgFqwcwKMU0wPk%3DwHtz3CIM3eluP3XQDNfXobhvApEBTpyYeWrJ31ZxUukMm1idUj'\r\n \r\n tweets = Array.new\r\n JSON.parse(response)['statuses'].each do |t|\r\n hashtags = Array.new\r\n t[\"entities\"][\"hashtags\"].each do |h|\r\n hashtags << (\"#\" + h[\"text\"].downcase)\r\n end\r\n tweet={\r\n \"id\" => t[\"id\"],\r\n \"text\" => t['text'],\r\n \"hashtags\" => hashtags\r\n }\r\n tweets << tweet\r\n end\r\n tweets\r\n end",
"def show\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweeter }\n end\n end"
] | [
"0.81149495",
"0.7980108",
"0.78602517",
"0.77103835",
"0.76598436",
"0.7516168",
"0.74348384",
"0.7411584",
"0.7408587",
"0.73615396",
"0.7359439",
"0.73008704",
"0.72418225",
"0.718084",
"0.7124409",
"0.7104599",
"0.7093725",
"0.7082312",
"0.7082312",
"0.7082312",
"0.7082312",
"0.7082312",
"0.7082312",
"0.7070022",
"0.7060827",
"0.6981474",
"0.69642556",
"0.6925612",
"0.6903563",
"0.6902247",
"0.69017804",
"0.6885947",
"0.6870759",
"0.68568087",
"0.6852478",
"0.68524426",
"0.6851327",
"0.6849812",
"0.6849784",
"0.68450415",
"0.6817673",
"0.6816227",
"0.67988235",
"0.67979276",
"0.67979276",
"0.67977434",
"0.67879945",
"0.6785059",
"0.67832553",
"0.67733717",
"0.67637706",
"0.67431283",
"0.67289186",
"0.66887516",
"0.6686033",
"0.6671452",
"0.6661404",
"0.6649245",
"0.6643121",
"0.6640894",
"0.66393125",
"0.66370994",
"0.66273975",
"0.6613563",
"0.65976435",
"0.659656",
"0.6590618",
"0.6566491",
"0.6556162",
"0.6539188",
"0.6536121",
"0.65206426",
"0.6518604",
"0.65141374",
"0.65120757",
"0.65120476",
"0.6505858",
"0.6502929",
"0.6479216",
"0.64698017",
"0.64696467",
"0.64662534",
"0.64638186",
"0.6456607",
"0.6424989",
"0.6418246",
"0.6411508",
"0.6408761",
"0.6401472",
"0.63652384",
"0.6361849",
"0.63615084",
"0.63594264",
"0.63555545",
"0.63442916",
"0.6344198",
"0.63377386",
"0.63373345",
"0.6336516",
"0.63289356"
] | 0.7095569 | 16 |
GET /tweets/1 GET /tweets/1.json | def show
puts current_user.is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def show\n user = user_from_token\n @tweet = user.tweets.where(:id => params[:id])\n render :json => @tweet\n end",
"def index\n chain = Tweet\n chain = chain.since_id(params[:since_id]) if params[:since_id]\n @tweets = chain.all(:order => 'msg_twid ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def list\r\n #page = params[:page].nil? ? 0 : params[:page]\r\n tweets = Tweet.all\r\n render json: tweets\r\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def latest_tweets\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n end\n\n count = params[:count] || 10\n time_line = client.user_timeline(current_user.twitter_handle, {count: count})\n current_user.update(time_fetched: current_user.time_fetched+1)\n if time_line.class == Twitter::Error::NotFound\n render json: {status: 400, success: false, message: 'Twitter handle or id not valid'}\n else\n render json: {status: 200, success: true, message: 'Success', data: time_line.map{|a| a.text}.as_json}\n end\n\n rescue => e\n Rails.logger.error \"account_controller#latest_tweets - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def show\r\n tweet = Tweet.find(params[:id])\r\n render json: tweet\r\n end",
"def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end",
"def get_tweets\n # TODO-JW: look into -- respond_to :json\n @card = Card.find(params[:id])\n @api = Twitter.user_timeline(@card.twitter_handle, options={count: 10})\n if @api\n tweets = []\n @api.each_with_index do |tweet,i|\n tweets[i] = {}\n tweets[i][:tweet_id] = String(tweet.id)\n tweets[i][:text] = auto_link(tweet.text)\n tweets[i][:created] = tweet.created_at\n tweets[i][:user_id] = tweet.user.screen_name\n end\n render json: tweets \n else\n [].to_json\n end\n end",
"def list_tweets\n tweets\n end",
"def get_timeline\n HTTParty.post(\"#{@api_path}/tweets/#{@handle}/#{@password}\")\n end",
"def getThreeTweets\n\t\trender json: TwitterAPI.get_top_3_tweets(params[:twitter_id])\n\tend",
"def index\n if params[:page] && current_user\n render json: current_user, scope: {page: params[:page]}, serializer: UserWithTweetsSerializer, meta: {total_pages: current_user.timeline_tweets.count/25}\n elsif current_user\n render json: current_user, serializer: UserWithTweetsSerializer\n elsif params[:page]\n @tweets = Tweet.all.page(params[:page])\n render json: @tweets\n else\n @tweets = Tweet.all\n render json: @tweets\n end\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def tweets(opts={})\n params = {\n :screen_name => NAME,\n :trim_user => true,\n :include_entities => true\n }.merge(opts)\n get(\"/statuses/user_timeline.json\",params)\n end",
"def index\n #Array of all tweets. Used for index html page\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def index\n @tweets = Tweet.all\n end",
"def show\r\n @tweets = Tweet.all\r\n @tweet = Tweet.find(params[:id])\r\n end",
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users you follow.\", data: tweets}\n\t\telse\n\t\t\trender json: {:status=>\"failure\", :message=>\"User is not present.\", data: tweets}\n\t\tend\n\tend",
"def show\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:get, params[:id])\n format.html # show.rhtml\n format.json { render :json => @tweet.to_json }\n format.xml { render :xml => @tweet.to_xml }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format)\n end\n end\n end",
"def index\n\t\t@tweets = current_user.tweets\n\tend",
"def search\n @tweets = TwitterClient.search(params[:query], result_type: 'recent').take(20)\n render json: @tweets\n end",
"def index\n number_tweets = if params[\"count\"] then params[\"count\"].to_i else 10 end\n tweet_ids = []\n if @user.interests\n for i in 1..number_tweets\n interest = @user.interests.sample\n tweet = Rails.application.config.twitter_client.search(\"#{interest[:hashtag]}\", count: 1).take(1)\n tweet_ids.push(tweet.first.id.to_s)\n end\n end\n\n render json: tweet_ids, status: :ok\n end",
"def getTweets\n\t\tputs 'in getTweets'\n\t\t@client.on_timeline_status do |tweet|\n\t\t\tputs 'getTweets: ' + tweet.text\n\n\t\t\t#binding.pry\n\t\t\tpopPlayQueue(tweet)\n\t\tend\n\tend",
"def index\n @tweets = Tweet.all\n end",
"def get_tweet(search,since_id = 0, throtle = 20)\n\turl = 'http://search.twitter.com/search.json?q='+search+'&rpp='+throtle.to_s+'&since_id='+since_id.to_s\n\tprint \"Asking with this url \" + url+ \"\\n\"\n\tresp = Net::HTTP.get_response(URI.parse(url))\n\tresponse_array = JSON.parse(resp.body)\nend",
"def index\n @tweets = Tweetaro.all\n end",
"def print_timeline(tweets)\n \n puts tweets [0][\"user\"][\"screen_name\"]\n puts tweets [0][\"text\"]\n\n \n\nend",
"def show\n render json: @tweet\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n end\n end",
"def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end",
"def tweets\n @tweets = @user.tweets.order(created_at: :desc).paginate(:page => params[:page], :per_page => 5) # order OWN tweets according to when they were created, with the most recent tweet at the top.\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end",
"def show\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n config.access_token = ENV[\"TWITTER_ACCESS_TOKEN\"]\n config.access_token_secret = ENV[\"TWITTER_ACCESS_TOKEN_SECRET\"]\n end\n\n begin\n timelines = client.user_timeline(@club.twitter_id)\n @tweets = []\n rescue\n end\n\n if timelines.present?\n timelines.each do |timeline_tweet|\n tweet = client.status(timeline_tweet.id)\n @tweets << tweet.text\n end\n end\n end",
"def latest_tweets(k=5)\n\n # Get the tweets\n response = make_response(\"statuses\",\"user_timeline\")\n timeline = JSON.parse(response.body)\n tweets = timeline[0..k-1]\n\nend",
"def print_tweet(tweets)\ngets tweets.each do |tweet| puts tweet[\"text\"]\nend\nend",
"def index\n @actor_tweets = ActorTweet.all\n end",
"def index\n reader = inject( Java::pl.goldmann.confitura.beans.TweetReader )\n \n @tweets = reader.read\n @total = reader.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tweets }\n end\n end",
"def get_tweet(id)\n\n\t\t# tweet = Tweet.where({:tweet_id => id})\n\n\n\tend",
"def show\n @tweetsandwich = Tweetsandwich.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweetsandwich }\n end\n end",
"def index\n authenticate\n @tweets = Tweet.where(\n user_id: current_user.id,\n stat: nil\n ).order(:id)\n end",
"def get_latest_tweets(num_of_tweets)\n client = configure_authentication\n latest = client.home_timeline({:count => num_of_tweets})\n client.end_session\n info = latest.to_json\n end",
"def show\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_list }\n end\n end",
"def twitter\n @user = User.find(session[:user_id])\n t = @user.twitter\n unless t.present?\n redirect_to @user, :notice => \"Please add your twitter account!\"\n return\n end\n @tweets = t.home_timeline\n @posts = []\n @tweets.each do |tweet|\n if Post.exists?(:tweet_id => tweet[:id])\n @posts.push(Post.find_by_tweet_id(tweet[:id]))\n else\n p = Post.new\n p.tweet_id = tweet[:id]\n p.tweeter_twitter_id = tweet[:user][:id]\n if User.exists?(:twitter_id => tweet[:user][:id])\n p.user_id = User.find_by_twitter_id(tweet[:user][:id]).id\n else\n p.user_id = -1\n end\n p.post_type = 3\n p.created_at = tweet[:created_at].to_datetime\n url = \"https://api.twitter.com/1/statuses/oembed.json?id=#{tweet[:id]}&omit_script=true\"\n begin\n tweet_page = open(URI.parse(url))\n p.body = JSON.parse(tweet_page.read)['html']\n if p.save!\n @posts.push(p)\n end\n rescue\n # Tried to access a protected tweet, just skip it\n end\n end\n end\n\n @body_class = 'twitter-background'\n respond_to do |format|\n format.html # twitter.html.erb\n format.json { render json: @posts }\n end\n end",
"def by_user\r\n tweets = Tweet.where(user_id: params[:user_id])\r\n render json: tweets\r\n end",
"def index\n @following_user_ids = @user.following.pluck(:id)\n\n @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user)\n json_response(@tweets)\n end",
"def default\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = \"0EOMlVsBuU0VNShIxBpoobxhk\"\n config.consumer_secret = \"e2JDYCId5uucBtgsCV5epvu5GO7vjSVrnFI1Lj0Z3SkWK0KJrV\"\n config.access_token = \"429379668-BgRseD5d6XHjZ3cZIE8KP21QCO3aqBp5sTsysXtr\"\n config.access_token_secret = \"SAJXh81CWxHM6N8WmYo6OgVdKjAoJSdBkFq7zGEjUlIM3\"\n end\n\n timeline = client.user_timeline(twitter_id)\n tweets = timeline.map { |tweet| tweet.text }\n content = { title: 'Tweets del Diario Hoy', body: strip_urls(tweets) }\n\n respond content, { type: 'list' }\n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { @tweets_url = query ? \"/tweets.json?q=#{query}\" : '/tweets.json' }\n format.json do\n tweets, has_more =\n if query\n search_result =\n Tweet.search(\n query,\n page: params[:page] || 1,\n per_page: 20,\n includes: [\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n ],\n )\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets =\n pagy Tweet\n .includes(\n { user: { avatar_attachment: %i[blob] } },\n :likes,\n { images_attachments: %i[blob] },\n { comments: { user: { avatar_attachment: %i[blob] } } },\n )\n .order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: { has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n end\n end\n end",
"def index\n respond_with RawTweet.all\n end",
"def show\n @tweet = Tweet.find(params[:id])\n end",
"def show\n @tweet = Tweet.find(params[:id])\n end",
"def user_tweet\n get_tweets params[:Enter_what_you_want_to_search]\n respond_to do |format|\n format.html \n format.json \n end\n \nend",
"def show\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweeter }\n end\n end",
"def index\r\n @tweets = Tweet.all\r\n @tweet = Tweet.new\r\n end",
"def user_tweets(user_id)\n twitter.user_timeline(user_id)\n end",
"def index\n # binding.pry\n @tweet = Tweet.new\n if current_user\n friend_ids = Friend.where(user_id: current_user).pluck(:friends_id) \n @tweets = Tweet.where(user_id: friend_ids)\n else\n @tweets = Tweet.includes([:user]).all\n end\n\n @tweets = @tweets.order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def user_timeline(query={})\n\t\t# La fonction user_timeline est disponible à partir de l'API REST mais pas à partir de l'API \"twitter\", j'ai refait la fonction à la main \n\t\tHTTParty.get('http://twitter.com/statuses/user_timeline.json', :query => query)\n end",
"def show\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tweet }\n format.xml { render xml: @tweet }\n end\n end",
"def index\n timeline = Tweet.where(user_id: User.find(@current_user_id).follows).or(Tweet.where(user_id: @current_user_id))\n render json: {timeline: timeline}\n end",
"def index\n @tweets = Tweet.all.reverse\n respond_with(@tweets)\n end",
"def news\n #creamos el hash para mostrar los datos en la api\n @tweet = Tweet.includes(:likes)\n\n #User.includes(:posts)\n api = []\n @tweet.each do |tweet|\n api << Hash[:id => tweet.id, :content => tweet.content, :user_id => tweet.user_id, :likes_count => tweet.likes.count,:retweets_count => tweet.count_tweet,:rewtitted_from => tweet.tweet_id]\n end\n @tweets = api.last(50)#ultimos50 tweets\n render json: @tweets \n end",
"def show\n @tag = Tag.find(params[:id])\n\n @tweets = @tag.tweets.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tag }\n end\n end",
"def tweet(postids)\n handle_response(get(\"/content/tweet.json\", :query => {:postids => postids}))\n end",
"def index\n @new_tweets = NewTweet.all\n end",
"def show\n @twitter_id = TwitterId.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_id }\n end\n end",
"def get_tweet_by_id(id)\n tweet = Twitter.status(id)\n {:message => tweet.text, :author => tweet.user.screen_name, :date => tweet.created_at} \n end",
"def index\n query = params[:q]\n respond_to do |format|\n format.html { \n if query\n @tweets_url = \"/tweets.json?q=#{query}\"\n else\n @tweets_url = \"/tweets.json\" \n end\n }\n format.json { \n tweets, has_more = if query\n search_result = Tweet.search(query, \n page: params[:page] || 1, \n per_page: 20, \n includes: [\n {user: {avatar_attachment: [:blob]}},\n :likes, {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}\n ])\n [search_result.results, search_result.current_page < search_result.total_pages]\n else\n @pagy, tweets = pagy Tweet.includes({user: {avatar_attachment: [:blob]}},\n :likes, \n {images_attachments: [:blob]},\n {comments: {user: {avatar_attachment: [:blob]}}}).order(created_at: :desc)\n [tweets, @pagy.page < @pagy.pages]\n end\n render json: {has_more: has_more, data: TweetBlueprint.render_as_hash(tweets) }\n }\n end\n end",
"def url\n \"http://twitter.com/#{self.username}/statuses/#{self.twitter_id}\"\n end",
"def index\n @tweets = Tweet.all.order(created_at: :desc).page(params[:page]).per(25)\n @tweet = Tweet.new\n end",
"def show\n @tweets = @usuario.tweets\n end",
"def index\n @tweeters = Tweeter.all\n end",
"def status_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::StatusTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::StatusTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(created_at)\n tweets = ::S3::StatusTweet.where(uid: uid) if tweets.blank?\n tweets.map { |tweet| ::TwitterDB::Status.new(uid: uid, screen_name: screen_name, raw_attrs_text: tweet.raw_attrs_text) }\n end",
"def print_twitter_search(tweets)\n #puts JSON.pretty_generate(tweet)\n tweets.each do |tweet|\n puts tweet[\"text\"] \n end \n end",
"def print_timeline(response)\n \n tweets = response[\"statuses\"]\n \n for tweet in tweets\n puts tweet[\"user\"][\"screen_name\"]\n puts tweet[\"text\"]\n end\n \nend",
"def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end",
"def fetch_user_timeline(n=200)\n tweets.destroy_all if n == 200\n statuses = Twitter.user_timeline(screen_name, count: n)\n Tweet.many_from_twitter(statuses)\n end",
"def tweet_from_api\n @tweet_api = User.find(2).tweets.create(tweet_params)\n render json: @tweet_api\n end",
"def show\n @all_tweets = set_tweet_collection.tweets\n end",
"def find_tweet\n\t\t@tweet = Tweet.find(params[:id])\n\tend",
"def show\n @retweet = Retweet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retweet }\n end\n end",
"def tweets\n @_tweets ||= client.filter_tweets(screen_names)\n end",
"def index\n\n #client = Twitter::REST::Client.new do |config|\n # config.consumer_key = \"0SA42a0JKM6PdD1q0PNCZg\"\n # config.consumer_secret = \"YV97lqlpZd7T1sNrkDMZOqN9Gnd1pvOxrzwgv9jQuo\"\n # config.access_token = \"106499488-wdXh967DnNt5e1zW26YBQYqSOCggCtu9SdivrAc8\"\n # config.access_token_secret = \"diKltR3e8H8T9K7fCuZfGxenvgpWsvN5PwdhEyX7tQ\"\n #end\n\n require \"rubygems\"\n\n # Certain methods require authentication. To get your Twitter OAuth credentials,\n # register an app at http://dev.twitter.com/apps\n Twitter.configure do |config|\n config.consumer_key = \"0SA42a0JKM6PdD1q0PNCZg\"\n config.consumer_secret = \"YV97lqlpZd7T1sNrkDMZOqN9Gnd1pvOxrzwgv9jQuo\"\n config.oauth_token = \"106499488-wdXh967DnNt5e1zW26YBQYqSOCggCtu9SdivrAc8\"\n config.oauth_token_secret = \"diKltR3e8H8T9K7fCuZfGxenvgpWsvN5PwdhEyX7tQ\"\n end\n\n # Initialize your Twitter client\n client = Twitter::Client.new\n\n # Post a status update\n client.update(\"I just posted a status update via the Twitter Ruby Gem !\")\n redirect_to request.referer, :notice => 'Tweet successfully posted'\n\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def url\n \"http://twitter.com/#{attribute_get(:username)}/statuses/#{attribute_get(:id)}\"\n end",
"def show\n @user = User.find_by!(username: params[:username])\n #This saves user tweets in desc order.\n @tweets = @user.tweets.order(created_at: :desc)\n end",
"def index\n @q = Tweet.order('created_at DESC').page(params[:page]).ransack(params[:q])\n @tweets = @q.result(distinct: true)\n # render json: @tweets.each {|tweet| tweet.id}\n end",
"def index\n respond_to do |format|\n # Shows all the tweets in the HTML version.\n format.html { @tweets = Tweet.all }\n \n if this_one_should_fail_randomly?\n format.json { render json: json_error_message, :status => :error }\n format.xml { render xml: xml_error_message, :status => :error }\n else\n format.json { render json: Tweet.random_sample }\n format.xml { render xml: Tweet.random_sample }\n end\n end\n end",
"def get_tweets(list)\n if list.authorized?(@user)\n list.tweets\n else\n []\n end\nend",
"def show\n @watcher = Watcher.includes(:tweets).friendly.find(params[:id])\n @statuses = Status.all\n respond_to do |format|\n format.html { render :show, offset: params[:offset]}\n format.json { render json: @watcher.tweets }\n end\n end",
"def friends_timeline(params = {})\n get \"statuses/friends_timeline\", params\n end",
"def retweets_of_me(options = {})\n @req.get(\"/1.1/statuses/retweets_of_me.json\", options)\n end",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def index\n @tweets = Tweet.select { |tweet| tweet.user_id == current_user.id }\n end"
] | [
"0.7779338",
"0.7740531",
"0.75970775",
"0.74841213",
"0.746445",
"0.74599075",
"0.74334455",
"0.72242004",
"0.71207714",
"0.70800984",
"0.70530766",
"0.7043736",
"0.70432067",
"0.7039998",
"0.7039422",
"0.6973632",
"0.6973632",
"0.6967428",
"0.69544315",
"0.69518745",
"0.69518745",
"0.69518745",
"0.69518745",
"0.69518745",
"0.69518745",
"0.69515496",
"0.68964726",
"0.6888821",
"0.6877757",
"0.68454695",
"0.68302137",
"0.6811801",
"0.67847925",
"0.6783721",
"0.67810166",
"0.67723024",
"0.6740175",
"0.6717407",
"0.67108023",
"0.6706321",
"0.6700474",
"0.66428554",
"0.66294473",
"0.66269237",
"0.6619493",
"0.661943",
"0.6615845",
"0.6615377",
"0.6614834",
"0.66108066",
"0.6610456",
"0.6606387",
"0.66053885",
"0.6599577",
"0.6595971",
"0.65935326",
"0.6592766",
"0.6590153",
"0.6590153",
"0.65818477",
"0.6558235",
"0.65505934",
"0.65436757",
"0.65332985",
"0.6531921",
"0.65286875",
"0.6528503",
"0.6527872",
"0.6526777",
"0.65213364",
"0.6506082",
"0.6494432",
"0.6489607",
"0.6480068",
"0.6474691",
"0.64669484",
"0.64605033",
"0.64574015",
"0.6452008",
"0.64486593",
"0.6448579",
"0.644682",
"0.6441129",
"0.643694",
"0.6422172",
"0.6408458",
"0.6403972",
"0.63995385",
"0.6398769",
"0.63588953",
"0.6348284",
"0.63429683",
"0.63426614",
"0.6315913",
"0.62971294",
"0.6273939",
"0.6273261",
"0.6269804",
"0.6266788",
"0.6260318",
"0.6255216"
] | 0.0 | -1 |
POST /tweets POST /tweets.json | def create
puts params[:post_now]
if params[:post_now] == "1"
client = Twitter::REST::Client.new do |config|
config.consumer_key = TWITTER_API_KEY
config.consumer_secret = TWITTER_API_SECRECT
config.access_token = current_user.access_token
config.access_token_secret = current_user.access_token_secret
end
content = params[:tweet][:content]
end
@tweet = current_user.tweets.build(tweet_params)
respond_to do |format|
if @tweet.save
if client.update("#{content}")
puts @tweet.update(tweeted: true)
flash[:notice] = "Successfully posted "
else
flash[:notice] = "not updated "
end
format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }
format.json { render :show, status: :created, location: @tweet }
else
format.html { render :new }
format.json { render json: @tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @tweet = current_user.tweets.create(params[:tweet])\n respond_with(@tweet, :location => tweet_url(@tweet))\n end",
"def create\n @tweet = @user.tweets.build(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to user_tweet_path(@user, @tweet), notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: user_tweet_path(@user, @tweet) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_from_api\n @tweet_api = User.find(2).tweets.create(tweet_params)\n render json: @tweet_api\n end",
"def create\n @user = User.find(params[:user_id])\n @tweet = @user.tweets.create(tweet_params)\n redirect_to user_tweets_path\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n if @tweet.username == nil\n # This is for the current user posting tweets\n @tweet.username = current_user.name\n @tweet.user_id = current_user.id\n # Updates to Twitter\n current_user.twitter.update(@tweet.tweetbody)\n else \n # Incoming tweets from the daemon script\n @tweet.save\n end\n respond_with(@tweet)\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n \n respond_to do |format|\n if @tweet.save\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet(tweet_body)\n encoded_url = url_encode \"#{@handle}/#{@password}/#{tweet_body}\"\n HTTParty.post(\"#{@api_path}/tweets/new/#{encoded_url}\")\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:post, params[:text])\n flash[:notice] = 'Tweet was successfully created.'\n format.html { redirect_to tweet_url(@tweet) }\n format.json { head :created, :location => tweet_url(@tweet) }\n format.xml { head :created, :location => tweet_url(@tweet) }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format, 'new')\n end\n end\n end",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def post_tweet\n # @tweets << tweet: violates SST\n Tweet.new('tweet message', self)\n end",
"def create_twit(twit)\n RestClient.post configuration.base_url + '/twits',\n { twit: twit }.to_json,\n content_type: :json,\n accept: :json\n end",
"def create\n @tweett = Tweett.new(tweett_params)\n\n respond_to do |format|\n if @tweett.save\n format.html { redirect_to @tweett, notice: 'Tweett was successfully created.' }\n format.json { render :show, status: :created, location: @tweett }\n else\n format.html { render :new }\n format.json { render json: @tweett.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params.merge(user: current_user))\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.create(:user_id => current_user.id, :text => tweet_params[:text])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.new tweet_params\n\n if current_user\n @tweet.user_id = current_user.id\n end\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n begin \n new_tweet = Tweet.new(tweet_params)\n if new_tweet.save()\n render(status: 201, json: {tweet: new_tweet})\n else # if validation fails\n render(status: 422, json: {error: new_tweet.errors})\n end\n rescue => error\n render(status: 500, json: {error: \"Internal Server Error: #{error.message}\"})\n end\n end",
"def create\r\n @tweet = Tweet.new(tweet_params)\r\n @tweet.user = current_user\r\n \r\n respond_to do |format|\r\n if @tweet.save\r\n format.html { redirect_to @tweet, notice: \"Tweet was successfully created.\" }\r\n format.json { render :show, status: :created, location: @tweet }\r\n else\r\n format.html { render :new, status: :unprocessable_entity }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @tweet = current_user.tweets.new(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_back fallback_location: root_path, notice: 'ツーイトの投稿が完了しました。' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @new_tweet = NewTweet.new(new_tweet_params)\n\n respond_to do |format|\n if @new_tweet.save\n format.html { redirect_to @new_tweet, notice: 'New tweet was successfully created.' }\n format.json { render :show, status: :created, location: @new_tweet }\n else\n format.html { render :new }\n format.json { render json: @new_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n\n if @tweet.save\n render :show, status: :created, location: { tweet: @tweet }\n else\n render json: @tweet.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user = current_user\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet creado felizmente.\" }\n format.json { redirect_to root_path, status: :created, location: @tweet }\n else\n format.html { redirect_to root_path, notice: \"No se puede tuitear nada.\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n #respond_to do |format|\n if @tweet.save\n flash[:success] = 'ツイートを投稿しました。'\n redirect_to tweets_path\n #format.html { redirect_to @tweet }\n #format.json { render :show, status: :created, location: @tweet }\n else\n @tweets = current_user.feed_tweets.order(id: :desc).page(params[:page])\n flash.now[:danger] = 'ツイートを投稿できませんでした。'\n render 'tweets/index'\n #format.html { render :new }\n #format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:tweet)\n end",
"def create\n # Use current_user below, so that new tweets are only created by the logged in user #MDM\n #@tweet = Tweet.new(tweet_params)\n @tweet = current_user.tweets.new(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.build(tweet_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to member_url(current_user), notice: '投稿しました' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_tweet(message)\n tweet = Tweet.new(self, message)\n self.tweets << tweet\n end",
"def tweet(postids)\n handle_response(get(\"/content/tweet.json\", :query => {:postids => postids}))\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_id = current_user.id\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tu Tweet se ha publicado con exito!\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = FuKing::Twitter.update(params[:tweet][:text])\n\n respond_to do |format|\n if @tweet\n flash[:notice] = 'Tweet was successfully created.'\n format.html { redirect_to(:action => :index) }\n format.mobile { redirect_to(:action => :index) }\n format.xml { render :xml => @tweet, :status => :created, :tweet => @tweet }\n else\n format.html { render :action => \"new\" }\n format.mobile { render :action => \"new\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_vote = 0\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_tweet(user_id, tweet_id)\n @alltweets << [user_id, tweet_id]\n end",
"def create\n @tweet_collection = TweetCollection.new(tweet_collection_params)\n Tweet.tweets.each {|t| @tweet_collection.tweets << t}\n \n respond_to do |format|\n if @tweet_collection.save\n format.html { redirect_to @tweet_collection, notice: 'Tweet collection was successfully created.' }\n format.json { render :show, status: :created, location: @tweet_collection }\n else\n format.html { render :new }\n format.json { render json: @tweet_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to(@tweet, :notice => 'Tweet was successfully created.') }\n format.xml { render :xml => @tweet, :status => :created, :location => @tweet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet_post = TweetPost.new(tweet_post_params)\n\n respond_to do |format|\n if @tweet_post.save\n format.html { redirect_to @tweet_post, notice: \"Tweet post was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet_post }\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet_post.errors, status: :unprocessable_entity }\n \n end\n end\n end",
"def create\n @tweet = Tweet.create(tweet_params)\n\n @tweet = get_tagged(@tweet)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to home_path, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.new(params[:tweet])\n @user = User.find(session[:user_id])\n @tweet.user = @user\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: :created, location: @tweet }\n else\n @tweets = Tweet.paginate page: params[:page], order:'created_at desc', per_page: 10\n @user = User.new\n format.html { render action: \"index\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def twitter\n @user = User.find(session[:user_id])\n t = @user.twitter\n unless t.present?\n redirect_to @user, :notice => \"Please add your twitter account!\"\n return\n end\n @tweets = t.home_timeline\n @posts = []\n @tweets.each do |tweet|\n if Post.exists?(:tweet_id => tweet[:id])\n @posts.push(Post.find_by_tweet_id(tweet[:id]))\n else\n p = Post.new\n p.tweet_id = tweet[:id]\n p.tweeter_twitter_id = tweet[:user][:id]\n if User.exists?(:twitter_id => tweet[:user][:id])\n p.user_id = User.find_by_twitter_id(tweet[:user][:id]).id\n else\n p.user_id = -1\n end\n p.post_type = 3\n p.created_at = tweet[:created_at].to_datetime\n url = \"https://api.twitter.com/1/statuses/oembed.json?id=#{tweet[:id]}&omit_script=true\"\n begin\n tweet_page = open(URI.parse(url))\n p.body = JSON.parse(tweet_page.read)['html']\n if p.save!\n @posts.push(p)\n end\n rescue\n # Tried to access a protected tweet, just skip it\n end\n end\n end\n\n @body_class = 'twitter-background'\n respond_to do |format|\n format.html # twitter.html.erb\n format.json { render json: @posts }\n end\n end",
"def create\n tweet.user = current_user\n\n respond_to do |format|\n if tweet.save\n format.html { redirect_to tweet, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: tweet }\n else\n format.html { render :new }\n format.json { render json: tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_new_tweet(tweet)\n #setup twitter client\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = $consumer_key\n config.consumer_secret = $consumer_secret\n config.access_token = $access_token\n config.access_token_secret = $access_token_secret\n end\n\n $log.debug(tweet)\n client.update(tweet)\n $log.info(\"Successfully tweeted!\")\nend",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def create\n signin_apikey\n \n if session[:user_id] != nil\n @tweet = Tweet.new(tweet_params)\n @tweet.author = User.find(session[:user_id]).email.split('@')[0].strip\n @tweet.user_id = User.find(session[:user_id]).id\n if !@tweet.url.blank?\n if !is_url(@tweet.url)\n respond_to do |format|\n format.json { render json: \"Invalid url!\".to_json, status: 400 }\n end\n return\n end\n @tweet.url = @tweet.url.sub \"https://\", \"\"\n @tweet.url = @tweet.url.sub \"www.\", \"\"\n @urlsplit = @tweet.url.split(\"/\")\n @urlsplit.each do |suburl|\n if suburl.include?(\".\")\n @tweet.shorturl = suburl\n end\n end\n end\n @tweet2 = Tweet.find_by url: @tweet.url\n if (@tweet.content.blank? && !@tweet.url.blank?)\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif (@tweet2 != nil)\n format.html { redirect_to '/tweets/' + @tweet2.id.to_s }\n msg = \"The URL already exists\"\n format.json { render json: msg.to_json , status: 400, location: @tweet }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n elsif (@tweet.url.blank? && !@tweet.content.blank?)\n @tweet.ask = true\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n @comment_text=@tweet.content\n @tweet.content=nil\n @tweet.ask = false\n \n if @tweet.save\n Comment.create(contribution: @tweet.id, text: @comment_text, escomment: true, comment_id: nil, user: @tweet.user_id)\n render :json => @tweet.attributes.merge( )\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:content, :total_tweet, :retweet)\n end",
"def post_tweet(message)\n Tweet.new(message, self)\n end",
"def create\n @tweetsandwich = Tweetsandwich.new(params[:tweetsandwich])\n\n respond_to do |format|\n if @tweetsandwich.save\n format.html { redirect_to @tweetsandwich, notice: 'Tweetsandwich was successfully created.' }\n format.json { render json: @tweetsandwich, status: :created, location: @tweetsandwich }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweetsandwich.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tweet = @user.tweets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tweet }\n end\n end",
"def postTweet(status)\n\t\t\t@client.update(status)\n\t\tend",
"def create\n @tweet = Tweet.new(tweet_params)\n @tweet.user_id = current_user.id\n\n \n\n \n \n \n\n \n \n \n\n\n \n\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to root_path, notice: \"Tweet was successfully created.\" }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def tweet_params\n params.require(:tweet).permit(:status, :message, :location, :user_id)\n end",
"def tweet_params\n params.require(:tweet).permit(:username, :tweetbody)\n end",
"def post_tweet(message)\n Tweet.new(message, self)\n end",
"def create\n \n @tweet = Tweet.new(params[:tweet])\n \n # write stats\n @keywords.each do |word|\n \n if @tweet.text.downcase.include? word then\n \n stat = WordStatistic.where(:word => word, :day => DateTime.now.beginning_of_day..DateTime.now).first\n if stat.nil? then\n new_stat = WordStatistic.new(:word => word, :day => DateTime.now, :freq => 1)\n new_stat.save\n else\n \n stat.freq += 1\n stat.save\n end\n end\n end # keywords\n\n respond_to do |format|\n if @tweet.save\n format.json { render :json => @tweet, :notice => 'Tweet was successfully created.' }\n format.xml { render :xml => @tweet, :status => :created, :location => @tweet }\n else\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweetaro.new(tweetaro_params)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to @tweet, notice: 'Tweetしました!' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n tweet = params[:tweet]\n message = tweet[:message]\n @tweet = current_user.tweets.create(tweet_params)\n @comment = Comment.new\n \n redirect_to action: \"index\"\n end",
"def tweet_params\n params.require(:tweet).permit(:text)\n end",
"def tweet_params\n params.require(:tweet).permit(:text)\n end",
"def create\n @tweeeet = current_user.tweeeets.build(tweeeet_params)\n\n respond_to do |format|\n if @tweeeet.save\n format.html { redirect_to root_path, notice: 'Tweet creado con éxito!' }\n format.json { render :show, status: :created, location: @tweeeet }\n else\n format.html { render :new }\n format.json { render json: @tweeeet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:content, :user_id, :tweet_id)\n end",
"def tweett_params\n params.require(:tweett).permit(:tweett)\n end",
"def get_timeline\n HTTParty.post(\"#{@api_path}/tweets/#{@handle}/#{@password}\")\n end",
"def tweet_params\n params.require(:tweet).permit(:body)\n end",
"def tweet_params\n params.require(:tweet).permit(:body)\n end",
"def tweet_params\n params.require(:tweet).permit(:body)\n end",
"def tweet_params\n params.require(:tweet).permit(:user_id, :text)\n end",
"def tweet_params\n params.require(:tweet).permit(:usuario_id, :texto)\n end",
"def create\n @tweeter = Tweeter.new(params[:tweeter])\n\n respond_to do |format|\n if @tweeter.save\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully created.' }\n format.json { render json: @tweeter, status: :created, location: @tweeter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:content, :user_id, :tweet_id)\n end",
"def create\n @fr_tweet = FrTweet.new(fr_tweet_params)\n\n respond_to do |format|\n if @fr_tweet.save\n format.html { redirect_to @fr_tweet, notice: 'Fr tweet was successfully created.' }\n format.json { render :show, status: :created, location: @fr_tweet }\n else\n format.html { render :new }\n format.json { render json: @fr_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @watcher = Watcher.new(watcher_params)\n\n respond_to do |format|\n if @watcher.save\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = \"1jFn305ISZq4moZsv6mYyGls4\"\n config.consumer_secret = \"i8JvIWmswNqA7c9HIpTHJ1nIxZAGGcWyLaGBxfteQXMkNK4DqK\"\n config.access_token = \"14191779-n4X4Fs1WDx9IlNqjt5WhDYT0oMttRlmBP3ysoUhII\"\n config.access_token_secret = \"dixLEBjwapLNrmlZEu2amiB8qcZGihvPnLXoN5d15AgsA\"\n end\n # TODO: max_id, since_id\n client.search(@watcher.keywords, :lang => 'en', :count => 100).take(100).collect do |tweet|\n Tweet.create(:watcher_id => @watcher.id, :tweet_id => tweet.id, :fields => tweet.to_h)\n end\n\n format.html { redirect_to @watcher, notice: 'Watcher was successfully created.' }\n format.json { render :show, status: :created, location: @watcher }\n else\n format.html { render :new }\n format.json { render json: @watcher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @favorite_tweet = FavoriteTweet.new(favorite_tweet_params)\n\n respond_to do |format|\n if @favorite_tweet.save\n format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' }\n format.json { render action: 'show', status: :created, location: @favorite_tweet }\n else\n format.html { render action: 'new' }\n format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = current_user.tweets.new(tweet_params)\n\n # respond_to do |format|\n if @tweet.save\n # format.html { \n # puts \"html\"\n # render json: TweetBlueprint.render(@tweet), status: :created \n # }\n # format.json { \n puts \"json\"\n render json: TweetBlueprint.render(@tweet), status: :created \n # }\n else\n # format.html { \n # puts \"error html\"\n # render :new \n # }\n # format.json { \n puts \"error json\"\n render json: { result: 'error', error: @tweet.errors }, status: :unprocessable_entity \n # }\n end\n # end\n end",
"def create\n @tweeter = Tweeter.new(tweeter_params)\n\n respond_to do |format|\n if @tweeter.save\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully created.' }\n format.json { render :show, status: :created, location: @tweeter }\n else\n format.html { render :new }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet(tweet)\n\t\tclient = Twitter::REST::Client.new do |config|\n\t\tconfig.consumer_key = Rails.application.config.twitter_key\n\t\tconfig.consumer_secret = Rails.application.config.twitter_secret\n\t\tconfig.access_token = oauth_token\n\t\tconfig.access_token_secret = oauth_secret\n\tend\n\tclient.update(tweet)\n\tend",
"def tweet_params\r\n params.require(:tweet).permit(:content, :twauthor, :user_id)\r\n end",
"def tweet_params\n params.require(:tweet).permit(:content,:tweet)\n end",
"def create\n @retweet = Retweet.new(params[:retweet])\n\n respond_to do |format|\n if @retweet.save\n format.html { redirect_to @retweet, notice: 'Retweet was successfully created.' }\n format.json { render json: @retweet, status: :created, location: @retweet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:contents, :id_user, :tweet_id)\n end",
"def create\n\n if Tweet::Create.(current_user, tweet_params)\n return redirect_to tweets_path, notice: 'Tweet was successfully created.'\n end\n\n end",
"def ttweet_params\n params.require(:ttweet).permit(:tweet_body, :ttweet_body)\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def tweet_params\n params.require(:tweet).permit(:content, :user_id)\n end",
"def create\n @twitter_user = TwitterUser.new(params[:twitter_user])\n\n respond_to do |format|\n if @twitter_user.save\n format.html { redirect_to @twitter_user, notice: 'Twitter user was successfully created.' }\n format.json { render json: @twitter_user, status: :created, location: @twitter_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @twitter_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tweet_params\n params.require(:tweet).permit(:content, :user_id)\n\n end",
"def tweet_params\n params.require(:tweet).permit(:message)\n end",
"def tweet_params\n params.require(:tweet).permit(:message, :user_id)\n end",
"def create\n @twee = Twee.new(twee_params)\n\n respond_to do |format|\n if @twee.save\n format.html { redirect_to twees_path, notice: 'Twee was successfully created.' }\n format.json { render :show, status: :created, location: @twee }\n else\n format.html { render :new }\n format.json { render json: @twee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def latest_tweets\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n end\n\n count = params[:count] || 10\n time_line = client.user_timeline(current_user.twitter_handle, {count: count})\n current_user.update(time_fetched: current_user.time_fetched+1)\n if time_line.class == Twitter::Error::NotFound\n render json: {status: 400, success: false, message: 'Twitter handle or id not valid'}\n else\n render json: {status: 200, success: true, message: 'Success', data: time_line.map{|a| a.text}.as_json}\n end\n\n rescue => e\n Rails.logger.error \"account_controller#latest_tweets - Error: #{e.message}\"\n render json: {status: 500, success: false, message: 'Unexpected error'}\n end",
"def tweet_params\n @tweet_parms = params.require(:tweet).permit(:tweet)\n @tweet_parms[:user] = auth_user\n @tweet_parms\n end",
"def tweet_params\n params.require(:tweet).permit(:status, :zombie_id)\n end",
"def index\n @tweets = current_user.feed_tweets.order(id: :desc).page(params[:page])\n @tweet = current_user.tweets.build\n end",
"def create\n username = params[:username]\n tweets = timeline_query username\n tweet_sentiment_list = get_sentiment(tweets)\n redirect_to :action => \"index\", :tweets => tweet_sentiment_list\n end",
"def tweet_params\n params.require(:tweet).permit(:message, :user_id, :link)\n end",
"def tweet_params\n params.require(:tweet).permit(:message, :user_id, :link)\n end",
"def tweet_params\n params.require(:tweet).permit(:message, :user_id, :link)\n end",
"def save_tweet(params)\n @tweet=self.tweets.new(params)\n @tweet.save\n schedule_tweet(@tweet)\n end",
"def add_tweet(tweet)\n @tweets << tweet\n end"
] | [
"0.7703366",
"0.72558355",
"0.71856695",
"0.7130213",
"0.705414",
"0.7018085",
"0.7003551",
"0.6994446",
"0.698963",
"0.69707346",
"0.69707346",
"0.6893714",
"0.68830514",
"0.6881277",
"0.6819126",
"0.67953306",
"0.678633",
"0.6756683",
"0.6734242",
"0.6720373",
"0.67184824",
"0.67015386",
"0.6692809",
"0.6688971",
"0.6660959",
"0.6652602",
"0.6619241",
"0.6610901",
"0.66014075",
"0.6588078",
"0.6583952",
"0.6577264",
"0.6575487",
"0.6560885",
"0.6553536",
"0.65377945",
"0.64969575",
"0.64789677",
"0.6477812",
"0.6456235",
"0.6440694",
"0.6417829",
"0.64158803",
"0.64096445",
"0.6399313",
"0.63684237",
"0.63681716",
"0.6368104",
"0.6346833",
"0.6345507",
"0.6321917",
"0.63176996",
"0.63128597",
"0.63021123",
"0.6288606",
"0.62878996",
"0.62828463",
"0.62812185",
"0.62740135",
"0.62740135",
"0.6269486",
"0.62581265",
"0.6254715",
"0.62517226",
"0.62512225",
"0.62512225",
"0.62512225",
"0.6250293",
"0.6240649",
"0.6237568",
"0.62123644",
"0.62103504",
"0.6202427",
"0.6195873",
"0.6195465",
"0.61805546",
"0.6173272",
"0.6154754",
"0.61457133",
"0.6145482",
"0.614153",
"0.61276716",
"0.61191547",
"0.6106033",
"0.6079822",
"0.60763955",
"0.60699207",
"0.6069722",
"0.60656446",
"0.6062217",
"0.6062156",
"0.60591173",
"0.6053989",
"0.6035548",
"0.603289",
"0.60306555",
"0.60306555",
"0.60306555",
"0.60301596",
"0.60298157"
] | 0.69071674 | 11 |
PATCH/PUT /tweets/1 PATCH/PUT /tweets/1.json | def update
respond_to do |format|
if @tweet.update(tweet_params)
format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }
format.json { render :show, status: :ok, location: @tweet }
else
format.html { render :edit }
format.json { render json: @tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweet.update(tweet_params)\n respond_with(@tweet)\n end",
"def update(tweet)\n client.update tweet\n end",
"def update\n # Add in this #MDM\n @tweet = Tweet.find(params[:id]) \n \n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to user_tweet_path(@user, @tweet), notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if tweet.save\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: tweet }\n else\n format.html { render :edit }\n format.json { render json: tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tweet.update(tweet_params)\r\n format.html { redirect_to @tweet}\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tweet.update(tweet_params)\r\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\r\n format.json { render :show, status: :ok, location: @tweet }\r\n else\r\n format.html { render :edit, status: :unprocessable_entity }\r\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n check_tweet_for_user\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @retweet = Retweet.find(params[:id])\n\n respond_to do |format|\n if @retweet.update_attributes(params[:retweet])\n format.html { redirect_to @retweet, notice: 'Retweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @new_tweet.update(new_tweet_params)\n format.html { redirect_to @new_tweet, notice: 'New tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @new_tweet }\n else\n format.html { render :edit }\n format.json { render json: @new_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweett.update(tweett_params)\n format.html { redirect_to @tweett, notice: 'Tweett was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweett }\n else\n format.html { render :edit }\n format.json { render json: @tweett.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @favorite_tweet.update(favorite_tweet_params)\n format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @tweet.assign_attributes(tweet_params)\n @tweet.uuid = session[:uid]\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweetaro_params)\n format.html { redirect_to @tweet, notice: 'Tweetを更新しました。' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trash_tweet.update(trash_tweet_params)\n format.html { redirect_to @trash_tweet, notice: 'Trash tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @trash_tweet }\n else\n format.html { render :edit }\n format.json { render json: @trash_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to root_path, notice: 'ツーイトの編集が完了しました。' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @retweet.update(tweet_params)\n format.html { redirect_to retweets_path, notice: 'Retweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @retweet }\n else\n format.html { render :edit }\n format.json { render json: @retweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: '編集しました' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweeter = Tweeter.find(params[:id])\n\n respond_to do |format|\n if @tweeter.update_attributes(params[:tweeter])\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @tweet.user == current_user\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to @tweet, notice: \"Tweet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_path, notice: \"You did not tweeted this tweet!\"\n end\n end",
"def update\n \t@project = Project.find(params[:project_id])\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to(project_tweet_path(@project,@tweet), :notice => 'Tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweeeet.update(tweeeet_params)\n format.html { redirect_to @tweeeet, notice: 'Tweet actualizado con éxito!' }\n format.json { render :show, status: :ok, location: @tweeeet }\n else\n format.html { render :edit }\n format.json { render json: @tweeeet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweetsandwich = Tweetsandwich.find(params[:id])\n\n respond_to do |format|\n if @tweetsandwich.update_attributes(params[:tweetsandwich])\n format.html { redirect_to @tweetsandwich, notice: 'Tweetsandwich was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweetsandwich.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet.update(tweet_params)\n format.js\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @twitter_user = TwitterUser.find(params[:id])\n\n respond_to do |format|\n if @twitter_user.update_attributes(params[:twitter_user])\n format.html { redirect_to @twitter_user, notice: 'Twitter user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @twitter_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n signin_apikey\n if session[:user_id] != nil\n if @tweet.user_id.to_s == session[:user_id].to_s\n respond_to do |format|\n if @tweet.update(tweet_update_params)\n format.html { redirect_to @tweet, notice: 'Tweet was successfully edited.' }\n format.json { render json: @tweet, status: 200 }\n else\n format.html { render :edit }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Forbidden, you can\\'t edit a tweet that is not yours' }, status: 403 }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fr_tweet.update(fr_tweet_params)\n format.html { redirect_to @fr_tweet, notice: 'Fr tweet was successfully updated.' }\n format.json { render :show, status: :ok, location: @fr_tweet }\n else\n format.html { render :edit }\n format.json { render json: @fr_tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twee.update(twee_params)\n format.html { redirect_to @twee, notice: 'Twee was successfully updated.' }\n format.json { render :show, status: :ok, location: @twee }\n else\n format.html { render :edit }\n format.json { render json: @twee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet_post.update(tweet_post_params)\n format.html { redirect_to @tweet_post, notice: \"Tweet post was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tweet_post }\n \n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tweet_post.errors, status: :unprocessable_entity }\n \n end\n end\n end",
"def update\n @search_tweet = SearchTweet.find(params[:id])\n\n respond_to do |format|\n if @search_tweet.update_attributes(params[:search_tweet])\n format.html { redirect_to(@search_tweet, :notice => 'Search tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @search_tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if params == [:tweet_id,:id]\n @tweet = Tweet.find(params[:tweet_id])\n @actor_tweet = ActorTweet.find(params[:id])\n respond_to do |format|\n if @actor_tweet.update(actor_tweet_params)\n format.html { redirect_to @actor_tweets, notice: 'Actor tweet actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @actor_tweet }\n else\n format.html { render :edit }\n format.json { render json: @actor_tweet.errors, status: :unprocessable_entity }\n end\n end\n end\n if params == [:actor_id,:id]\n @actors = Actor.find(params[:actor_id])\n @actor_tweet = ActorTweet.find(params[:id])\n respond_to do |format|\n if @actor_tweet.update(actor_tweet_params)\n format.html { redirect_to @actor_tweets, notice: 'Actor tweet actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @actor_tweet }\n else\n format.html { render :edit }\n format.json { render json: @actor_tweet.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @tweet_collection.update(tweet_collection_params)\n format.html { redirect_to @tweet_collection, notice: 'Tweet collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet_collection }\n else\n format.html { render :edit }\n format.json { render json: @tweet_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tweet(id)\n RawTweet.update(id, is_processed: true)\n end",
"def update\n respond_to do |format|\n if @change_table_tweet_info.update(change_table_tweet_info_params)\n format.html { redirect_to @change_table_tweet_info, notice: 'Change table tweet info was successfully updated.' }\n format.json { render :show, status: :ok, location: @change_table_tweet_info }\n else\n format.html { render :edit }\n format.json { render json: @change_table_tweet_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twittter.update(twittter_params)\n format.html { redirect_to @twittter, notice: 'Twittter was successfully updated.' }\n format.json { render :show, status: :ok, location: @twittter }\n else\n format.html { render :edit }\n format.json { render json: @twittter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweeter.update(tweeter_params)\n format.html { redirect_to @tweeter, notice: 'Tweeter was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweeter }\n else\n format.html { render :edit }\n format.json { render json: @tweeter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @avatar_tweet = AvatarTweet.find(params[:id])\n\n respond_to do |format|\n if @avatar_tweet.update_attributes(params[:avatar_tweet])\n format.html { redirect_to(@avatar_tweet, :notice => 'Avatar tweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @avatar_tweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twet.update(twet_params)\n format.html { redirect_to @twet, notice: \"Twet was successfully updated.\" }\n format.json { render :show, status: :ok, location: @twet }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @twet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twet.update(twet_params)\n format.html { redirect_to @twet, notice: 'Twet was successfully updated.' }\n format.json { render :show, status: :ok, location: @twet }\n else\n format.html { render :edit }\n format.json { render json: @twet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @twitter_list = TwitterList.find(params[:id])\n\n respond_to do |format|\n if @twitter_list.update_attributes(params[:twitter_list])\n format.html { redirect_to @twitter_list, notice: 'Twitter list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @twitter_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def tweet_new_tweet(tweet)\n #setup twitter client\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = $consumer_key\n config.consumer_secret = $consumer_secret\n config.access_token = $access_token\n config.access_token_secret = $access_token_secret\n end\n\n $log.debug(tweet)\n client.update(tweet)\n $log.info(\"Successfully tweeted!\")\nend",
"def tweet(tweet)\n\t\tclient = Twitter::REST::Client.new do |config|\n\t\tconfig.consumer_key = Rails.application.config.twitter_key\n\t\tconfig.consumer_secret = Rails.application.config.twitter_secret\n\t\tconfig.access_token = oauth_token\n\t\tconfig.access_token_secret = oauth_secret\n\tend\n\tclient.update(tweet)\n\tend",
"def update\n\t\t@tweet.update(tweet_params)\n\n\t\tif @tweet.valid?\n\t\t\tredirect_to_tweet('Your tweet was sucessfully updated!')\n\t\telse\n\t\t\trender(:edit)\n\t\tend\n\tend",
"def update\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n\n respond_to do |format|\n if @tweets_chosen_thread.update_attributes(params[:tweets_chosen_thread])\n format.html { redirect_to(@tweets_chosen_thread, :notice => 'TweetsChosenThread was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweets_chosen_thread.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n\n respond_to do |format|\n if @tweets_chosen_thread.update_attributes(params[:tweets_chosen_thread])\n format.html { redirect_to(@tweets_chosen_thread, :notice => 'TweetsChosenThread was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tweets_chosen_thread.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @twizzle.update(twizzle_params)\n format.html { redirect_to @twizzle, notice: 'Twizzle was successfully updated.' }\n format.json { render :show, status: :ok, location: @twizzle }\n else\n format.html { render :edit }\n format.json { render json: @twizzle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t# find our post\n\t\tid = params[:id]\n\t\t@post = Post.find(id)\n\n\t\t# increment the number of votes\n\t\tif params[:tweet] == \"true\"\n\t\t\t@post.votes = @post.votes + 1\n\t\t\t@post.save\n\t\telsif params[:flagged] == \"true\"\n\t\t\t@post.flagged = @post.flagged + 1\n\t\t\t@post.save\n\t\tend\n\t\t\n\t\t# TODO: ask Tom what this does again\n\t\trender :json => @post\n\tend",
"def update\n if current_user.id==@tweet.user_id\n \n \n respond_to do |format|\n if @tweet.update(tweet_params)\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n elsif current_user.id!=@tweet.user_id\n \n\n \n redirect_to tweets_url, {notice: 'You Cannot update the tweet since you are not the author :p .'}\n end\n\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n #if the tweet was updated, redirects to the show page and issues a notice to the user\n if @tweet.update( tweet_params )\n format.html {redirect_to @tweet, notice: 'Post was successfully updated'}\n else\n #if the tweet does not update, user will stay on the edit page\n format.html {render :edit}\n end\n end\n\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @twitterfeed = Twitterfeed.find(params[:id])\n\n respond_to do |format|\n if @twitterfeed.update_attributes(params[:twitterfeed])\n flash[:notice] = 'Twitterfeed was successfully updated.'\n format.html { redirect_to(@twitterfeed) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @twitterfeed.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n Twitter.user_timeline(params[:foodtruck][:handle])\n foodtruck = Foodtruck.find(params[:id])\n foodtruck.update_attributes(params[:foodtruck])\n redirect_to '/foodtrucks'\n rescue\n redirect_to \"/foodtrucks/#{params[:id]}\"\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update(todo_params)\n render json: @todo\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bottle.update(bottle_params)\n format.html { redirect_to user_path(current_user.id), notice: 'Bottle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @timeline.update(timeline_params)\n format.html { redirect_to @timeline, notice: 'Timeline was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @timeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @favoritetweet = Favoritetweet.find(params[:id])\n\n respond_to do |format|\n if @favoritetweet.update_attributes(params[:favoritetweet])\n format.html { redirect_to(@favoritetweet, :notice => 'Favoritetweet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @favoritetweet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n @old_twit = OldTwit.find(params[:id])\n\n respond_to do |format|\n if @old_twit.update_attributes(params[:old_twit])\n format.html { redirect_to(@old_twit, :notice => 'Old twit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @old_twit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n put :update\n end",
"def update\n respond_to do |format|\n if @zweet.update(zweet_params)\n format.html { redirect_to @zweet, notice: 'Zweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @zweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tweeter_queue = TweeterQueue.find(params[:id])\n\n respond_to do |format|\n if @tweeter_queue.update_attributes(params[:tweeter_queue])\n format.html { redirect_to @tweeter_queue, notice: 'Tweeter queue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tweeter_queue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @timeline = Timeline.find(params[:id])\n\n respond_to do |format|\n if @timeline.update_attributes(params[:timeline])\n format.html { redirect_to @timeline, notice: 'Timeline was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @timeline = Timeline.find(params[:id])\n\n respond_to do |format|\n if @timeline.update_attributes(params[:timeline])\n format.html { redirect_to @timeline, notice: 'Timeline was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tweet_db.update(tweet_db_params)\n format.html { redirect_to @tweet_db, notice: 'Tweet db was successfully updated.' }\n format.json { render :show, status: :ok, location: @tweet_db }\n else\n format.html { render :edit }\n format.json { render json: @tweet_db.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n if @trend.update_attributes(params[:trend])\n format.html { redirect_to @trend, :notice => 'Trend was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @t = T.find(params[:id])\n\n respond_to do |format|\n if @t.update_attributes(params[:t])\n format.html { redirect_to @t, notice: 'T was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @t.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @timeline.update(timeline_params)\n format.html { redirect_to @timeline, notice: 'Timeline was successfully updated.' }\n format.json { render :show, status: :ok, location: @timeline }\n else\n format.html { render :edit }\n format.json { render json: @timeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @timeline.update(timeline_params)\n format.html { redirect_to @timeline, notice: 'Timeline was successfully updated.' }\n format.json { render :show, status: :ok, location: @timeline }\n else\n format.html { render :edit }\n format.json { render json: @timeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tw_stat.update(tw_stat_params)\n format.html { redirect_to @tw_stat, notice: 'Tw stat was successfully updated.' }\n format.json { render :show, status: :ok, location: @tw_stat }\n else\n format.html { render :edit }\n format.json { render json: @tw_stat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n if @trend.update_attributes(params[:trend])\n format.html { redirect_to @trend, notice: 'Trend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @avatar_twitter = AvatarTwitter.find(params[:id])\n\n respond_to do |format|\n if @avatar_twitter.update_attributes(params[:avatar_twitter])\n format.html { redirect_to(@avatar_twitter, :notice => 'Avatar twitter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @avatar_twitter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @account = Account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n #current_user.twitter.update(@account.content) if params[:twitter] == 'yes'\n #if params[:facebook] == 'yes'\n # current_user.facebook.feed!(:message => \"test\",\n # :link => \"http://moonkey.jp\",\n # :name => \"TEST\",\n # :description => \"test\")\n #end\n format.html { redirect_to accounts_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def set_tweet\n @tweet = Tweet.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @tweet_store.update(tweet_store_params)\n format.html { redirect_to @tweet_store, notice: 'Tweet store was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tweet_store.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end",
"def set_tweet\n \t\t@tweet = Tweet.find(params[:id])\n \tend",
"def postTweet(status)\n\t\t\t@client.update(status)\n\t\tend",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def sendtweet\n text=params[:tuit]\n client.update(text) unless text == nil\n respond_to do |format|\n format.html { }\n\t format.json { head :no_content }\n\t format.js\n end\n end",
"def set_tweet\n @tweet = Tweet.find(params[:id])\n end",
"def set_tweet\n @tweet = Tweet.find(params[:id])\n end",
"def set_tweet\n @tweet = Tweet.find(params[:id])\n end"
] | [
"0.71972436",
"0.71972436",
"0.71972436",
"0.7189728",
"0.71033686",
"0.70858943",
"0.70805454",
"0.70317155",
"0.6947886",
"0.6947886",
"0.6947886",
"0.6947886",
"0.6911463",
"0.6911463",
"0.6911463",
"0.68916214",
"0.68813294",
"0.6845525",
"0.68304396",
"0.6797358",
"0.6795",
"0.6788931",
"0.6749023",
"0.6743533",
"0.6731177",
"0.66769356",
"0.66621065",
"0.6661248",
"0.6627785",
"0.6603272",
"0.6596375",
"0.65760195",
"0.6554275",
"0.65316695",
"0.6507397",
"0.64225847",
"0.6416041",
"0.6394849",
"0.6314257",
"0.63072866",
"0.62584215",
"0.6251688",
"0.6225269",
"0.6214913",
"0.6208079",
"0.6197717",
"0.61948425",
"0.6190553",
"0.6182456",
"0.6169689",
"0.61693805",
"0.6161149",
"0.6161111",
"0.61386734",
"0.61272043",
"0.60961443",
"0.6086358",
"0.6086358",
"0.6071449",
"0.606141",
"0.60598683",
"0.60422397",
"0.60304326",
"0.60106623",
"0.59758353",
"0.59577215",
"0.5938756",
"0.5923827",
"0.59225774",
"0.59099764",
"0.58937347",
"0.5888661",
"0.58634037",
"0.58445394",
"0.5842041",
"0.5826733",
"0.5811028",
"0.5803579",
"0.5803579",
"0.58027405",
"0.5801824",
"0.58003294",
"0.5800061",
"0.57999045",
"0.57999045",
"0.5794211",
"0.57894486",
"0.5777967",
"0.5777332",
"0.5775946",
"0.57694453",
"0.5766249",
"0.5756861",
"0.57548934",
"0.5744169",
"0.57427406",
"0.5736639",
"0.57307833",
"0.57307833",
"0.57307833"
] | 0.69473106 | 12 |
DELETE /tweets/1 DELETE /tweets/1.json | def destroy
@tweet.destroy
respond_to do |format|
format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n user = user_from_token\n user.tweets.destroy(params[:id])\n head :no_content\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @interesting_tweet.destroy\n respond_to do |format|\n format.html { redirect_to interesting_tweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: '削除しました' }\n format.json { head :no_content }\n end\n end",
"def destroy\n tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_path, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n respond_to do |format|\n begin\n @tweet = TweetApp::ClientContext.status(:delete, params[:id])\n flash[:message] = \"Tweet with id #{params[:id]} was deleted from Twitter\"\n format.html { redirect_to tweets_url }\n format.json { head :ok }\n format.xml { head :ok }\n rescue Twitter::RESTError => re\n handle_rest_error(re, format)\n end\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweeeet.destroy\n respond_to do |format|\n format.html { redirect_to tweeeets_url, notice: 'Tweet eliminado con éxito!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n death = []\r\n death << Retweet.where(tweet_id: @tweet.id)\r\n death.flatten!\r\n death.each do |die|\r\n die.destroy\r\n end\r\n\r\n @tweet.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to tweets_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\r\n @tweet.destroy\r\n respond_to do |format|\r\n format.html { redirect_to tweets_url, notice: \"Tweet was successfully destroyed.\" }\r\n format.json { head :no_content }\r\n end \r\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.delete_tweet_keep_sub_tweets\n @tweet.reload\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'ツーイトの削除が完了しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trash_tweet.destroy\n respond_to do |format|\n format.html { redirect_to trash_tweets_url, notice: 'Trash tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitter_id = TwitterId.find(params[:id])\n @twitter_id.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_ids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n redirect_to tweets_path\n #respond_to do |format|\n #format.html { redirect_to tweets_url }\n #format.json { head :no_content }\n #end\n end",
"def destroy\n check_tweet_for_user\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retweet = Retweet.find(params[:id])\n @retweet.destroy\n\n respond_to do |format|\n format.html { redirect_to retweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweetaros_url, notice: 'Tweetを削除しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @new_tweet.destroy\n respond_to do |format|\n format.html { redirect_to new_tweets_url, notice: 'New tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n\n if @tweet.user_id == session[:user_id]\n @tweet.retweets.destroy_all\n\n @tweet.destroy\n else\n flash[:notice] = \"Tweet can not be deleted\"\n end\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end \n end",
"def destroy\n @actor_tweet.destroy\n respond_to do |format|\n format.html { redirect_to @tweet, notice: 'Actor tweet eliminado correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweett.destroy\n respond_to do |format|\n format.html { redirect_to tweetts_url, notice: 'Tweett was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n respond_with(@tweet)\n end",
"def destroy\n @tweeter = Tweeter.find(params[:id])\n @tweeter.destroy\n\n respond_to do |format|\n format.html { redirect_to tweeters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @zweet.destroy\n respond_to do |format|\n format.html { redirect_to zweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @avatar_tweet = AvatarTweet.find(params[:id])\n @avatar_tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(avatar_tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fr_tweet.destroy\n respond_to do |format|\n format.html { redirect_to fr_tweets_url, notice: 'Fr tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweetsandwich = Tweetsandwich.find(params[:id])\n @tweetsandwich.destroy\n\n respond_to do |format|\n format.html { redirect_to tweetsandwiches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @search_tweet = SearchTweet.find(params[:id])\n @search_tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(search_tweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @retweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Retweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n run Tweet::Delete\n\n flash[:alert] = \"Tweet deleted\"\n redirect_to tweets_path\n end",
"def destroy\n #deletes selected tweet\n @tweet.destroy\n\n #After tweet is deleted, redirects back to the main tweet URL\n #Also, adds a notice to let the user know the tweet was deleted\n respond_to do |format |\n format.html {redirect_to tweets_url, notice: \"Post was deleted\" }\n end\n\n end",
"def destroy\n @twitter_user = TwitterUser.find(params[:id])\n @twitter_user.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tweet_db.destroy\n respond_to do |format|\n format.html { redirect_to tweet_dbs_url, notice: 'Tweet db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n TwitterSyncWorker.new.delete(session[:user_id], @favorite_tweet.id)\n @favorite_tweet.destroy\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favoritetweet = Favoritetweet.find(params[:id])\n @favoritetweet.destroy\n\n respond_to do |format|\n format.html { redirect_to(favoritetweets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweet_post.destroy\n respond_to do |format|\n format.html { redirect_to tweet_posts_url, notice: \"Tweet post was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Add in this #MDM\n # Use current_user below, so that new tweets are only created by the logged in user #MDM\n # @tweet = Tweet.find(params[:id])\n @tweet = current_user.tweets.find(params[:id])\n \n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitter_list = TwitterList.find(params[:id])\n @twitter_list.destroy\n\n respond_to do |format|\n format.html { redirect_to twitter_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twee.destroy\n respond_to do |format|\n format.html { redirect_to twees_url, notice: 'Twee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @tweet_store.destroy\n respond_to do |format|\n format.html { redirect_to tweet_stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twet.destroy\n respond_to do |format|\n format.html { redirect_to twets_url, notice: \"Twet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twet.destroy\n respond_to do |format|\n format.html { redirect_to twets_url, notice: 'Twet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tweets!\n self.twittertexts.destroy_all\n end",
"def destroy\n @qweet.destroy\n respond_to do |format|\n format.html { redirect_to qweets_url, notice: \"Qweet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet_collection.destroy\n respond_to do |format|\n format.html { redirect_to tweet_collections_url, notice: 'Tweet collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twitterfeed = Twitterfeed.find(params[:id])\n @twitterfeed.destroy\n\n respond_to do |format|\n format.html { redirect_to(twitterfeeds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweet.destroy\n respond_to do |format|\n format.js\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tw_stat.destroy\n respond_to do |format|\n format.html { redirect_to tw_stats_url, notice: 'Tw stat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twenty.destroy\n respond_to do |format|\n format.html { redirect_to twenties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweet.destroy\n\n head :no_content\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to \"/timeline\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twizzle.destroy\n respond_to do |format|\n format.html { redirect_to twizzles_url, notice: 'Twizzle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n @tweets_chosen_thread.destroy\n\n respond_to do |format|\n format.html { redirect_to(tweets_chosen_threads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweets_chosen_thread = TweetsChosenThread.find(params[:id])\n @tweets_chosen_thread.destroy\n\n respond_to do |format|\n format.html { redirect_to(tweets_chosen_threads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tweeter.destroy\n respond_to do |format|\n format.html { redirect_to tweeters_url, notice: 'Tweeter was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timeline.destroy\n respond_to do |format|\n format.html { redirect_to timelines_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n if @tweet.client == current_client\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n format.js {render :js=>\"$.notify('Tweet deleted', 'success');removeTweet(#{@tweet.id})\"}\n end\n else\n respond_to do |format|\n format.html { redirect_to tweets_url, :status => :forbidden, notice: 'Unauthized.' }\n format.json {render json: {:error=>\"forbidden\"},:status=> :forbidden }\n end\n end\n end",
"def destroy\n signin_apikey\n if session[:user_id] != nil\n if @tweet.user_id.to_s == session[:user_id].to_s\n @tweet.destroy\n respond_to do |format|\n format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }\n format.json { render json: {message: 'Contribution destroyed!' } }\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Forbidden, you can\\'t delete a tweet that is not yours' }, status: 403 }\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end",
"def delete\n render json: Like.delete(params[\"id\"])\n end",
"def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @user_follower = UserFollower.find(:first, :conditions => {:user_id => params[:id], :follower_id => params[:user_id]})\n @user_follower.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_tweets_path(current_user)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @timeline = Timeline.find(params[:id])\n @timeline.destroy\n\n respond_to do |format|\n format.html { redirect_to timelines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @twittter.destroy\n respond_to do |format|\n format.html { redirect_to twittters_url, notice: 'Twittter was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @example_two.destroy\n respond_to do |format|\n format.html { redirect_to example_twos_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @twentyeight.destroy\n respond_to do |format|\n format.html { redirect_to twentyeights_url }\n format.json { head :no_content }\n end\n end",
"def destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @twentytwo.destroy\n respond_to do |format|\n format.html { redirect_to twentytwos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @avatar_twitter = AvatarTwitter.find(params[:id])\n @avatar_twitter.destroy\n\n respond_to do |format|\n format.html { redirect_to(avatar_twitters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @todo = Todo.find(params[:id])\n @todo.destroy\n render json: nil, status: :ok\n end",
"def delete_status(id)\n delete(\"/statuses/#{id}\")\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\t\t\n\t\tbegin\n\t\t\t@retweet = current_user.tweets_users.find(params[:id])\n\t\trescue ActiveRecord::RecordNotFound\n\t\t\trender :text => \"Record Not Found\"\n\t\tend\n\t\t\n\t\trender :text => \"Retweet not posted successfully\" && return if !@retweet.destroy\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html {redirect_to tweets_path}\n\t\tend\n\tend",
"def destroy\n @weibo = Weibo.find(params[:id])\n @weibo.destroy\n\n respond_to do |format|\n format.html { redirect_to weibos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Feed.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @trend = Trend.find(params[:id])\n @trend.destroy\n\n respond_to do |format|\n format.html { redirect_to trends_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @change_table_tweet_info.destroy\n respond_to do |format|\n format.html { redirect_to change_table_tweet_infos_url, notice: 'Change table tweet info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @old_twit = OldTwit.find(params[:id])\n @old_twit.destroy\n\n respond_to do |format|\n format.html { redirect_to(old_twits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trend = Trend.find(params[:id])\n @trend.destroy\n\n respond_to do |format|\n format.html { redirect_to trends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @word_count = WordCount.find(params[:id])\n @word_count.destroy\n\n respond_to do |format|\n format.html { redirect_to word_counts_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.76199996",
"0.7450857",
"0.7450857",
"0.7447384",
"0.7429406",
"0.7330124",
"0.73026913",
"0.7290236",
"0.7262342",
"0.72382593",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.7211454",
"0.7209999",
"0.7209999",
"0.7209999",
"0.7209999",
"0.7209999",
"0.7198669",
"0.7172167",
"0.7149214",
"0.7134847",
"0.71338797",
"0.71254003",
"0.7120872",
"0.7113737",
"0.7084184",
"0.70801175",
"0.70738715",
"0.7049133",
"0.7041509",
"0.7005985",
"0.6956369",
"0.6951371",
"0.69182694",
"0.6906971",
"0.6904089",
"0.6890399",
"0.68603015",
"0.6859062",
"0.68303055",
"0.68140453",
"0.6783385",
"0.6777403",
"0.67723584",
"0.677195",
"0.6755713",
"0.66980267",
"0.6678964",
"0.6653729",
"0.66388994",
"0.66325164",
"0.66218156",
"0.6602527",
"0.6595164",
"0.6590409",
"0.656496",
"0.65576714",
"0.65509486",
"0.652575",
"0.6519718",
"0.65115285",
"0.6498843",
"0.6498235",
"0.6498129",
"0.6498043",
"0.6489908",
"0.6461169",
"0.64610493",
"0.64545625",
"0.64515126",
"0.6431691",
"0.64314145",
"0.6428608",
"0.6401754",
"0.63985467",
"0.6397914",
"0.638301",
"0.6381239",
"0.6375807",
"0.63566065",
"0.63522345",
"0.6349266",
"0.63397986",
"0.6339744",
"0.63326395",
"0.6332589",
"0.63243526",
"0.6314457",
"0.63136876",
"0.6309394",
"0.6307769",
"0.63065094",
"0.630638",
"0.62966084",
"0.6294841"
] | 0.6927889 | 38 |
Use callbacks to share common setup or constraints between actions. | def set_tweet
@tweet = Tweet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.5332605",
"0.5312215",
"0.5296594",
"0.52965283",
"0.52957606",
"0.5259903",
"0.52443177",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.52329034",
"0.52322394",
"0.5227445",
"0.5222394",
"0.5220348",
"0.5212759",
"0.5207747",
"0.5205933",
"0.5176468",
"0.5173833",
"0.5171983",
"0.51663405",
"0.5159596",
"0.5158247",
"0.51526845",
"0.5152398",
"0.5151361",
"0.5145775",
"0.5140135",
"0.51338995",
"0.51127726",
"0.5112607",
"0.5112607",
"0.5110613",
"0.51067513",
"0.5092337",
"0.508788",
"0.5081578",
"0.5080434",
"0.50679874",
"0.50567716",
"0.5051213",
"0.5048352",
"0.5048352",
"0.5035347",
"0.5026666",
"0.5023127",
"0.5016081",
"0.50129867",
"0.5000684",
"0.4999752",
"0.49979812",
"0.499026",
"0.499026",
"0.49866846",
"0.49800366",
"0.49795717",
"0.49771172",
"0.4968475",
"0.4965813",
"0.4958072",
"0.49561292",
"0.4954901",
"0.49536785",
"0.4953058",
"0.49468648",
"0.49424478",
"0.4932989",
"0.49291888",
"0.49273813",
"0.49271655",
"0.4925948",
"0.49236968",
"0.49203572",
"0.49181753",
"0.49173692",
"0.4916862",
"0.49161318",
"0.49155986"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tweet_params
params.require(:tweet).permit(:content, :send_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
after reviewing LS solution, and recognizing that my original solution is too redundant | def uuid_generator
uuid = []
segments = [8, 4, 4, 4, 12]
segments.each do |num|
uuid << CHARS.sample(num).join
end
p uuid.join('-')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hook_solution?(a); end",
"def recursive_solution\n\n end",
"def anchored; end",
"def solution4(input)\n end",
"def dpll\n\t\t#need to count degree, best_guess, assignments and such heuristic stuff somewhere... makes sense to do it here\n\t\t#should make a version without heuristics aswell\n##############################################3\n#\t\tputs \"the kb : \" + @kb.to_s\n\n\t\t@kb.each do |sente|\n##########################################################333\n#\t\t\tputs \" the sentences: \" + sente.to_s\n\n\t\t\tif(sente.size==1)\n\t\t\t\tindex=sente[0]\n\t\t\t\tif(index > 0)\n\t\t\t\t\t@id_array[index-1].pos_increment\n\t\t\t\t\t@id_array[index-1].puret=true\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tindex*=-1\n\t\t\t\t\t@id_array[index-1].neg_increment\n\t\t\t\t\t@id_array[index-1].puref = true\n\t\t\t\tend\t\n\t\t\telse\t\n\t\t\t\tsente.each do |atome|\n#############################################################\n#\t\t\t\t\tputs \"the individual atoms: \" + atome.to_s\n\t\t\t\t\tif(atome > 0)\n\t\t\t\t\t\tindex = atome-1\n\t\t\t\t\t\t@id_array[index].pos_increment\n\t\t\t\t\telse\n\t\t\t\t\t\tindex = -1*atome-1\n\t\t\t\t\t\t@id_array[index].neg_increment\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\t\n\t\tend\n\t\t@id_array.each do |var|\n\t\t\tif(!var.assignment_intialize)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\t\n\t\t#intialization stuff\n\t\t##########heuristic sort!\n\t\tvar_list = @id_array\n\t\tvar_list.sort!\n\t\t\n\t\tdepth=0\n\t\tassignment = Array.new\n\t\tsatisfiable = false\n\t\tstack = []\n\t\n\t\t#make parallel array assignment\n\t\tid_array.map { assignment << 0}\n\t\t\n\n\t\t#insert root\n\t\t(var_list[depth].assignments).map do |child|\n\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\tend\n\t\t\n\t\t#start depth-first search\n\t\twhile(stack.size()>0)\n\t\n\t\t\ttemp = stack.pop\n\t\t\n\t\t\t#comparing depth to make sure assignment variables reassigned if popping up the tree\n\t\t\twhile(depth>temp.depth)\n\t\t\t\tassignment[depth] = 0\n\t\t\t\tdepth -=1\n\t\t\tend\t\n\t\t\t#add it to the assignment evaluation list (depth doubles as index through var_list)\n\t\t\tassignment[var_list[temp.depth].id - 1] = temp.value\n\t\t\n\t\t\t#Evaluate the assignment list\n\t\t\tif(satisfiable_assignment?(assignment)==1)\n##########################################################################333\n\t\t\t\tputs \"the kb is: \" + @kb.to_s \n\t\t\t\tputs \"the assignment that evaluates to true: \"\n\t\t\t\tputs assignment.to_s\n#############################################################################\n\t\t\t\t\n\t\t\t\treturn true\n\t\t\tend\n\t\n\t\t\t#add children\n\t\t\tdepth+=1\t\n\t\n\t\t\t#if not bottumed out, add more children based on values from the var\n\t\t\tif(depth<var_list.size())\n\t\t\t\t(var_list[depth].assignments).map do |child|\n\t\t\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\t\t\tend\t \n\t\t\telse\n\t\t#reset to bottom value\n\t\t\t\tdepth =var_list.size-1\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def corrections; end",
"def solved(ans)\n\n end",
"def solve\n end",
"def lsi; end",
"def schumann; end",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def solution\n\n return self if solved?\n\n while [hidden_singles, naked_singles].any?\n end\n\n return self if solved?\n\n\n # Brute force\n i = each_empty_cell.sort_by { |cell, n| legal_values(n).size }.first.try :last\n\n legal_values(i).map do |value|\n fill(i, value).solution\n end.compact.select { |n| n.solved? }.first\n end",
"def initVectorial\n docs = Array.new\n docs_names = Array.new\n terms = Array.new\n @question.each { |word| docs += (@postings.find_one({:term => word}).to_a) }\n for i in 0..@question.size-1\n terms[i] = @postings.find_one({:term => @question[i]}).to_a\n end\n for i in 0..docs.size-1\n docs_names[i] = docs[i][0]\n end\n docs_names = docs_names - ['_id', 'term']\n docs_names = docs_names.uniq\n data = Array.new(docs_names.size) { Array.new(terms.size, 0) }\n data_w = Array.new(docs_names.size) { Array.new(terms.size, 0) }\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n for k in 0..terms[j].size-1\n if docs_names[i].eql?(terms[j][k][0])\n data[i][j] = terms[j][k][1]\n end\n end\n end\n end\n#CONTAR.SI\n count_if = Array.new(@question.size, 0)\n log_count_if = Array.new(@question.size, 0)\n for j in 0..docs_names.size-1\n for i in 0..@question.size-1\n count_if[i] += data[j][i]\n end\n end\n#LOGARITHM count_if\n#--------------------------------\n log_count_if = Array.new(count_if.size, 0)\n for i in 0..count_if.size-1\n #WARNING HERE\n log_count_if[i] = Math.log10(count_if[i]) \n end\n#DATA_W--------------------------------\n#MISSING Q¿?\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n data_w[i][j] = data[i][j]/log_count_if[j]\n end\n end\n#SUM---------------------------------\n sum = Array.new(docs_names.size,0)\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n sum[i] += data_w[i][j]\n end\n end\n#SUM---------------------------------\n e1 = Array.new(docs_names.size,0)\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n e1[i] += (data_w[i][j])**2\n end\n end\n sum.each_index { |i| e1[i] += sum[i]**2 } \n#E2---------------------------------\n e2 = e1.collect{|item| item*terms.size}\n#SUMA/E2----------------------------\n ranking = Array.new(docs_names.size,0)\n results = Array.new(docs_names.size) { Array.new(4) }\n for i in 0..e1.size-1\n results[i][0] = docs_names[i]\n results[i][1] = 1 - sum[i]/e2[i]\n results[i][2] = getIdDoc(docs_names[i])\n results[i][3] = getDocPath(docs_names[i])\n end\n results = results.sort_by{|e| e[1]}\n results = results.reverse\n return results\n end",
"def solve!\n end",
"def alg; end",
"def schubert; end",
"def classificateResult(label, sampleMap, foundAllArr)\n puts \"[classificateResult] started label #{label}\"\n foundArr = foundAllArr.select{|found| matchLabels?(found.label, label)}\n expRecognitionResult = Spnt::Exp::Data::ExpRecognitionResult.new()\n expRecognitionResult.falseNegative = []\n expRecognitionResult.falsePostive = []\n #missed = sampleArr - foundArr\n #1 step. filter that was found and transform to array\n substituted = sampleMap.select{|ekey, sample|\n if(matchLabels?( label, sample.label))\n nil == foundArr.detect{|found| sample.ekey == found.ekey && found.shouldStart != @@UNDEFINED_CELL} \n end\n }.collect { |k, v| v }\n deleted =foundArr.select{|found|\n found.foundStart == nil || found.foundStart == @@UNDEFINED_CELL \n }\n inserted =foundArr.select{|found|\n found.shouldStart == nil || found.shouldStart == @@UNDEFINED_CELL \n }\n \n puts \"[classificateResult] %s substituted: %i\" % [label, substituted.length]\n puts \"[classificateResult] %s deleted: %i\" % [label, deleted.length]\n puts \"[classificateResult] %s inserted: %i\" % [label, inserted.length]\n\n expRecognitionResult.falseNegative = (expRecognitionResult.falseNegative << substituted).flatten\n expRecognitionResult.falseNegative = (expRecognitionResult.falseNegative << deleted).flatten\n expRecognitionResult.falsePostive = (expRecognitionResult.falsePostive << inserted).flatten\n \n puts \"[classificateResult] %s falseNegative: %i\" % [label, expRecognitionResult.falseNegative.length]\n puts \"[classificateResult] %s falsePostive: %i\" % [label, expRecognitionResult.falsePostive.length]\n\n\n puts \"[classificateResult]substituted: \" + substituted.collect{|v| \" %i => %s[%s]\" % [v.id, v.ekey, v.foundStart]}.join(\"; \")\n\n# foundDuplicates = {}\n# expRecognitionResult.correct = foundArr.select{|found|\n# sample = sampleMap[found.ekey]\n# if(sample != nil && matchLabels?( label, found.label))\n# if(found.foundStart == nil)\n# #puts \"[classificateResult]falseNegative [#{found.ekey}] no start: #{sample.shouldStart} #{found.foundStart}\"\n# expRecognitionResult.falseNegative << sample\n# false\n# else\n# absStartDelta = (sample.shouldStart - found.foundStart).abs\n# absEndDelta = (sample.shouldEnd - found.foundEnd).abs\n# matched = sample.ekey == found.ekey && absStartDelta <= @@thresholdStart && absEndDelta <= @@thresholdEnd\n# if matched == true\n# foundDuplicateElement = foundDuplicates[found.ekey]\n# if foundDuplicateElement == nil\n# foundDuplicateElement = []\n# foundDuplicates[found.ekey] = foundDuplicateElement\n# end\n# foundDuplicateElement << found\n# #puts \"foundDuplicates[#{sample.ekey}] #{foundDuplicates[sample.ekey].length} #{matched && foundDuplicates[sample.ekey].length == 1}\"\n# end\n# matched && foundDuplicates[sample.ekey].length == 1\n# end\n# else\n# false\n# end\n# }\n #expRecognitionResult.falsePostive = foundArr.select{|found| !expRecognitionResult.correct.include?(found) && !expRecognitionResult.falseNegative.include?(found)}\n# expRecognitionResult.correct = foundArr.select{|found|\n# expRecognitionResult.falsePostive.include?(found) && expRecognitionResult.falseNegative.include?(found)\n# }\n expRecognitionResult.correct = foundArr.to_set - expRecognitionResult.falsePostive.to_set - expRecognitionResult.falseNegative.to_set;\n puts \"falsePostive[#{expRecognitionResult.falsePostive.length}] + falseNegative[#{expRecognitionResult.falseNegative.length}]+correct[#{expRecognitionResult.correct.length}] = foundArr[#{foundArr.length}]\"\n expRecognitionResult\n end",
"def stderrs; end",
"def silly_adjective; end",
"def minimize; end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def malts; end",
"def update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0]+@mastermind.hits(@last_guess,x)[1])\r\n }\r\n\r\n end",
"def suivre; end",
"def sld; end",
"def diff1; end",
"def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend",
"def solver (seed_char, blanks_words_sizes, matrix)\n\t# Set numerical target\n\ttarget = magic_num(seed_char)\t\n\t# Find magic number sum buckets\n\tskynet(target, blanks_words_sizes, blanks_words_sizes.length - 1, 0, [])\n\t# Alphabetical sort input matrix\n\tsorted_seed_char = seed_char.chars.sort.join\t\n\n\t# Find unique sets from skynet solutions\n\t$answer[:trace].each do |arrOarr|\n\t\tarrOarr.sort!\n\tend \n\n\t$answer[:trace].uniq!\t\n\t\n\t# Finds match for complete set of words from skynet solutions\n\t$answer[:trace].each do |answer_arr_el|\t\t\t\t\n\t\tunordered_match(sorted_seed_char, matrix, answer_arr_el, answer_arr_el.length - 1, \"\", [])\n\t\t# Can be ignored\n\t\t$ops += $seed[answer_arr_el[0][0]][:num_groups][answer_arr_el[0][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length\t\t\n\tend\n\t\n\treturn $answer[:words]\nend",
"def solution_correct?\n current = params[:solution].strip\n current.gsub!(/\\/\\*[\\w\\s]*\\*\\//,\"\") \n current.gsub!(/--.*\\n/,\"\")\n existing = format_str(@lesson.solution.strip)\n current = format_str(current.strip)\n if existing == current\n return true\n else\n existing_arr = existing.split\n current_arr = current.split\n len= existing_arr.length\n err =[]\n j=0 \n for i in 0..len\n if existing_arr[i]!=current_arr[i]\n err[j]= existing_arr[i]\n j=j+1 \n end\n end\n return err\n end \n end",
"def offences_by; end",
"def solve(points)\r\n min_dis = BigDecimal(\"-1\")\r\n p min_dis.class\r\n \r\n min_route = []\r\n (1..points.length-1).to_a.permutation(points.length-1).to_a.each do |route|\r\n route.unshift(0)\r\n #p route\r\n dis = BigDecimal(\"0\")\r\n (0...route.length-1).each do |i|\r\n dis += Math.sqrt((BigDecimal(points[route[i]][0].to_s) - BigDecimal(points[route[i+1]][0]))**2 + (BigDecimal(points[route[i]][1]) - BigDecimal(points[route[i+1]][1]))**2)\r\n end\r\n dis += Math.sqrt((BigDecimal(points[route[route.length-1]][0]) - BigDecimal(points[route[0]][0]))**2 + (BigDecimal(points[route[route.length-1]][1]) - BigDecimal(points[route[0]][1]))**2)\r\n #p dis\r\n if min_dis == -1 || min_dis > dis\r\n #p dis.class\r\n min_dis = dis\r\n min_route = route\r\n end\r\n end\r\n\r\n p min_dis.class\r\n print \"{{\"\r\n (0...min_route.length).each do |i|\r\n print \"#{min_route[i]+1},\"\r\n end\r\n print \"1},#{min_dis}}\\n\"\r\n #p min_dis\r\n #p min_route\r\n\r\nend",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def corrections\n #For each word to be looked at\n $words.each do |word_array|\n #If the word is misspelled attempt corrections\n possible_matches = Array.new\n if word_array[1] == false\n #Sets word to the actual word, instead of array pair\n word = word_array[0]\n # Get lexicon searching vars\n first_char = word[0]\n len = word.length\n\n ##Find words with similar letters\n #Saves the length of the word for eaiser access\n size = word.length\n #Iterates over words with matching starting letter and length +- 1\n $lexicon[first_char][len].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n # only check shorter words if length is greater than 1\n if len > 1\n $lexicon[first_char][len-1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n end\n\n $lexicon[first_char][len+1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n #Iterate over the possible matches, taking the match with the highest percentage\n #Hash to hold similarity\n similarity = Hash.new(0.0)\n possible_matches.each do |word_to_compare|\n similarity[word_to_compare] = match_percentage word, word_to_compare\n end\n\n best_match = ''\n similarity.each do |match|\n if match[1] > similarity[best_match]\n best_match = match[0]\n end\n end\n $correction[word] = best_match\n end\n end\nend",
"def failed_split(*bonds)\n puts \"Ground Truth: #{basic_split(*bonds).inspect}\"\n self.find_internal_adducts unless @adducts\n # binding.pry if bonds.size == 2\n returns = []\n mols = []\n mols2 = []\n product_mols = []\n if bonds.size > 0\n # set apart the adducts\n p delete_and_restore_bonds(*bonds) do |mol|\n mol.ob.separate.map(&:upcast)\n end\n bonds.each do |bond|\n delete_and_restore_bonds(bond) do |mol| \n mols = mol.ob.separate.map(&:upcast)\n puts \"MOLS: #{mols.inspect}\"\n mols = []\n adducts_present = []\n mol.ob.separate.map(&:upcast).map {|a| @adducts.include?(a) ? adducts_present << a : mols << a}\n puts \"MOLS: #{mols.inspect}\"\n product_mols << mols\n end\n end # bonds.each\n puts \"PMOLS: #{product_mols.inspect}\"\n mols\n else\n mols = self.ob.separate.map(&:upcast).delete_if {|a| @adducts.include?(a)}\n mols2 = mols.map(&:dup)\n mols_all = mols.map(&:dup)\n @adducts.map do |adduct|\n #mols2.each {|mol| mol.associate_atom! adduct.atoms.first }\n mols_all.product([adduct]).map {|mol, adduct| mol.associate_atom! adduct.atoms.first }\n mols2.product([adduct]).map {|mol, adduct| mol.associate_atom! adduct.atoms.first }\n end\n# p mols3\n# p mols_all\n# puts \"+\"*50\n# p mols2 != mols\n products = mols2 != mols ? mols.product(mols2) : [mols]\n # p products\n products.delete_if do |set|\n puts \"set: #{set}\"\n set.last.ob.separate.map(&:upcast).include?(set.first)\n puts \"set: #{set}\"\n end\n # p products\n #binding.pry\n #puts \"adduct_added: #{adduct_added.inspect}\"\n # Right now, I'm making the response sets of matched pairs, even if they have adducts... which they should?\n # Is there a better way to feed these back?\n #adduct_added.empty? ? mols : mols.flatten.sort_by(&:mol_wt).reverse.zip(adduct_added.sort_by(&:mol_wt))\n #products.first.is_a?(Array) ? products.flatten : products\n products\n end\n end",
"def in_law; end",
"def reduce_solved\n before = 9*9*9\n after = entropy\n while before > after\n before = after\n reduce_line\n reduce_col\n reduce_grid\n after = entropy\n end\n self\n end",
"def calculate\n candidates = []\n\n generalized_cause = NLU::Generalization.new(symbols: @symbols).generalize(@cause)\n\n #ap \"sentence: #{cause_sentence}\"\n #ap \"learned: #{@learned.inspect}\"\n\n # We go through everything that was learned before\n @learned.each do |function_name, criteria|\n criteria[:generalizations].each do |generalization|\n\n # We generate a pre-candidate for this generalization. It starts\n # with score zero because we don't know yet whether this criteria\n # fits the sentence or not.\n local_candidate = {\n fn: function_name,\n attrs: { },\n score: 0.0\n }\n\n #ap \"generalized_cause #{generalized_cause}\"\n\n # We then generalize the cause sentence and go through it.\n # We will match *each* learned generalization against the cause\n # generalization.\n generalized_cause.each_with_index do |cause_rule, cause_index|\n\n\n # Wildcard\n #\n # Matches these:\n #\n # > i want a [type:wildcard:some_name_for_this_wildcard]\n # > i want a ford\n #\n wildcard = \"[#{NLU::Generalization::RESERVED_TYPES[:wildcard]}]\"\n #ap \"wildcard: #{wildcard}\"\n wildcard_regex = Regexp.escape(wildcard)\n if generalization =~ /wildcard/i\n wildcard_generalization = generalization\n .gsub(/\\[(type:wildcard)(.+)\\]/i, '[\\1]')\n end\n #ap \"wildcard_generalization(#{wildcard_generalization}) =~ cause_rule(#{wildcard_regex})\"\n if wildcard_generalization.to_s =~ Regexp.new(wildcard_regex, Regexp::IGNORECASE)\n #ap \"true -> #{wildcard_generalization} =~ /#{Regexp.new(wildcard_regex, Regexp::IGNORECASE)}/i\"\n\n rule = wildcard_generalization.gsub(\"#{wildcard}\", \"(.+)\")\n #ap \"rule #{rule}\"\n #binding.pry\n if value = cause_sentence.join(\" \").match(Regexp.new(rule, Regexp::IGNORECASE))\n value = value[-1]\n prop = attr_name_from_type_param(generalization)\n\n local_candidate = local_candidate.merge({\n attrs: {\n prop => value\n },\n score: 0.75\n })\n end\n\n # If we find a learned generalization that matches the generalized\n # sentence, we will save it.\n elsif generalization == cause_rule\n cause_rule.split(\" \").each_with_index do |typed_string, index|\n\n # If the learned generalization has a type anywhere, we will\n # check what is the corresponding word in the cause sentence.\n #\n # For example, consider the following sentence:\n #\n # [type:subject] want a [type:make]\n #\n # and the sentence\n #\n # I want a ford\n #\n # Finding `[type:make]` at position 3 of the array, we will\n # get `ford` at the position 3 of the cause sentence. With\n # that we can come up with `{make: 'ford'}`.\n #\n if typed_string =~ /\\[type/i\n local_candidate[:score] += 1\n type = attr_name_from_type_param(typed_string)\n prop = type_properties(type)\n type_token_length = prop[:token_length]\n\n # In `i want a car`, this will get the `i`. If the type\n # says instead that it's formed by two symbols (e.g\n # `i want`), then it will take `i want`.\n #\n # The -1 in the brackets is because otherwise it would be\n # translated to the following if the type had 1 symbol\n #\n # cause_sentence[1..1+1]\n #\n # That would take 2 words (`[1..2]`). We want one word, so\n #\n # cause_sentence[1..1+1-1]\n #\n word_for_type = cause_sentence[index..index+(type_token_length-1)]\n #ap \"> type: #{type} - #{index} #{cause_sentence[index..index+type_token_length]}\"\n\n local_candidate[:attrs][type] = word_for_type.join(\" \")\n\n # When it's just the same sentence as one seen before, no\n # generalizations\n else\n local_candidate[:score] = 1\n end\n end\n\n end\n end\n\n if local_candidate[:score] > 0\n candidates << local_candidate\n end\n end\n end\n\n # TODO - normalization is taking out some elements that are good.\n #candidates = normalize_scores(candidates)\n candidates = pick_candidates(candidates)\n candidates = merge_attributes(candidates)\n\n candidates\n end",
"def exercise_1113 (matrix)\n end",
"def singular_siegler; end",
"def diff2; end",
"def solve(file)\r\n x, y = Integer($sx), Integer($sy)\r\n visited = []\r\n discovered = []\r\n value = $table[\"#{x} #{y}\"]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n discovered.push(\"#{x} #{y}\")\r\n \r\n while discovered.size != 0\r\n current = discovered.pop\r\n x, y = current.split(/\\s/)\r\n x = Integer(x)\r\n y = Integer(y)\r\n value = $table[current]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n \r\n if visited.include?(current) == false\r\n visited.push(current)\r\n direction = direction.split(//)\r\n \r\n i = 0\r\n while i < direction.size\r\n case direction[i]\r\n when \"u\"\r\n y = y - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y + 1\r\n when \"d\"\r\n y = y + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y - 1\r\n when \"l\"\r\n x = x - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x + 1\r\n when \"r\"\r\n x = x + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x - 1\r\n end\r\n i = i + 1\r\n end\r\n end\r\n end\r\n puts discovered\r\n if result == true\r\n puts result\r\n else\r\n puts false\r\n end\r\n end",
"def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end",
"def steal_engine(ltr, pool, stealable, pool_active=[], stealable_active=[], lv=1, candidates=nil)\n all_active = pool_active.join('') + stealable_active.join('')\n\n if candidates.nil?\n print '| '*lv+ \"STEALENGINE: Trying #{stealable_active} + #{pool_active} : \"\n\n candidates = ltr.find_superset_str(all_active)\n return false unless candidates\n\n #puts '| '*lv+ \"STEALENGINE: Trying #{stealable_active} + pool #{pool_active}\"\n puts '| '*lv+ \" : OK! Remain #{stealable} + #{pool}\"\n else\n puts '| '*lv+ \"continue : #{stealable_active} + #{pool_active}\"\n end\n\n puts '| '*lv+ \" : Some candidates: \"+candidates.join(', ')\n\n if stealable.empty? and pool.empty?\n puts '| '*lv+\"COMPLETE\"\n if (!pool_active.empty?) and normalize_word(all_active) == normalize_word(candidates[0])\n return candidates[0]\n else\n return false\n end\n end\n\n if stealable.empty?\n # Deplete the pool\n puts '| '*lv+ \"pool draw\"\n\n pool.each_index do |pool_idx|\n letter = pool[pool_idx]\n\n new_pool = pool.dup\n new_pool.delete_at(pool_idx)\n\n res = steal_engine(ltr, new_pool, stealable, pool_active + [letter], stealable_active, lv+1)\n if res\n return res\n end\n\n res = steal_engine(ltr, new_pool, stealable, pool_active, stealable_active, lv+1, candidates)\n if res\n return res\n end\n end\n\n else\n puts '| '*lv+ \"stealables draw\"\n\n stealable.each_index do |steal_idx|\n steal = stealable[steal_idx]\n\n new_stealable = stealable.dup\n new_stealable.delete_at(steal_idx)\n\n # Try adding this steal\n res = steal_engine(ltr, pool, new_stealable, pool_active, stealable_active + [steal], lv+1)\n if res\n return res\n end\n\n # Try without adding additional steal\n res = steal_engine(ltr, pool, new_stealable, pool_active, stealable_active, lv+1, candidates)\n if res\n return res\n end\n end\n\n end\n\n return false\nend",
"def alternatives; end",
"def internship_passed; end",
"def romeo_and_juliet; end",
"def solution\n 971 * (-61)\nend",
"def class_disambiguation(rdfdata,transitive)\n puts \"RDF to SVM WITH META PROPERTIES ...\"\n number_homonyms=[]\n max=nil\n min=nil\n svmmodelbygroup=[]\n ftotal = 0\n max_featuresbygroup=[]\n min_featuresbygroup=[]\n global_maximum=0\n\n # puts \"DATA DEBUG 1\"\n # puts rdfdata[0][0]\n puts \"############# RESTRICTED INVERSE FUNCTIONAL PROPERTIES\"\n # puts $textp\n ifp = restricted_IFP(rdfdata) + $textp + propertyoverflow(rdfdata)\n ifp.uniq!\n # puts ifp\n ifp.map!{|x| getCode(x.to_s.hash.abs)}\n\n groups_counter=[]\n count=-1\n pivot = nil # the smallest ambiguous set\n\n rdfdata.each{|group|\n count=count+1\n ######################## All Predicates ##########################\n # puts \"Encoding group ...\"\n #puts group.uniq.map{|s,p,o| s.to_s + \" \" + p.to_s + \" \" + o.to_s}\n new_group = group.uniq.map{|s,p,o| [getCode(s.to_s.hash.abs),getCode(p.to_s.hash.abs),getCode(o.to_s.hash.abs),o.instance_of?(RDFS::Resource) ] }.compact\n # new_group = group.uniq.map{|s,p,o| [ (s.to_s ), (p.to_s ), (o.to_s),o.instance_of?(RDFS::Resource) ] }.compact\n # puts \"Selecting items of measurement ...\"\n predicate_counter = new_group.map{|s,p| p }.compact\n datatype_objects = new_group.map{|s,p,o,t| o if !t and !ifp.include?(p) }.compact\n object_properties = new_group.map{|s,p,o,t| o if t and !ifp.include?(p) }.compact\n tuple_counter = new_group.map{|s,p,o,t| p.to_s + \" \" + o.to_s if !ifp.include?(p) }.compact\n #tuple_counter = new_group.map{|s,p,o,t| p.to_s + \" \" + o.to_s if !ifp.include?(p) && discriminative_predicates.include?(p) }.compact\n\n # puts \"Grouping subjects ...\"\n subjects = new_group.map{|s,p,o,t| s}.uniq\n groupedsubject = subjects.map{|x| new_group.find_all{|s,p,o,t| s==x}}\n groups_counter << [groupedsubject,predicate_counter,datatype_objects,object_properties,tuple_counter]\n }\n\n puts \"Buiding Model ...\"\n #####################################################################\n groups_counter_idx = -1\n groups_counter.each{|gs, group_predicates, group_datatype, group_objects, group_tuple|\n groups_counter_idx = groups_counter_idx + 1\n ################ GLOBAL PREDICATES AND OBJECTS ##############\n lines=[]\n max=nil\n count=count+1\n puts \"GROUP############## - \" + groups_counter_idx.to_s\n puts gs.size\n number_homonyms << gs.size\n gs.each{|subject|\n predicates = subject.map{|s,p| p }.compact\n datatype_objects = subject.map{|s,p,o,t| o if !t and !ifp.include?(p) }.compact\n object_properties = subject.map{|s,p,o,t| o if t and !ifp.include?(p) }.compact\n tuple_counter = subject.map{|s,p,o| p.to_s + \" \" + o.to_s if !ifp.include?(p) }.compact\n # tuple_counter = subject.map{|s,p,o| p.to_s + \" \" + o.to_s if !ifp.include?(p) && discriminative_predicates.include?(p) }.compact\n\n features = []\n sim1 = 0\n sim2 = 0\n sim3 = 0\n sim4 = 0\n counter1 = -1\n # puts \"SUBJECT\"\n puts subject[0][0]\n # puts tuple_counter\n ############################ Resource Vs. Origin Pivot\n if groups_counter_idx < $origin_subjects.size\n # puts \"ORIGIN SIZE \"\n # puts $origin_subjects.size\n # puts $origin_subjects[groups_counter_idx].size\n\n origin_s = $origin_subjects[groups_counter_idx].map{|p,o| [ getCode(p.to_s.hash.abs),getCode(o.to_s.hash.abs),o.instance_of?(RDFS::Resource) ] }.compact\n # origin_s = $origin_subjects[groups_counter_idx].map{|p,o| [ (p.to_s ), (o.to_s),o.instance_of?(RDFS::Resource) ] }.compact\n origin_predicates = origin_s.map{|p,o| p}.compact\n origin_datatype_objects = origin_s.map{|p,o,t| o if !t }.compact\n origin_object_properties = origin_s.map{|p,o,t| o if t }.compact\n origin_tuple_counter = origin_s.map{|p,o| p.to_s + \" \" + o.to_s }.compact\n\n groups_counter.each{|gs,group_predicates,group_datatype, group_objects, group_tuple|\n sim1 = sim1 + hm(origin_predicates,predicates, gs.size.to_f)\n sim2 = sim2 + hm(origin_datatype_objects, datatype_objects, gs.size.to_f)\n sim3 = sim3 + hm(origin_object_properties, object_properties, gs.size.to_f)\n sim4 = sim4 + hm(origin_tuple_counter, tuple_counter, gs.size.to_f)\n }\n end\n # puts \"PIVOT SIMILARITY\"\n # puts sim1\n # puts sim2\n # puts sim3\n # puts sim4\n ############################ Resource Vs. Pseudo-Homonyms\n groups_counter.each{|gs,group_predicates,group_datatype, group_objects, group_tuple|\n counter1 = counter1 + 1\n next if groups_counter_idx == counter1\n sim1 = sim1 + hm(group_predicates,predicates, gs.size.to_f)\n sim2 = sim2 + hm(group_datatype, datatype_objects, gs.size.to_f)\n sim3 = sim3 + hm(group_objects, object_properties, gs.size.to_f)\n sim4 = sim4 + hm(group_tuple, tuple_counter, gs.size.to_f)\n }\n # puts \"SIMILARITY\"\n # puts sim1\n # puts sim2\n # puts sim3\n # puts sim4\n # features << sim1\n # features << sim2\n # features << sim3\n # features << sim4\n features << (sim1 + sim2 + sim3 + sim4 ).abs\n\n lines << features\n max = Array.new(features) if max == nil\n max.each_index{|idx| max[idx] = features[idx] if max[idx] < features[idx]}\n }\n max.each {|gg| global_maximum = gg if global_maximum < gg}\n max_featuresbygroup << max\n svmmodelbygroup << lines\n # lines.each{|ss| puts ss.join (\" \") }\n puts \"END GROUP ###\"\n }\n # put \"####### Maximum Absolute\"\n # max_featuresbygroup.map{|v| }\n puts \"########### Normalizing Features\"\n idx=-1\n svmmodelbygroup.map!{|g|\n idx=idx+1\n subidx = -1\n g.map!{|f|\n subidx = subidx+1\n line = \"\"\n f.each_index{|i|\n v = f[i]\n if max_featuresbygroup[idx][i] != 0\n v = f[i] / global_maximum\n\n # v = f[i] / max_featuresbygroup[idx][i]\n\n if f[i] == global_maximum\n # add_pivot(rdfdata[idx], @searchedlabels[idx] ,subidx) if $usepivot\n add_pivot(rdfdata[idx], nil ,subidx) if $usepivot\n end\n end\n line = line + \"#{i+1}:#{v} \" if !v.nan?\n }\n line\n }\n }\n # puts \"THRESHOLD USED\"\n # # change this if more than one feature is used.\n # $threshold_global = (max_featuresbygroup.flatten.sum.to_f/ max_featuresbygroup.size.to_f) / global_maximum\n # if $threshold_global > 0.90\n # $threshold_global = max_featuresbygroup.flatten.min\n # end\n puts $threshold_global\n # svmmodelbygroup.each{|g| puts \"GROUP ########\"\n # puts g\n # puts \"############3\"\n # }\n puts \"NUMBER OF GROUPS\"\n puts svmmodelbygroup.size\n puts \"NUMBER OF ELEMENTS BY GROUPS 0\"\n puts svmmodelbygroup[0].size if svmmodelbygroup.size > 0\n puts \"NUMBER OF HOMONYMS\"\n number_homonyms.each{|v | $number_homonyms = $number_homonyms + v}\n $list_number_homonyms = $list_number_homonyms + number_homonyms\n puts number_homonyms.sort.join(\"\\t\")\n puts number_homonyms.join(\"\\t\")\n\n return svmmodelbygroup\n end",
"def fit; end",
"def king_richard_iii; end",
"def original_result; end",
"def solutions(args)\n book = require_arg(args,'book')\n hw = get_hw_from_file_or_die(require_arg(args,'in_file'))\n sets = hw_to_sets(hw,book)\n stream_labels = assign_starts_of_streams_to_sets(sets,hw)\n out_file = require_arg(args,'out_file')\n class_title = require_arg(args,'class_title')\n sets = require_arg(args,'sets')\n gb_file = require_arg(args,'gb_file')\n sample = (args.has_key?('sample') && args['sample'].to_i==1)\n roster = get_roster_from_opengrade(gb_file) # roster[\"blow_joe\"]={last, first, class, id_string, and id_int}\n solution_in_book = {} # [label]=boolean\n sources_parent_dir = File.expand_path(require_arg(args,'sources_parent_dir'))\n subdir_list = []\n Dir.chdir(sources_parent_dir) do # do block so we chdir back afterward\n subdir_list=Dir[\"*\"].reject{|o| not File.directory?(o)}.sort\n end\n probs = {}\n n_hw_defined=0\n header = true\n students_encountered = {}\n problem_labels_encountered = []\n File.readlines(sets).each { |line|\n if header then\n header = false\n else\n # set,book,ch,num,parts,flags,chunk,student\n unless line=~/(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)/ then fatal_error(\"illegal line in #{sets}: #{line}\") end\n hw,ch,num,student = [$1.to_i,$3.to_i,$4,$8] # no to_i on num, could be \"g7\"\n if hw>n_hw_defined then n_hw_defined=hw end\n students_encountered[student] = true\n if probs[student].nil? then probs[student] = {} end\n if probs[student][hw].nil? then probs[student][hw] = [] end\n l = $num_to_label[[ch,num]]\n if l.nil? then fatal_error(\"no label found for ch. #{ch}, problem #{num}\") end\n problem_labels_encountered.push(l)\n probs[student][hw].push(l)\n end\n }\n students_encountered.keys.each { |k|\n unless roster.has_key?(k) then fatal_error(\"student #{k} occurs in #{sets}, but not in #{gb_file}\") end\n }\n roster.keys.each { |k|\n unless students_encountered.has_key?(k) then fatal_error(\"student #{k} occurs in #{gb_file}, but not in #{sets}\") end\n }\n label_to_source_file = {}\n problem_labels_encountered.each { |l|\n p = $label_to_num[l]\n solution_in_book[l] = $has_solution[p]\n subdir_list.each { |d|\n t = sources_parent_dir+\"/\"+d+\"/\"+l+\".tex\"\n if File.exists?(t) then label_to_source_file[l] = t; next end\n }\n if !solution_in_book[l] && label_to_source_file[l].nil? then $stderr.print \"warning: no solution found for #{l} in any subdirectory of #{sources_parent_dir}\\n\" end\n }\n head = <<-\"HEAD\"\n \\\\documentclass{simplesolns}\n \\\\begin{document}\n {\\\\Huge\\\\textbf{Solutions for #{class_title}}}\\\\\\\\\\n\n HEAD\n tail = <<-'TAIL'\n \\end{document}\n TAIL\n toc = ''\n tex = ''\n 1.upto(n_hw_defined) { |hw|\n toc = toc + \"\\\\noindent Homework #{hw} ... \\\\pageref{set#{hw}}\\\\\\\\\\n\"\n first_student = true\n roster.keys.sort.each { |student|\n label_for_toc = ''\n if sample && !first_student then break end\n if first_student then label_for_toc = \"\\\\label{set#{hw}}\" end\n tex = tex + <<-\"TEX\"\n\n \\\\pagebreak\n\n \\\\noindent%\n {\\\\large\\\\textbf{Solutions to Homework #{hw}, #{class_title},\n #{roster[student][\"first\"]} #{roster[student][\"last\"]} }}#{label_for_toc}\\\\\\\\\\n\n TEX\n first_student = false\n probs[student][hw].each { |label|\n p = $label_to_num[label]\n if solution_in_book[label] then\n tex = tex+solution_helper(p,'solution in the back of the book')\n else\n source_file = label_to_source_file[label]\n missing = false\n if source_file.nil?\n missing = true\n else\n s,err = slurp_file_with_detailed_error_reporting(source_file)\n if s.nil? then \n missing=true \n $stderr.print \"warning: error reading file #{source_file}, #{err}\"\n else\n tex = tex+solution_helper(p,s)\n end\n end\n if missing then\n tex = tex+solution_helper(p,'!!!!!!!!!!! missing solution !!!!!!!!!!!!!!')\n end\n end\n }\n }\n }\n File.open(out_file,'w') { |f|\n f.print head+toc + \"\\\\pagebreak\" + tex+tail\n }\nend",
"def NL43_locator(seq=\"\",temp_dir=File.dirname($0))\n hxb2_ref = \"TGGAAGGGCTAATTTGGTCCCAAAAAAGACAAGAGATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGATTGGCAGAACTACACACCAGGGCCAGGGATCAGATATCCACTGACCTTTGGATGGTGCTTCAAGTTAGTACCAGTTGAACCAGAGCAAGTAGAAGAGGCCAAATAAGGAGAGAAGAACAGCTTGTTACACCCTATGAGCCAGCATGGGATGGAGGACCCGGAGGGAGAAGTATTAGTGTGGAAGTTTGACAGCCTCCTAGCATTTCGTCACATGGCCCGAGAGCTGCATCCGGAGTACTACAAAGACTGCTGACATCGAGCTTTCTACAAGGGACTTTCCGCTGGGGACTTTCCAGGGAGGTGTGGCCTGGGCGGGACTGGGGAGTGGCGAGCCCTCAGATGCTACATATAAGCAGCTGCTTTTTGCCTGTACTGGGTCTCTCTGGTTAGACCAGATCTGAGCCTGGGAGCTCTCTGGCTAACTAGGGAACCCACTGCTTAAGCCTCAATAAAGCTTGCCTTGAGTGCTCAAAGTAGTGTGTGCCCGTCTGTTGTGTGACTCTGGTAACTAGAGATCCCTCAGACCCTTTTAGTCAGTGTGGAAAATCTCTAGCAGTGGCGCCCGAACAGGGACTTGAAAGCGAAAGTAAAGCCAGAGGAGATCTCTCGACGCAGGACTCGGCTTGCTGAAGCGCGCACGGCAAGAGGCGAGGGGCGGCGACTGGTGAGTACGCCAAAAATTTTGACTAGCGGAGGCTAGAAGGAGAGAGATGGGTGCGAGAGCGTCGGTATTAAGCGGGGGAGAATTAGATAAATGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAACAATATAAACTAAAACATATAGTATGGGCAAGCAGGGAGCTAGAACGATTCGCAGTTAATCCTGGCCTTTTAGAGACATCAGAAGGCTGTAGACAAATACTGGGACAGCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAGATCATTATATAATACAATAGCAGTCCTCTATTGTGTGCATCAAAGGATAGATGTAAAAGACACCAAGGAAGCCTTAGATAAGATAGAGGAAGAGCAAAACAAAAGTAAGAAAAAGGCACAGCAAGCAGCAGCTGACACAGGAAACAACAGCCAGGTCAGCCAAAATTACCCTATAGTGCAGAACCTCCAGGGGCAAATGGTACATCAGGCCATATCACCTAGAACTTTAAATGCATGGGTAAAAGTAGTAGAAGAGAAGGCTTTCAGCCCAGAAGTAATACCCATGTTTTCAGCATTATCAGAAGGAGCCACCCCACAAGATTTAAATACCATGCTAAACACAGTGGGGGGACATCAAGCAGCCATGCAAATGTTAAAAGAGACCATCAATGAGGAAGCTGCAGAATGGGATAGATTGCATCCAGTGCATGCAGGGCCTATTGCACCAGGCCAGATGAGAGAACCAAGGGGAAGTGACATAGCAGGAACTACTAGTACCCTTCAGGAACAAATAGGATGGATGACACATAATCCACCTATCCCAGTAGGAGAAATCTATAAAAGATGGATAATCCTGGGATTAAATAAAATAGTAAGAATGTATAGCCCTACCAGCATTCTGGACATAAGACAAGGACCAAAGGAACCCTTTAGAGACTATGTAGACCGATTCTATAAAACTCTAAGAGCCGAGCAAGCTTCACAAGAGGTAAAAAATTGGATGACAGAAACCTTGTTGGTCCAAAATGCGAACCCAGATTGTAAGACTATTTTAAAAGCATTGGGACCAGGAGCGACACTAGAAGAAATGATGACAGCATGTCAGGGAGTGGGGGGACCCGGCCATAAAGCAAGAGTTTTGGCTGAAGCAATGAGCCAAGTAACAAATCCAGCTACCATAATGATACAGAAAGGCAATTTTAGGAACCAAAGAAAGACTGTTAAGTGTTTCAATTGTGGCAAAGAAGGGCACATAGCCAAAAATTGCAGGGCCCCTAGGAAAAAGGGCTGTTGGAAATGTGGAAAGGAAGGACACCAAATGAAAGATTGTACTGAGAGACAGGCTAATTTTTTAGGGAAGATCTGGCCTTCCCACAAGGGAAGGCCAGGGAATTTTCTTCAGAGCAGACCAGAGCCAACAGCCCCACCAGAAGAGAGCTTCAGGTTTGGGGAAGAGACAACAACTCCCTCTCAGAAGCAGGAGCCGATAGACAAGGAACTGTATCCTTTAGCTTCCCTCAGATCACTCTTTGGCAGCGACCCCTCGTCACAATAAAGATAGGGGGGCAATTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAATTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAAGACAGTATGATCAGATACTCATAGAAATCTGCGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGCTGCACTTTAAATTTTCCCATTAGTCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAAATGGAAAAGGAAGGAAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGATTTCTGGGAAGTTCAATTAGGAATACCACATCCTGCAGGGTTAAAACAGAAAAAATCAGTAACAGTACTGGATGTGGGCGATGCATATTTTTCAGTTCCCTTAGATAAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAGTGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTCATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAACTGAGACAACATCTGTTGAGGTGGGGATTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAGGACAGCTGGACTGTCAATGACATACAGAAATTAGTGGGAAAATTGAATTGGGCAAGTCAGATTTATGCAGGGATTAAAGTAAGGCAATTATGTAAACTTCTTAGGGGAACCAAAGCACTAACAGAAGTAGTACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGGGAGATTCTAAAAGAACCGGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAAGGGTGCCCACACTAATGATGTGAAACAATTAACAGAGGCAGTACAAAAAATAGCCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAATTACCCATACAAAAGGAAACATGGGAAGCATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTCAATACCCCTCCCTTAGTGAAGTTATGGTACCAGTTAGAGAAAGAACCCATAATAGGAGCAGAAACTTTCTATGTAGATGGGGCAGCCAATAGGGAAACTAAATTAGGAAAAGCAGGATATGTAACTGACAGAGGAAGACAAAAAGTTGTCCCCCTAACGGACACAACAAATCAGAAGACTGAGTTACAAGCAATTCATCTAGCTTTGCAGGATTCGGGATTAGAAGTAAACATAGTGACAGACTCACAATATGCATTGGGAATCATTCAAGCACAACCAGATAAGAGTGAATCAGAGTTAGTCAGTCAAATAATAGAGCAGTTAATAAAAAAGGAAAAAGTCTACCTGGCATGGGTACCAGCACACAAAGGAATTGGAGGAAATGAACAAGTAGATGGGTTGGTCAGTGCTGGAATCAGGAAAGTACTATTTTTAGATGGAATAGATAAGGCCCAAGAAGAACATGAGAAATATCACAGTAATTGGAGAGCAATGGCTAGTGATTTTAACCTACCACCTGTAGTAGCAAAAGAAATAGTAGCCAGCTGTGATAAATGTCAGCTAAAAGGGGAAGCCATGCATGGACAAGTAGACTGTAGCCCAGGAATATGGCAGCTAGATTGTACACATTTAGAAGGAAAAGTTATCTTGGTAGCAGTTCATGTAGCCAGTGGATATATAGAAGCAGAAGTAATTCCAGCAGAGACAGGGCAAGAAACAGCATACTTCCTCTTAAAATTAGCAGGAAGATGGCCAGTAAAAACAGTACATACAGACAATGGCAGCAATTTCACCAGTACTACAGTTAAGGCCGCCTGTTGGTGGGCGGGGATCAAGCAGGAATTTGGCATTCCCTACAATCCCCAAAGTCAAGGAGTAATAGAATCTATGAATAAAGAATTAAAGAAAATTATAGGACAGGTAAGAGATCAGGCTGAACATCTTAAGACAGCAGTACAAATGGCAGTATTCATCCACAATTTTAAAAGAAAAGGGGGGATTGGGGGGTACAGTGCAGGGGAAAGAATAGTAGACATAATAGCAACAGACATACAAACTAAAGAATTACAAAAACAAATTACAAAAATTCAAAATTTTCGGGTTTATTACAGGGACAGCAGAGATCCAGTTTGGAAAGGACCAGCAAAGCTCCTCTGGAAAGGTGAAGGGGCAGTAGTAATACAAGATAATAGTGACATAAAAGTAGTGCCAAGAAGAAAAGCAAAGATCATCAGGGATTATGGAAAACAGATGGCAGGTGATGATTGTGTGGCAAGTAGACAGGATGAGGATTAACACATGGAAAAGATTAGTAAAACACCATATGTATATTTCAAGGAAAGCTAAGGACTGGTTTTATAGACATCACTATGAAAGTACTAATCCAAAAATAAGTTCAGAAGTACACATCCCACTAGGGGATGCTAAATTAGTAATAACAACATATTGGGGTCTGCATACAGGAGAAAGAGACTGGCATTTGGGTCAGGGAGTCTCCATAGAATGGAGGAAAAAGAGATATAGCACACAAGTAGACCCTGACCTAGCAGACCAACTAATTCATCTGCACTATTTTGATTGTTTTTCAGAATCTGCTATAAGAAATACCATATTAGGACGTATAGTTAGTCCTAGGTGTGAATATCAAGCAGGACATAACAAGGTAGGATCTCTACAGTACTTGGCACTAGCAGCATTAATAAAACCAAAACAGATAAAGCCACCTTTGCCTAGTGTTAGGAAACTGACAGAGGACAGATGGAACAAGCCCCAGAAGACCAAGGGCCACAGAGGGAGCCATACAATGAATGGACACTAGAGCTTTTAGAGGAACTTAAGAGTGAAGCTGTTAGACATTTTCCTAGGATATGGCTCCATAACTTAGGACAACATATCTATGAAACTTACGGGGATACTTGGGCAGGAGTGGAAGCCATAATAAGAATTCTGCAACAACTGCTGTTTATCCATTTCAGAATTGGGTGTCGACATAGCAGAATAGGCGTTACTCGACAGAGGAGAGCAAGAAATGGAGCCAGTAGATCCTAGACTAGAGCCCTGGAAGCATCCAGGAAGTCAGCCTAAAACTGCTTGTACCAATTGCTATTGTAAAAAGTGTTGCTTTCATTGCCAAGTTTGTTTCATGACAAAAGCCTTAGGCATCTCCTATGGCAGGAAGAAGCGGAGACAGCGACGAAGAGCTCATCAGAACAGTCAGACTCATCAAGCTTCTCTATCAAAGCAGTAAGTAGTACATGTAATGCAACCTATAATAGTAGCAATAGTAGCATTAGTAGTAGCAATAATAATAGCAATAGTTGTGTGGTCCATAGTAATCATAGAATATAGGAAAATATTAAGACAAAGAAAAATAGACAGGTTAATTGATAGACTAATAGAAAGAGCAGAAGACAGTGGCAATGAGAGTGAAGGAGAAGTATCAGCACTTGTGGAGATGGGGGTGGAAATGGGGCACCATGCTCCTTGGGATATTGATGATCTGTAGTGCTACAGAAAAATTGTGGGTCACAGTCTATTATGGGGTACCTGTGTGGAAGGAAGCAACCACCACTCTATTTTGTGCATCAGATGCTAAAGCATATGATACAGAGGTACATAATGTTTGGGCCACACATGCCTGTGTACCCACAGACCCCAACCCACAAGAAGTAGTATTGGTAAATGTGACAGAAAATTTTAACATGTGGAAAAATGACATGGTAGAACAGATGCATGAGGATATAATCAGTTTATGGGATCAAAGCCTAAAGCCATGTGTAAAATTAACCCCACTCTGTGTTAGTTTAAAGTGCACTGATTTGAAGAATGATACTAATACCAATAGTAGTAGCGGGAGAATGATAATGGAGAAAGGAGAGATAAAAAACTGCTCTTTCAATATCAGCACAAGCATAAGAGATAAGGTGCAGAAAGAATATGCATTCTTTTATAAACTTGATATAGTACCAATAGATAATACCAGCTATAGGTTGATAAGTTGTAACACCTCAGTCATTACACAGGCCTGTCCAAAGGTATCCTTTGAGCCAATTCCCATACATTATTGTGCCCCGGCTGGTTTTGCGATTCTAAAATGTAATAATAAGACGTTCAATGGAACAGGACCATGTACAAATGTCAGCACAGTACAATGTACACATGGAATCAGGCCAGTAGTATCAACTCAACTGCTGTTAAATGGCAGTCTAGCAGAAGAAGATGTAGTAATTAGATCTGCCAATTTCACAGACAATGCTAAAACCATAATAGTACAGCTGAACACATCTGTAGAAATTAATTGTACAAGACCCAACAACAATACAAGAAAAAGTATCCGTATCCAGAGGGGACCAGGGAGAGCATTTGTTACAATAGGAAAAATAGGAAATATGAGACAAGCACATTGTAACATTAGTAGAGCAAAATGGAATGCCACTTTAAAACAGATAGCTAGCAAATTAAGAGAACAATTTGGAAATAATAAAACAATAATCTTTAAGCAATCCTCAGGAGGGGACCCAGAAATTGTAACGCACAGTTTTAATTGTGGAGGGGAATTTTTCTACTGTAATTCAACACAACTGTTTAATAGTACTTGGTTTAATAGTACTTGGAGTACTGAAGGGTCAAATAACACTGAAGGAAGTGACACAATCACACTCCCATGCAGAATAAAACAATTTATAAACATGTGGCAGGAAGTAGGAAAAGCAATGTATGCCCCTCCCATCAGTGGACAAATTAGATGTTCATCAAATATTACTGGGCTGCTATTAACAAGAGATGGTGGTAATAACAACAATGGGTCCGAGATCTTCAGACCTGGAGGAGGCGATATGAGGGACAATTGGAGAAGTGAATTATATAAATATAAAGTAGTAAAAATTGAACCATTAGGAGTAGCACCCACCAAGGCAAAGAGAAGAGTGGTGCAGAGAGAAAAAAGAGCAGTGGGAATAGGAGCTTTGTTCCTTGGGTTCTTGGGAGCAGCAGGAAGCACTATGGGCTGCACGTCAATGACGCTGACGGTACAGGCCAGACAATTATTGTCTGATATAGTGCAGCAGCAGAACAATTTGCTGAGGGCTATTGAGGCGCAACAGCATCTGTTGCAACTCACAGTCTGGGGCATCAAACAGCTCCAGGCAAGAATCCTGGCTGTGGAAAGATACCTAAAGGATCAACAGCTCCTGGGGATTTGGGGTTGCTCTGGAAAACTCATTTGCACCACTGCTGTGCCTTGGAATGCTAGTTGGAGTAATAAATCTCTGGAACAGATTTGGAATAACATGACCTGGATGGAGTGGGACAGAGAAATTAACAATTACACAAGCTTAATACACTCCTTAATTGAAGAATCGCAAAACCAGCAAGAAAAGAATGAACAAGAATTATTGGAATTAGATAAATGGGCAAGTTTGTGGAATTGGTTTAACATAACAAATTGGCTGTGGTATATAAAATTATTCATAATGATAGTAGGAGGCTTGGTAGGTTTAAGAATAGTTTTTGCTGTACTTTCTATAGTGAATAGAGTTAGGCAGGGATATTCACCATTATCGTTTCAGACCCACCTCCCAATCCCGAGGGGACCCGACAGGCCCGAAGGAATAGAAGAAGAAGGTGGAGAGAGAGACAGAGACAGATCCATTCGATTAGTGAACGGATCCTTAGCACTTATCTGGGACGATCTGCGGAGCCTGTGCCTCTTCAGCTACCACCGCTTGAGAGACTTACTCTTGATTGTAACGAGGATTGTGGAACTTCTGGGACGCAGGGGGTGGGAAGCCCTCAAATATTGGTGGAATCTCCTACAGTATTGGAGTCAGGAACTAAAGAATAGTGCTGTTAACTTGCTCAATGCCACAGCCATAGCAGTAGCTGAGGGGACAGATAGGGTTATAGAAGTATTACAAGCAGCTTATAGAGCTATTCGCCACATACCTAGAAGAATAAGACAGGGCTTGGAAAGGATTTTGCTATAAGATGGGTGGCAAGTGGTCAAAAAGTAGTGTGATTGGATGGCCTGCTGTAAGGGAAAGAATGAGACGAGCTGAGCCAGCAGCAGATGGGGTGGGAGCAGTATCTCGAGACCTAGAAAAACATGGAGCAATCACAAGTAGCAATACAGCAGCTAACAATGCTGCTTGTGCCTGGCTAGAAGCACAAGAGGAGGAAGAGGTGGGTTTTCCAGTCACACCTCAGGTACCTTTAAGACCAATGACTTACAAGGCAGCTGTAGATCTTAGCCACTTTTTAAAAGAAAAGGGGGGACTGGAAGGGCTAATTCACTCCCAAAGAAGACAAGATATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGATTGGCAGAACTACACACCAGGGCCAGGGGTCAGATATCCACTGACCTTTGGATGGTGCTACAAGCTAGTACCAGTTGAGCCAGATAAGGTAGAAGAGGCCAATAAAGGAGAGAACACCAGCTTGTTACACCCTGTGAGCCTGCATGGAATGGATGACCCTGAGAGAGAAGTGTTAGAGTGGAGGTTTGACAGCCGCCTAGCATTTCATCACGTGGCCCGAGAGCTGCATCCGGAGTACTTCAAGAACTGCTGACATCGAGCTTGCTACAAGGGACTTTCCGCTGGGGACTTTCCAGGGAGGCGTGGCCTGGGCGGGACTGGGGAGTGGCGAGCCCTCAGATGCTGCATATAAGCAGCTGCTTTTTGCCTGTACTGGGTCTCTCTGGTTAGACCAGATCTGAGCCTGGGAGCTCTCTGGCTAACTAGGGAACCCACTGCTTAAGCCTCAATAAAGCTTGCCTTGAGTGCTTCAAGTAGTGTGTGCCCGTCTGTTGTGTGACTCTGGTAACTAGAGATCCCTCAGACCCTTTTAGTCAGTGTGGAAAATCTCTAGCACCCAGGAGGTAGAGGTTGCAGTGAGCCAAGATCGCGCCACTGCATTCCAGCCTGGGCAAGAAAACAAGACTGTCTAAAATAATAATAATAAGTTAAGGGTATTAAATATATTTATACATGGAGGTCATAAAAATATATATATTTGGGCTGGGCGCAGTGGCTCACACCTGCGCCCGGCCCTTTGGGAGGCCGAGGCAGGTGGATCACCTGAGTTTGGGAGTTCCAGACCAGCCTGACCAACATGGAGAAACCCCTTCTCTGTGTATTTTTAGTAGATTTTATTTTATGTGTATTTTATTCACAGGTATTTCTGGAAAACTGAAACTGTTTTTCCTCTACTCTGATACCACAAGAATCATCAGCACAGAGGAAGACTTCTGTGATCAAATGTGGTGGGAGAGGGAGGTTTTCACCAGCACATGAGCAGTCAGTTCTGCCGCAGACTCGGCGGGTGTCCTTCGGTTCAGTTCCAACACCGCCTGCCTGGAGAGAGGTCAGACCACAGGGTGAGGGCTCAGTCCCCAAGACATAAACACCCAAGACATAAACACCCAACAGGTCCACCCCGCCTGCTGCCCAGGCAGAGCCGATTCACCAAGACGGGAATTAGGATAGAGAAAGAGTAAGTCACACAGAGCCGGCTGTGCGGGAGAACGGAGTTCTATTATGACTCAAATCAGTCTCCCCAAGCATTCGGGGATCAGAGTTTTTAAGGATAACTTAGTGTGTAGGGGGCCAGTGAGTTGGAGATGAAAGCGTAGGGAGTCGAAGGTGTCCTTTTGCGCCGAGTCAGTTCCTGGGTGGGGGCCACAAGATCGGATGAGCCAGTTTATCAATCCGGGGGTGCCAGCTGATCCATGGAGTGCAGGGTCTGCAAAATATCTCAAGCACTGATTGATCTTAGGTTTTACAATAGTGATGTTACCCCAGGAACAATTTGGGGAAGGTCAGAATCTTGTAGCCTGTAGCTGCATGACTCCTAAACCATAATTTCTTTTTTGTTTTTTTTTTTTTATTTTTGAGACAGGGTCTCACTCTGTCACCTAGGCTGGAGTGCAGTGGTGCAATCACAGCTCACTGCAGCCTCAACGTCGTAAGCTCAAGCGATCCTCCCACCTCAGCCTGCCTGGTAGCTGAGACTACAAGCGACGCCCCAGTTAATTTTTGTATTTTTGGTAGAGGCAGCGTTTTGCCGTGTGGCCCTGGCTGGTCTCGAACTCCTGGGCTCAAGTGATCCAGCCTCAGCCTCCCAAAGTGCTGGGACAACCGGGCCCAGTCACTGCACCTGGCCCTAAACCATAATTTCTAATCTTTTGGCTAATTTGTTAGTCCTACAAAGGCAGTCTAGTCCCCAGCAAAAAGGGGGTTTGTTTCGGGAAAGGGCTGTTACTGTCTTTGTTTCAAACTATAAACTAAGTTCCTCCTAAACTTAGTTCGGCCTACACCCAGGAATGAACAAGGAGAGCTTGGAGGTTAGAAGCACGATGGAATTGGTTAGGTCAGATCTCTTTCACTGTCTGAGTTATAATTTTGCAATGGTGGTTCAAAGACTGCCCGCTTCTGACACCAGTCGCTGCATTAATGAATCGGCCAACGCGCGGGGAGAGGCGGTTTGCGTATTGGGCGCTCTTCCGCTTCCTCGCTCACTGACTCGCTGCGCTCGGTCGTTCGGCTGCGGCGAGCGGTATCAGCTCACTCAAAGGCGGTAATACGGTTATCCACAGAATCAGGGGATAACGCAGGAAAGAACATGTGAGCAAAAGGCCAGCAAAAGGCCAGGAACCGTAAAAAGGCCGCGTTGCTGGCGTTTTTCCATAGGCTCCGCCCCCCTGACGAGCATCACAAAAATCGACGCTCAAGTCAGAGGTGGCGAAACCCGACAGGACTATAAAGATACCAGGCGTTTCCCCCTGGAAGCTCCCTCGTGCGCTCTCCTGTTCCGACCCTGCCGCTTACCGGATACCTGTCCGCCTTTCTCCCTTCGGGAAGCGTGGCGCTTTCTCATAGCTCACGCTGTAGGTATCTCAGTTCGGTGTAGGTCGTTCGCTCCAAGCTGGGCTGTGTGCACGAACCCCCCGTTCAGCCCGACCGCTGCGCCTTATCCGGTAACTATCGTCTTGAGTCCAACCCGGTAAGACACGACTTATCGCCACTGGCAGCAGCCACTGGTAACAGGATTAGCAGAGCGAGGTATGTAGGCGGTGCTACAGAGTTCTTGAAGTGGTGGCCTAACTACGGCTACACTAGAAGGACAGTATTTGGTATCTGCGCTCTGCTGAAGCCAGTTACCTTCGGAAAAAGAGTTGGTAGCTCTTGATCCGGCAAACAAACCACCGCTGGTAGCGGTGGTTTTTTTGTTTGCAAGCAGCAGATTACGCGCAGAAAAAAAGGATCTCAAGAAGATCCTTTGATCTTTTCTACGGGGTCTGACGCTCAGTGGAACGAAAACTCACGTTAAGGGATTTTGGTCATGAGATTATCAAAAAGGATCTTCACCTAGATCCTTTTAAATTAAAAATGAAGTTTTAAATCAATCTAAAGTATATATGAGTAAACTTGGTCTGACAGTTACCAATGCTTAATCAGTGAGGCACCTATCTCAGCGATCTGTCTATTTCGTTCATCCATAGTTGCCTGACTCCCCGTCGTGTAGATAACTACGATACGGGAGGGCTTACCATCTGGCCCCAGTGCTGCAATGATACCGCGAGACCCACGCTCACCGGCTCCAGATTTATCAGCAATAAACCAGCCAGCCGGAAGGGCCGAGCGCAGAAGTGGTCCTGCAACTTTATCCGCCTCCATCCAGTCTATTAATTGTTGCCGGGAAGCTAGAGTAAGTAGTTCGCCAGTTAATAGTTTGCGCAACGTTGTTGCCATTGCTACAGGCATCGTGGTGTCACGCTCGTCGTTTGGTATGGCTTCATTCAGCTCCGGTTCCCAACGATCAAGGCGAGTTACATGATCCCCCATGTTGTGCAAAAAAGCGGTTAGCTCCTTCGGTCCTCCGATCGTTGTCAGAAGTAAGTTGGCCGCAGTGTTATCACTCATGGTTATGGCAGCACTGCATAATTCTCTTACTGTCATGCCATCCGTAAGATGCTTTTCTGTGACTGGTGAGTACTCAACCAAGTCATTCTGAGAATAGTGTATGCGGCGACCGAGTTGCTCTTGCCCGGCGTCAATACGGGATAATACCGCGCCACATAGCAGAACTTTAAAAGTGCTCATCATTGGAAAACGTTCTTCGGGGCGAAAACTCTCAAGGATCTTACCGCTGTTGAGATCCAGTTCGATGTAACCCACTCGTGCACCCAACTGATCTTCAGCATCTTTTACTTTCACCAGCGTTTCTGGGTGAGCAAAAACAGGAAGGCAAAATGCCGCAAAAAAGGGAATAAGGGCGACACGGAAATGTTGAATACTCATACTCTTCCTTTTTCAATATTATTGAAGCATTTATCAGGGTTATTGTCTCATGAGCGGATACATATTTGAATGTATTTAGAAAAATAAACAAATAGGGGTTCCGCGCACATTTCCCCGAAAAGTGCCACCTGACGTCTAAGAAACCATTATTATCATGACATTAACCTATAAAAATAGGCGTATCACGAGGCCCTTTCGTCTCGCGCGTTTCGGTGATGACGGTGAAAACCTCTGACACATGCAGCTCCCGGAGACGGTCACAGCTTGTCTGTAAGCGGATGCCGGGAGCAGACAAGCCCGTCAGGGCGCGTCAGCGGGTGTTGGCGGGTGTCGGGGCTGGCTTAACTATGCGGCATCAGAGCAGATTGTACTGAGAGTGCACCATATGCGGTGTGAAATACCGCACAGATGCGTAAGGAGAAAATACCGCATCAGGCGCCATTCGCCATTCAGGCTGCGCAACTGTTGGGAAGGGCGATCGGTGCGGGCCTCTTCGCTATTACGCCAGGGGAGGCAGAGATTGCAGTAAGCTGAGATCGCAGCACTGCACTCCAGCCTGGGCGACAGAGTAAGACTCTGTCTCAAAAATAAAATAAATAAATCAATCAGATATTCCAATCTTTTCCTTTATTTATTTATTTATTTTCTATTTTGGAAACACAGTCCTTCCTTATTCCAGAATTACACATATATTCTATTTTTCTTTATATGCTCCAGTTTTTTTTAGACCTTCACCTGAAATGTGTGTATACAAAATCTAGGCCAGTCCAGCAGAGCCTAAAGGTAAAAAATAAAATAATAAAAAATAAATAAAATCTAGCTCACTCCTTCACATCAAAATGGAGATACAGCTGTTAGCATTAAATACCAAATAACCCATCTTGTCCTCAATAATTTTAAGCGCCTCTCTCCACCACATCTAACTCCTGTCAAAGGCATGTGCCCCTTCCGGGCGCTCTGCTGTGCTGCCAACCAACTGGCATGTGGACTCTGCAGGGTCCCTAACTGCCAAGCCCCACAGTGTGCCCTGAGGCTGCCCCTTCCTTCTAGCGGCTGCCCCCACTCGGCTTTGCTTTCCCTAGTTTCAGTTACTTGCGTTCAGCCAAGGTCTGAAACTAGGTGCGCACAGAGCGGTAAGACTGCGAGAGAAAGAGACCAGCTTTACAGGGGGTTTATCACAGTGCACCCTGACAGTCGTCAGCCTCACAGGGGGTTTATCACATTGCACCCTGACAGTCGTCAGCCTCACAGGGGGTTTATCACAGTGCACCCTTACAATCATTCCATTTGATTCACAATTTTTTTAGTCTCTACTGTGCCTAACTTGTAAGTTAAATTTGATCAGAGGTGTGTTCCCAGAGGGGAAAACAGTATATACAGGGTTCAGTACTATCGCATTTCAGGCCTCCACCTGGGTCTTGGAATGTGTCCCCCGAGGGGTGATGACTACCTCAGTTGGATCTCCACAGGTCACAGTGACACAAGATAACCAAGACACCTCCCAAGGCTACCACAATGGGCCGCCCTCCACGTGCACATGGCCGGAGGAACTGCCATGTCGGAGGTGCAAGCACACCTGCGCATCAGAGTCCTTGGTGTGGAGGGAGGGACCAGCGCAGCTTCCAGCCATCCACCTGATGAACAGAACCTAGGGAAAGCCCCAGTTCTACTTACACCAGGAAAGGC\"\n hxb2_l = hxb2_ref.size\n head = \"\"\n 8.times {head << (65 + rand(25)).chr}\n temp_file = temp_dir + \"/temp\"\n temp_aln = temp_dir + \"/temp_aln\"\n\n l1 = 0\n l2 = 0\n name = \">test\"\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts hxb2_ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test2 = $2\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n ref_size = ref.size\n if ref_size > 1.3*(seq.size)\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n max_seq = aln_test2.scan(/[ACGT]+/).max_by(&:length)\n aln_test2 =~ /#{max_seq}/\n before_aln_seq = $`\n before_aln = $`.size\n post_aln_seq = $'\n post_aln = $'.size\n before_aln_seq_size = before_aln_seq.scan(/[ACGT]+/).join(\"\").size\n b1 = (1.3 * before_aln_seq_size).to_i\n post_aln_seq_size = post_aln_seq.scan(/[ACGT]+/).join(\"\").size\n b2 = (1.3 * post_aln_seq_size).to_i\n if (before_aln > seq.size) and (post_aln <= seq.size)\n ref = ref[(before_aln - b1)..(ref_size - post_aln - 1)]\n l1 = l1 + (before_aln - b1)\n elsif (post_aln > seq.size) and (before_aln <= seq.size)\n ref = ref[before_aln..(ref_size - post_aln - 1 + b2)]\n l2 = l2 + post_aln - b2\n elsif (post_aln > seq.size) and (before_aln > seq.size)\n ref = ref[(before_aln - b1)..(ref_size - post_aln - 1 + b2)]\n l1 = l1 + (before_aln - b1)\n l2 = l2 + (post_aln - b2)\n end\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test2 = $2\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n ref_size = ref.size\n end\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test = $2\n aln_test =~ /^(\\w+)(\\-*)\\w/\n s1 = $1.size\n g1 = $2.size\n aln_test =~ /\\w(\\-*)(\\w+)$/\n s2 = $2.size\n g2 = $1.size\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n repeat = 0\n\n if g1 == g2 and (s1 + g1 + s2) == ref.size\n if s1 > s2 and g2 > 2*s2\n ref = ref[0..(-g2-1)]\n repeat = 1\n l2 = l2 + g2\n elsif s1 < s2 and g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n else\n if g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n if g2 > 2*s2\n ref = ref[0..(-g2 - 1)]\n repeat = 1\n l2 = l2 + g2\n end\n end\n\n while repeat == 1\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n aln_test =~ /^(\\-*)(\\w.*\\w)(\\-*)$/\n gap_begin = $1.size\n gap_end = $3.size\n aln_test = $2\n aln_test =~ /^(\\w+)(\\-*)\\w/\n s1 = $1.size\n g1 = $2.size\n aln_test =~ /\\w(\\-*)(\\w+)$/\n s2 = $2.size\n g2 = $1.size\n ref = aln_seq[\">ref\"]\n ref = ref[gap_begin..(-gap_end-1)]\n l1 = l1 + gap_begin\n l2 = l2 + gap_end\n repeat = 0\n if g1 > 2*s1\n ref = ref[g1..-1]\n repeat = 1\n l1 = l1 + g1\n end\n if g2 > 2*s2\n ref = ref[0..(-g2 - 1)]\n repeat = 1\n l2 = l2 + g2\n end\n end\n ref = hxb2_ref[l1..(hxb2_l - l2 - 1)]\n\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n ref = aln_seq[\">ref\"]\n\n #refine alignment\n\n if ref =~ /^(\\-+)/\n l1 = l1 - $1.size\n elsif ref =~ /(\\-+)$/\n l2 = l2 + $1.size\n end\n l1 = 0 if l1 < 0\n if (hxb2_l - l2 - 1) >= l1\n ref = hxb2_ref[l1..(hxb2_l - l2 - 1)]\n temp_in = File.open(temp_file,\"w\")\n temp_in.puts \">ref\"\n temp_in.puts ref\n temp_in.puts name\n temp_in.puts seq\n temp_in.close\n print `muscle -in #{temp_file} -out #{temp_aln} -quiet`\n aln_seq = fasta_to_hash(temp_aln)\n aln_test = aln_seq[name]\n ref = aln_seq[\">ref\"]\n\n ref_size = ref.size\n sim_count = 0\n (0..(ref_size-1)).each do |n|\n ref_base = ref[n]\n test_base = aln_test[n]\n sim_count += 1 if ref_base == test_base\n end\n similarity = (sim_count/ref_size.to_f*100).round(1)\n print `rm -f #{temp_file}`\n print `rm -f #{temp_aln}`\n loc_p1 = l1 + 1\n loc_p2 = hxb2_l - l2\n if seq.size != (loc_p2 - loc_p1 + 1)\n indel = true\n elsif aln_test.include?(\"-\")\n indel = true\n end\n return [loc_p1,loc_p2,similarity,indel,aln_test,ref]\n else\n return [0,0,0,0,0,0,0]\n end\nrescue\n return [0,0,0,0,\"N\",\"N\"]\nend",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def prepare_result\n\t\t\tsuper\n\t\t\t@lowest_old = MM.get_lowest_old(@current_point, @start_vector, @hd_config, false, @tuning_range)\n if @lowest_old[0] == nil\n\t\t\t\t@initial_run = true\n\t\t\t\tthrow :jump_back\n\t\t\tend\n\t\tend",
"def solve_zero_vs_six_vs_nine\n return if @arr[1].nil? || @arr[4].nil?\n\n #p \"1,4: #{@arr[1]},#{@arr[4]}\"\n\n @words.filter{|x| x.length == 6 && @hash[x].nil?}.each{|w|\n if @arr[4].chars.all?{|c| w.chars.include?(c)}\n solved(9, w)\n elsif @arr[1].chars.all?{|c2| w.chars.include?(c2)}\n solved(0, w)\n else\n solved(6, w)\n end\n }\n end",
"def sequence(hidden, open)\n weight = { 1 => \"A\", 2 => \"2\", 3 => \"3\", 4 => \"4\", 5 => \"5\", 6 => \"6\", 7 => \"7\", 8 => \"8\", 9 => \"9\", \n 10 => \"T\", 11 => \"J\", 12 => \"Q\", 13 => \"K\" }\n i = 0\n result = []\n inputs = 1\n differ = 0\n if weight.key(hidden[i]) > weight.key(hidden[i+2])\n small = weight.key(hidden[i+2])\n big = weight.key(hidden[i])\n differ = big - small\n elsif weight.key(hidden[i]) < weight.key(hidden[i+2])\n small = weight.key(hidden[i])\n big = weight.key(hidden[i+2])\n differ = big - small\n else\n return false\n end\n return false if differ > 4\n if differ > 1\n start = small + 1\n end1 = big - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n inputs += 1\n end \n end \n end \n end\n end\n return false unless differ == inputs \n if result.size < 6\n steps = (6-result.size)/2\n start = big + 1\n end1 = big + steps\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n if result.size < 6\n steps = (6-result.size)/2\n return false if small - steps < 1 \n start = small - steps\n end1 = small - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n return false if result.size < 6\n end\n end \n result \n end",
"def minimize\n# create a new one, or modify the current one in place,\n# and return it\nfa = FiniteAutomaton.new\nkeys = @state.keys.sort\np0, p1 = [], []\nkeys.each{|k|\nif is_final?(k)\np0 = p0.push(k)\nelsif\np1 = p1.push(k)\nend\n}\nnewfa = {}\nrstate = []\nif p0 != nil then rstate.push(p0) end\nif p1 != nil then rstate.push(p1) end\npstate = []\nwhile pstate != rstate\npstate = []\nrstate.each{|r| pstate.push(r)}\nrstate = []\npstate.each{|p|\np = p.sort\nresult = split(p, pstate)\np0 = result[0]\np1 = result[1]\nresult.each{|r|\nif r != []\nr = r.sort\nrstate = rstate.push(r)\nend\n}\n}\nend\nstart = []\nfinal = []\nrstate.each{|r| newfa[r] = fa.new_state}\nlist = newfa.keys\nlist.each{|l|\nl.each{|k|\nif k == @start\nstart.push(l)\nend\nif is_final?(k)\nfinal.push(l)\nend\n}\n}\nif start != []\nstart.each{|s| if newfa[s] then fa.set_start(newfa[s]) end}\nend\nif final != []\nfinal.each{|f| fa.set_final(newfa[f], true)}\nend\nrstate.each{|r0|\nr0.each{|r1|\n@alphabet.each{|a|\nif get_transition(r1, a) != nil\nrstate.each{|r|\nif r.include?(get_transition(r1, a)[0])\nif !(fa.get_transition(newfa[r0], a))\nfa.add_transition(newfa[r0], newfa[r], a)\nif fa.get_alpha.include?(a) == false\nfa.get_alpha.push(a)\nend\nend\nend\n}\nend\n}\n}\n}\nfa\nend",
"def ismn; end",
"def fully_extend_all reps=nil\n dist.branches.times do |i|\n hits = mapee(i).hits\n len = mapee(i).length\n mapee(i).clear_hits\n reps = (@len.to_f / len).round if reps.nil?\n mapee(i).length = @len\n reps.times do |j|\n new_hits = HitSq.new\n new_hits << hits\n new_hits * (1.0/reps)\n new_hits + (j.to_f / reps)\n# puts new_hits.hits.inspect\n mapee(i) << new_hits\n end\n# puts mapee(i).hits.hits.inspect\n end\n end",
"def probers; end",
"def start_solution plan\n solutions = []\n 15.times do\n s = mutate_pairs plan, valid_solution2(false)\n solutions << s\n end\n\n #0.times do\n # s = random_solution plan\n #end\n\n 10.times do\n s = structured_solution plan\n solutions << mutate_pairs(plan, s)\n end\n sort_soluitons plan, solutions\n end",
"def masterwork_prob_bonus; 0; end",
"def set_solution\r\n @solutions = true\r\n end",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend",
"def solve_stupid\n nodes_num.times.collect{|node_num| make_wave(node_num) }.min\n end",
"def terpene; end",
"def analyze_component_breakdown\n\n end",
"def find_single_hidden\n before = self.entropy\n reduce_hidden_single_line\n reduce_hidden_single_col\n reduce_hidden_single_grid\n reduce_solved if before > self.entropy\n end",
"def prepare_preferred_algorithms!; end",
"def slop!; end",
"def slop!; end",
"def search( grid, init , deltas, cost, goal , delta_names)\n # ----------------------------------------\n # insert code here and make sure it returns the appropriate result\n # ----------------------------------------\n closed = copy_array_dimensions grid\n expand = copy_array_dimensions grid #, -1\n action = copy_array_dimensions grid, -1\n\t#initalize starting location \n\tclosed[init[0]][init[1]] =1\n\n\tx = init[0]\n\ty = init[1]\n\tg = 0 \n\t\n\topen = [[g,x,y]]\n\tputss 'open', open\n\tputss closed\n\tprint_array expand\n\t#flags\n\tfound = false\n\tresign = false \n\t\n\twhile ( found == false && resign == false )\n\t\t\n\t\tif open.size == 0 \n\t\t\tresign = true \n\t\t\tputs 'fail'\n\t\t\tclosed.each do | row | \n\t\t\t\tputs row.inspect\n\t\t\tend\n\t\telse\n\t\t\topen.sort()\n\t\t\topen.reverse()\n\t\t\tnext_ = open.pop() #use unshift\n\t\t\tputss 'next', next_[0], next_[1]\n\t\t\tx = next_[1] \n\t\t\ty = next_[2]\n\t\t\tg = next_[0] \n\t\t\t\n\t\t\tif x == goal[0] && y == goal[1]\n\t\t\t\tfound = true \n\t\t\t\tputss 'done', next_\n\t\t\telse\n\t\t\t\t#apply action , nod eexpantion\n\t\t\t\tdeltas.each_with_index do | delta, i | \n\t\t\t\t\tx2 = x + delta[0]\n\t\t\t\t\ty2 = y + delta[1]\n\t\t\t\t\tif x2 >= 0 && x2 < grid.size &&\n\t\t\t\t\t\ty2 >= 0 && y2 < grid[0].size\n\t\t\t\t\t\t#putss 'add to open list', [ x2, y2]\n\t\t\t\t\t\t#if not closed and natvigable \n\t\t\t\t\t\tif closed[x2][y2] == 0 && grid[x2][y2] == 0 \n\t\t\t\t\t\t\tg2 = g + cost\n\t\t\t\t\t\t\topen << [g2, x2, y2]\n\t\t\t\t\t\t\texpand[x2][y2] = g2\n\t\t\t\t\t\t\t#putss 'add to open list', [ x2, y2]\n\t\t\t\t\t\t\tclosed[x2][y2] = 1\n\t\t\t\t\t\t\taction[x2][y2] = i\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif grid[x2][y2] != 0 \n\t\t\t\t\t\t\texpand[x2][y2] = -1\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\tend\n\t\n\t\n\t#\n\tpolicy = copy_array_dimensions grid, ' '\n\tx = goal[0]\n\ty = goal[1]\n\tpolicy[x][y] = '*'\n\t\n\tprint_array action\n\tputss init, x, y\n\t#return\n\tif resign != true\n\t\twhile ( x != init[0] && y != init[1] )\n\t\t\t#apply inverse action \n\t\t\tx2 = x - deltas[action[x][y]][0]\n\t\t\ty2 = y - deltas[action[x][y]][1]\n\t\t\tpolicy[x][y] = delta_names[action[x][y]]\n\t\t\tx = x2\n\t\t\ty = y2\n\t\tend\n\t\t\n\t\tprint_array policy\n\tend\n\texpand\nend",
"def scientist; end",
"def outsense_edist(u, v)\n\n # initialize m and n\n m = u.length\n n = v.length\n\n # create hash of arrays where \n # hash.key holds h and array index holds d\n # thus hash[h][d] = front(h, d) = i\n front = Hash.new(Array.new)\n \n # initialize d with 0 for the first front\n d = 0\n\n # calculate front(0, 0)\n front[0][d] = lcplen(u, v, m, n)\n \n # till front(n - n, d) = m\n while front[n-m][d] != m-1\n\n # increase d\n d += 1\n \n # fronts calculated according to script\n ((-d)..d).each do |h|\n front[h][d] = outsense_next_front(front, h, d, u, v, m, n)\n end\n end\n\n # length of array with hash key m - n (= h) is \n # as long as the index of its last entry (= d) + 1\n return (front[m-n].length - 1)\nend",
"def private; end",
"def solve\n solution_candidate(intersections.next_people_with_similar_tastes)\n end",
"def solve\n\t\t# Attempt to find a mismatch in start/end\n\t\t# letters in the maps. This signifies first\n\t\t# and last words of the solution\n\t\tdiff_list = []\n\t\t@start_map.each {|k,v|\n\t\t\tr = @end_map[k]\n\t\t\tdiff = r-v\n\t\t\tputs \"#{k} => #{v} | #{r} diff #{diff}\"\n\t\t\t\n\t\t\t# If values in map don't match, remember this\n\t\t\tif diff != 0\n\t\t\t\tdiff_list << diff\n\t\t\tend\n\t\t}\n\n\t\t# Ensure the matchings satisfy the properties of\n\t\t# and solvable puzzle. If there are \n\t\tputs diff_list\n\t\tif diff_list.size == 0\n\t\t\t# This means there are cycles (multiple\n\t\t\t# choices for the first word).\n\t\telsif diff_list.size == 2\n\t\t\t# Ensure there is exactly one starting\n\t\t\t# word and exactly one ending word\n\t\t\treturn [] if !diff_list.include?( 1 )\n\t\t\treturn [] if !diff_list.include?( -1 )\n\t\telse\n\t\t\t# This signifies an unsolvable puzzle\n\t\t\tputs \"Not Solvable\"\n\t\t\treturn []\n\t\tend\n\n\t\t# The characteristics of this word list look\n\t\t# good so far. Let's now try to enumerate the\n\t\t# solution array\n\t\treturn enumerate_solution\n end",
"def minimize\n\t\tdfa = DFA.new\n\t\tif @alphabet.empty?\n\t\t\treturn self\n\t\tend\n\t\taccept = @final.keys\n\t\treject = @state.keys - accept\n\t\t#print \"Accept { \" + accept.join(\", \").to_s + \" }\\n\"\n\t\t#print \"Reject { \" + reject.join(\", \").to_s + \" }\\n\"\n\t\tcounter = @@nextID\n\t\ta = counter\n\t\tif(!reject.empty?)\n\t\t\tcounter+=1\n\t\tend\n\t\tb = counter\n\t\tsymbol = nil\n\t\tdestination = nil\n\t\t\n\t\tif(!reject.empty?)\n\t\t\tdfa.state_rep[a] = reject\n\t\t\tdfa.state_rep[b] = accept\n\t\telse\n\t\t\tdfa.state_rep[a] = accept\n\t\tend\n\t\t\t\n\t\tstack = Array.new\n\t\tstack.push a\n\t\tstack.push b\n\t\tpartitions = Array.new\n\t\t#dfa.prettyPrint\n\t\twhile(partitions != stack)\n\t\t\tpartitions = stack\n\t\t\tstack = Array.new\n\t\t\t#puts \"Part: \" + partitions.to_s + \"stak: \" + stack.to_s\n\t\t\t#print \"R = {\" + partitions.join(\", \").to_s + \"}\\n\"\n\t\t\tpartitions.flatten.each{ |p|\n\t\t\t\t#print \"Split partition: { \" + dfa.state_rep[p].join(\", \").to_s + \" }\\n\"\n\t\t\t\tdfa.state_rep[p], temp = split(dfa.state_rep[p], dfa.state_rep)\n\t\t\t\t#print p.to_s + \" now contains: { \" + dfa.state_rep[p].join(\", \").to_s + \" }\\n\"\n\t\t\t\t#print \"Temp: { \" + temp.join(\", \").to_s + \" }\\n\"\n\t\t\t\tif(!temp.empty?)\n\t\t\t\t\tcounter+=1\n\t\t\t\t\tc = counter\n\t\t\t\t\tstack.push p\n\t\t\t\t\tstack.push c\n\t\t\t\t\t#print c.to_s + \" now contains { \" + temp.join(\", \").to_s + \" }\\n\"\n\t\t\t\t\t#dfa.prettyPrint\n\t\t\t\t\tdfa.state_rep[c] = temp\n\t\t\t\tend\n\t\t\t\tdfa.state_rep.keys.each { |state|\n\t\t\t\t\tdfa.clear_trans(state)\n\t\t\t\t\tdfa.state_rep[state].each { |stuffs|\n\t\t\t\t\t@alphabet.each{ |c|\n\t\t\t\t\t\tdest = get_transition(stuffs, c)\n\t\t\t\t\t\tif dest != nil\n\t\t\t\t\t\t\tparks = dfa.state_rep.keys.dup\n\t\t\t\t\t\t\tparks.each{ |place|\n\t\t\t\t\t\t\t\tif dfa.state_rep[place].include?(dest)\n\t\t\t\t\t\t\t\t\t#puts \"adding (\" + state.to_s + \" \" + c.to_s + \" \" + place.to_s + \"\\n\" \n\t\t\t\t\t\t\t\t\tdfa.add_transition(state, place, c)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#end\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#print dfa.state.to_s + \"\\n\"\n\t\t\t\t#puts \"-------------------------------\"\n\t\t\t}\n\t\t\t#puts \"Part: \" + partitions.to_s + \"stak: \" + stack.to_s\n\t\tend\n\t\tdfa.state.keys.each{ |parts|\n\t\t\tresult = 0\n\t\t\tis_start = 0\n\t\t\t#puts parts\n\t\t\tdfa.state_rep[parts].each { |state|\n\t\t\t\tif(is_final?(state))\n\t\t\t\t\tresult = 1\n\t\t\t\tend\n\t\t\t\tif(state == @start)\n\t\t\t\t\tis_start = 1\n\t\t\t\tend\n\t\t\t\t}\n\t\t\tif result == 1\n\t\t\t\tdfa.set_final(parts)\n\t\t\tend\n\t\t\tif(is_start == 1)\n\t\t\t\tdfa.set_start(parts)\n\t\t\tend\n\t\t}\n\t\tdfa\n end",
"def solve(notes)\n ############################################\n # Preprocessing\n notes = uniq(notes).sort.select{|n| !n.is_rest?}\n return [[]] if notes.length == 0\n raise ArgumentError, \"There are more unique notes than strings!\" if notes.length > @guitar.nstrings\n # Separate the notes to be solved into two categories: open notes vs non-open notes\n open_notes = notes.select{|note| @open_notes.key?(note.val)}\n non_open_notes = notes.select{|note| !@open_notes.key?(note.val)}.sort\n\n # If there are zero non-open notes, then all the notes can be played with no fingers.\n return [open_notes.map{|note| [note.name, @open_notes[note.val].first, 0]}] if non_open_notes.length == 0\n\n # Note we can arbitrarily choose any note as our point of reference for spatial locality for a given string.\n # However, notes that can utilize open strings may reduce cost but negatively affect the premise of spatial locality of note-string assignment.\n # Therefore, use lowest note that cannot be an open string note to preserve spatial locality.\n # With this, there is no need to choose between an open string or non-open string for a potential open string note.\n base_note = non_open_notes.first\n base_note_task = notes.each_with_index.select{|n,i| n == base_note}.first[1]\n note_offsets = notes.map{|note| note.num_steps_from(base_note)}\n\n # Initialize basic cost matrix\n cost_matrix = init_cost_matrix(notes)\n\n if !AssignmentSolver::solvable?(cost_matrix)\n warn [notes.join(\",\"), \"is unsolvable\"].join(\" \")\n return []\n end\n \n ############################################\n # String-Note Optimal Assignment\n # Use as many strings needed from highest (right) to lowest (left)\n solutions = Set.new\n (0..@guitar.nstrings-notes.length).to_a.reverse.each {|from|\n used_strings = @sorted_tuning[from...@guitar.nstrings]\n string_offsets = @offsets_grid[from][from...@guitar.nstrings]\n # Grab the submatrix of partially filled cost_matrix\n base = (from...@guitar.nstrings).map{|r|\n cost_matrix[r]\n }\n \n # Fill in the nil elements of the submatrix with relative offsets\n layer = string_offsets.map{|s_offset| note_offsets.map{|n_offset| (n_offset - s_offset)}}\n layer_abs = layer.map{|row| row.map{|e| e.abs}}\n\n # Relative positions\n relative_pos = overlay(base, layer)\n # Euclidean distance conversion\n costs = overlay(base, layer_abs)\n costs = Matrix.new(costs, used_strings, notes)\n \n # Compute best assignment solution\n solver = HungarianSolver.new(costs)\n solution = solver.run()\n next if solution.length == 0\n\n # Find the offset on the string being used as a point of reference for the base_note\n base_str, note_idx = solution.select{|w,t| t == base_note_task}.first\n base_note_offset = base_note.num_steps_from(used_strings[base_str])\n\n # Adjust relative offsets to center around the designated base note position.\n adjustment = layer[base_str][note_idx] * -1\n layer.each{|row| row.map!{|e| e += adjustment}}\n\n solution = solution.select{|w,t| layer[w][t]}.map{|w,t|\n relative_offset = layer[w][t]\n # Check if this is an open string note\n offset_from_capo = if base[w][t] == 0\n # Open note string since base element is 0\n 0\n else\n # Compute offset from capo for this string\n base_note_offset + relative_offset\n end\n [used_strings[w].name, from+w, offset_from_capo]\n }\n solutions << solution\n }\n\n return solutions.to_a\n end",
"def solve(ingredients, part_two: false)\n score = 0\n max = 0\n\n (0..100).each do |i|\n (0..100 - i).each do |j|\n (0..100 - i - j).each do |k|\n l = 100 - i - j - k\n capacity = calculate_total(ingredients, \"capacity\", i, j, k, l)\n durability = calculate_total(ingredients, \"durability\", i, j, k, l)\n flavor = calculate_total(ingredients, \"flavor\", i, j, k, l)\n texture = calculate_total(ingredients, \"texture\", i, j, k, l)\n calories = calculate_total(ingredients, \"calories\", i, j, k, l)\n\n next if part_two && calories != 500\n next if capacity <= 0 || durability <= 0 || flavor <= 0 || texture <= 0\n\n score = capacity * durability * flavor * texture\n max = score if score > max\n end\n end\n end\n max\nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def required_positionals; end",
"def main()\n rules = { # a/bc/bcd/bcdd/bcda/bcdbc/bcbc/cbc/aa/\n 'abcd' => [''],\n 'a' => ['bc'],\n 'bc' => ['bcd', 'c'],\n 'd' => ['a', 'db'],\n 'db' => ['b'],\n 'cbc' => ['ab'],\n '...' => ['a']\n }\n rows= [\n 'bd',\n ]\n moves = 10\n width = 7\n solver = Solver.new(rules, moves, width)\n game_data = GameState.new(rules, rows[0], width)\n solution = solver.find_solution(game_data)\n\n if !solution.nil?\n solution.each do |move|\n puts(move.to_s)\n end\n else\n puts 'No solution found'\n end\nend",
"def verdi; end",
"def same; end",
"def irredundant(on,dc,deadline)\n # Step 1: get the relatively essential.\n # print \"on=#{on}\\n\"\n cubes, es_rel = on.each_cube.partition do |cube| \n ((on+dc) - cube).cofactor_cube(cube).is_tautology?\n end\n return on.clone if cubes.empty? # There were only relatively essentials.\n # print \"cubes = #{cubes}\\n\"\n # print \"es_rel = #{es_rel}\\n\"\n \n # Step 2: get the partially and totally redundants.\n es_rel_dc = Cover.new(*on.each_variable)\n es_rel.each { |cube| es_rel_dc << cube }\n dc.each { |cube| es_rel_dc << cube }\n red_tot, red_par = cubes.partition do |cube|\n es_rel_dc.cofactor_cube(cube).is_tautology?\n end\n # red_par is to be used as a cover.\n red_par_cover = Cover.new(*on.each_variable)\n red_par.each { |cube| red_par_cover << cube }\n # print \"es_rel_dc = #{es_rel_dc}\\n\"\n # print \"red_tot = #{red_tot}\\n\"\n # print \"red_par = #{red_par}\\n\"\n\n # Step 3: get the minimal sets of partially redundant.\n red_par_sets = red_par.map do |cube|\n # print \"for cube=#{cube}\\n\"\n minimal_set_covers( cofactor_cube_indexed(red_par_cover,cube),\n cofactor_cube_indexed(es_rel_dc,cube) )\n end\n # red_par_sets.each { |set| set.map! {|i| red_par[i] } }\n # print \"red_par_sets=#{red_par_sets}\\n\"\n\n # Step 4: find the smallest minimal set using the minimal column covers\n # algorithm.\n # For that purpose build the boolean matrix whose columns are for the\n # partially redundant cubes and the rows are for the sets, \"1\" \n # indication the cube is the in set.\n matrix = [] \n red_par_sets.each do |sets|\n sets.each do |set|\n row = \"0\" * red_par.size\n # set.each { |i| row[i] = \"1\" }\n set.each { |i| row.setbyte(i,49) }\n matrix << row\n end\n end\n # print \"matrix=#{matrix}\\n\"\n smallest_set_cols = minimal_column_covers(matrix,true,deadline)\n # print \"smallest_set_cols=#{smallest_set_cols}\\n\"\n \n # Creates a new cover with the relative essential cubes and the\n # smallest set of partially redundant cubes.\n cover = Cover.new(*on.each_variable)\n es_rel.each { |cube| cover << cube.clone }\n # smallest_set_cols.each do |set| \n # set.each { |col| cover << red_par[col].clone }\n # end\n smallest_set_cols.each { |col| cover << red_par[col].clone }\n # print \"cover=#{cover}\\n\"\n return cover \n end",
"def leeway; end",
"def leeway; end",
"def offences_by=(_arg0); end",
"def get_original_combination\n nil\n end",
"def solved?\n end",
"def isp; end",
"def isp; end"
] | [
"0.6125088",
"0.6057885",
"0.6032047",
"0.596112",
"0.5855799",
"0.5728863",
"0.5724712",
"0.5719958",
"0.56593394",
"0.5632929",
"0.5628762",
"0.56110376",
"0.5605961",
"0.5596298",
"0.5592266",
"0.5574005",
"0.5560274",
"0.5557256",
"0.5544934",
"0.5530675",
"0.5527182",
"0.5527182",
"0.5527182",
"0.5527182",
"0.55144966",
"0.54950005",
"0.5483669",
"0.5463399",
"0.5421542",
"0.540197",
"0.53897464",
"0.5383247",
"0.5375409",
"0.5368301",
"0.53626275",
"0.53626275",
"0.53626275",
"0.53626275",
"0.53626275",
"0.5352962",
"0.53430337",
"0.5333804",
"0.5328156",
"0.5326078",
"0.53225404",
"0.53211445",
"0.52990067",
"0.5298757",
"0.5297215",
"0.52883464",
"0.528172",
"0.5271854",
"0.5271393",
"0.5249403",
"0.52396077",
"0.52385736",
"0.52319884",
"0.5230394",
"0.5211853",
"0.52004355",
"0.5195782",
"0.51866335",
"0.5179244",
"0.5179229",
"0.51727337",
"0.51646763",
"0.5160443",
"0.514946",
"0.5148902",
"0.514764",
"0.5146611",
"0.5143687",
"0.5143459",
"0.5142204",
"0.5138892",
"0.5133925",
"0.5133794",
"0.513302",
"0.513302",
"0.51314753",
"0.51244175",
"0.51226515",
"0.51194525",
"0.511718",
"0.5113477",
"0.51124775",
"0.51106477",
"0.51103336",
"0.5098521",
"0.5098458",
"0.5091802",
"0.5083634",
"0.5081198",
"0.50768834",
"0.5074726",
"0.5074726",
"0.5073684",
"0.5069455",
"0.506813",
"0.5065626",
"0.5065626"
] | 0.0 | -1 |
Creates the four required columns that constitutes a single cascading namespace settings attribute. This helper is only appropriate if the setting is not already present as a noncascading attribute. Creates the `setting_name` column along with the `lock_setting_name` column in both `namespace_settings` and `application_settings`. This helper is not reversible and must be defined in conjunction with `remove_cascading_namespace_setting` in separate up and down directions. setting_name The name of the cascading attribute same as defined in `NamespaceSetting` with the `cascading_attr` method. type The column type for the setting itself (:boolean, :integer, etc.) options Standard Rails column options hash. Accepts keys such as `null` and `default`. `null` and `default` options will only be applied to the `application_settings` column. In most cases, a nonnull default value should be specified. | def add_cascading_namespace_setting(setting_name, type, **options)
lock_column_name = "lock_#{setting_name}".to_sym
check_cascading_namespace_setting_consistency(setting_name, lock_column_name)
namespace_options = options.merge(null: true, default: nil)
add_column(:namespace_settings, setting_name, type, **namespace_options)
add_column(:namespace_settings, lock_column_name, :boolean, default: false, null: false)
add_column(:application_settings, setting_name, type, **options)
add_column(:application_settings, lock_column_name, :boolean, default: false, null: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setting_class\n @setting_class ||= case orm\n when :activerecord\n require 'settler/orm/activerecord/setting'\n Settler::ORM::Activerecord::Setting\n else\n require 'settler/orm/ruby/setting'\n Settler::ORM::Ruby::Setting\n end\n end",
"def setting_params\n params.require(:setting).permit(:namespace, :value)\n end",
"def setting(name)\n\t\t\tval = config.settings.where(\"name = ?\", name.to_s).first\n\t\t\tif val.nil?\n\t\t\t\tval = config.control_system.zones.joins(:settings).where('settings.name = ?', name.to_s).first\n\t\t\t\tval = val.settings.where(\"name = ?\", name.to_s).first unless val.nil?\n\t\t\t\t\n\t\t\t\tval = config.dependency.settings.where(\"name = ?\", name.to_s).first if val.nil?\n\t\t\tend\n\t\t\t\n\t\t\tif val.present?\n\t\t\t\tcase val.value_type\n\t\t\t\t\twhen 0\n\t\t\t\t\t\treturn val.text_value\n\t\t\t\t\twhen 1\n\t\t\t\t\t\treturn val.integer_value\n\t\t\t\t\twhen 2\n\t\t\t\t\t\treturn val.float_value\n\t\t\t\t\twhen 3\n\t\t\t\t\t\treturn val.datetime_value\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\treturn nil\n\t\tend",
"def has_settings(*args)\n options = args.extract_options!\n attribute_name = args.shift || HasSettings.config[:settings_attribute_name]\n association_name = \"_#{attribute_name}\"\n class_name = options[:class_name] || HasSettings.config[:settings_class_name]\n \n has_many association_name.to_sym,\n :class_name => class_name,\n :as => :configurable,\n :dependent => :destroy\n \n define_method attribute_name do\n instance_variable_get(:\"@#{attribute_name.to_s}\") || instance_variable_set(:\"@#{attribute_name.to_s}\", SettingsAccessor.new(self, association_name.to_sym, options[:inherit]))\n end\n end",
"def config_setting\n @config_access_name = \"config_setting\"\n @setting ||= Setting.new(ContainerAdapter.new(self))\n end",
"def setting(setting_name)\n context = Config.find_in_hash(options, Keys::Options::CONTEXT)\n Config.find_in_hash(options, setting_name) ||\n Config.find_in_hash(user_config, [Keys::SETTINGS, context, setting_name]) ||\n Config.find_in_hash(user_config, [Keys::SETTINGS, setting_name]) ||\n Config.find_in_hash(defaults, setting_name)\n end",
"def [](option_name)\n # :full_table_name will be generated on first request\n generate_full_name if option_name == :full_table_name && !configuration[:full_table_name]\n configuration[option_name]\n end",
"def settings=(setting_options = [])\n # for arrays, set in raw form \n @settings = if setting_options.is_a?(Array)\n setting_options\n # set optional shortcuts for settings\n # :keyword_match_setting => { :opt_in => false } # =>\n # { :xsi_type => 'KeywordMatchSetting', :opt_in => false }\n elsif setting_options.is_a?(Hash)\n setting_options.map do |key, values|\n { :xsi_type => key.to_s.camelcase }.merge(values).symbolize_keys\n end\n end\n end",
"def wrap_at=(setting)\n @wrap_at = setting == :auto ? output_cols : setting\n end",
"def setting_name\n return @setting_name\n end",
"def metadata(setting)\n if setting.is_a?(Puppet::Settings::FileSetting)\n {\n :owner => setting.owner,\n :group => setting.group,\n :mode => setting.mode\n }.delete_if { |key, value| value.nil? }\n else\n nil\n end\n end",
"def set_setting_type\n @setting_type = SettingType.find(params[:id])\n end",
"def table_setting_params\n params.require(:table_setting).permit(:table_name, :column_name, :attribute, :standard, :use, :custom_name_ja, :custom_name_en, :description_ja, :description_en, :required, :default, :sys_lower, :sys_high, :custom_lower, :custom_high, :format, :currency, :order_input, :order_list, :order_result)\n end",
"def setting_params\n params.require(:setting).permit(:name, :description, :enabled,\n :tick_types_attributes => [:name, :description, :setting_id],\n :cross_types_attributes => [:name, :description, :setting_id],\n :qa_settings_attributes => [:name, :setting_id, :team_id, :description, :out_of, :qa, :position],\n :qa_general_settings_attributes => [:name, :value, :team_id, :disabled]\n )\n end",
"def setting_params\n params.require(:setting).permit(:data_type, :key, :value)\n end",
"def create_setting(setting, opts = {})\n create_setting_with_http_info(setting, opts)\n nil\n end",
"def setting_type_params\n params.require(:setting_type).permit(:name, :description)\n end",
"def setting(name, type=:object, default=nil)\n item = Item.new\n item.name, item.ruby_type, item.default = name.to_s, type, default\n fields[name.to_s] = item\n add_setting_accessor(item)\n end",
"def set_standard_defaults( opts = self.opts )\n\n # We set NOT NULL on everything by default, but note the ?\n # syntax (like Text?) which declares the column as NULL.\n\n set_defaults :global, :null => false\n\n # We also like our keys unsigned, so we allow setting that, too.\n # Unfortunately, :unsigned currently works only with :integer,\n # not the default :Integer, and :integer can't be specified for compound keys,\n # so we have to use the callback to set the type only at correct times.\n # Furthermore, Postgres's autoincrementing serials only work with Integer,\n # so we set the type only as long as the unsigned keys are requested.\n\n unsigned_keys = !! opts[ :unsigned_keys ]\n\n set_defaults :Key, :integer, :unsigned => unsigned_keys\n set_defaults :primary_key, :unsigned => unsigned_keys do |opts,args,table|\n opts[ :type ] ||= :integer unless args.first.is_a? Array or not opts[ :unsigned ]\n end\n set_defaults :foreign_key, :key => :id, :unsigned => unsigned_keys do |opts,args,table|\n opts[ :type ] ||= :integer unless args.first.is_a? Array or not opts[ :unsigned ]\n end\n\n # Save some typing for unique and fulltext indexes.\n\n set_defaults :unique, :index, :unique => true\n set_defaults :fulltext, :index, :type => :full_text do |opts,args,table|\n opts[ :name ] ||= [ table, *args, :fulltext ].join( '_' ).to_sym\n end\n\n # Type shortcuts we use frequently.\n\n set_defaults :Bool, :TrueClass\n set_defaults :True, :TrueClass, :default => true\n set_defaults :False, :TrueClass, :default => false\n\n set_defaults :Signed, :integer, :unsigned => false\n set_defaults :Unsigned, :integer, :unsigned => ! opts[ :signed_unsigned ]\n\n set_defaults :String, :text => false\n set_defaults :Text, :String, :text => true\n\n # We want times to be stored as 4 byte timestamps, however\n # we have to be careful to turn off the MySQL autoupdate behavior.\n # That's why we have to set defaults explicitly.\n\n default_time = ( opts[ :zero_timestamps ] || ( opts[ :mysql_timestamps ] && opts[ :zero_timestamps ].nil? ) ) ? ZERO_TIME : DEFAULT_TIME\n set_defaults :Time, :timestamp, :default => default_time\n set_defaults :Time?, :timestamp, :default => nil\n\n self\n end",
"def call\n setting_item = build_setting_item(name, type, default)\n register_setting setting_item\n define_setting setting_item\n setting_item\n end",
"def setting_name=(value)\n @setting_name = value\n end",
"def create_setting\n if setting_options.is_a?(Hash)\n setting_options[:options][:validations] = setting_options[:validations]\n setting = Supports::Settingable::Models::Setting.new name: setting_options[:name]\n setting.options = setting_options[:options]\n setting.settingable= self\n setting.save\n end\n end",
"def buildtype_settings(options={})\n assert_options(options)\n response = get(\"buildTypes/#{locator(options)}/settings\")\n response['property']\n end",
"def locking_column=(value)\n reload_schema_from_cache\n @locking_column = value.to_s\n end",
"def setting_params\n params.require(:setting).permit!\n end",
"def settings_for_node\n cluster_name = self.parent.name.to_sym\n cluster_role = self.name.to_sym\n node_settings = {\n :user_data => { :attributes => { :run_list => [] } },\n :cluster_name => cluster_name,\n :cluster_role => cluster_role,\n }.deep_merge(Settings)\n node_settings.delete :pools\n raise \"Please define the '#{cluster_name}' cluster and the '#{cluster_role}' role in your ~/.chef/cluster_chef.yaml\" if (Settings[:pools][cluster_name].blank? || Settings[:pools][cluster_name][cluster_role].blank?)\n node_settings = node_settings.deep_merge(\n Settings[:pools][cluster_name][:common] ||{ }).deep_merge(\n Settings[:pools][cluster_name][cluster_role] ||{ })\n configure_aws_region node_settings\n node_settings\nend",
"def settings\n @settings ||= OpenStruct.new(opts[:dm_config].first)\n # dm_js_location, dm_css_location\n # dm_js_location: javascripts\n # dm_css_location: stylesheets\n end",
"def setting_params\n params.require(:setting).permit(:name, :value)\n end",
"def ensure_setting\n self.setting ||= Setting.build_default(self)\n end",
"def setting(name)\n @settings[normalize_key(name)]\n end",
"def scaffold_column_type_options(type)\n @scaffold_column_type_options ||= {}\n @scaffold_column_type_options[type] ||= SCAFFOLD_OPTIONS[:column_type_options][type] || {}\n end",
"def setting_params\n params.permit(:setting, :key, :value, :location) #, :key, :value, :location, #:system_node_id )\n end",
"def user_setting_params\n params.require(:user_setting).permit(setting: {})\n end",
"def setting_params\n params.require(:setting).permit(:is_insta, :display_mode, :user_id)\n end",
"def setting_params\n params.require(:setting).permit(\n :documentbox,\n :remove_documentbox,\n :published,\n\n # SEO Settings\n :seo_title,\n :seo_description,\n :seo_tags,\n :seo_imagebox,\n :remove_seo_imagebox,\n :offline_title,\n :offline_description\n )\n end",
"def initialize_setting\n unless new_record?\n if cached_setting.nil?\n create_setting\n if self.class.respond_to?(:object_caches_suffix)\n clear_cache! caches_suffix_list= [], object_caches_suffix=[\"setting\"]\n end\n end\n parameterize_name = setting_options[:name].downcase.parameterize.underscore\n setting_options[:options].except(:validations).keys.each do |opt_key|\n send(\"#{parameterize_name}_#{opt_key}=\", cached_setting.get_setting_of(opt_key))\n end\n end\n end",
"def setting_params\n params.require(:setting).permit(:key, :key_is, :value, :field_type, :locked_at, :id)\n end",
"def []=(namespace = :default, index, value)\n obj = get_setting(namespace, index)\n if obj\n obj.instance_eval do\n write_attribute(setting_value_field, value)\n end\n obj.save\n write_cache(obj)\n else\n obj = write_cache(self.create(setting_name_field => index, setting_namespace_field => namespace, setting_value_field => value))\n end\n end",
"def setting_params\n params.require(:setting).permit(:background, :fontSize, :fontColor, :fontFamily, :user_name)\n end",
"def augment_column_config(c)\n super\n set_default_data_index(c)\n set_default_xtype c\n end",
"def setting(setting_name, setting_value)\n setting_specs << {:name => setting_name.to_s, :value => setting_value.to_s, :config_line => get_config_line(caller)}\n end",
"def setting_params\n params.require(:setting).permit(:space_id, :stripe_publishable_key, :stripe_secret_key_unencrypted)\n end",
"def create_default_settings\n setting = Setting.new\n setting.user_id = self.id\n setting.save!\n end",
"def [](symbol_or_name)\n setting = find_setting(symbol_or_name).try(:value)\n if setting.nil? && has_parent?\n return parent.__send__(:[], symbol_or_name)\n else\n return setting\n end\n end",
"def setting_params\n params.require(:setting).permit(:company_id, :email_domain, :email_username, :email_password, :year_start)\n end",
"def setting_params\n params.require(:setting).permit :company_name, :contact_email, :site_name, :site_tagline, :blog_name, :blog_tagline, :disable_blog, :enable_comments_in_pages, :enable_comments_in_blog, :twitter_handle, :facebook_username, :google_plus_username, :instagram_username, :youtube_username, :linkedin_username\n end",
"def create_setting_with_http_info(setting, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SettingsApi.create_setting ...'\n end\n # verify the required parameter 'setting' is set\n if @api_client.config.client_side_validation && setting.nil?\n fail ArgumentError, \"Missing the required parameter 'setting' when calling SettingsApi.create_setting\"\n end\n # resource path\n local_var_path = '/settings'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(setting) \n\n # return_type\n return_type = opts[:return_type] \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SettingsApi#create_setting\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def setting(name)\n roots = []\n if @environment_name\n roots << @config.send(@environment_name)\n end\n roots << @config\n roots.each do |root|\n begin\n setting_value = name.split('.').inject(root) { |node,prop| if node.include?(prop.to_sym) then node.send(prop) else raise \"Undefined property #{prop} for #{node.name}\" end}\n return setting_value\n rescue => e\n # Fall through to next case\n end\n end\n # If we get here the property does not exist\n #XXX - should probably ask for a default, and if one is not provided, raise an error\n nil\n end",
"def create_tog_config_table\n ActiveRecord::Base.connection.create_table \"config\", :force => false do |t|\n t.string :key, :limit => 255, :default => \"\", :null => false\n t.string :value\n t.timestamps\n end\n ActiveRecord::Base.connection.add_index \"config\", [\"key\"], :name => \"key\", :unique => true\n end",
"def default_columns\n [\n {:name => \"id\", :attr_type => :integer, :meta => true},\n {:name => \"position\", :attr_type => :integer, :meta => true},\n {:name => \"attr_type\", :attr_type => :string, :meta => true},\n *config[:owner].class.meta_columns.map { |c| c[:name] == \"name\" ? inject_combo_for_name_column(c) : c }\n ]\n end",
"def settings_class\n @settings_class ||= \"Course::Settings::#{name.demodulize}\".safe_constantize\n end",
"def create\n\n @setting = Setting.new(\n :tenant => Tenant.current,\n :user => current_user,\n :name => params[:name],\n :value => params[:value])\n\n respond_to do |format|\n if @setting.save\n format.html { redirect_to \"/settings/#{@setting.id}\", notice: 'Setting was successfully created.' }\n format.json { render json: @setting, status: :created, location: @setting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def apply_devise_schema(name, type, options={})\n column name, type.to_s.downcase.to_sym, options\n end",
"def property_schema_hash(repository, property)\n schema = super\n\n if property.serial?\n schema.delete(:default) # the sequence will be the default\n schema[:sequence_name] = sequence_name(repository, property)\n end\n\n # TODO: see if TypeMap can be updated to set specific attributes to nil\n # for different adapters. precision/scale are perfect examples for\n # Postgres floats\n\n # Postgres does not support precision and scale for Float\n if property.primitive == Float\n schema.delete(:precision)\n schema.delete(:scale)\n end\n\n schema\n end",
"def setting_for(key)\n ensure_config_loaded!\n setting_class.find_by_key(key.to_s)\n end",
"def column(name, type, options = {})\n def_accessors(name)\n set_attribute_default(name, options[:default])\n end",
"def setting(name)\n @_settings = {} unless @_settings\n\n unless @_settings.include? name.to_sym\n begin\n @_settings[name.to_sym] = Setting.find_by(name: name.to_s).value\n rescue\n @_settings[name.to_sym] = nil\n end\n end\n\n @_settings[name.to_sym]\n end",
"def set_belongs_to_attr(col, owner, options = {})\n _col = column(col)\n unless belongs_to_synced?(_col, owner)\n _set_attr(_col.name, owner)\n rebuild_relation(_col, owner, set_inverse: options[:set_inverse])\n if _col.polymorphic\n set_polymorphic_attr(_col.name, owner)\n else\n _set_attr(_col.foreign_key, owner ? owner.id : nil)\n end\n end\n\n owner\n end",
"def setting_params\n params.require(:setting).permit(:code, :value, :user_id)\n end",
"def set_default_xtype(c)\n c[:xtype] = 'treecolumn' if c[:name].to_s == config[:treecolumn].to_s\n end",
"def settings_create_setting(request, opts = {})\n data, _status_code, _headers = settings_create_setting_with_http_info(request, opts)\n data\n end",
"def force_singular\n AttributeOptions.new(type: type, hashable: hashable)\n end",
"def setting_params\n params.require(:setting).permit(:overtime_hours_day, :overtime_hours_week, :break_length, :break_time, \n :work_start_time, :work_end_time, :work_time_tolerance, :week_start_day, :book_travel_time, :distance_tolerance, \n :app_al_breaks, :app_al_schedule, :app_al_OT, :app_al_no_clock_in, :app_al_no_clock_out, :app_off_site, :no_clock_in_int, \n :no_clock_out_int, :adm_al_Overtime, :no_clock_in, :late_clock_in, :late_clock_out, :adm_al_away_site, \n :app_op_job_id, :app_op_notes, :app_op_flag, :app_op_recpt, :app_op_sched, :app_op_job_name, :company_id, :gps_check, :gps_occurrence, \n :app_al_OT_occurrence, :app_al_no_clock_in_occurrence, :app_al_no_clock_out_occurrence, :app_off_site_occurrence)\n end",
"def setting_params\n params.require(:setting).permit(:user_id,\n :country_id,\n :show_business_cards,\n :show_personal_cards,\n :show_credit_cards,\n :show_charge_cards,\n :include_bonuses_in_calculations,\n :include_current_point_balances_in_calculations,\n :include_authorized_user_bonus,\n :fly_on_star_alliance,\n :fly_on_skyteam,\n :fly_on_oneworld,\n :maximum_cards_comfortable_applying_for_at_once).merge(user_id: current_user.id)\n end",
"def build_change_column_definition(table_name, column_name, type, **options) # :nodoc:\n column = column_for(table_name, column_name)\n type ||= column.sql_type\n\n unless options.key?(:default)\n options[:default] = column.default\n end\n\n unless options.key?(:null)\n options[:null] = column.null\n end\n\n unless options.key?(:comment)\n options[:comment] = column.comment\n end\n\n if options[:collation] == :no_collation\n options.delete(:collation)\n else\n options[:collation] ||= column.collation if text_type?(type)\n end\n\n unless options.key?(:auto_increment)\n options[:auto_increment] = column.auto_increment?\n end\n\n td = create_table_definition(table_name)\n cd = td.new_column_definition(column.name, type, **options)\n ChangeColumnDefinition.new(cd, column.name)\n end",
"def setting_params\n params.require(:setting).permit(:var, :value)\n end",
"def connection_table_column_params\n params.require(:connection_table_column).permit(:alias, :columnname, :type, :grouping, :foreignkey, :display, :connection_table_id)\n end",
"def setting_params\n params.require(:setting).permit(:first_name, :allow_reminder_for_birthdays)\n end",
"def admin_setting_params\n\t params.require(:setting).permit! #(:name, :value, :descr)\n\t end",
"def settings\n attributes.fetch(:settings)\n end",
"def config_set_app_setting(document, settingName, settingValue)\n\t config_set_attribute(document, '//configuration/appSettings/add', 'key', settingName, 'value', settingValue)\n\tend",
"def column\n cast_type = ActiveRecord::Base.connection.send(:lookup_cast_type, definition)\n metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(\n type: cast_type.type,\n sql_type: definition,\n limit: cast_type.limit\n )\n mysql_metadata = ActiveRecord::ConnectionAdapters::MySQL::TypeMetadata.new(metadata)\n @column ||= self.class.column_factory.new(\n name,\n default_value,\n mysql_metadata,\n null_value\n )\n end",
"def convert_border_options(setting)\n case setting\n when TrueClass\n { color: '000000', style: 'solid', width: 1 }\n when String\n matched = setting.match(REGEX_BORDER_OPTION)\n raise ArgumentError if matched.nil?\n {\n color: full_color_code(matched[:color]),\n style: matched[:style],\n width: convert_numeric(matched[:width].to_f, matched[:unit])\n }\n when Hash\n setting\n end\n end",
"def attribute_type #nodoc\n case @options[:association]\n when :has_many then Associations::HasMany\n when :belongs_to then Associations::BelongsTo\n when :has_one then Association::HasOne\n when :has_and_belongs then Association::HasAndBelongs\n else Property\n end\n end",
"def create\n @org_setting = OrgSetting.new(org_setting_params)\n\n if @org_setting.save\n render json: @org_setting, status: :created, location: @org_setting\n else\n render json: @org_setting.errors, status: :unprocessable_entity\n end\n end",
"def settings(options = {})\n ensure_config_loaded!\n setting_class.all_keys(options)\n end",
"def set_setting\n @o_single = Setting.find(params[:id])\n end",
"def setting_value(setting_name)\n if Setting.exists?(name: setting_name)\n setting = Setting.find_by(name: setting_name)\n setting.value.empty? ? default_setting_value(setting_name) : setting.value\n else\n default_setting_value(setting_name)\n end\n end",
"def setting(key)\n @setting_cache ||= {}\n return @setting_cache[key] if @setting_cache[key].present?\n\n log \"looking up business setting: <strong>#{key}</strong>\"\n setting = Setting.business(business).key(key).first\n raise \"Unknown Setting key:#{key}\" if setting.nil?\n\n @setting_cache[key] = setting\n setting\n end",
"def custom_settings\n hash = HashWithIndifferentAccess.new\n configurations.each do |c|\n case c.data_type\n when :boolean\n value = c.value == 'true' ? true : false\n when :integer\n value = c.value.to_i\n when :string\n value = c.value\n else\n raise 'not implemented'\n end\n hash[c.key] = value # cast\n end\n hash\n end",
"def admin_setting_params\n params.require(:setting).permit(:key, :value)\n end",
"def set_table_setting\n @table_setting = TableSetting.find(params[:id])\n end",
"def client_setting(name, default = nil, opts = {})\n setting(name, default, opts)\n client_settings << name.to_sym\n end",
"def setting(name, default_value=nil, default_proc: nil, &block)\n if block_given?\n # Create a nested setting\n setting_config = @settings[name]&.value || ConfigStruct.new(\"#{@name}.#{name}\")\n setting = ConfigValue.new\n setting.value = setting_config\n @settings[name] = setting\n setting_config.instance_eval(&block)\n else\n setting = ConfigValue.new\n setting.default_proc = default_proc\n setting.default_value = default_value\n setting.reset!\n @settings[name] = setting\n end\n end",
"def create\n @o_single = Setting.new(setting_params)\n respond_to do |format|\n if @o_single.save\n format.html { redirect_to admin_settings_url, notice: t(\"general.successfully_created\") }\n format.json { head :no_content }\n else\n format.html { render action: 'new' }\n format.json { render json: @o_single.errors, status: :unprocessable_entity }\n end\n end\n end",
"def to_table_column\n col_type = type ? type.to_sym : :string\n [column_name, col_type, { index: index_options, default: default }]\n end",
"def settings\n\n\t\tif @settings.nil? then\n\t\t\thash = {}\n\t\t\tproperty_settings.includes(:property_definition).each do |setting|\n\t\t\t\tp_def = setting.property_definition\n\t\t\t\tvalue = case p_def.def_type\n\t\t\t\t\t\t\twhen \"string\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"text\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"html\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"integer\"\n\t\t\t\t\t\t\t\tsetting.number.to_i\n\t\t\t\t\t\t\twhen \"file\" \n\t\t\t\t\t\t\t\tMedia.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"url\"\n\t\t\t\t\t\t\t\tPage.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"date\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t:dontknowhowtointerpretthis\n\t\t\t\t\t\tend\n\t\t\t\thash[setting.property_definition.label.to_sym] = value\n\t\t\tend\n\t\t\t@settings = OpenStruct.new(hash)\n\t\tend\t\t\t\n\n\t\t@settings\n\tend",
"def fetch_plugin_setting(setting_name, default = nil)\n env_var_name = \"INSPEC_CHEF_#{setting_name.upcase}\"\n config_name = \"chef_api_#{setting_name.downcase}\"\n ENV[env_var_name] || plugin_conf[config_name] || default\n end",
"def setting=(value)\n @setting = value\n end",
"def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end",
"def delete_application_configuration_setting_with_http_info(setting_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ApplicationManagementApi.delete_application_configuration_setting ...'\n end\n # verify the required parameter 'setting_id' is set\n if @api_client.config.client_side_validation && setting_id.nil?\n fail ArgumentError, \"Missing the required parameter 'setting_id' when calling ApplicationManagementApi.delete_application_configuration_setting\"\n end\n if @api_client.config.client_side_validation && opts[:'learning_standard'] && !['SCORM_11', 'SCORM_12', 'SCORM_2004_2ND_EDITION', 'SCORM_2004_3RD_EDITION', 'SCORM_2004_4TH_EDITION', 'AICC', 'XAPI', 'CMI5'].include?(opts[:'learning_standard'])\n fail ArgumentError, 'invalid value for \"learning_standard\", must be one of SCORM_11, SCORM_12, SCORM_2004_2ND_EDITION, SCORM_2004_3RD_EDITION, SCORM_2004_4TH_EDITION, AICC, XAPI, CMI5'\n end\n # resource path\n local_var_path = '/appManagement/configuration/{settingId}'.sub('{' + 'settingId' + '}', setting_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'learningStandard'] = opts[:'learning_standard'] if !opts[:'learning_standard'].nil?\n query_params[:'singleSco'] = opts[:'single_sco'] if !opts[:'single_sco'].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 = ['APP_NORMAL', 'OAUTH']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ApplicationManagementApi#delete_application_configuration_setting\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def setting_params\n params.require(:setting).permit(:autoopen, :autoopen_interval, :guard_time)\n end",
"def apply_devise_schema(name, type, options={})\n return unless Devise.apply_schema\n property name, :cast_as => type\n end",
"def setting_params\n params.require(:setting).permit(:debug, :security_level, :size, :similarity, :weight,:description,:in_use,:min_value)\n end",
"def setting_params\n params.require(:setting).permit(:title, :description, :blob, :user_file_path)\n end",
"def columns_for_klass(klass)\n if klass == 'Tenant'\n [:name, :use_config_for_attributes]\n elsif klass.safe_constantize.column_names.include?('name')\n [:name]\n else\n [:description]\n end\n end",
"def configure_canonical(canonical_flag_type, canonical_value_type,\n canonical_value_label, canonical_value_delim)\n return unless flag_type.nil?\n @flag_type = canonical_flag_type\n return unless canonical_flag_type == :value\n @value_type = canonical_value_type\n canonical_value_delim = \"\" if canonical_value_delim == \"=\" && flag_style == :short\n canonical_value_delim = \"=\" if canonical_value_delim == \"\" && flag_style == :long\n @value_delim = canonical_value_delim\n @value_label = canonical_value_label\n label = @value_type == :optional ? \"[#{@value_label}]\" : @value_label\n @canonical_str = \"#{str_without_value}#{@value_delim}#{label}\"\n end",
"def set_settings_type\n @settings_type = SettingsType.find(params[:id])\n end",
"def project_setting_params\n params.require(:project_setting).permit(:project_setting_name)\n end",
"def autoreport_column(column)\n return if column.name == 'id'\n belongs_to_ref = klass.reflections.find { |_, a| a.foreign_key == column.name }\n if belongs_to_ref\n name, ref = belongs_to_ref\n name_col = (ref.klass.column_names & autoreport_association_name_columns(ref)).first\n if name_col\n name_expr = \"#{ref.klass.table_name}.#{name_col}\"\n category_dimension name, expression: name_expr, relation: ->(r) { r.joins(name) }\n else\n category_dimension column.name\n end\n elsif column.cast_type.type == :datetime\n time_dimension column.name\n elsif column.cast_type.number?\n number_dimension column.name\n else\n category_dimension column.name\n end\n end"
] | [
"0.49649224",
"0.4823334",
"0.47971034",
"0.46413702",
"0.4559991",
"0.4529144",
"0.45199347",
"0.450397",
"0.44972235",
"0.44927645",
"0.44905928",
"0.44677636",
"0.44619715",
"0.44599438",
"0.44313174",
"0.4407542",
"0.43775278",
"0.43568566",
"0.4345559",
"0.43305054",
"0.43201193",
"0.4318149",
"0.43176955",
"0.4294976",
"0.42422625",
"0.42403355",
"0.42124623",
"0.4211681",
"0.4204287",
"0.420266",
"0.4177637",
"0.4154045",
"0.41533798",
"0.41507915",
"0.4147555",
"0.41351703",
"0.4131804",
"0.4131256",
"0.413044",
"0.41260913",
"0.41212353",
"0.41185173",
"0.41063243",
"0.40994778",
"0.40989622",
"0.40731955",
"0.40693465",
"0.40682244",
"0.40672302",
"0.4066244",
"0.4065588",
"0.4058765",
"0.4043361",
"0.40393224",
"0.40344995",
"0.4030696",
"0.40269622",
"0.400039",
"0.39945257",
"0.39893007",
"0.39866418",
"0.39701238",
"0.39693078",
"0.39653215",
"0.39643922",
"0.3961328",
"0.39559105",
"0.39377415",
"0.392397",
"0.391656",
"0.39141595",
"0.39106503",
"0.3909474",
"0.3898663",
"0.38969427",
"0.3893999",
"0.38844645",
"0.38814482",
"0.38738894",
"0.3872348",
"0.38666195",
"0.38627005",
"0.38541913",
"0.38450393",
"0.3840662",
"0.3838395",
"0.38364238",
"0.38340026",
"0.38334072",
"0.38313377",
"0.38262448",
"0.38247728",
"0.38244766",
"0.38213015",
"0.38208118",
"0.38201123",
"0.3812693",
"0.38117063",
"0.38109607",
"0.38043186"
] | 0.80753994 | 0 |
Because pagy gem method pagy_next_url return url base on request url, but sometime we want specify base url. So this is what this method doing. | def next_url_for_path(path, pagy)
return unless pagy.next
url = URI.parse(path); url_query = Rack::Utils.parse_query url.query
url.query = Rack::Utils.build_query url_query.merge(pagy.vars[:page_param].to_s => pagy.next)
url.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page_url\n \"#{request.path}?page=#{@page + 1}\"\n end",
"def next_url_str\n \"#{@url_base_str}?#{QUERY_STRING_PART1}&#{@query_str_next_page}\"\n end",
"def next_page_path; end",
"def next_page_url\n current_page = params[:page].try(:to_i) || 1\n if request.path.match /\\/page\\/(\\d+)/\n request.path.gsub(/\\/page\\/(\\d+)$/, \"/page/#{current_page+1}\")\n else\n \"#{request.path}/page/#{current_page+1}\"\n end\n end",
"def pagy_url_for(page, pagy)\n params = request.query_parameters.merge(:only_path => true, pagy.vars[:page_param] => page )\n url_for(params)\n end",
"def next_page; end",
"def next_page_path(response)\n response.get(\"_links.next.href\")\n end",
"def paginable_base_url(page = 1)\n return url_for(@paginable_path_params.merge({ controller: @paginable_params[:controller],\n action: @paginable_params[:action], page: page }))\n end",
"def paginable_base_url(page = 1)\n @args = @args.with_indifferent_access\n url_params = @paginable_path_params.merge(\n controller: @args[:controller],\n action: @args[:action],\n page: page\n )\n url_for(url_params)\n end",
"def next_page\n end",
"def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend",
"def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend",
"def next_page; link 'next' end",
"def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend",
"def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend",
"def next_page_link\n paging['next'] if paging\n end",
"def url(page)\n if self.class.base_url.blank?\n return super(page)\n else\n url_params = {}\n add_current_page_param(url_params, page)\n ret = @template.url_for(url_params)\n \"#{self.class.base_url}?#{ret.split('?')[-1]}\"\n end\n end",
"def url(page)\n if self.class.base_url.blank?\n return super(page)\n else\n url_params = {}\n add_current_page_param(url_params, page)\n ret = @template.url_for(url_params)\n \"#{self.class.base_url}?#{ret.split('?')[-1]}\"\n end\n end",
"def next_url(page_number)\n onliner_url.gsub(/page=\\d{1,}/, \"page=#{page_number + 1}\")\n end",
"def next\n perform_request(next_page_uri) if next?\n end",
"def next_page\n pagination_adapter.next_page\n end",
"def next_page(extra_params = {})\n base, args = next_page_params\n base ? @api.get_page([base, args.merge(extra_params)]) : nil\n end",
"def next_page!\n page = @doc.css(\".paginator span.pagination_current\").first\n @next_page = page.next_element[\"href\"] if page\n on_url(@next_page) if @next_page\n end",
"def next_page\n # The only difference from the default here is we renamed the link to \"More\"\n # and added a custom class, twitter_pagination\n previous_or_next_page(@collection.next_page, '<div class=\"hover-move\"><img src=\"assets/next.png\" alt=\"next\"/></div><img src=\"assets/barre.png\"/>', 'next_pagination') if @collection.next_page\n end",
"def url_for_pagination(page, path = request.path, q = request.query_string)\n # Remove any current reference to page in the query string\n q = q.to_s.gsub(/page=(-?[\\d]+)(&?)/, '')\n # Assemble new link\n link = \"#{path}?page=#{page}&#{q}\"\n link = link[0..-2] if link[-1..-1] == '&' # Strip trailing ampersand\n link\n end",
"def parse\n super\n if next_page_url\n @doc = get_document(URI(next_page_url))\n self.parse\n end\n self\n end",
"def page_url\n page_value = @current_page == 1 ? 0 : @current_page\n \"#{URL}?page=#{page_value}\"\n end",
"def next_page(params = nil)\n perform_request(@next_page_link)\n end",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(url)\n next_link = page.xpath(\".//a[@title='Go to next page']\")\n puts next_link\n if next_link && next_link[0]\n puts next_link[0]['href']\n next_url = BASE_URL + next_link[0]['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(url)\n next_link = page.xpath(\".//a[@title='Go to next page']\")\n puts next_link\n if next_link && next_link[0]\n puts next_link[0]['href']\n next_url = BASE_URL + next_link[0]['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def base_url_for(page)\n \"#{request.path}#{model.framework.prefix}/#{page}\"\n end",
"def set_base_url\n uri = URI.parse(@page_url)\n @base_url = \"#{uri.scheme}://#{uri.host}\"\n end",
"def link_to_next_page(page)\n a = page.search(PAGER_NEXT_SELECTOR).first\n return unless a\n path = a.attribute('href').value.strip\n URI.join(WEBSITE_URL, path).to_s\n end",
"def next_page\n url = @entity[:next]\n return unless url\n\n query = URI.decode_www_form(URI(url).query).to_h\n query = query.to_h { |k, v| [k.to_sym, v] }\n self.class.list(**query)\n end",
"def rel_next_href_params(records, original_params = original_request_params.clone)\n @rel_next_href_params ||= records.is_a?(WillPaginate::Collection) && records.next_page ?\n original_params.merge({ :page => records.next_page }) : nil\n end",
"def next_page\n @page.link_with(:text => /Next/)\n end",
"def pagy_url_for(n)\n url = File.join(request.script_name.to_s, request.path_info)\n params = request.GET.merge('page' => n.to_s)\n url << '?' << Rack::Utils.build_nested_query(params)\n end",
"def updateNextURI\n # Parse next result page link from the currently marked one\n nextPagePath = @currentPage.at_css(\"table#nav tr td.cur\").next_sibling().at_css(\"a\")['href']\n\n # Construct the URI\n @nextURI = \"https://www.google.com\" + nextPagePath\n end",
"def next; pager.page(page + 1); end",
"def next\n return nil unless has_next?\n perform_request(next_page_uri)\n end",
"def paginate_path(site, num_page); end",
"def next_page\n @links['next']\n end",
"def next_page\n string = QJ.next_string()\n url = BSU + string\n BR.goto(url)\nend",
"def next_page\n\t\t\tFeed.parse_url(next_page_url,@browser)\n\t\tend",
"def get_next_page_url(first_page_doc)\n first_page_doc.css('span.paging:first-of-type a:last-of-type').first['href']\nend",
"def next_page\n sync.get(next_page_url) if next_page?\n end",
"def get_next_page\n nextlink = @doc.search(\"//p[@class='nextprev']/a[@rel='nofollow next']\")\n nextlink.map! { |link| \"#{link['href']}\" }\n stringlink = nextlink[0]\n @doc = open(stringlink) { |f| Hpricot(f) }\n get_links\n end",
"def get_paginated_urls(doc)\n doc.xpath(\"//div[@class='k2Pagination initialPagination']\").first.content =~ /\\d+ of (\\d+)/\n last_page_number = $1.to_i\n (1..last_page_number).map do |n|\n \"https://www.strayrescue.org/animals-for-adoption/page-#{n}\"\n end\n end",
"def set_next_page(node)\n @next_page = node.attributes[:href]\n end",
"def next_page!\n unless next_page?\n @page = nil\n return @page\n end\n\n next_request = @request.dup\n next_request.page_token = @page.next_page_token\n\n @response = @service_stub.send @method_name, next_request, @options\n @page = Page.new @response, @resource_field_name, format_resource: @format_resource\n end",
"def pages_url\n return @pages_url\n end",
"def page_url(page)\n \"#{request.path}?page=#{page}\"\n end",
"def next_page?\n # rubocop:disable Style/DoubleNegation\n !!next_page_url\n # rubocop:enable Style/DoubleNegation\n end",
"def next_page\n @page = info(@page[:next_page])\n end",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(page)\n next_link = page.at_css('a.next')\n if next_link \n p next_link\n next_url = BASE_URL + next_link['href']\n p next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(page)\n next_link = page.at_css('a.next')\n if next_link \n p next_link\n next_url = BASE_URL + next_link['href']\n p next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def next_page\n return nil if @query_str_next_page.empty?\n @url_str = next_url_str\n @page = InWebPage.new(@url_str)\n @page_count += 1\n\n # Prepare for getting the page which follows.\n @doc = REXML::Document.new(@page.to_s)\n @query_str_next_page = ''\n @doc.root.elements.each(XPATH_NEXT_PAGE){|e| @query_str_next_page = \"resumptionToken=#{e.text}\"}\n true\n end",
"def prev_page_url\n if @page <= 2\n request.path\n else\n \"#{request.path}?page=#{@page - 1}\"\n end\n end",
"def paginable_base_url_with_query_params(page: 1, **stringify_query_params_options)\n base_url = paginable_base_url(page)\n stringified_query_params = stringify_query_params(stringify_query_params_options)\n if stringified_query_params.present?\n return \"#{base_url}?#{stringified_query_params}\"\n end\n return base_url\n end",
"def extract_next_page(pagination)\n return nil if pagination[:next].nil?\n\n CGI.parse(URI.parse(pagination[:next]).query)[\"page\"].first\n rescue\n nil\n end",
"def pagination\n [ :next_page ]\n end",
"def get_next_page(page)\n # Todo: Put your code here to get the next page to be scraped\n if has_next_page(page)\n next_page_condition = page.at('input[id$=nextPageHyperLink]')\n link = get_next_url()\n \n page = @agent.get(link)\n return page\n else\n return nil\n end\nend",
"def get_next_page(page)\n # Todo: Put your code here to get the next page to be scraped\n if has_next_page(page)\n next_page_condition = page.at('input[id$=nextPageHyperLink]')\n link = get_next_url()\n \n page = @agent.get(link)\n return page\n else\n return nil\n end\nend",
"def get_next_page\n response = @next_method.call(@next_link).value! unless @next_method.nil?\n unless response.nil?\n @next_link = response.body.next_link\n @value = response.body.value\n self\n end\n end",
"def next\n @links.key?(:next) ? Page.new(@links[:next], {}, @headers) : nil\n end",
"def pages_url=(value)\n @pages_url = value\n end",
"def next_page\n @client.get(@raw_page['nextRecordsUrl']).body if has_next_page?\n end",
"def next_link_for(records)\n page_link(records, page: 'next')\n end",
"def jsonapi_pagination(resources)\n links = { self: request.base_url + request.fullpath }\n pagination = jsonapi_pagination_meta(resources)\n\n return links if pagination.blank?\n\n original_params = params.except(\n *jsonapi_path_parameters.keys.map(&:to_s)\n ).as_json.with_indifferent_access\n\n original_params[:page] = original_params[:page].dup || {}\n original_url = request.base_url + request.path + '?'\n\n pagination.each do |page_name, number|\n next if page_name == :records\n\n original_params[:page][:number] = number\n links[page_name] = original_url + CGI.unescape(\n original_params.to_query\n )\n end\n\n links\n end",
"def base_url_path=(_arg0); end",
"def next_page!\n next_page.tap { |page| update_self(page) }\n end",
"def redirect_url\n if @next_url.present?\n @next_url = CGI.unescape(@next_url)\n @next_url = nil if !ValidateLink.is_valid_redirect_path?(@next_url)\n end\n\n if !@has_valid_mfa_session\n next_url_param = @next_url.present? ? \"?next=#{CGI.escape @next_url}\" : \"\"\n GlobalConstant::WebUrls.multifactor_auth + next_url_param\n else\n @admin.has_accepted_terms_of_use? ? get_application_url : GlobalConstant::WebUrls.terms_and_conditions\n end\n end",
"def base_url_path; end",
"def paged_api_request(url, pages = config(:mirror_history_pages_back),\n last = nil)\n\n url = ensure_max_per_page(url)\n data = api_request_raw(url)\n\n return [] if data.nil?\n\n unless data.meta['link'].nil?\n links = parse_links(data.meta['link'])\n last = links['last'] if last.nil?\n\n if pages > 0\n pages = pages - 1\n if pages == 0\n return parse_request_result(data)\n end\n end\n\n if links['next'].nil?\n parse_request_result(data)\n else\n parse_request_result(data) | paged_api_request(links['next'], pages, last)\n end\n else\n parse_request_result(data)\n end\n end",
"def pagy_link_proc(pagy, link_extra: '')\n p_prev = pagy.prev\n p_next = pagy.next\n left, right = %(<a href=\"#{pagy_url_for(pagy, PAGE_PLACEHOLDER, html_escaped: true)}\" #{\n pagy.vars[:link_extra]} #{link_extra}).split(PAGE_PLACEHOLDER, 2)\n lambda do |page, text = pagy.label_for(page), extra_attrs = ''|\n %(#{left}#{page}#{right}#{ case page\n when p_prev then ' rel=\"prev\"'\n when p_next then ' rel=\"next\"'\n else ''\n end } #{extra_attrs}>#{text}</a>)\n end\n end",
"def get_next_page(page)\n\n # Todo: Put your code here to get the next page to be scraped\n\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\n\n if !next_page_condition.empty? \n\n link = get_next_url()\n\n page = @agent.get(link)\n\n return page\n\n else\n\n return nil\n\n end\n\nend",
"def get_next_page(page)\n\n # Todo: Put your code here to get the next page to be scraped\n\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\n\n if !next_page_condition.empty? \n\n link = get_next_url()\n\n page = @agent.get(link)\n\n return page\n\n else\n\n return nil\n\n end\n\nend",
"def base_url\n return url\n end",
"def initialize(response)\n return super unless response\n \n super(response['data'])\n paging = response['paging'] || {}\n self.next_url = paging['next']\n self.previous_url = paging['previous']\n end",
"def next_page\n next_page? ? updated_collection(next_page_params.merge(from: from)) : self\n end",
"def base_url\n base_href || url\n end",
"def next_page\n go_to_page(@current_page+1)\n end",
"def next_page\n return unless @next_page\n \"<a class='btn' href=\\\"#{modify_page(1)}\\\">Next Page</a>\"\n end",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n end",
"def next_link_tag(url, options={})\n tag :link, { :rel => 'next', :href => url }.merge(options)\n end",
"def next_page\n return nil unless paginated?\n return nil unless (total_pages - current_page) > 0\n request_with(page: current_page + 1)\n end",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend",
"def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend",
"def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend",
"def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend",
"def next_page\n current_page < total_pages ? (current_page + 1) : nil\n end",
"def next_page\n current_page < total_pages ? (current_page + 1) : nil\n end"
] | [
"0.7240253",
"0.72379565",
"0.71005315",
"0.6989908",
"0.6839695",
"0.674903",
"0.66792136",
"0.6646795",
"0.6597067",
"0.6586699",
"0.6576461",
"0.6576461",
"0.65652233",
"0.65496325",
"0.65496325",
"0.6504919",
"0.6459087",
"0.6459087",
"0.6455604",
"0.6445155",
"0.6340858",
"0.63215375",
"0.63194704",
"0.6291469",
"0.6264292",
"0.62584305",
"0.6257434",
"0.6207741",
"0.6199298",
"0.6199298",
"0.6197708",
"0.61894065",
"0.6159371",
"0.61036223",
"0.6094035",
"0.608728",
"0.6084256",
"0.60793394",
"0.60732216",
"0.6057251",
"0.6046989",
"0.60463494",
"0.60420346",
"0.60160226",
"0.59781665",
"0.59670234",
"0.5954257",
"0.59201634",
"0.58988935",
"0.5879481",
"0.58447564",
"0.58278763",
"0.5803063",
"0.5795406",
"0.5789508",
"0.5789508",
"0.5775726",
"0.57658064",
"0.57496387",
"0.5744644",
"0.57384914",
"0.57366836",
"0.57366836",
"0.5727498",
"0.5726186",
"0.570497",
"0.57001776",
"0.56912553",
"0.5689875",
"0.5687378",
"0.56836665",
"0.5655335",
"0.56485254",
"0.5645496",
"0.56449133",
"0.5636324",
"0.5636324",
"0.56336904",
"0.56292653",
"0.56247467",
"0.5616478",
"0.56104875",
"0.560345",
"0.56006736",
"0.56006736",
"0.56006736",
"0.56006736",
"0.5582258",
"0.55802625",
"0.557454",
"0.55719614",
"0.5571762",
"0.5571762",
"0.5571762",
"0.5571762",
"0.5570361",
"0.5570361",
"0.5570361",
"0.5564847",
"0.5564847"
] | 0.73391056 | 0 |
Check for valid request token and return user | def authorize_request
@current_user = (AUTHORIZER.new(request.headers).call)[:user]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_authentication_token\n \n @user = User.find_by_services_authentification_token(params[:auth_token])\n bad_request if @user.nil?\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n \n unless user\n render json: { errors: 'user must signed in' }, status: :unprocessable_entity\n end\n end",
"def verify_auth_token\n halt 401 unless valid_user?(extracted_token)\n end",
"def authenticate_user_from_token\n unless authenticate_with_http_token { |token, options| User.find_by(auth_token: token) }\n render json: { error: 'Bad Token'}, status: 401\n end\n end",
"def verify_auth_token\n token = params[:auth_token]\n if token.nil?\n render_json_response(400, \"Authorization token needed\")\n return\n end\n\n user = User.find_by_authentication_token(token)\n if user.nil?\n render_json_response(401, \"Bad token\")\n return\n end\n\n @user = user\n end",
"def authenticate_user\n @token = Token.find_by(auth_token: request.headers['HTTP_AUTH_TOKEN'])\n return render json: { message: 'token invalid' }, status: 422 unless @token\n\n @current_user = @token.user\n end",
"def check_authenticate_user\n if request.headers[:token].present?\n @auth_token = AuthToken.find_by(token: request.headers[:token])\n @current_user = auth_token.user if @auth_token.present?\n unless @auth_token && @current_user\n error_response_with_obj(HTTP_UNAUTHORIZED[:code], \"Invalid Authentication token\")\n end\n else\n error_response_with_obj(HTTP_UNAUTHORIZED[:code], \"Invalid Authentication token\")\n end\n end",
"def authenticate_user_from_token!\n\t\t@api_token = ApiToken.find_by_token(params[:token])\n @user = @api_token.try(:user)\n if @user.nil?\n render json: { error: 'Not authorized' }, status: 401\n end\n end",
"def validate_token\n token = params[:token]\n return false if token.nil?\n \n user = User.validate_token(token)\n return false if user.nil?\n \n login_user(user)\n return true\n end",
"def user\n @user ||= User.find(decoded_auth_token[:user_id]) if decoded_auth_token\n @user || errors.add(:token, 'Invalid Token') && nil\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n # else\n # authentication_error\n end\n end",
"def token_verify\r\n\r\n #render json: {id: params[\"user\"][\"id\"], params: params}\r\n \r\n user_tmp = User.find(params[:id])\r\n if user_tmp.authentication_token == params[:authentication_token]\r\n $granted = true\r\n render json: false\r\n else\r\n \r\n render json: false\r\n end\r\n end",
"def check_authentication\n @token = request.headers[:token]\n @user = Usuario.find_by_token(@token) \n if @user ==nil\n json_response={\n error: 'authentication error'\n }\n respond_with json_response, location: nil\n end \n \n end",
"def get_token\n # Get the user by email\n user = User.find_by_email(params[:email])\n \n # return unauthorized if the user was not found\n if !user \n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if the user is not authenticated via the authenticate method\n # then return unauthorized\n if !user.authenticate( params[:password] )\n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if our code gets here, we can generate a token and response.\n # JWT's include an expiry, we will expire the token in 24 hours\n token = jwt_encode({user_id: user.id}, 24.hours.from_now)\n render json: {token: token, exp: 24, username: user.email, userId: user.id},\n status: :ok\n \n end",
"def fetch_user_from_auth_token\n @user = decode_auth_token ? User.find(decode_auth_token['user_id']) : nil\n errors.add(:token, 'invalid token') if @user.nil?\n @user\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authenticate_error\n end\n end",
"def authenticate_user_from_token!\n # user_id = params[:user_id].presence\n # user = user_id && User.find(user_id)\n # api_token = params[:api_token] || env['HTTP_API_TOKEN']\n # if user && Devise.secure_compare(user.api_token, api_token)\n # sign_in user, store: false and return\n # end\n\n # render_error({ :error => \"Please sign in first.\" })\n end",
"def authenticate_request!\n\t\t# unless is if in reverse. If user_id_in_token == false then render error\n\t unless user_id_in_token?\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\t return\n\t end\n\t @current_user = User.find(auth_token[:user_id])\n\trescue JWT::VerificationError, JWT::DecodeError\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\tend",
"def authenticate_user_from_token\n unless authenticate_with_http_token { |token, options| User.find_by(api_token: token) }\n render json: { error: 'Bad Token'}, status: 401\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end",
"def check_token\n @usuario = Credentials.check_token(authorization: request.headers[\"Authorization\"])\n end",
"def verify_jwt_token\n begin\n if request.format.json?\n token = request.headers['Authorization'].split(' ').last\n decoded_token = JWT.decode token, nil, false\n @current_user = User.find(decoded_token[0][\"user_id\"])\n head :unauthorized if request.headers['Authorization'].nil? || !AuthToken.valid?(token)\n else\n authenticate_user!\n end\n rescue => exception\n head :unauthorized \n end\n end",
"def verify_token\n associate = Associate.where(id: params[:associate_id])[0] if params[:associate_id]\n #checking signed_in user\n if user_signed_in?\n #checking token is nil or not.\n if params[:token].nil?\n #response in json format\n render :json=> { success: false, message: \"Token is required to proceed further.\" },:status=> 203\n return\n elsif associate && associate.associate_user == true\n return true\n #checking token with the current_user\n elsif current_user.authentication_token != params[:token]\n render :json=> { success: false, message: \"Problem with the authentication token.please check token.\" },:status=> 203\n return\n else\n end\n end\n end",
"def check_token\n input_token = request.headers['X-Auth-Token'] || params[:token]\n return unless input_token\n\n token = AuthenticationToken.find_by(token: input_token)\n return unless token\n\n # Count token usage\n token.inc(number_of_use: 1)\n # Update the updated_at because inc doesn't do it\n token.set(updated_at: Time.now.getlocal)\n\n # Sign in\n sign_in token.user\n end",
"def authenticate_user_from_token\n authenticate_with_http_token do |token, options|\n user_email = options[:email]\n user_email && User.where(email: user_email, authentication_token: token).first\n end\n end",
"def verify_token\n token ||= request.env['HTTP_AUTHORIZATION']\n if token.nil?\n error 401, { :error => 'Unauthorized.' }.to_json\n else\n token = token.split(' ').last unless token.nil?\n begin\n @user = verify(token)\n rescue JWT::ExpiredSignature\n error 401, { :error => 'Expired token.' }.to_json\n end\n end\n 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 send_token_for_valid_login_of(user)\n\t\trender json: {token: user.auth_token }\n\tend",
"def valid_token\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['valid_token']) do\n if ![\"facebook\"].include?(params[:provider]) # using include? allows us to do this for twitter/tumblr in the future\n return render_error(404, \"this route only currently supports facebook as a provider.\")\n end\n\n if auth = current_user.first_provider(params[:provider]) and auth.is_a? Authentication\n @token_valid = GT::UserFacebookManager.verify_auth(auth.oauth_token)\n @status = 200\n else\n return render_error(404, \"This user does not have a #{params[:provider]} authentication to check on\")\n end\n end\n end",
"def authenticate\n authenticate_or_request_with_http_token do |token _options|\n @current_user = User.find_by token: token\n end\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n if user_token\n user = User.where(authentication_token: user_token.to_s).first\n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n else\n render status: 401, json: {success: false, error: \"invalid token\" }\n end\n end\n end",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def verify_access_token\n user = User.find_by(access_token: params[:session][:access_token])\n if user\n render json: user, status: :ok\n else\n render json: 'Token failed verification', status: :unprocessable_entity\n end\n end",
"def verify_access_token\n debugger\n @user = User.find_by(access_token: params[:session][:access_token])\n if @user\n render text: \"verified\", status: 200\n else\n render text: \"Token failed verification\", status: 422\n end\n end",
"def valid_user(user_id)!\n user = User.find(user_id)\n if user\n p \"valid user!!!!!!!!!\"\n if user_id && params[:token] == user.token\n @current_user = user\n @verified_request = true\n p \"valid request!\"\n else\n p \"Salted Token Error\"\n render :json => { :success => false, :message => 'Salted Token Error' }, :status => 401\n end\n else\n p \"user not found :( \"\n #TODO: Hide this error in the future\n render :json => { :success => false, :message => 'User not found!' }, :status => 404\n end\n end",
"def authenticate_user (temp = false)\r\n token = request.headers['token']\r\n user_token = Token.find_by(access_token: token)\r\n @current_user = nil\r\n if params[:hashtoken].present?\r\n if params[:id].present?\r\n hash_token = TokenEventInvite.where(access_token: params[:hashtoken], event_id: params[:id].to_i).first\r\n if hash_token.present?\r\n user_id = hash_token.user_id\r\n @current_user = User.find_by(id: user_id)\r\n else\r\n @current_user = authenticate_old_event( params[:hashtoken], params[:id].to_i)\r\n end\r\n else\r\n hash_token = TokenUserConfirmation.where(access_token: params[:hashtoken]).first ||\r\n TokenPasswordReset.where(access_token: params[:hashtoken]).first\r\n if hash_token != nil\r\n user_id = hash_token.user_id\r\n @current_user = User.find_by(id: user_id)\r\n else\r\n render json: ErrorResponse.new(\r\n code: 401, message: 'Missing token. Authorization has been denied for this request.'\r\n ), adapter: :json, status: :unauthorized unless temp\r\n return nil\r\n end\r\n end\r\n elsif user_token.present?\r\n user_id = user_token.user_id\r\n @current_user = User.find_by(id: user_id)\r\n if @current_user.present? && request.path.include?(\"/ambassador/\")\r\n @current_user = @current_user.admin.present? ? @current_user.admin : @current_user.av_user\r\n end\r\n else\r\n if token.present?\r\n @current_user = authenticate_old( token)\r\n if @current_user.present?\r\n if @current_user.present? && request.path.include?(\"/ambassador/\")\r\n @current_user = @current_user.admin.present? ? @current_user.admin : @current_user.av_user\r\n end\r\n return nil\r\n else\r\n render json: ErrorResponse.new(\r\n code: 401, message: 'User not found. Authorization has been denied for this request.'\r\n ), adapter: :json, status: :unauthorized unless temp\r\n return nil\r\n end\r\n end\r\n render json: ErrorResponse.new(\r\n code: 401, message: 'Missing token. Authorization has been denied for this request.'\r\n ), adapter: :json, status: :unauthorized unless temp\r\n return nil\r\n end\r\n if @current_user.blank?\r\n render json: ErrorResponse.new(\r\n code: 401, message: 'Bad Request: User not found'\r\n ), adapter: :json, status: :unauthorized unless temp\r\n nil\r\n end\r\n end",
"def authenticate_user\n if not params.has_key?(:auth_token)\n failure\n return\n end\n @current_user = User.find_by_authentication_token(params[:auth_token])\n # Adding the conditional to throw json error\n unless @current_user\n failure\n end\n end",
"def verify_access_token\n \tuser = User.find_by(auth_token: params[:session][:auth_token])\n\n \tif user\n \t\trender text: \"verified\", status: 200\n \telse\n \t\trender text: \"Invalid token\", status: 422\n \tend\n end",
"def check_session_create\n if params[:user][:token].present?\n @user = User.find_by_authentication_token(params[:user][:token])\n if @user.blank?\n render :json => {:success => \"false\", :errors => \"authentication failed\"}\n return\n end\n else\n render :json => {:success => \"false\", :errors => \"authentication failed\"}\n end\n end",
"def current_user\n if decode_token\n #returns an array\n #user_id is the key on our payload\n user_id = decode_token[0]['user_id']\n #using user_id to find our user\n @user = User.find_by(id: user_id)\n else\n render json: { message: 'Did not find user.' }, status: :unauthorized \n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n user = User.find_by(access_token: auth_token)\n\n fail AccessDenied unless user\n\n @current_user = user\n end",
"def show\n if User.find_by_authentication_token(params[:Token])\n @user = User.find_by_authentication_token(params[:Token])\n batsd_log_success\n elsif !params[:Token]\n batsd_log_error(:type => :auth)\n respond_error(\"No token supplied.\")\n else\n batsd_log_error(:type => :auth)\n respond_error(\"Invalid API key.\")\n end \n end",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def authorize_request\n\t\tauthenticate_with_http_token do |token, options|\n\t\t\tUser.find_by(token: token)\n\t\tend\n\tend",
"def verify\n token = params[:token]\n @user = User.verify token\n if @user\n render json: {\n data: {\n token: @user.token,\n user: @user,\n },\n }\n else\n render json: {message: error_messages[:incorrect_verification_token]},\n status: :unprocessable_entity\n end\n end",
"def request_token\n @token = current_client_application.create_request_token\n if @token\n render :text => @token.to_query\n else\n render :nothing => true, :status => 401\n end\n end",
"def token_auth\n user = User.find_by_login_and_single_access_token(params[:login], params[:token])\n respond_to do |format|\n if user\n format.xml { render :xml => \"ok\" }\n else\n format.xml { render :xml => \"fail\" }\n end\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n client_id = request.headers['Client-ID']\n\n if auth_token\n authenticate_with_auth_token(auth_token, client_id)\n else\n authentication_error\n end\n end",
"def require_token_or_user\n if params[:token].present? && params[:salt].present?\n require_token\n else\n require_user\n end\n end",
"def restrict_access\n authenticate_or_request_with_http_token do |token, options|\n if User.exists?(token: token)\n @currentUser = User.find_by_token(token)\n end\n end\n end",
"def authorize_request\n authenticate_with_http_token do |token, option|\n User.find_by(token: token)\n end\n end",
"def authenticated_user_with_token\n ApiKey.find_user_with_token(decoded_token)\n end",
"def check_auth_token\n token = decoded_auth_token\n render json: { error: 'Not Authorized' }, status: :unauthorized unless token\n end",
"def authorize_request\n authenticate_with_http_token do |token, options|\n User.find_by(token: token)\n end\n end",
"def validation_login\n validate_token User, params[:token]\n end",
"def request_token\n @token=current_client_application.create_request_token\n if @token\n render :text=>@token.to_query\n else\n render :nothing => true, :status => 401\n end\n end",
"def verify_access_token\n auth_token = request.headers['Authorization']\n user_id = auth_token.split(':').first\n \n if user_id == params[:id]\n @user = User.find(user_id)\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: { error: I18n.t('unauthorized') }, status: 401\n end\n end",
"def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end",
"def authenticate_with_token\n # get the token from the header\n # get the token from the post body\n # get the token from json post\n \n token = request.headers[\"HTTP_AUTHORIZATION\"]\n \n if (!token)\n if (not_protected self.controller_name, self.action_name)\n return nil\n end\n\n redirect_to controller: 'application', action: 'index' \n end\n\n #@user = get_user_by_token(token)\n end",
"def validate_token\n token = params[:token]\n return false if token.nil?\n \n user = User.validate_token(token)\n return false if user.nil?\n \n login_user(user)\n return true\n end",
"def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end",
"def authenticate_user_from_token!\n raise AuthorizationError unless http_auth_token.present?\n result = find_user\n raise BadRequestError, result.errors if result.failure?\n @current_user = result.current_user\n end",
"def authenticate_user\n authenticate_or_request_with_http_token do |token, options|\n @user = User.find_by_auth_key(token)\n head :unauthorized unless @user\n return\n end\n end",
"def user \n @user ||= User.find(decoded_token[:user_id]) if decoded_token\n rescue ActiveRecord::RecordNotFound => e \n raise (ExceptionHandler::InvalidToken, e.message)\n end",
"def get_current_user\n return if !bearer_token\n decoded_jwt = decode_token(bearer_token)\n User.find(decoded_jwt[0][\"user\"][\"id\"])\n end",
"def autenticate_user\n auth_token = request.headers[:HTTP_AUTH_TOKEN] #auth_token in header\n return render_message ({status:ERR_STATUS, responseMessage: \"Sorry! You are not an authenticated user.\",responseCode: ERROR}) unless auth_token\n @user = User.find_by(auth_token: auth_token)\n unless @user\n return render_message({status:ERR_STATUS,responseMessage: UNAUTHORIZED_MESSAGE,responseCode: UNAUTHORIZED})\n end\n end",
"def verify_token\n check_auth_token(request.headers['authtoken'],params[:profile_id])\n end",
"def user\n # find a User matching the decoded token if the decode operation was successfull\n user = User.find(decoded_auth_token[:user_id]) if decoded_auth_token\n\n if user\n # return the user if active\n return user if user.active\n\n # Else raise a JWTException Inactive Account\n raise(API::JWTExceptionHandler::InactiveAccount, APIMessages.account_not_active)\n end\n rescue ActiveRecord::RecordNotFound => e\n # Raise an Invalid Token if there is no matching User from db\n raise(API::JWTExceptionHandler::InvalidToken, (\"#{APIMessages.invalid_token} #{e.message}\"))\n end",
"def authorize_request\n authenticate_with_http_token do |token, options|\n User.find_by(token: token)\n end\n end",
"def current_user\n authenticate_token\n end",
"def authenticate_request!\n fail NotAuthenticatedError unless user_id_included_in_auth_token?\n @current_user = User.find(decoded_auth_token[:user_id] || decoded_auth_token[:id])\n fail NotAuthenticated if @current_user.blank?\n rescue JWT::ExpiredSignature, JWT::ImmatureSignature\n raise AuthenticationTimeoutError\n rescue JWT::VerificationError, JWT::DecodeError, ActiveRecord::RecordNotFound\n raise NotAuthenticatedError\n end",
"def authenticate_token!\n return render_error(\"Problem with Authentication Token\",401, 401) unless Token.find_by(access_token: params[:access_token])\n end",
"def valid_token\n return access_token if access_token && !expiring?\n return access_token if request_access_token\n raise 'No valid access token.'\n end",
"def authorize\n @user = User.find_by_id_and_multitrack_token(params[:user_id], params[:token])\n head(@user ? :ok : :forbidden)\n end",
"def token\n authenticated\n end",
"def auth_token\n return token if token.present?\n\n false\n # raise(CustomException::MissingToken, 'token is missing')\n end",
"def validate_token\n return true if @current_username\n token = get_token\n token.force_encoding('utf-8') if token\n token_object = AccessToken.find_by_token(token)\n if token_object && token_object.validated?\n @current_username = token_object.username\n return true\n else\n return false\n end\n end",
"def authenticate\n \t# get token from header\n \tauthentication_token = request.headers['token']\n \t@user = User.find_by_authentication_token authentication_token if authentication_token\n \t\n \tunless @user\n \t\trender json: {success: false, message: I18n.t('unauthorized'), data: {}}, status: :unauthorized\n \t\treturn false\n \tend\n end",
"def require_access_token\n # make sure the request has been signed correctly\n verify_signature\n \n # NOTE make sure you define Controller#find_token which\n # returns an object that responds to the access_token? message\n # access_token? should return true if the token object is an AccessToken\n # it should return false if the token object is a RequestToken\n if !current_token.access_token?\n throw :halt, render(invalid_access_token_message, :status => 401, :layout => false)\n end\n end",
"def user_present?\n user_token_present? && User.find_by(auth_token: user_token)\n end",
"def authenticate_token\n render_401 if @token.blank? || !@token.active?\n end",
"def authenticate!\n client_id = params[:client_id] || params[:query][:client_id] rescue nil\n token = params[:token] || params[:query][:token] rescue nil\n user = User.get_user(client_id, token)\n unless user\n render json: { 'errors' => ['Authorized users only.'] }, status: 401\n end\n user\n end",
"def get_user_by_token(token)\n decoded = JWT.decode(token, 'somesecrethere')\n now = Time.now().to_i\n\n if (decoded[0][:expires] < now)\n return nil\n end\n\n user = User.find_by uuid: decoded[0][:user_id]\n if (!user)\n return nil\n end\n\n return user\n end",
"def token_or_current_or_guest_user\n token_user || current_or_guest_user\n end",
"def authenticate_token \n\t\tauthenticate_with_http_token do | token, options| \n\t\t\tUser.find_by(auth_token: token)\n\t\tend\n\tend",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n \n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def current_user\n token_locations = [cookies[:auth_token], ENV['DANGEROUS_AUTH_HACK'], params[:auth_token]]\n token = token_locations.find{|x| !x.blank? }\n if token\n Identity.includes(:person).find_by(token: token).try(:person)\n else\n nil\n end\n end",
"def call\n fetch_user_from_auth_token\n end",
"def authenticated_user\n return render_error(2, 'Invalid auth token') if logged_device.nil?\n logged_device\n end",
"def get_user_info\n userTokenInfo = request.env['oauth.token']\n @user = userTokenInfo.user\n end",
"def token_verification\n user = User.with_reset_password_token(params[:user][:reset_password_token])\n if user && user.email == params[:user][:email] && user.reset_password_period_valid?\n render_success_response({},\"Token is valid\")\n else\n json_response({\n success: false,\n message: \"Invalid Token\"\n }, 400)\n end\n end",
"def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end",
"def processToken(token, context=nil)\n if token.nil? or token.empty?\n debug(\"Error: processToken: Null/empty token.\")\n return\n end\n stoken = decodeToken token\n stoken = validateToken stoken\n stoken = parse stoken\n unless stoken\n debug(\"Error: processToken: Failed to decode/validate token: #{token}\")\n return\n end\n sappid = stoken['appid']\n unless sappid == appid\n debug(\"Error: processToken: Application ID in token did not match ours: #{sappid}, #{appid}\")\n return\n end\n begin\n user = User.new(stoken['ts'], stoken['uid'], stoken['flags'], \n context, token)\n return user\n rescue Exception => e\n debug(\"Error: processToken: Contents of token considered invalid: #{e}\")\n return\n end\n end",
"def verify_jwt_token\n # token = request.headers['HB-UserToken']\n # if not token\n # render :status => 401, :json => {:message => \"User token required\"}\n # return\n # end\n \n #begin\n # jwt = JWT.decode(token, JWT_SECRET)\n #rescue JWT::DecodeError\n # render :status => :unauthorized, :json => {:message => \"Invalid token\"}\n # return\n #end\n \n #@current_user = User.find_by_authentication_token(jwt[0][\"user_token\"])\n @current_user = User.find_by_email('mercury.solar02@gmail.com')\n #if not @current_user\n # render :status => 401, :json => {:message => \"Invalid user token\"}\n # return\n #end\n \n @ability = Ability.new(@current_user)\n \n end",
"def current_user\n puts decoded_token\n \n if decoded_token\n # user_id = User.find_by(id: user_id)\n User.find_by(id: decoded_token[0][\"user_id\"])\n\n end\n end",
"def authenticate_request!\n payload, header = JsonWebToken.verify(http_token)\n header if false # Commeent this line\n @requested_user = {\n email: payload['https://sassbox.com/email'],\n first_name: payload['https://sassbox.com/first_name'],\n last_name: payload['https://sassbox.com/last_name']\n }\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end",
"def get_user_id_from_token\n if request.headers['Authorization'].present?\n @token = request.headers['Authorization'].split(' ').last\n @payload ||= AuthToken.decode(@token)\n if @payload && @payload[:user_id]\n return @payload[:user_id]\n end\n end\n return nil\n end",
"def get_user_by_auth_token\n user = UserSession.find_by_auth_token!(params[:auth_token]).user\n\n json_response 200,\n success: true,\n message_id: 'ok',\n message: I18n.t('success.ok'),\n data: {\n user: user.slice(:id, :username)\n }\n end",
"def sign_in\n @user = User.find_by_email(params[:auth][:email])\n if @user && @user.authenticate(params[:auth][:password])\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token, moderator: !!@user.moderator }, status: 200\n else \n render json: { error: 'incorrect details entered' }, status: 404\n end\nend",
"def authenticate_or_use_token\n if params[:token].blank?\n return current_account.users.authenticate(params[:login], params[:password])\n else\n return current_account.users.first(:conditions => { :admin_login_token => params[:token] })\n end\n end"
] | [
"0.7766165",
"0.76144505",
"0.74394107",
"0.740302",
"0.7395052",
"0.7388174",
"0.73447704",
"0.7312916",
"0.7312101",
"0.72916806",
"0.7257882",
"0.7255303",
"0.7249056",
"0.7247693",
"0.7243509",
"0.71877116",
"0.7186487",
"0.7179645",
"0.71792054",
"0.7157877",
"0.7157877",
"0.71539414",
"0.71468544",
"0.71441865",
"0.7136026",
"0.71336985",
"0.7122014",
"0.71218145",
"0.71117896",
"0.7104935",
"0.7074102",
"0.7067928",
"0.70670044",
"0.7060363",
"0.7052657",
"0.70483273",
"0.70397973",
"0.703513",
"0.70253724",
"0.7024541",
"0.70137733",
"0.7002479",
"0.70024467",
"0.6997841",
"0.69908446",
"0.69893885",
"0.6986333",
"0.6986102",
"0.6985798",
"0.69786143",
"0.6977583",
"0.696892",
"0.6960694",
"0.6954493",
"0.695129",
"0.69448894",
"0.6943399",
"0.6939542",
"0.6938966",
"0.6937623",
"0.69320244",
"0.6915963",
"0.6907332",
"0.68668747",
"0.6864778",
"0.68614954",
"0.6858957",
"0.68570065",
"0.6848529",
"0.68371964",
"0.68348813",
"0.6834363",
"0.6827167",
"0.6818124",
"0.68134767",
"0.6787535",
"0.67798233",
"0.6770991",
"0.67668855",
"0.6754496",
"0.6751503",
"0.67477036",
"0.6742445",
"0.67407054",
"0.67367965",
"0.6733406",
"0.6730069",
"0.6715827",
"0.67144156",
"0.670597",
"0.6700602",
"0.66982085",
"0.66884637",
"0.6688297",
"0.6687684",
"0.66816336",
"0.6680309",
"0.6662608",
"0.66621095",
"0.6652161",
"0.6645836"
] | 0.0 | -1 |
transform to json format | def json
@@id += 1
"{" +
"\"type\": \"LEX_SELECT\", \"id\": \"S#{@@id}\", " +
"\"offset\": #{@offset}, \"length\": #{@length}, " +
"\"value\": [" + @candidates.map{|elem| elem.json}.join(",") +
"]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tojson\n\t\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n to_parsed.to_json\n end",
"def to_json\n to_h.to_json\n end",
"def to_json\n to_h.to_json\n end",
"def to_json\r\n to_hash.to_json\r\n end",
"def to_json\n # convert the result to JSON\n MultiJson.dump(to_hash)\n end",
"def to_json\n JSON.generate(to_h)\n end",
"def to_json\n\n end",
"def to_json\n to_a.to_json\n end",
"def to_json\n JSON(as_json)\n end",
"def to_json\n to_raw.to_json\n end",
"def to_json\n MultiJson.encode(to_hash)\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_json_object.to_json\n end",
"def to_json\n Oj.dump(to_hash)\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n JSON.generate to_hash\n end",
"def to_json\n to_s.to_json\n end",
"def to_json\n data.to_json\n end",
"def to_json\n Yajl::Encoder.encode(to_hash, :pretty => true)\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n return to_hash.to_json\n end",
"def as_json\n to_s.as_json\n end",
"def to_json\n return Json.dump(to_hash)\n end",
"def to_json\n self.to_h.to_json\n end",
"def conv_to_json\n {\n :id => self.id,\n :borough_id => self.borough_id,\n :business_quantity => self.business_quantity,\n :woman_quantity => self.woman_quantity,\n :people_quantity => self.people_quantity,\n :man_quantity => self.man_quantity,\n :woman_ceo_quantity => self.woman_ceo_quantity \n }\n end",
"def to_json\n MultiJson.encode(result)\n end",
"def to_json\n JSON.pretty_generate(to_hash)\n end",
"def to_json\n JSON.pretty_generate(to_h)\n end",
"def to_json\n operate\n end",
"def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end",
"def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end",
"def to_json\n Yajl::Encoder.encode(@raw_data)\n end",
"def to_json\n @values.inject({}) { |result, (k, v)| result.update(k => v.to_s) }\n end",
"def to_json\n @json.to_json\n end",
"def json\n @data.to_json\n end",
"def to_json\n @data.to_json\n end",
"def to_json\n i = 0\n datas = Array.new\n td = Array.new\n\n ds = @data\n ds.each_with_index do |row,index|\n data = \"{\"\n td.clear\n row.each_pair do |key,value|\n td.push(\"#{format(key)}: #{format(value)}\")\n end\n\n data +=td.join(\",\")\n data += \"}\"\n datas.push(data)\n end\n data = \"[#{datas.join(\",\")}]\"\n data\n end",
"def to_json\n self.to_hash.to_json\n end",
"def to_json\n JSON.generate(__to_json_map__)\n end",
"def to_json\n JSON.generate(__to_json_map__)\n end",
"def to_json\n JSON.generate(__to_json_map__)\n end",
"def to_json\n JSON.generate(__to_json_map__)\n end",
"def json_serialize\n end",
"def to_json\n @json ||= get_json\n end",
"def to_json(what)\n what.to_hash.to_json\n end",
"def to_json\n self.to_hash.to_json\n end",
"def to_json\n self.to_hash.to_json\n end",
"def to_json(*)\n #This is a stub, used for indexing\n end",
"def to_json\n object.to_json\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def to_json(_context = nil)\n to_h.to_json\n end",
"def toJson()\n json = { 'class' => self.class.to_s }\n json['id'] = @id ;\n json['index'] = @index ;\n json['allow'] = @allow ;\n json['disallow'] = @disallow ;\n json['speed'] = @speed ;\n json['length'] = @length ;\n json['originalId'] = @originalId ;\n\n json['shape'] = genShapeJson() ;\n\n return json ;\n end",
"def to_json\n\t\t\t{name: @name, ar_model: @ar_model.to_json, api_model: @api_model.to_json}\n\t\tend",
"def to_json_raw_object()\n #This is a stub, used for indexing\n end",
"def to_json\n return self.to_hash.to_json\n end",
"def to_json(*)\n\t\t\t# to_json needs to not care about arguments with the C extension\n\t\t\t# version of the JSON gem.\n\t\t\t# See json-1.5.1/ext/json/ext/generator/generator.c:902\n\t\t\tto_hash.to_json\n\t\tend",
"def to_json\n\t\tresult = {}\n\t\tself.filters.collect { |c| result[c[0].to_sym] = c[1] }\n\t\treturn result.to_json\n\tend",
"def to_json\n MultiJson.dump(raw)\n end",
"def to_json\n MultiJson.dump(raw)\n end",
"def to_json\n j = \"{\\n\"\n @data.each_pair {|k,v| j += \"#{k}:'#{v}'\\n\"}\n j += '}'\n end",
"def to_json\n io = StringIO.new << \"{\"\n\n io << JSON.create_id.to_json << \":\" << self.class.name.to_json << \",\"\n\n @data.each {|key, value|\n io << key.to_json.to_s << \":\" << value.to_json << \",\"\n }\n\n io.seek(-1, IO::SEEK_CUR)\n io << \"}\"\n\n io.string\n end",
"def serialize_to_json\n @data.to_json\n end",
"def as_json(*)\n {\n asiakasnro: asiakasnro,\n email: email,\n kieli: kieli,\n maa: maa,\n nimi: nimi,\n nimitark: nimitark,\n osoite: osoite,\n postino: postino,\n postitp: postitp,\n puhelin: puhelin,\n toim_maa: toim_maa,\n tunnus: tunnus,\n ytunnus: ytunnus,\n }\n end",
"def to_json\n JSON.pretty_generate(@data)\n end",
"def as_json\n\t\t{\n\t\t\t:id => self.id,\n\t\t\t:nombre => self.nombre,\n\t\t\t:abreviacion => self.abreviacion,\n\t\t}\t\t\n\tend",
"def to_json\n hash = to_h\n\n hash.each do |k, v|\n hash[k] = self.class.convert(v, k, :to_json)\n end\n\n Oj.dump(hash, omit_nil: true)\n end",
"def to_json(*options)\n as_json(*options).to_json(*options)\n \tend",
"def to_json_sub\n to_json_struct.to_json\n end",
"def to_json arg\n as_json.to_json\n end",
"def to_json\n FFI_Yajl::Encoder.encode(@data, pretty: true)\n end",
"def to_json(*args); end",
"def serialize\n JSON.generate(to_h)\n end",
"def as_json\n\t\t{\n\t\t\t:id => self.id,\n\t\t\t:agencia => self.agencia.as_json,\n\t\t\t:usuario => self.usuario.as_json,\n\t\t}\n\tend",
"def to_json\n [status, price, date]\n .reduce(&:merge)\n .to_json\n end",
"def json\n @json_hash.to_json\n end",
"def to_json\n Clever::JSON.dump @values\n end",
"def to_json\n JSON.dump ({\n :name => @name,\n :age => @age,\n :gender => @gender\n })\n end",
"def jsonify(input); end",
"def json_\n hash = {\n \"Id\" => id,\n \"Created\" => created,\n \"CreatedBy\" => created_by,\n \"Modified\" => modified,\n \"ModifiedBy\" => modified_by\n }\n\n hash.to_json\n end",
"def to_json\n Formatter::JSON.render(self)\n end",
"def to_json\n raise StandardError, \"Not implemented!\"\n end",
"def to_json!\n self.to_hash.to_json\n end",
"def to_json(*)\n to_hash.to_json\n end",
"def as_json(*)\n to_h\n end",
"def to_json *args \n self.to_hash.to_json\n end",
"def to_json *args \n self.to_hash.to_json\n end"
] | [
"0.7705823",
"0.769111",
"0.769111",
"0.7574801",
"0.7439115",
"0.7439115",
"0.74229664",
"0.7371268",
"0.73579794",
"0.7331206",
"0.7321626",
"0.72884166",
"0.72716767",
"0.726922",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7218302",
"0.72101355",
"0.7193622",
"0.7193622",
"0.7187826",
"0.71754867",
"0.7173935",
"0.7153356",
"0.71343964",
"0.71217906",
"0.7118155",
"0.7106089",
"0.71040666",
"0.70734805",
"0.70690733",
"0.70606637",
"0.7060517",
"0.703566",
"0.70217514",
"0.70217514",
"0.7009411",
"0.69835186",
"0.69792473",
"0.6978999",
"0.69784206",
"0.69740593",
"0.69686145",
"0.6964732",
"0.6964732",
"0.6964732",
"0.6964732",
"0.69506854",
"0.693386",
"0.6933841",
"0.6929546",
"0.6929546",
"0.69250464",
"0.6910941",
"0.69070226",
"0.69070226",
"0.6879908",
"0.68764323",
"0.68717366",
"0.6855978",
"0.68559414",
"0.684609",
"0.68412626",
"0.68356407",
"0.68356407",
"0.6807065",
"0.6802635",
"0.6796939",
"0.6791641",
"0.6790684",
"0.67858744",
"0.6784052",
"0.6783743",
"0.67790717",
"0.6778223",
"0.6768578",
"0.67681885",
"0.6764618",
"0.67425734",
"0.6737619",
"0.6715381",
"0.671376",
"0.6683719",
"0.66830987",
"0.6666276",
"0.6666187",
"0.66636866",
"0.66332746",
"0.66227484",
"0.6617624",
"0.6616341",
"0.6616341"
] | 0.0 | -1 |
GET /magic_item_names GET /magic_item_names.json | def index
@magic_item_names = MagicItemName.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end",
"def name_list\n begin\n @products = Product.pluck(:name)\n render json: { names: @products }, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end",
"def names\n get('names')\n end",
"def index\n @material_item_names = MaterialItemName.all\n end",
"def names()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Names::NamesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def index\n @magic_items = MagicItem.all.sort_by(&:name)\n end",
"def item_name\n params['item_name']\n end",
"def index\n @item_selected_names = ItemSelectedName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_selected_names }\n end\n end",
"def do_names\n animal_list = get_names()\n print_names(animal_list)\n end",
"def name\n Item.find(item_id).name\n end",
"def name\n Item.find(item_id).name\n end",
"def find_names(names)\n query = names.to_query('displayName').delete('%5B%5D') # delete '[]'\n uri = URI.parse(\"https://developer-paragon.epicgames.com/v1/accounts/find?#{query}\")\n request = Net::HTTP::Get.new(uri)\n request.add_field(\"X-Epic-ApiKey\", ENV[\"API_KEY\"])\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n response = http.request(request)\n return JSON.parse response.body\n end",
"def gather_names(item:)\n names = []\n return names unless item.present? && item.is_a?(Hash)\n\n names << item[:domain] if item[:domain].present?\n names << item[:aliases] if item[:aliases].present?\n names << item[:acronyms] if item[:acronyms].present?\n item.fetch(:labels, []).map { |hash| names << hash[:label] }\n names.flatten.compact.uniq\n end",
"def products_by_name\n render json: Product.where(\"name LIKE ? OR name LIKE ?\", \"#{params[:name]}%\", \"%#{params[:name]}%\").offset(params[:offset]).limit(20).map(&:simple_info), status: :ok\n end",
"def named(name)\n # do we need to modify the json\n # url_char_name = name.gsub!(' ','+')\n url_char_name = name.gsub(' ','+')\n self.class.get(\"/cards/named?fuzzy=#{url_char_name}\")\n end",
"def item\n # Url generated from Js script function => getitem() of _form.html.erb file under Views of different controllers\n @item = Report.where(\"user_id = ?\" , current_user.id).pluck(:item_name )\n # send item_names' in form of json\n render json: @item\n end",
"def get_names\n @names\n end",
"def collection_names\n response = RequestResponse.new\n name_resp = collections_info.defer_as_a\n name_resp.callback do |docs|\n names = docs.collect{ |doc| doc['name'] || '' }\n names = names.delete_if {|name| name.index(self.name).nil? || name.index('$')}\n names = names.map{ |name| name.sub(self.name + '.','')}\n response.succeed(names)\n end\n name_resp.errback { |err| response.fail err }\n response\n end",
"def name\n metadata['itemName'] rescue nil\n end",
"def get_names(spicy_foods)\n spicy_foods.map { |spicy_food_hash| spicy_food_hash[:name] }\nend",
"def list\n dispensaries = Dispensary.find(:all, :conditions => [\"name like ?\", params[:term]+\"%\"])\n result = []\n \n for d in dispensaries\n result << d.name\n end\n \n render(:json => result)\n end",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(params[:id])\n end",
"def list_names # :nologin:\n query = create_query(:Name, :all, :by => :name)\n show_selected_names(query)\n end",
"def getItemList(name, vault = \"Private\")\n regex = %r{#{name}}i\n all = self.op \"list\", \"items\", \"--vault\", vault\n arr = all.select{|i| regex.match?(i[\"overview\"][\"title\"])}\n return_arr = []\n if arr.class == Array\n arr.each do |item|\n return_arr << item[\"overview\"][\"title\"]\n end\n end\n return_arr\n end",
"def show\n @itemname = Itemname.find(params[:id])\n @locations = Location.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemname }\n end\n end",
"def names(ids, optional={})\n region = optional[:region] || @sightstone.region\n ids = ids.join(',')\n uri = \"https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids}/name\"\n response = _get_api_response(uri)\n _parse_response(response) { |resp|\n data = JSON.parse(resp)\n\n names_hash = Hash.new\n data.each do |id, name|\n names_hash[id.to_i] = name\n end\n if block_given?\n yield names_hash\n else\n return names_hash\n end\n }\n end",
"def list_items\r\n list = \"\"\r\n items.each{ |item| list = list + item.name + \"\\n\"}\r\n list\r\n end",
"def get_character_names\n\t\t\tget_all_character_uris.map { |uri| get_character_name(json(uri)) }\n end",
"def cmd_people_names\n\t\tquery_json do\n\t\t\t\"SELECT DISTINCT ?name\n\t\t\tWHERE {\n\t\t\t\t?p a foaf:Person .\n\t\t\t\t?p foaf:name ?name .\n\t\t\t}\n\t\t\tORDER BY ?name\"\n\t\tend\n\tend",
"def ids_names(items)\n\t\titems.reject(&:new_record?).collect {|item| {id: item.id, name: item.name.html_escape}}\n\tend",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def all\n render :json => User.all_names\n end",
"def items\n response[\"items\"]\n end",
"def item_names\n @registry.keys\n end",
"def autocomplete_name\n @tags = Tag.where([\"name ILIKE ?\", \"*#{params[:term]}*\".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name)\n respond_to do |format|\n format.json { render :json => @tags }\n end\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def user_item_names(record)\n record.user.send(item_plural(record)).all.collect { |item| item.name.downcase }\n end",
"def find_item_names(doc)\nend",
"def index\n @apiv1_items = Item.all.order(:name)\n end",
"def cost_names\n @cost_names = Item.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names += Detail.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names = @cost_names.uniq\n respond_to do |format|\n format.json { render json: @cost_names }\n end\n end",
"def names\n all.map { |item| item.name_sym }\n end",
"def get_books(response)\n response[\"items\"]\nend",
"def return_names\n url = URI.parse\"http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=#{@options[:zip]}\"\n JSON.parse(Net::HTTP.get(url)).delete('results')\n end",
"def names\n\n get_list['list'].collect { |re, pa| re }\n end",
"def items\n all(locator(:item)).map do |item|\n item.find(locator(:item_name)).text\n end\n end",
"def name\n \tself.item.name\n end",
"def item_name\n return if self.item_id.nil?\n\n # TODO: Redundant now\n if self.item_id.present?\n self.item_id\n else\n self.item.name\n end\n end",
"def index\n @items = Item.valid_items.search(params[:search],params[:action]).order(sort_column('Item', 'name') + ' ' + sort_direction).paginate(:page => params[:page], :per_page => 1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json {\n data=CatalogItem.all\n .where(\"name LIKE ?\", \"%#{params[:name]}%\")\n .where(\"description LIKE ?\", \"%#{params[:description]}%\")\n render json: {'value' => data}\n }\n #.where(\"name LIKE ?\", \"%#{params[:name]}%\")\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def all_names(pokemon)\n pokemon.map do |pokemon_data|\n pokemon_data[:name]\n end\nend",
"def names\n\t\tbegin\n\t\t\tcase provider\n\t\t\twhen \"facebook\"\n\t\t\t\tresponse = get(\"/me?fields=name,username\")\n\t\t\t\tr = { fullname: response['name'] }\n\t\t\t\tr[:username] = response['username'] if response['username'] != nil\n\t\t\t\treturn r\n\t\t\t\t\n\t\t\twhen \"twitter\"\n\t\t\t\tresponse = get(\"/1.1/users/show.json?user_id=#{uid}\")\n\t\t\t\treturn {\n\t\t\t\t\tusername: response['screen_name'],\n\t\t\t\t\tfullname: response['name']\n\t\t\t\t}\n\t\t\t\t\n\t\t\twhen \"google_oauth2\"\n\t\t\t\tresponse = get(\"/oauth2/v1/userinfo\")\n\t\t\t\treturn {\n\t\t\t\t\tfullname: response['name'],\n\t\t\t\t\tusername: response['email'].split('@',2)[0]\n\t\t\t\t}\n\t\t\t\t\n\t\t\twhen \"vimeo\"\n\t\t\t\tresponse = get(\"/api/v2/#{uid}/info.json\")\n\t\t\t\treturn { fullname: response['display_name'] }\n\t\t\t\t\n\t\t\twhen \"lastfm\"\n\t\t\t\tresponse = get(\"/2.0/?method=user.getinfo&format=json&user=#{uid}&api_key=#{creds['id']}\")\n\t\t\t\treturn {\n\t\t\t\t\tusername: response['user']['name'],\n\t\t\t\t\tfullname: response['user']['realname']\n\t\t\t\t}\n\t\t\t\t\n\t\t\tend\n\t\trescue Exception => e\n\t\t\traise e if Rails.env.test?\n\t\t\tlogger.debug \"error fetching names from #{provider}\"\n\t\t\tlogger.debug e.to_yaml\n\t\tend\n\t\treturn {}\n\tend",
"def name\n response[\"name\"]\n end",
"def list_names\n @lib.list_names\n end",
"def autoname\n# auto completed to get list of users. Nee to expand it to seach name field and names in the user table\n# puts \"----------->>>>>>>>>>>>>>>>> in Auto Name\"\n \n if (params[:term] && !current_account.user.mycontacts.nil?)\n like= \"%\".concat(params[:term].concat(\"%\"))\n clone_emails = current_account.user.mycontacts.where(\"clone_email LIKE ? OR name LIKE ? \", like, like)\n # puts \"clone emails = \"+clone_emails.inspect\n else\n clone_emails = []\n end\n\n #list = clone_emails.map {|u| Hash[ :id => u.id, :label => (u.clone_email), :name => u.clone_email]}\n list = clone_emails.map {|u| Hash[ :id => u.id, :label => concat_email_name(u), :name => u.clone_email]}\n render :json => list\nend",
"def index\n @items = Item.all.order(name: :asc) #Returns all items sorted by name.\n end",
"def create\n @magic_item_name = MagicItemName.new(magic_item_name_params)\n\n respond_to do |format|\n if @magic_item_name.save\n format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully created.' }\n format.json { render :show, status: :created, location: @magic_item_name }\n else\n format.html { render :new }\n format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def names(params = {})\n Iterable.request(conf, '/catalogs', params).get\n end",
"def summoner_names(summoner_ids)\n summoner_ids = array_options(summoner_ids)\n url = url_for(\"#{region}/v1.3/summoner/#{summoner_ids.join(',')}/name\")\n get url, SummonerNamesRepresenter.new({})\n end",
"def names\n return @names unless @names.nil?\n @names = names_with_io.data\n @names\n end",
"def index\n @my_names = MyName.all\n end",
"def names\n [name]\n end",
"def just_names(list)\n names = list.map do |c|\n c[:name]\n end\n return names\nend",
"def list_by_name(name)\n params = Hash.new\n params[:name] = name\n self.list(params)\n end",
"def names name = \"\"\n find_all_by_name( name ).map(&:name)\n end",
"def names\n @json['tags'].map { |ent| ent['name'] }\n end",
"def index\n #@part_names = PartName.find(:all, :order => 'name')\n\t@part_names = PartName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @part_names }\n end\n end",
"def list\n @collections = Admin::Collection.names\n\n render json: { collections: @collections }\n end",
"def item_name\n item.try(:name)\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def list\n slugs = Slug.all\n result = slugs.collect{ |x|\n\n {\n 'name' => x.name }\n }\n\n render json: {available_slugs: result}\n end",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @foams = Foam.order(\"lower(name) ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foams }\n end\n end",
"def fetch_list_characters\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n response_hash = JSON.parse(response_string)\n\n character = response_hash[\"results\"].map {|char| char[\"name\"]}\nend",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def items\n authors\n end",
"def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end",
"def names\n sql = 'SELECT DISTINCT resources.name '\\\n 'FROM resources '\\\n 'LEFT JOIN locations ON locations.id = resources.location_id '\\\n 'LEFT JOIN repositories ON locations.repository_id = repositories.id '\\\n 'LEFT JOIN institutions ON repositories.institution_id = institutions.id '\\\n 'WHERE institutions.id = ' + params[:institution_id].to_i.to_s\n conn = ActiveRecord::Base.connection\n results = conn.execute(sql)\n render json: results.map{ |r| r['name'] }\n end",
"def get(ctx, names)\n if names.empty?\n # Log something at level 'info', mostly to show how that works\n ctx.log \"info: listing everything\"\n @data\n else\n names.map do |name|\n @data.find { |x| x[\"name\"] == name } ||\n { \"name\" => name, \"ensure\" => \"absent\" }\n end\n end\n end",
"def get_ingredients_names\n self.ingredients.map{|ingredient| ingredient.name}\n end",
"def index\n @product_names = @product_names.order(:id).search(params[:search], params[:page])\n end",
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def get_names()\n names = [\"Matt\", \"Abby\", \"Bobby\", \"Danny\", \"Eddie\", \"Lily\", \"Ollie\", \"Penny\", \"Ruby\", \"Molly\", \"Katie\", \"Harry\", \"Wally\", \"Polly\", \"Rolly\", \"Billy\", \"Millie\", \"Ginny\", \"Nancy\"]\n # names = [\"Matt\", \"Abby\", \"Bobby\"]\n # names = [\"Matt\", \"Abby\"]\n # names = [\"Matt\"]\n # json = read_json()\n # json.each { |user_hash| names.push(user_hash[\"user_name\"]) }\n sorted = names.sort # sort names alphabetically\n sorted = sorted.count > 3 ? rotate_names(sorted) : sorted # if more than 3 names, need to rearrange for desired column format\nend",
"def index\n respond_to do |format|\n format.html\n format.json do\n types = { name: \"string\" }\n custom_field = { name: lambda do |name|\n \"(`items`.`name` like '%#{name}'%)\"\n end\n }\n items = Batch.resolve(current_user).joins(:item)\n items, total = KendoFilter.filter_grid(params,items, types)\n items = items.map do |e|\n {\n id: e.id,\n name: e.item.name,\n item_id: e.item.id,\n batch_count: e.count,\n have_weight: e.item.have_weight,\n last_added: e.created_at,\n price: e.price,\n supplier_price: e.supplier_price,\n amount: e.item.have_weight ? (e.count / 1000) : e.count\n } if e.item\n end\n render json: {data:items, total: total }\n end\n end\n end",
"def name(item)\n return $data_items[item.item_id].name if item.item?\n return $data_system.item_types[item.category_id] if item.category?\n end",
"def index\n @action_names = ActionName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @action_names }\n end\n end",
"def names\n cached_json_for_searchbar = current_educator.student_searchbar_json\n\n if cached_json_for_searchbar\n render json: cached_json_for_searchbar\n else\n render json: SearchbarHelper.names_for(current_educator)\n end\n end",
"def names\n cached_json_for_searchbar = current_educator.student_searchbar_json\n\n if cached_json_for_searchbar\n render json: cached_json_for_searchbar\n else\n render json: SearchbarHelper.names_for(current_educator)\n end\n end",
"def search_user_names_for_message\n @users = (session[:from_follower_following] ? @login_user.from_follower_following(params[:term]) : @login_user.all_message_users(params[:term]))\n @usernames = []\n @users.collect{|u| @usernames << u.username}\n respond_to do |format|\n format.json { render :json => @usernames }\n end\n end",
"def getItem(name, fields = \"website,username,title,password\", vault = \"Private\")\n all = self.op \"list\", \"items\", \"--vault\", vault\n arr = all.select{|i| i[\"overview\"][\"title\"].casecmp(name) == 0 }\n if arr.class == Array\n self.op \"get\", \"item\", arr[0][\"uuid\"], \"--fields\", fields\n else\n {}\n end\n end",
"def full_item_types_name\n full_item_type_name.pluralize\n end",
"def getLists()\n url = \"https://api.nytimes.com/svc/books/v3/lists/names.json\"\n params = {}\n self.request(url, params)\n end",
"def index\n order = filter_sortable_column_order %w{friendly_name receipt_name receipt_item_category.name}\n @receipt_item_types = current_account.receipt_item_types.include_names.order(order)\n respond_with @receipt_item_types\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end"
] | [
"0.73406905",
"0.67368335",
"0.66846734",
"0.65237606",
"0.63395196",
"0.63226616",
"0.63028604",
"0.6240045",
"0.61300594",
"0.60667986",
"0.60667986",
"0.60496145",
"0.60417163",
"0.59857535",
"0.5984824",
"0.59831995",
"0.59586614",
"0.5957465",
"0.5909478",
"0.58989453",
"0.5883512",
"0.58757055",
"0.58665556",
"0.58541787",
"0.5836733",
"0.58126855",
"0.58042794",
"0.5738751",
"0.5734868",
"0.5733761",
"0.57222533",
"0.57194036",
"0.57148665",
"0.57068986",
"0.57028997",
"0.5702831",
"0.569956",
"0.5687871",
"0.5685705",
"0.5678674",
"0.56691974",
"0.5666789",
"0.56649196",
"0.5660239",
"0.56491446",
"0.5622369",
"0.5614194",
"0.5600936",
"0.5598969",
"0.5580169",
"0.55762523",
"0.5574393",
"0.5559576",
"0.55381864",
"0.55329746",
"0.55301625",
"0.55289894",
"0.5524247",
"0.5514567",
"0.55046535",
"0.55027515",
"0.5500689",
"0.5493459",
"0.5491128",
"0.5482272",
"0.548115",
"0.5471199",
"0.5460776",
"0.54587317",
"0.5456654",
"0.54496264",
"0.54484946",
"0.5442492",
"0.5442492",
"0.5442492",
"0.5442492",
"0.5436653",
"0.54271746",
"0.5425548",
"0.54231536",
"0.54126674",
"0.5406092",
"0.5401997",
"0.54002327",
"0.5397402",
"0.5395481",
"0.5383111",
"0.53817487",
"0.53770846",
"0.5375577",
"0.5373984",
"0.53732014",
"0.5371992",
"0.5371992",
"0.53685117",
"0.5363929",
"0.5361645",
"0.5357621",
"0.5351374",
"0.5350744"
] | 0.7702119 | 0 |
GET /magic_item_names/1 GET /magic_item_names/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @magic_item_names = MagicItemName.all\n end",
"def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end",
"def item_name\n params['item_name']\n end",
"def index\n @material_item_names = MaterialItemName.all\n end",
"def name\n Item.find(item_id).name\n end",
"def name\n Item.find(item_id).name\n end",
"def name_list\n begin\n @products = Product.pluck(:name)\n render json: { names: @products }, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(params[:id])\n end",
"def item\n # Url generated from Js script function => getitem() of _form.html.erb file under Views of different controllers\n @item = Report.where(\"user_id = ?\" , current_user.id).pluck(:item_name )\n # send item_names' in form of json\n render json: @item\n end",
"def name\n metadata['itemName'] rescue nil\n end",
"def named(name)\n # do we need to modify the json\n # url_char_name = name.gsub!(' ','+')\n url_char_name = name.gsub(' ','+')\n self.class.get(\"/cards/named?fuzzy=#{url_char_name}\")\n end",
"def show\n @itemname = Itemname.find(params[:id])\n @locations = Location.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemname }\n end\n end",
"def index\n @item_selected_names = ItemSelectedName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_selected_names }\n end\n end",
"def index\n @magic_items = MagicItem.all.sort_by(&:name)\n end",
"def names()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Names::NamesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def create\n @magic_item_name = MagicItemName.new(magic_item_name_params)\n\n respond_to do |format|\n if @magic_item_name.save\n format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully created.' }\n format.json { render :show, status: :created, location: @magic_item_name }\n else\n format.html { render :new }\n format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def names\n get('names')\n end",
"def products_by_name\n render json: Product.where(\"name LIKE ? OR name LIKE ?\", \"#{params[:name]}%\", \"%#{params[:name]}%\").offset(params[:offset]).limit(20).map(&:simple_info), status: :ok\n end",
"def name\n \tself.item.name\n end",
"def item_name\n return if self.item_id.nil?\n\n # TODO: Redundant now\n if self.item_id.present?\n self.item_id\n else\n self.item.name\n end\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def name\n response[\"name\"]\n end",
"def do_names\n animal_list = get_names()\n print_names(animal_list)\n end",
"def index\n @apiv1_items = Item.all.order(:name)\n end",
"def update\n respond_to do |format|\n if @magic_item_name.update(magic_item_name_params)\n format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully updated.' }\n format.json { render :show, status: :ok, location: @magic_item_name }\n else\n format.html { render :edit }\n format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end",
"def getItem(name, fields = \"website,username,title,password\", vault = \"Private\")\n all = self.op \"list\", \"items\", \"--vault\", vault\n arr = all.select{|i| i[\"overview\"][\"title\"].casecmp(name) == 0 }\n if arr.class == Array\n self.op \"get\", \"item\", arr[0][\"uuid\"], \"--fields\", fields\n else\n {}\n end\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def getItemList(name, vault = \"Private\")\n regex = %r{#{name}}i\n all = self.op \"list\", \"items\", \"--vault\", vault\n arr = all.select{|i| regex.match?(i[\"overview\"][\"title\"])}\n return_arr = []\n if arr.class == Array\n arr.each do |item|\n return_arr << item[\"overview\"][\"title\"]\n end\n end\n return_arr\n end",
"def item_name\n item.try(:name)\n end",
"def find_names(names)\n query = names.to_query('displayName').delete('%5B%5D') # delete '[]'\n uri = URI.parse(\"https://developer-paragon.epicgames.com/v1/accounts/find?#{query}\")\n request = Net::HTTP::Get.new(uri)\n request.add_field(\"X-Epic-ApiKey\", ENV[\"API_KEY\"])\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n response = http.request(request)\n return JSON.parse response.body\n end",
"def item(name)\n __item(name)\n end",
"def get_books(response)\n response[\"items\"]\nend",
"def index\n respond_to do |format|\n format.html\n format.json {\n data=CatalogItem.all\n .where(\"name LIKE ?\", \"%#{params[:name]}%\")\n .where(\"description LIKE ?\", \"%#{params[:description]}%\")\n render json: {'value' => data}\n }\n #.where(\"name LIKE ?\", \"%#{params[:name]}%\")\n end\n end",
"def name\n unless recipe_item_id.blank?\n case recipe_item_type\n when \"Ingredient\"; recipe_item.name\n when \"Recipe\"; recipe_item.name\n end\n end\n end",
"def autocomplete_name\n @tags = Tag.where([\"name ILIKE ?\", \"*#{params[:term]}*\".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name)\n respond_to do |format|\n format.json { render :json => @tags }\n end\n end",
"def cmd_get_name argv\n setup argv\n uuid = @hash['uuid']\n response = @api.get_name(uuid)\n msg response\n return response\n end",
"def gather_names(item:)\n names = []\n return names unless item.present? && item.is_a?(Hash)\n\n names << item[:domain] if item[:domain].present?\n names << item[:aliases] if item[:aliases].present?\n names << item[:acronyms] if item[:acronyms].present?\n item.fetch(:labels, []).map { |hash| names << hash[:label] }\n names.flatten.compact.uniq\n end",
"def get_item name\n if (@listOfItem)\n @listOfItem.select do |item|\n item.product.name == name\n end.first\n else\n puts \"@listOfItem is null, so can't get an item from this\"\n end\n end",
"def show\n @item_selected_name = ItemSelectedName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_selected_name.item_revision }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def cost_names\n @cost_names = Item.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names += Detail.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names = @cost_names.uniq\n respond_to do |format|\n format.json { render json: @cost_names }\n end\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def autoname\n# auto completed to get list of users. Nee to expand it to seach name field and names in the user table\n# puts \"----------->>>>>>>>>>>>>>>>> in Auto Name\"\n \n if (params[:term] && !current_account.user.mycontacts.nil?)\n like= \"%\".concat(params[:term].concat(\"%\"))\n clone_emails = current_account.user.mycontacts.where(\"clone_email LIKE ? OR name LIKE ? \", like, like)\n # puts \"clone emails = \"+clone_emails.inspect\n else\n clone_emails = []\n end\n\n #list = clone_emails.map {|u| Hash[ :id => u.id, :label => (u.clone_email), :name => u.clone_email]}\n list = clone_emails.map {|u| Hash[ :id => u.id, :label => concat_email_name(u), :name => u.clone_email]}\n render :json => list\nend",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def list\n dispensaries = Dispensary.find(:all, :conditions => [\"name like ?\", params[:term]+\"%\"])\n result = []\n \n for d in dispensaries\n result << d.name\n end\n \n render(:json => result)\n end",
"def name(item)\n return $data_items[item.item_id].name if item.item?\n return $data_system.item_types[item.category_id] if item.category?\n end",
"def show\n @ingredients_name = IngredientsName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ingredients_name }\n end\n end",
"def get_names(spicy_foods)\n spicy_foods.map { |spicy_food_hash| spicy_food_hash[:name] }\nend",
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def collection_names\n response = RequestResponse.new\n name_resp = collections_info.defer_as_a\n name_resp.callback do |docs|\n names = docs.collect{ |doc| doc['name'] || '' }\n names = names.delete_if {|name| name.index(self.name).nil? || name.index('$')}\n names = names.map{ |name| name.sub(self.name + '.','')}\n response.succeed(names)\n end\n name_resp.errback { |err| response.fail err }\n response\n end",
"def destroy\n @magic_item_name.destroy\n respond_to do |format|\n format.html { redirect_to magic_item_names_url, notice: 'Magic item name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @items = Item.valid_items.search(params[:search],params[:action]).order(sort_column('Item', 'name') + ' ' + sort_direction).paginate(:page => params[:page], :per_page => 1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def item_name\n return GameData::Item[item_db_symbol].name\n end",
"def showName\n render json: User.findByName(params[\"name\"])\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def list_by_name(name)\n params = Hash.new\n params[:name] = name\n self.list(params)\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def items\n response[\"items\"]\n end",
"def list_items\r\n list = \"\"\r\n items.each{ |item| list = list + item.name + \"\\n\"}\r\n list\r\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def all\n render :json => User.all_names\n end",
"def cmd_people_names\n\t\tquery_json do\n\t\t\t\"SELECT DISTINCT ?name\n\t\t\tWHERE {\n\t\t\t\t?p a foaf:Person .\n\t\t\t\t?p foaf:name ?name .\n\t\t\t}\n\t\t\tORDER BY ?name\"\n\t\tend\n\tend",
"def product_name(array_item)\n\tarray_item[\"title\"]\nend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n #@part_names = PartName.find(:all, :order => 'name')\n\t@part_names = PartName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @part_names }\n end\n end",
"def list_names # :nologin:\n query = create_query(:Name, :all, :by => :name)\n show_selected_names(query)\n end",
"def getItemByPageName(name)\n request('getItemByPageName', {'name' => name})\n end",
"def magic_item_name_params\n params.require(:magic_item_name).permit(:name, :affix)\n end",
"def rename\n\t\tresult = Investor.update_name(params[:id], params[:name], params[:avatar_id])\n\n\t\treturn render json: result if result[:status] != 0\n\n\t\trender json: { status: 0, avatar_url: result[:result].avatar.url(:thumb) }\n\tend",
"def index\n @items = Item.all.order(name: :asc) #Returns all items sorted by name.\n end",
"def resource_item_name\n resource_name.to_s.singularize.to_sym\n end",
"def ids_names(items)\n\t\titems.reject(&:new_record?).collect {|item| {id: item.id, name: item.name.html_escape}}\n\tend",
"def names(ids, optional={})\n region = optional[:region] || @sightstone.region\n ids = ids.join(',')\n uri = \"https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids}/name\"\n response = _get_api_response(uri)\n _parse_response(response) { |resp|\n data = JSON.parse(resp)\n\n names_hash = Hash.new\n data.each do |id, name|\n names_hash[id.to_i] = name\n end\n if block_given?\n yield names_hash\n else\n return names_hash\n end\n }\n end",
"def getitem\n\n int_parent = params[:parent]\n @items = Item.where(\"manifestation_id = ?\", int_parent).order(\"item_siglum ASC\")\n @items_master = Array.new\n @items.each do |it|\n @holding_institution = HoldingInstitution.find(it.holding_institution_id)\n str_it_string = \"(\" + it.item_siglum + \") \" + @holding_institution.holding_institution_name + \" [\" + it.item_shelfmark + \"]\"\n @it_item = [str_it_string, it.id]\n @items_master.push(@it_item)\n end\n\n\n respond_to do |format|\n format.html { render json: @items_master }\n format.json { render json: @items_master }\n end\n end",
"def fetch_list_characters\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n response_hash = JSON.parse(response_string)\n\n character = response_hash[\"results\"].map {|char| char[\"name\"]}\nend",
"def index\n respond_to do |format|\n format.html\n format.json do\n types = { name: \"string\" }\n custom_field = { name: lambda do |name|\n \"(`items`.`name` like '%#{name}'%)\"\n end\n }\n items = Batch.resolve(current_user).joins(:item)\n items, total = KendoFilter.filter_grid(params,items, types)\n items = items.map do |e|\n {\n id: e.id,\n name: e.item.name,\n item_id: e.item.id,\n batch_count: e.count,\n have_weight: e.item.have_weight,\n last_added: e.created_at,\n price: e.price,\n supplier_price: e.supplier_price,\n amount: e.item.have_weight ? (e.count / 1000) : e.count\n } if e.item\n end\n render json: {data:items, total: total }\n end\n end\n end",
"def item_name=(name)\n self.item_id = Item.find_by(name: name).id if name.present?\n end",
"def item_title\n if @res[\"title\"].present?\n @res[\"title\"].length > 20 ? \"#{@res[\"title\"][0,20]}...\" : @res[\"title\"]\n else\n \"Item #{@res[\"identifier\"]}\"\n end\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def get_names\n @names\n end",
"def index\n render json: RequestItem.all\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def name\n return item_info.name + quality_txt\n end",
"def get_character_names\n\t\t\tget_all_character_uris.map { |uri| get_character_name(json(uri)) }\n end",
"def update_names\n\t\tparams[:item].each do |key, item|\n\t\t\tcurrent_item = Item.find(key)\n\t\t\tcurrent_item.update(:claimed_by => item[:claimed_by])\n\t\tend\n\t\tflash[:success] = \"Names updated.\"\n\t\tredirect_to(:back)\n\tend",
"def item_index\n #@items = Item.all\n \n\tif (params[item_index_path].nil? ||\n params[item_index_path][:nome].empty?)\n nome = nil\n else\n nome = params[item_index_path][:nome]\n end\n if nome != nil\n @items = Item.where(\"nome like '%#{nome}%'\")\n else\n @items = Item.all\n end\n end",
"def find_item_names(doc)\nend",
"def get_name(region)\n url = 'https://uinames.com/api/'\n uri= URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n result[\"name\"]\n \nend",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def listing_items\n @products.each do |item|\n puts \"item: #{item[:name]} \\n reference_number: #{item[:reference_number]} \\n price: #{item[:price]}\"\nend\nend",
"def show\n @name = Name.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @name }\n end\n end",
"def show\n @name = Name.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @name }\n end\n end"
] | [
"0.7534825",
"0.68902236",
"0.6624686",
"0.6471059",
"0.64435923",
"0.64435923",
"0.6442859",
"0.6419516",
"0.63064563",
"0.6299243",
"0.62249994",
"0.6216738",
"0.61759204",
"0.61327213",
"0.61228824",
"0.6092892",
"0.6037217",
"0.6016646",
"0.60059625",
"0.5969734",
"0.5867657",
"0.5850185",
"0.5840959",
"0.5825219",
"0.5806543",
"0.5775219",
"0.57751083",
"0.5775013",
"0.57722783",
"0.57680243",
"0.57550895",
"0.57479256",
"0.5696243",
"0.56850505",
"0.5680873",
"0.5676923",
"0.5666566",
"0.5665903",
"0.56613266",
"0.56473625",
"0.5625997",
"0.56182295",
"0.56158036",
"0.5600067",
"0.55985034",
"0.5597457",
"0.55878913",
"0.5584578",
"0.55789495",
"0.55786216",
"0.55756825",
"0.5570545",
"0.55625176",
"0.55538726",
"0.5539696",
"0.5539696",
"0.5539696",
"0.5539696",
"0.5539326",
"0.5531979",
"0.5522644",
"0.55193686",
"0.55176026",
"0.5516718",
"0.55093",
"0.5503001",
"0.54953414",
"0.5490474",
"0.54802305",
"0.54782534",
"0.54774326",
"0.5474976",
"0.54634386",
"0.5453896",
"0.54533446",
"0.54414845",
"0.54337394",
"0.54329026",
"0.54256433",
"0.54249823",
"0.5423894",
"0.54201186",
"0.54186547",
"0.54148847",
"0.5414098",
"0.54135877",
"0.54121673",
"0.5408741",
"0.5396887",
"0.5396551",
"0.53946954",
"0.5393461",
"0.5393441",
"0.5392436",
"0.5388231",
"0.53812575",
"0.53781396",
"0.5374691",
"0.5373394",
"0.5364609",
"0.5364609"
] | 0.0 | -1 |
POST /magic_item_names POST /magic_item_names.json | def create
@magic_item_name = MagicItemName.new(magic_item_name_params)
respond_to do |format|
if @magic_item_name.save
format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully created.' }
format.json { render :show, status: :created, location: @magic_item_name }
else
format.html { render :new }
format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @magic_item_names = MagicItemName.all\n end",
"def magic_item_name_params\n params.require(:magic_item_name).permit(:name, :affix)\n end",
"def item_name\n params['item_name']\n end",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(params[:id])\n end",
"def update_names\n\t\tparams[:item].each do |key, item|\n\t\t\tcurrent_item = Item.find(key)\n\t\t\tcurrent_item.update(:claimed_by => item[:claimed_by])\n\t\tend\n\t\tflash[:success] = \"Names updated.\"\n\t\tredirect_to(:back)\n\tend",
"def material_item_name_params\n params.require(:material_item_name).permit(:material_item_id, :name, :name_type_id)\n end",
"def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end",
"def ids_names(items)\n\t\titems.reject(&:new_record?).collect {|item| {id: item.id, name: item.name.html_escape}}\n\tend",
"def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def names()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Names::NamesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def name_list\n begin\n @products = Product.pluck(:name)\n render json: { names: @products }, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end",
"def change_item_name(new_name:, **)\n self.name = new_name # This will generate the event!\n end",
"def item_params\n params.permit(:name)\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def test_create_name_with_quotes\n name = 'Foo \"bar\" Author'\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => name },\n :approved_name => name\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:success) # really means failed\n assert(name = Name.find_by_text_name('Foo \"bar\"'))\n assert_equal('Foo \"bar\" Author', name.search_name)\n end",
"def test_create_name_with_quotes\n name = 'Foo \"bar\" Author'\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => name },\n :approved_name => name\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:success) # really means failed\n assert(name = Name.find_by_text_name('Foo \"bar\"'))\n assert_equal('Foo \"bar\" Author', name.search_name)\n end",
"def update\n respond_to do |format|\n if @magic_item_name.update(magic_item_name_params)\n format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully updated.' }\n format.json { render :show, status: :ok, location: @magic_item_name }\n else\n format.html { render :edit }\n format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def gather_names(item:)\n names = []\n return names unless item.present? && item.is_a?(Hash)\n\n names << item[:domain] if item[:domain].present?\n names << item[:aliases] if item[:aliases].present?\n names << item[:acronyms] if item[:acronyms].present?\n item.fetch(:labels, []).map { |hash| names << hash[:label] }\n names.flatten.compact.uniq\n end",
"def rename_fs_item\n\n err_str = ''\n begin # a one time loop to allow break\n \n new_name = params[:name]\n if ( new_name.blank? )\n err_str = 'Empty name not allowed'\n break\n end\n \n generic_ty = Integer(params[:sel_kind]) rescue generic_ty = FSTYPE_INVALID\n elem_id = Integer(params[:sel_id]) rescue elem_id = -1\n if ( elem_id <= 0 )\n err_str = 'Invalid index'\n break\n end\n \n if ( generic_ty == FSTYPE_FILE )\n to_upd = Dfile.find_by_id( elem_id )\n if ( to_upd )\n to_upd.name = new_name\n if to_upd.save\n reponse = { action_id: params[:action_id],\n new_id: to_upd.id,\n new_name: to_upd.name,\n parent_id: to_upd.directory_id,\n kind_name: 'generic'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to save file name'\n break\n end\n else\n err_str = 'File does not exist'\n break\n end\n elsif ( generic_ty == FSTYPE_DIR )\n to_upd = Directory.find_by_id( elem_id )\n if ( to_upd )\n to_upd.name = new_name\n if to_upd.save\n reponse = { action_id: params[:action_id],\n new_id: to_upd.id,\n new_name: to_upd.name,\n parent_id: to_upd.parent_id,\n kind_name: 'directory'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to save directory'\n break\n end\n else\n err_str = 'Directory does not exist'\n break\n end\n else\n err_str = 'Invalid entry type'\n break\n end\n \n end until true # a one time loop to allow break\n render json: err_str, status: :unprocessable_entity and return\n end",
"def do_names\n animal_list = get_names()\n print_names(animal_list)\n end",
"def create_items\n @items.each do |item|\n create_item(item) unless Item.where(name: item['name']).first\n end\n end",
"def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end",
"def create\n @locations = Location.all\n @itemname = Itemname.new(params[:itemname])\n\n respond_to do |format|\n if @itemname.save\n format.html { redirect_to @itemname, notice: 'Item creado.' }\n format.json { render json: @itemname, status: :created, location: @itemname }\n else\n format.html { render action: \"new\" }\n format.json { render json: @itemname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item\n # Url generated from Js script function => getitem() of _form.html.erb file under Views of different controllers\n @item = Report.where(\"user_id = ?\" , current_user.id).pluck(:item_name )\n # send item_names' in form of json\n render json: @item\n end",
"def item_name=(name)\n self.item_id = Item.find_by(name: name).id if name.present?\n end",
"def create\n @material_item_name = MaterialItemName.new(material_item_name_params)\n\n respond_to do |format|\n if @material_item_name.save\n format.html { redirect_to @material_item_name, notice: 'Material item name was successfully created.' }\n format.json { render :show, status: :created, location: @material_item_name }\n else\n format.html { render :new }\n format.json { render json: @material_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @magic_item = MagicItem.new(magic_item_params)\n\n respond_to do |format|\n if @magic_item.save\n format.html { redirect_to @magic_item, notice: 'Magic item was successfully created.' }\n format.json { render :show, status: :created, location: @magic_item }\n else\n format.html { render :new }\n format.json { render json: @magic_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item_selected_name = ItemSelectedName.new(item_selected_name_params)\n\n respond_to do |format|\n if @item_selected_name.save\n format.html { redirect_to @item_selected_name, notice: 'Item selected name was successfully created.' }\n format.json { render json: @item_selected_name, status: :created, location: @item_selected_name }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_selected_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @material_item_names = MaterialItemName.all\n end",
"def add_item(list, item_name_string, quantity=1)\r\n\titem_key = item_name_string.to_sym\r\n\tlist[item_key] = quantity\r\n\treturn list\r\nend",
"def name\n metadata['itemName'] rescue nil\n end",
"def magic_item_params\n params.require(:magic_item).permit(:name, :wondrous, :weight, :tier, :rarity, :attunement, :description)\n end",
"def set_item_name(value, index = 0)\n value = GameData::Item[value].name if value.is_a?(Integer) || value.is_a?(Symbol)\n set_variable(ITEM2[index].to_s, value.to_s)\n end",
"def index\n @item_selected_names = ItemSelectedName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_selected_names }\n end\n end",
"def destroy\n @magic_item_name.destroy\n respond_to do |format|\n format.html { redirect_to magic_item_names_url, notice: 'Magic item name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def add_item(list, item_name, quantity)\n list[item_name.to_sym] = quantity\n list \nend",
"def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n 'currency_code' => 'USD',\n 'amount' => 400\n }\n }\n ]\n }\n\n response = Unirest.post CONNECT_HOST + '/v1/' + LOCATION_ID + '/items',\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully created item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item creation failed'\n puts response.body\n return nil\n end\nend",
"def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end",
"def item_params\n params.require(:item).permit(:symbol, :name)\n end",
"def renamed(item, oldName, newName)\n end",
"def name\n Item.find(item_id).name\n end",
"def name\n Item.find(item_id).name\n end",
"def parse_new_name\n return unless @new_name\n raise 'new_name field contains an existing resource name.' if @resource_type.new(@client, name: @new_name).retrieve!\n @data['name'] = @new_name\nend",
"def create\n item = params[:item_alias].delete(:item)\n @item_alias = ItemAlias.new(params[:item_alias])\n @item_alias.item = Item.find_by_name(item)\n respond_to do |format|\n if @item_alias.save\n format.html { redirect_to(@item_alias, :notice => 'Item alias was successfully created.') }\n format.xml { render :xml => @item_alias, :status => :created, :location => @item_alias }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item_alias.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_new_items(list, item_name, quantity=1)\n list[item_name] = quantity\n list\nend",
"def bulk_name_edit # :prefetch: :norobots:\n @list_members = nil\n @new_names = nil\n if request.method == :post\n list = params[:list][:members].strip_squeeze rescue ''\n construct_approved_names(list, params[:approved_names])\n sorter = NameSorter.new\n sorter.sort_names(list)\n if sorter.only_single_names\n sorter.create_new_synonyms\n flash_notice :name_bulk_success.t\n redirect_to(:controller => 'observer', :action => 'list_rss_logs')\n else\n if sorter.new_name_strs != []\n # This error message is no longer necessary.\n flash_error \"Unrecognized names given, including: #{sorter.new_name_strs[0].inspect}\" if TESTING\n else\n # Same with this one... err, no this is not reported anywhere.\n flash_error \"Ambiguous names given, including: #{sorter.multiple_line_strs[0].inspect}\"\n end\n @list_members = sorter.all_line_strs.join(\"\\r\\n\")\n @new_names = sorter.new_name_strs.uniq.sort\n end\n end\n end",
"def product_name(array_item)\n\tarray_item[\"title\"]\nend",
"def named(name)\n # do we need to modify the json\n # url_char_name = name.gsub!(' ','+')\n url_char_name = name.gsub(' ','+')\n self.class.get(\"/cards/named?fuzzy=#{url_char_name}\")\n end",
"def create_list(items)\r\n\r\n\tgrocery_list = {}\r\n\r\n\tlist_items = items.split(\" \")\r\n\r\n\t#best practice...\r\n\tlist_items.each do |item_name|\r\n\t\tgrocery_list = add_item(grocery_list, item_name)\r\n\tend\r\n\r\n\treturn grocery_list\r\nend",
"def autoname\n# auto completed to get list of users. Nee to expand it to seach name field and names in the user table\n# puts \"----------->>>>>>>>>>>>>>>>> in Auto Name\"\n \n if (params[:term] && !current_account.user.mycontacts.nil?)\n like= \"%\".concat(params[:term].concat(\"%\"))\n clone_emails = current_account.user.mycontacts.where(\"clone_email LIKE ? OR name LIKE ? \", like, like)\n # puts \"clone emails = \"+clone_emails.inspect\n else\n clone_emails = []\n end\n\n #list = clone_emails.map {|u| Hash[ :id => u.id, :label => (u.clone_email), :name => u.clone_email]}\n list = clone_emails.map {|u| Hash[ :id => u.id, :label => concat_email_name(u), :name => u.clone_email]}\n render :json => list\nend",
"def unique_name_for(item)\n item.to_s\n end",
"def rename_pets(uncustomized_pets_ordered, pets_to_update)\n counter = 1 # Because the pets are ordered by admittance date already, a counter can be used to properly number them\n uncustomized_pets_ordered.each do |pet|\n pet.name = \"#{pet.breed} #{counter}\"\n pets_to_update << pet\n counter += 1\n end\n end",
"def create_list(item, quantity = 1)\n\tlist = {}\n\tsplit_item = item.split(\" \")\n\tsplit_item.each do |item_name|\n\t\tlist[item_name] = quantity\n\tend\n\treturn list\nend",
"def test_send_delete_body_with_multiliner_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\\\\nnouman\",\"field\":\"QA\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_body(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def item_params\n params.require(:item).permit(:name, :tag_list, :type_list, :description)\n end",
"def add_items(list, item_name, quantity=0)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend",
"def next_uniq_child_name(item)\n taken_names = contents_names(item).map(&:downcase)\n name_generator = FileName.new(item.name, path: :relative, add: :always,\n format: '(%d)', delimiter: ' ')\n new_name = item.name\n new_name = name_generator.create while taken_names.include?(new_name.downcase)\n new_name\n end",
"def test_delete_form_test_with_multiliner_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\\\\nnouman\",\"field\":\"QA\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_form(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def index\n @magic_items = MagicItem.all.sort_by(&:name)\n end",
"def add_item(list,item_name, qty)\n list[item_name] = qty\nend",
"def save_items_data\n @parsed[\"order_items\"].each do |i| \n external_code = i['item']['id']\n item = Item.find_or_create_by(external_code: external_code)\n item.order_id = @order.id\n item.external_code = i['item']['id']\n item.name = i['item']['title']\n item.price = i['unit_price']\n item.quantity = i['quantity']\n item.total = i['full_unit_price']\n @subItems = []\n item.save\n end\n end",
"def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def create(name)\n Iterable.request(conf, '/lists').post(name: name)\n end",
"def create_list(items)\n\n\tgrocery_list = {}\n\n\tlist_items = items.split(\" \")\n\n\t#best practice...\n\tlist_items.each do |item_name|\n\t\tgrocery_list = add_item(grocery_list, item_name)\n\tend\n\n\treturn grocery_list\nend",
"def item_params\n params.require(:item).permit(:name, :value)\n end",
"def name(item)\n return $data_items[item.item_id].name if item.item?\n return $data_system.item_types[item.category_id] if item.category?\n end",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend",
"def valid_item_name?(name)\n !!(name =~ /\\A[-_ 0-9a-zA-Z]+\\Z/)\n end",
"def test_nameItem\n f = ItemFilter.new(\"name\", \"Potion\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 1\n end",
"def item_params\n params[:item][:ingredient_list] ||= [] \n params.require(:item).permit(:name, ingredient_list: [])\n end",
"def autocomplete_name\n @tags = Tag.where([\"name ILIKE ?\", \"*#{params[:term]}*\".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name)\n respond_to do |format|\n format.json { render :json => @tags }\n end\n end",
"def postEntityName( entity_id, name, formal_name, branch_name)\n params = Hash.new\n params['entity_id'] = entity_id\n params['name'] = name\n params['formal_name'] = formal_name\n params['branch_name'] = branch_name\n return doCurl(\"post\",\"/entity/name\",params)\n end",
"def name\n \tself.item.name\n end",
"def handle\n @name.to_str.strip.downcase.split(/[_ ]+/).join(\"_\")\n end",
"def create_a_list(name, quantity)\n #list = name.split(\", \")\n list_items = {}\n #list.each do |name|\n list_items[name] = quantity\n #end\n p list_items\n return list_items\nend",
"def bakery_params\n params.permit(:name, :location, item_ids: [])\n end",
"def register(controller_name, item)\n @items[controller_name] ||= []\n @items[controller_name] << item\n end",
"def find_item_names(doc)\nend",
"def create\n @receipt_item_type = current_account.receipt_item_types.create(receipt_item_type_params)\n if @receipt_item_type\n respond_with @receipt_item_type do |format|\n format.json { render :json => current_account.receipt_item_types.include_names.find(@receipt_item_type.id) }\n end\n else\n respond_with @receipt_item_type\n end\n end",
"def validated_name_args(method_name, body)\n @args = json_parse(body)\n args = case method_name\n when /^sha$/ then []\n when /^alive$/ then []\n when /^ready$/ then []\n when /^image_names$/ then []\n when /^names$/ then []\n when /^manifests$/ then []\n when /^manifest$/ then [name]\n else\n raise ClientError, 'json:malformed'\n end\n if query?(method_name)\n method_name += '?'\n end\n [method_name, args]\n end",
"def add_item(item)\n unless item.nil?\n @items.push(item.to_s.downcase)\n end\n @items\n end",
"def item_params\n params.require(:item).permit(:name, :description, :img_link, :quantity)\n # params.require(:item).permit(:name)\n end",
"def create\n upload_item params[params[:item_type]], session['username'], params[:alternative_name], params[:tag_name], params[:item_type], params[:details]\n end",
"def add_item(item)\n @items[item.name] ||= []\n @items[item.name] << item\n end",
"def rawname_params\n params.require(:rawname).permit(:system_id, :system_name)\n end",
"def add_item(list, item_name, quantity=1)\n list[item_name] = quantity\nend",
"def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend",
"def cost_names\n @cost_names = Item.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names += Detail.select(\"DISTINCT name\").where(\"name like ?\", \"%#{params[:q]}%\").limit(20).map(&:name)\n @cost_names = @cost_names.uniq\n respond_to do |format|\n format.json { render json: @cost_names }\n end\n end",
"def item_params\n params.require(:item).permit(:name, :type_id, :user_id)\n end",
"def test_create_naming_fill_in_author\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => 'Agaricus campestris' },\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:success) # really means failed\n assert_equal('Agaricus campestris L.', @controller.instance_variable_get('@what'))\n end",
"def test_create_naming_fill_in_author\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => 'Agaricus campestris' },\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:success) # really means failed\n assert_equal('Agaricus campestris L.', @controller.instance_variable_get('@what'))\n end",
"def create\n @item = Item.new(item_params)\n if @item.save\n @items = Item.all\n render status: 201, :json => @item\n \n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n \n \n end",
"def test_create_naming_with_author_when_name_without_author_already_exists\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => \"Conocybe filaris (With) Author\" },\n :vote => { :value => \"3\" },\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:action => \"show_observation\", :id => observations(:coprinus_comatus_obs).id)\n # Dick is getting points for the naming, vote, and name change.\n assert_equal(12 + 10, @dick.reload.contribution)\n naming = Naming.last\n assert_equal(\"Conocybe filaris\", naming.name.text_name)\n assert_equal(\"(With) Author\", naming.name.author)\n assert_equal(names(:conocybe_filaris).id, naming.name_id)\n end",
"def test_create_naming_with_author_when_name_without_author_already_exists\n params = {\n :id => observations(:coprinus_comatus_obs).id,\n :name => { :name => \"Conocybe filaris (With) Author\" },\n :vote => { :value => \"3\" },\n }\n login(\"dick\")\n post(:create_naming, params)\n assert_response(:action => \"show_observation\", :id => observations(:coprinus_comatus_obs).id)\n # Dick is getting points for the naming, vote, and name change.\n assert_equal(12 + 10, @dick.reload.contribution)\n naming = Naming.last\n assert_equal(\"Conocybe filaris\", naming.name.text_name)\n assert_equal(\"(With) Author\", naming.name.author)\n assert_equal(names(:conocybe_filaris).id, naming.name_id)\n end"
] | [
"0.65030557",
"0.64285296",
"0.6226741",
"0.61364675",
"0.59521884",
"0.58190954",
"0.5768685",
"0.5681343",
"0.56139356",
"0.5612835",
"0.5602044",
"0.55766296",
"0.55756",
"0.55729985",
"0.5565371",
"0.5503138",
"0.548819",
"0.5464174",
"0.5464174",
"0.54093695",
"0.53995",
"0.5398434",
"0.53883445",
"0.53805864",
"0.53731656",
"0.5368314",
"0.5362268",
"0.5358181",
"0.534123",
"0.5332398",
"0.5305423",
"0.53031784",
"0.52920103",
"0.52747095",
"0.52550125",
"0.5220151",
"0.51932037",
"0.5189288",
"0.5170265",
"0.5168358",
"0.5159166",
"0.5155576",
"0.51251274",
"0.5113204",
"0.5113204",
"0.5078699",
"0.50695676",
"0.50571483",
"0.50501144",
"0.5040984",
"0.50204813",
"0.5013845",
"0.50074965",
"0.50067896",
"0.50033796",
"0.50024915",
"0.49964747",
"0.49929428",
"0.4990077",
"0.49889877",
"0.49797964",
"0.4978394",
"0.49695268",
"0.4969051",
"0.49658203",
"0.49658203",
"0.49576405",
"0.49546677",
"0.49473593",
"0.4935181",
"0.49348247",
"0.4933979",
"0.4933979",
"0.49279702",
"0.49207383",
"0.49163103",
"0.491586",
"0.49052703",
"0.49047863",
"0.4901894",
"0.49014178",
"0.49004933",
"0.48998407",
"0.48968837",
"0.48948997",
"0.48922536",
"0.48910934",
"0.4890868",
"0.48889887",
"0.4886158",
"0.4882233",
"0.48786795",
"0.4875707",
"0.48442483",
"0.4842122",
"0.4839634",
"0.4839634",
"0.48291072",
"0.4827739",
"0.4827739"
] | 0.6748295 | 0 |
PATCH/PUT /magic_item_names/1 PATCH/PUT /magic_item_names/1.json | def update
respond_to do |format|
if @magic_item_name.update(magic_item_name_params)
format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully updated.' }
format.json { render :show, status: :ok, location: @magic_item_name }
else
format.html { render :edit }
format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_names\n\t\tparams[:item].each do |key, item|\n\t\t\tcurrent_item = Item.find(key)\n\t\t\tcurrent_item.update(:claimed_by => item[:claimed_by])\n\t\tend\n\t\tflash[:success] = \"Names updated.\"\n\t\tredirect_to(:back)\n\tend",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(params[:id])\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end",
"def update\n @itemname = Itemname.find(params[:id])\n\n respond_to do |format|\n if @itemname.update_attributes(params[:itemname])\n format.html { redirect_to @itemname, notice: 'Item actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @itemname.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @magic_item.update(magic_item_params)\n format.html { redirect_to @magic_item, notice: 'Magic item was successfully updated.' }\n format.json { render :show, status: :ok, location: @magic_item }\n else\n format.html { render :edit }\n format.json { render json: @magic_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def rename_fs_item\n\n err_str = ''\n begin # a one time loop to allow break\n \n new_name = params[:name]\n if ( new_name.blank? )\n err_str = 'Empty name not allowed'\n break\n end\n \n generic_ty = Integer(params[:sel_kind]) rescue generic_ty = FSTYPE_INVALID\n elem_id = Integer(params[:sel_id]) rescue elem_id = -1\n if ( elem_id <= 0 )\n err_str = 'Invalid index'\n break\n end\n \n if ( generic_ty == FSTYPE_FILE )\n to_upd = Dfile.find_by_id( elem_id )\n if ( to_upd )\n to_upd.name = new_name\n if to_upd.save\n reponse = { action_id: params[:action_id],\n new_id: to_upd.id,\n new_name: to_upd.name,\n parent_id: to_upd.directory_id,\n kind_name: 'generic'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to save file name'\n break\n end\n else\n err_str = 'File does not exist'\n break\n end\n elsif ( generic_ty == FSTYPE_DIR )\n to_upd = Directory.find_by_id( elem_id )\n if ( to_upd )\n to_upd.name = new_name\n if to_upd.save\n reponse = { action_id: params[:action_id],\n new_id: to_upd.id,\n new_name: to_upd.name,\n parent_id: to_upd.parent_id,\n kind_name: 'directory'\n }\n render :json => reponse, :layout => false, :status => 200 and return\n else\n err_str = 'Failed to save directory'\n break\n end\n else\n err_str = 'Directory does not exist'\n break\n end\n else\n err_str = 'Invalid entry type'\n break\n end\n \n end until true # a one time loop to allow break\n render json: err_str, status: :unprocessable_entity and return\n end",
"def update\n item = Item.find(params[:item_id])\n\n item.name = params[:name]\n item.details = params[:details]\n item.save\n end",
"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 update\n respond_to do |format|\n if @material_item_name.update(material_item_name_params)\n format.html { redirect_to @material_item_name, notice: 'Material item name was successfully updated.' }\n format.json { render :show, status: :ok, location: @material_item_name }\n else\n format.html { render :edit }\n format.json { render json: @material_item_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_item(item_id)\n request_body = {\n 'name' => 'Malted Milkshake'\n }\n\n response = Unirest.put CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully updated item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item update failed'\n puts response.body\n return nil\n end\nend",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def rename(id, name = \"\")\n item = Item.find(id)\n item.class == Item ? item.update(:name => name) : item\n end",
"def update\n respond_to do |format|\n if @catalog_item.update(name: params[:name], description: params[:description])\n format.json { render json: @catalog_item }\n end\n end\n end",
"def update_name(new_name)\n ensure_uri\n response = @client.rest_put(@data['uri'], 'body' => { 'name' => new_name, 'type' => 'ArtifactsBundle' })\n @client.response_handler(response)\n @data['name'] = new_name\n true\n end",
"def change_item_name(new_name:, **)\n self.name = new_name # This will generate the event!\n end",
"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 update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def change_multiple_items\n @items = params[:items]\n\n @items.each do |item|\n @current_item = Item.find(item[:id])\n @current_item.update(quantity: item[:quantity])\n end\n\n render :json => @items.to_json\n end",
"def update\n @item = Item.find(item_params)\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.name, status: :unprocessable_entity }\n # format.html { render json: @item, notice: 'Item was not successfully updated.' }\n end\n end\n end",
"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 update\n @item_selected_name = ItemSelectedName.find(params[:id])\n\n respond_to do |format|\n if @item_selected_name.update_attributes(item_selected_name_params)\n format.html { redirect_to @item_selected_name, notice: 'Item selected name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_selected_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def magic_item_name_params\n params.require(:magic_item_name).permit(:name, :affix)\n end",
"def update_item(list, item_name, new_qty)\n if list.has_key?(item_name)\n list[item_name] = new_qty\n else\n list = add_method(list, item_name, new_qty)\n end\n list\nend",
"def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend",
"def update!(**args)\n @item_option = args[:item_option] if args.key?(:item_option)\n @name_info = args[:name_info] if args.key?(:name_info)\n end",
"def update(list, item_name, quantity)\n\tlist[item_name] = quantity\nend",
"def rename\n\t\tresult = Investor.update_name(params[:id], params[:name], params[:avatar_id])\n\n\t\treturn render json: result if result[:status] != 0\n\n\t\trender json: { status: 0, avatar_url: result[:result].avatar.url(:thumb) }\n\tend",
"def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend",
"def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend",
"def item_name=(name)\n self.item_id = Item.find_by(name: name).id if name.present?\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def update_quantity(list, item_name, qty)\n list[item_name] = qty\nend",
"def update_quanity(list, item_name, new_quantity)\n\n\tlist[item_name] = new_quantity\n\tp list\nend",
"def update_list(item_name, item_list, quantity)\n add_list(item_name, item_list, quantity)\nend",
"def update\n respond_to do |format|\n if @custom_item.update(custom_item_params)\n format.html { redirect_to order_bill_path(@custom_item.bill.order, @custom_item.bill), notice: 'Custom item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to order_bill_path(@custom_item.bill.order, @custom_item.bill) }\n format.json { render json: @custom_item.errors, status: :unprocessable_entity }\n end\n \n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @name = args[:name] if args.key?(:name)\n @os_info = args[:os_info] if args.key?(:os_info)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def update\n @inventory_item = InventoryItem.find(params[:id])\n @binder = Binder.find(@inventory_item.binder_id)\n \n authorize! :write, @inventory_item\n\n respond_to do |format|\n if @inventory_item.update_attributes(params[:inventory_item])\n @inventory_items = InventoryItem.where(:binder_id => @inventory_item.binder_id).order(\"name\")\n format.html { redirect_to @inventory_item, notice: 'Inventory item was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_item.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update_quantity(list, item_name, quantity)\r\n list[item_name] = quantity\r\nend",
"def update\n item = params[:item_alias].delete(:item)\n @item_alias = ItemAlias.find(params[:id])\n @item_alias.item = Item.find_by_name(item)\n respond_to do |format|\n if @item_alias.update_attributes(params[:item_alias])\n format.html { redirect_to(@item_alias, :notice => 'Item alias was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_alias.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update\n description = file_params[:description] || @file.description\n\n raise ApiError, \"Can't rename a file.\" unless @file.rename(file_params[:name], description)\n\n render json: @file, adapter: :json\n end",
"def update\n @item = Item.find(params[:id])\n\n logger.info \"Item: #{@item}\\nw/ param attr: #{params[:item].inspect}\"\n respond_to do |format|\n @item.attributes = params[:item].select{|k,v| ![:item_photos, :item_photos_attributes, :location].include?(k.to_sym) }\n\n @item.load_item_photos_with_params(params[:item] )\n\n if @item.save\n\n @item.set_by_user(auth_user)\n\n logger.info \" C) after save: attr: #{@item.attributes}\"\n\n if manage_item_photos(@item).present? || @item.changed?\n @item.save\n logger.info \" D) attr: #{@item.attributes}\"\n end\n\n format.html {\n redirect_to inventory_approve_item_path(:user_id => \"#{@item.owner.id}\")\n }\n format.json { render json:{ item: @item, success: true} }\n else\n set_flash_messages_from_errors(@item)\n format.html { render action: \"edit\" }\n format.json { render json: { error: @item.errors.first.join(' ') }, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @customizing_name.update(customizing_name_params)\n format.html { redirect_to @customizing_name, notice: 'Customizing name was successfully updated.' }\n format.json { render :show, status: :ok, location: @customizing_name }\n else\n format.html { render :edit }\n format.json { render json: @customizing_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item ' + @item.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend",
"def test_the_application_can_update_a_previous_item_title_on_our_to_do_list\n #Create an item to test\n #Send a PUT request to '/items/:id' that will update the item's title\n #Assert that the controller responds with a status of 200\n #Assert that the controller responds with a body of 'Item updated'\n #Assert that the item's title is the updated title and not the original title.\n end",
"def update\n @ingredients_name = IngredientsName.find(params[:id])\n\n respond_to do |format|\n if @ingredients_name.update_attributes(params[:ingredients_name])\n format.html { redirect_to @ingredients_name, notice: 'Ingredients name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ingredients_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(item, new_item)\n if item == \"first_name\"\n self.first_name = new_item\n elsif item == \"last_name\"\n self.last_name = new_item\n elsif\n item == \"email\"\n self.email = new_item\n else\n item == \"note\"\n self.note = new_item\n end\n end",
"def update\n respond_to do |format|\n if @needed_item.update(needed_item_params)\n format.html { redirect_to @needed_item, notice: 'Needed item was successfully updated.' }\n format.json { render :show, status: :ok, location: @needed_item }\n else\n format.html { render :edit }\n format.json { render json: @needed_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def 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 update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end",
"def renamed(item, oldName, newName)\n end",
"def update_name(user_id:, name:)\n path = '/users/{userId}/name'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n name: name,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PATCH',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def rename(new_name)\n json_body = { :name => new_name }.to_json\n HTTParty.put(base_request_uri, :body => json_body)\n @name = new_name\n end",
"def update\n @item = current_user.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: \"#{@item.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html do\n flash[:alert] = 'Something went wrong while updating an item.'\n render action: \"edit\"\n end\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"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 update_list(list, item_name, quantity=1)\r\n list[item_name] = quantity\r\n list\r\nend",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n if @item.update(params[:item])\n format.html { redirect_to({action: :show, id: @item}, notice: 'Item was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_list(list_id:, name:)\n check_token\n list = Todoable::List.new(name: name)\n response = self.class.patch(\n \"/lists/#{list_id}\",\n body: list.post_body,\n headers: headers,\n format: :text\n )\n check_and_raise_errors(response)\n # This endpoint returns a plaintext body: \"<new name> updated\", so\n # while I'd like to return a List with ListItems, that would require\n # first looking up the list which isn't ideal. So we'll return true, ask\n # todoable to fix this endpoint, and make developers keep track of the\n # name change\n true\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to items_path, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def updated(item)\n end",
"def test_update_name_destructive_merge\n old_name = agaricus_campestrus = names(:agaricus_campestrus)\n new_name = agaricus_campestris = names(:agaricus_campestris)\n new_versions = new_name.versions.size\n old_obs = old_name.namings[0].observation\n new_obs = new_name.namings.\n find { |n| n.observation.name == new_name }.observation\n\n params = {\n id: old_name.id,\n name: {\n text_name: agaricus_campestris.text_name,\n author: agaricus_campestris.author,\n rank: \"Species\",\n deprecated: agaricus_campestris.deprecated\n }\n }\n login(\"rolf\")\n\n # Fails because Rolf isn't in admin mode.\n put(:update, params: params)\n assert_redirected_to(emails_merge_request_path(\n type: :Name, old_id: old_name.id, new_id: new_name.id\n ))\n assert(Name.find(old_name.id))\n assert(new_name.reload)\n assert_equal(1, new_name.version)\n assert_equal(new_versions, new_name.versions.size)\n assert_equal(2, new_name.namings.size)\n assert_equal(agaricus_campestrus, old_obs.reload.name)\n assert_equal(agaricus_campestris, new_obs.reload.name)\n\n # Try again as an admin.\n make_admin\n put(:update, params: params)\n assert_flash_success\n assert_redirected_to(name_path(new_name.id))\n assert_no_emails\n assert_not(Name.exists?(old_name.id))\n assert(new_name.reload)\n assert_equal(1, new_name.version)\n assert_equal(new_versions, new_name.versions.size)\n assert_equal(3, new_name.namings.size)\n assert_equal(agaricus_campestris, old_obs.reload.name)\n assert_equal(agaricus_campestris, new_obs.reload.name)\n end",
"def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_quantity(new_list, item_name, quantity)\r\n \r\n new_list[item_name] = quantity\r\nend",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def update\n respond_to do |format|\n if @food.update(food_params)\n\n puts name = get_barcode_info(@food.picture.path.to_s)\n\n @food.update!(:name => name)\n\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n #@recipe.ingredients = params[:recipe_ingredients].map {|k, v|\n #ingredient = @recipe.ingredients.find(k) || @recipe.ingredients.build\n #ingredient.update_attributes(:item => Food.find(v[:item_id]), :quantity => v[:quantity]) unless v[:item_id].blank?\n #ingredient\n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_update(hash_items, item_name, quantity)\n hash_items[item_name] = quantity\n return hash_items\nend",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6601336",
"0.6478073",
"0.63877803",
"0.63482547",
"0.63341767",
"0.6286458",
"0.62237185",
"0.622177",
"0.6183182",
"0.61792547",
"0.61488265",
"0.6087684",
"0.6069304",
"0.603378",
"0.6031951",
"0.6026903",
"0.5998217",
"0.5994053",
"0.5974475",
"0.5969632",
"0.5966828",
"0.5952932",
"0.5949463",
"0.59352416",
"0.59085125",
"0.58805484",
"0.5863414",
"0.58617157",
"0.58512175",
"0.58512175",
"0.58506626",
"0.5822836",
"0.581527",
"0.58113277",
"0.5797752",
"0.5797341",
"0.5784064",
"0.5783322",
"0.5771454",
"0.5767476",
"0.57584995",
"0.57529026",
"0.57511336",
"0.57504976",
"0.57413",
"0.57399434",
"0.572704",
"0.572704",
"0.5724598",
"0.5724031",
"0.5721633",
"0.5714333",
"0.57037616",
"0.5695118",
"0.5691474",
"0.5670418",
"0.5669571",
"0.5654903",
"0.56483793",
"0.56449217",
"0.56421435",
"0.56410795",
"0.56405365",
"0.56397",
"0.56361955",
"0.5634517",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.56325585",
"0.5629974",
"0.5627277",
"0.5622051",
"0.5621578",
"0.56184185",
"0.56110084",
"0.56069916",
"0.56061035",
"0.5602448",
"0.5599435",
"0.55982053",
"0.55982053",
"0.5594124",
"0.55939984",
"0.5583385",
"0.558075",
"0.55764914",
"0.55764914",
"0.55764914",
"0.55764914",
"0.55764914"
] | 0.7312591 | 0 |
DELETE /magic_item_names/1 DELETE /magic_item_names/1.json | def destroy
@magic_item_name.destroy
respond_to do |format|
format.html { redirect_to magic_item_names_url, notice: 'Magic item name was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @itemname = Itemname.find(params[:id])\n @itemname.destroy\n\n respond_to do |format|\n format.html { redirect_to itemnames_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @magic_item.destroy\n respond_to do |format|\n format.html { redirect_to magic_items_url, notice: 'Magic item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(name); end",
"def delete(name); end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def delete(name)\n\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def delete_item(grocery,item_name)\n # input: list, item name.\n # steps: delete item_name from the hash\n grocery.delete(item_name)\n # output: display the latest list\n display_list(grocery)\nend",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def remove_item(list_items, item_name)\n list_items.delete(item_name)\nend",
"def delete_item(db, item_name, current_user)\r\n db.execute(\"DELETE FROM items WHERE item_name = ? AND user_id = ?\", [item_name, current_user])\r\nend",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_item\n\nend",
"def remove_item(list, item_name)\n list.delete(item_name)\nend",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end",
"def destroy\n# @item = Item.get(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to({action: :index}, notice: 'Item was successfully deleted.') }\n format.json { head :ok }\n end\n end",
"def destroy\n @material_item_name.destroy\n respond_to do |format|\n format.html { redirect_to material_item_names_url, notice: 'Material item name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleted(item)\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_path }\n format.json { head :no_content }\n end\n end",
"def test_send_delete_body_with_multiliner_name()\n # Parameters for the API call\n body = DeleteBody.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\\\\nnouman\",\"field\":\"QA\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_delete_body(body)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def remove_item(list, item_name)\n\t{|list| list.delete(\"mangoes\")}\nend",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @rackitem = Rackitem.find(params[:id])\n @rackitem.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Rackitem removed' }\n format.json { head :no_content }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\n end",
"def destroy\n @item_selected_name = ItemSelectedName.find(params[:id])\n @item_selected_name.destroy\n\n respond_to do |format|\n format.html { redirect_to item_selected_names_url }\n format.json { head :no_content }\n end\n end",
"def remove_item(list, name)\n list.delete(normalize_string(name))\n return list\nend",
"def remove_item(list, item_name)\n list.delete(item_name)\n list\nend",
"def destroy\n return if @name.nil?\n delete_rest \"extra/#{@name}\"\n end",
"def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def destroy\n @item = @user.items.find(params[:id])\n @item.destroy\n\n\n respond_to do |format|\n format.html { redirect_to user_items_path(@user) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url}\n format.json { head :no_content }\n end\n end",
"def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end",
"def destroy\n @item ||= Item.find_by_id_or_name(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @item = @course.items.find(:first, :conditions => ['lower(name) = ?', params[:id].downcase.gsub('_', ' ')])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(course_items_url(@course)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy_item(klass, name, type_name)\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException => e\n error_message = \"#{e.message}. Could not find a #{type_name} named #{name} to delete!\"\n ui.warn(error_message)\n raise CloudExceptions::ServerDeleteError, error_message\n end",
"def destroy\n self.auth_admin\n @hall = Hall.where(name: @item.location)\n @item.destroy\n respond_to do |format|\n format.html { redirect_to halls_path(@hall), notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_item (grocery, item_name)\n grocery.delete(item_name)\n display_list(grocery)\n end",
"def delete_item(list_name,name)\n if storage.list_exists?(list_name)\n list = List.find(list_name)\n if list.delete_item(name)\n output \"#{cyan(\"Boom!\")} #{yellow(name)} is gone forever.\"\n save\n else\n output \"#{yellow(name)} #{red(\"not found in\")} #{yellow(list_name)}\"\n end\n else\n output \"We couldn't find that list.\"\n end\n end",
"def item_destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy_item(klass, name, type_name)\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def remove_item(list, rm_item)\n# steps:\n # use delete method with key (item) as argument\n list.delete(rm_item)\n # return list\n list\nend",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def destroy_item(klass, name, type_name)\n begin\n object = klass.load(name)\n object.destroy\n ui.warn(\"Deleted #{type_name} #{name}\")\n rescue Net::HTTPServerException\n ui.warn(\"Could not find a #{type_name} named #{name} to delete!\")\n end\n end",
"def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tp list\nend",
"def destroy#\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manifest_item = ManifestItem.find(params[:id])\n @manifest_item.destroy\n\n respond_to do |format|\n format.html { redirect_to manifest_items_url }\n format.json { head :no_content }\n end\n end",
"def remove(list, item_name)\n\tlist.delete(item_name)\nend",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @items_mob = ItemsMob.find(params[:id])\n @items_mob.destroy\n\n respond_to do |format|\n format.html { redirect_to items_mobs_url }\n format.xml { head :ok }\n end\n end",
"def delete_item(access_token)\n @client.item.remove(access_token)\n end",
"def delete_item(name)\n previous = items.size\n items.reject! { |item| item.name == name}\n previous != items.size\n end",
"def delete(object)\n full_name = extract_full_name object\n post 'api/del', :id => full_name\n end",
"def remove_item(list, item_name)\n list.delete(item_name.to_sym)\n list\nend",
"def destroy\n # @item.destroy\n # respond_to do |format|\n # format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @convenience_item.destroy\n respond_to do |format|\n format.html { redirect_to convenience_items_url, notice: 'Convenience item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end"
] | [
"0.712925",
"0.70415443",
"0.6835347",
"0.6801185",
"0.6763019",
"0.6763019",
"0.6760498",
"0.6754438",
"0.67372817",
"0.66783565",
"0.66700804",
"0.6613633",
"0.66009676",
"0.65984744",
"0.65813076",
"0.6577654",
"0.6559557",
"0.6520968",
"0.6520809",
"0.64875764",
"0.6483742",
"0.6482077",
"0.647296",
"0.6444037",
"0.6434075",
"0.64294827",
"0.64228076",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64168817",
"0.64167523",
"0.64140755",
"0.641163",
"0.64004093",
"0.63943756",
"0.63928694",
"0.6381176",
"0.6380527",
"0.6379559",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63724047",
"0.63570255",
"0.63520664",
"0.6342221",
"0.6339461",
"0.6334219",
"0.6326107",
"0.6317851",
"0.6313879",
"0.6313879",
"0.63074803",
"0.6306844",
"0.63010335",
"0.6286926",
"0.628607",
"0.6276556",
"0.62716544",
"0.6268381",
"0.62562925",
"0.6255837",
"0.6253211",
"0.62456554",
"0.62456554",
"0.62456554",
"0.6243726",
"0.6240517",
"0.62312883",
"0.6230876",
"0.6230773",
"0.6227905",
"0.6225193",
"0.62197316",
"0.6219245",
"0.6210959",
"0.62068474",
"0.62051415",
"0.62022454",
"0.62009513",
"0.6200335",
"0.61973184"
] | 0.7403804 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_magic_item_name
@magic_item_name = MagicItemName.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.5332605",
"0.5312215",
"0.5296594",
"0.52965283",
"0.52957606",
"0.5259903",
"0.52443177",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.52329034",
"0.52322394",
"0.5227445",
"0.5222394",
"0.5220348",
"0.5212759",
"0.5207747",
"0.5205933",
"0.5176468",
"0.5173833",
"0.5171983",
"0.51663405",
"0.5159596",
"0.5158247",
"0.51526845",
"0.5152398",
"0.5151361",
"0.5145775",
"0.5140135",
"0.51338995",
"0.51127726",
"0.5112607",
"0.5112607",
"0.5110613",
"0.51067513",
"0.5092337",
"0.508788",
"0.5081578",
"0.5080434",
"0.50679874",
"0.50567716",
"0.5051213",
"0.5048352",
"0.5048352",
"0.5035347",
"0.5026666",
"0.5023127",
"0.5016081",
"0.50129867",
"0.5000684",
"0.4999752",
"0.49979812",
"0.499026",
"0.499026",
"0.49866846",
"0.49800366",
"0.49795717",
"0.49771172",
"0.4968475",
"0.4965813",
"0.4958072",
"0.49561292",
"0.4954901",
"0.49536785",
"0.4953058",
"0.49468648",
"0.49424478",
"0.4932989",
"0.49291888",
"0.49273813",
"0.49271655",
"0.4925948",
"0.49236968",
"0.49203572",
"0.49181753",
"0.49173692",
"0.4916862",
"0.49161318",
"0.49155986"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def magic_item_name_params
params.require(:magic_item_name).permit(:name, :affix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
3 ways to register filter 1. builtin filter filter.add_filter(:mtime, :passed, 30, :days) 2. custom filter filter.add_filter(my_filter) (my_filter must implements match?(path) method) 3. block filter filter.add_filter do |path| filter operations end | def add_filter(*args, &block)
# 3. block filter
if block_given?
filter = File::Visitor::Filter::Proc.new(block)
@filters.push(filter)
return true
end
# 2. custom filter
if (1 == args.size)
custom_filter = args.shift
unless (custom_filter.respond_to?(:match?))
raise ArgumentError,
"custom_filter must implement match?()"
end
@filters.push(custom_filter)
return true
end
# 1. built-in filter
filter_class = File::Visitor::FilterDispatcher.dispatch(args.shift)
@filters.push(filter_class.new(*args))
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_filter(mod); end",
"def add_filter(type, path = nil, **options, &block)\n source_location = block.respond_to?(:source_location) ?\n block.source_location.first : caller_files[1]\n result = super\n watch_element(source_location, :\"#{type}_filter\", filters[type].last)\n result\n end",
"def add_filter(filter = nil, &block)\n id = \"#{filter.inspect}/#{block.inspect}\".hash\n\n @filters[id] = if filter.is_a?(Filter)\n filter\n elsif filter.is_a?(String)\n StringFilter.new(filter)\n elsif filter.is_a?(Regexp)\n RegexpFilter.new(filter)\n elsif block\n BlockFilter.new(block)\n else\n raise ArgumentError, \"Please specify either a string, \" \\\n \"filter, or block to filter source files with!\"\n end\n\n true\n end",
"def add_filter(name, &block)\n raise ArgumentError, \"Expected block to be given\" if block.nil?\n\n @filters[name] = block\n end",
"def add_filters(filters); end",
"def add_filter filter = nil, &block\n @filters.push( filter ) unless filter.blank?\n @filters.push( block ) if block_given?\n end",
"def define_filter(name, &block)\n filters[name.to_sym] = block\n nil\n end",
"def filter(name, &block)\n @filters[name.to_s] = block\n end",
"def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def filter(&block)\n filters = self.filters << yield\n metaclass.send(:define_method, :_filters) do\n filters\n end\n end",
"def add_filter(type, &block)\n filters[type] << block\n end",
"def _add_filter(where, method_or_filter, options, block)\n self.filters[where] << [method_or_filter, options, block]\n end",
"def apply_filter\n end",
"def add_filter(filter)\n @filters << filter\n end",
"def add_file_filter(file_filter)\n @filter_file = file_filter\n end",
"def add_file_filter(file_filter)\n @filter_file = file_filter\n end",
"def named_filter; end",
"def add_filter\n @filter = true \n end",
"def filter(*args,&block)\n if args && args.any? || block_given?\n @filter = Lolita::Configuration::Filter.new(dbi,*args,&block)\n add_observer(@filter)\n end\n @filter\n end",
"def instance_filter(*args, &block)\n instance_filters << [args, block]\n end",
"def register_filter(mod)\n Strainer.global_filter(mod)\n end",
"def filter(*args, &block)\n @filter = block ? Filter.new(*args, &block) : args.first\n self\n end",
"def add_filter(filter)\n @filters << filter\n self\n end",
"def filter(*args, &block)\n if args.length == 1\n args = args.first\n else\n args.freeze\n end\n\n with_opts(:filter=>args, :filter_block=>block)\n end",
"def register_filter(mod)\n StrainerFactory.add_global_filter(mod)\n end",
"def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def filter(&callable)\n filters << callable\n end",
"def add_filter(filter)\n @filters <<\n if filter =~ /\\./\n filter\n else\n \"solr.#{filter}FilterFactory\"\n end\n end",
"def filter(name, &block)\n warn [\n \"NOTE: The fixed `filter` class method is deprecated.\",\n \"This will be removed in 0.22. Use the API for modifers instead.\"\n ].join\n registry.filter(name, &block)\n end",
"def global_filter; end",
"def before method_or_filter, options={}, &block\n _add_filter(:before, method_or_filter, options, block)\n end",
"def filter(name, **options)\n define_method(name) { options }\n end",
"def filters; end",
"def filters; end",
"def before_filter(&block)\n @before_filter = block\n end",
"def filter *filters\n spawn :@filters, @filters + parse_filter_input(filters)\n end",
"def filters\n end",
"def test_add_filter\n flunk\n end",
"def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end",
"def filter(type, &b)\n @app.filters[type] << b\n end",
"def add_filter(filter_symbol)\n filters << filter_symbol\n end",
"def add_filter(name, assertion, equals)\n @filters << Filter.new(name, assertion, equals)\n end",
"def add_filters( *args )\n args.flatten.each do |filter|\n next if filter.nil?\n unless filter.kind_of?(::Logging::Filter)\n raise TypeError, \"#{filter.inspect} is not a kind of 'Logging::Filter'\"\n end\n @filters << filter\n end\n self\n end",
"def event_filter(filter_name, event, &callback)\n case\n when @settings.filter_exists?(filter_name)\n filter = @settings[:filters][filter_name]\n matched = filter_attributes_match?(filter[:attributes], event)\n callback.call(filter[:negate] ? matched : !matched)\n when @extensions.filter_exists?(filter_name)\n extension = @extensions[:filters][filter_name]\n extension.safe_run(event) do |output, status|\n callback.call(status == 0)\n end\n else\n @logger.error(\"unknown filter\", :filter_name => filter_name)\n callback.call(false)\n end\n end",
"def filter( filter_name, value )\n defined? @filters \\\n or return nil\n @filters.respond_to? \"has_key?\" \\\n or return nil\n @filters.has_key? filter_name \\\n or return nil\n f = @filters[filter_name]\n f.call value\n end",
"def _run_filters(where, action)\n self.class.filters[where].each do |(method_or_filter, options, block)|\n if block\n block.call(self) if _filter_condition_met?(method_or_filter, options, action)\n else\n send(method_or_filter) if _filter_condition_met?(method_or_filter, options, action)\n end\n end\n end",
"def param_filter *args, **kwds, &blk\n if blk\n ParamFilter.with_block( self, *args, **kwds, &blk )\n else\n ParamFilter.with_methods( self, *args, **kwds )\n end\n end",
"def FilterExpr(path, parsed); end",
"def add_dir_filter(filter)\n @filter_dir = filter\n end",
"def add_dir_filter(filter)\n @filter_dir = filter\n end",
"def visit_filter(node)\n # For unknown reasons, haml doesn't escape interpolations in filters.\n # So we can rely on \\n to split / get the number of lines.\n filter_name_indent = @original_haml_lines[node.line - 1].index(/\\S/)\n if node.filter_type == 'ruby'\n # The indentation in node.text is normalized, so that at least one line\n # is indented by 0.\n lines = node.text.split(\"\\n\")\n lines.map! do |line|\n if line !~ /\\S/\n # whitespace or empty\n ''\n else\n ' ' * filter_name_indent + line\n end\n end\n\n @ruby_chunks << RubyFilterChunk.new(node, lines,\n haml_line_index: node.line, # it's one the next line, no need for -1\n start_marker_indent: filter_name_indent,\n end_marker_indent: filter_name_indent)\n elsif node.text.include?('#')\n name_indentation = ' ' * @original_haml_lines[node.line - 1].index(/\\S/)\n # TODO: HAML_LINT_FILTER could be in the string and mess things up\n lines = [\"#{name_indentation}#{script_output_prefix}<<~HAML_LINT_FILTER\"]\n lines.concat @original_haml_lines[node.line..(node.line + node.text.count(\"\\n\") - 1)]\n lines << \"#{name_indentation}HAML_LINT_FILTER\"\n @ruby_chunks << NonRubyFilterChunk.new(node, lines,\n end_marker_indent: filter_name_indent)\n # Those could be interpolation. We treat them as a here-doc, which is nice since we can\n # keep the indentation as-is.\n else\n @ruby_chunks << PlaceholderMarkerChunk.new(node, 'filter', indent: filter_name_indent,\n nb_lines: 1 + node.text.count(\"\\n\"))\n end\n end",
"def add_filter(key, callback = nil, &block)\n if callback.nil? && !block\n raise ArgumentError, '#add_filter needs either `callback\\' or a block'\n end\n\n agent&.add_filter(key, block || callback)\n end",
"def before_filter(filter_name, options)\n [options[:only]].flatten.each do |action|\n add_filter(filter_name, action)\n end\n end",
"def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end",
"def add(filter, args=nil)\n args = RDig.config.crawler.send(args) if args.is_a? Symbol\n case filter\n when Symbol\n if args.nil?\n @filters << lambda { |document|\n begin\n UrlFilters.send(filter, document)\n rescue Exception\n @logger.error \"error in URL filter #{filter}: #{$!}\"\n @logger.error $!.backtrace.join(\"\\n\")\n nil\n end\n }\n else\n @filters << lambda { |document|\n begin\n UrlFilters.send(filter, document, args)\n rescue Exception\n @logger.error \"error in URL filter #{filter}: #{$!}\"\n @logger.error $!.backtrace.join(\"\\n\")\n nil\n end\n }\n end\n when Class\n if args.nil?\n if filter.respond_to?(:instance)\n filter_instance = filter.instance\n else\n filter_instance = filter.new\n end\n else\n filter_instance = filter.new(args)\n end\n @filters << lambda { |document|\n filter_instance.apply(document)\n }\n end\n end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def prepend_meantime_filter(*filters)\n conditions = extract_conditions!(filters)\n add_action_conditions(filters, conditions)\n prepend_filter_to_chain('meantime', filters)\n end",
"def filter(filt = nil, *args, **opts)\n @filter = if filt.nil? && !defined?(@filter)\n Filters.default\n elsif filt\n Filters.resolve(filt, *args, **opts)\n else\n @filter\n end\n\n aggregator.filter = @filter\n\n @filter\n end",
"def add_filter!(filter, condition)\n if @root_filter.nil?\n @root_filter = filter\n else\n get_last_filter.set_next_filter!(filter, condition)\n end\n end",
"def before_filter(&block)\n @before_filter = block\n end",
"def file_filtering_conditions(resource_name)\n NfsStore::Filter::Filter.generate_filters_for resource_name, user: current_user\n end",
"def event_filter(&block)\n filter = EventFilter.new(block)\n @event_filters << filter\n filter\n end",
"def initialize(&block)\n @filter = (block || method(:filter))\n super()\n end",
"def apply_custom_filter(filter, value)\n self.scope = self.public_send(filter, value)\n end",
"def Filter=(arg0)",
"def to_filter_proc(filter)\n case ff = filter\n when NilClass then ->(f){ true }\n when Proc then ff\n when Regexp then ->(f){ ff =~ f.to_s }\n else\n ->(f){ ff === f }\n end\n end",
"def before(*args, &block)\n add_filter :before, &(args.empty? ? block : construct_filter(*args, &block))\n end",
"def add_content_filter(*patterns, &filter)\n content_filters << BlockContentFilter.new(patterns, filter)\n end",
"def strict_filters; end",
"def update_filters(l_filter)\n handle_action_exceptions(__method__) do\n raise 'Filters file not valid.' unless File.exist?(l_filter)\n\n do_upload_and_update_filter(l_filter)\n @json ? { 'result' => 'Success' } : true\n end\n end",
"def global_filter=(_arg0); end",
"def filter\n @filter ||= filter_class.new default_filter\n end",
"def addfilter( newfilter )\n if not subfilter\n @subfilter = newfilter\n else\n subfilter.addfilter( newfilter )\n end\n return self\n end",
"def filter_argument; end",
"def create_update_filter( *args )\n opts = args.last.is_a?( Hash ) ? args.pop.dup : {}\n\n opts[ :fields ] ||= args.shift #deprecated\n opts[ :on_content ] ||= args.shift\n opts[ :on_ref_update ] ||= args.shift\n opts[ :on_ref_new ] ||= args.shift\n\n f = UpdateFilter.new( data_source, field_mapper( opts[ :fields ] ) )\n updater_chain( opts[:on_ref_update]) { |c| f.update_ref_filter = c }\n updater_chain( opts[ :on_ref_new ] ) { |c| f.new_ref_filter = c }\n updater_chain( opts[ :on_content ] ) { |c| f.content_filter = c }\n updater_chain( opts[ :on_referer ] ) { |c| f.referer_filter = c }\n\n f.max_retries = opts[ :max_retries ] if opts[ :max_retries ]\n f.isolation_level = opts[:isolation_level] if opts[:isolation_level]\n\n f\n end",
"def add_filter(filter)\n filter = filter.filterhash if filter.respond_to? \"filterhash\"\n if @filterChainHash[:cifilterlist].nil?\n @filterChainHash[:cifilterlist] = [ filter ]\n else\n @filterChainHash[:cifilterlist].push(filter)\n end\n return @filterChainHash\n end",
"def after_filter(&block)\n @after_filter = block\n end",
"def entry_filter; end",
"def filter\n end",
"def add_filters\n add_term_filters\n add_terms_filters\n add_range_filters\n end",
"def filter(name, function)\n filters = (self.model.design_doc['filters'] ||= {})\n filters[name.to_s] = function\n end",
"def global_filter(&block)\n @filters[nil] = block\n end",
"def dispatch_filter(name, values, condition)\n case name\n when /event_property_(\\d+)/\n register_event_property_filter($1, values, condition)\n else\n super\n end\n end",
"def valid_filter_modifiers(anytext, filter)\n # Weed out invalid filter requests\n puts \"checking valid_filter_modifiers: #{anytext}, filter: #{filter.inspect}\" if self.verbose_filters\n # We do not make_symring for two reasons:\n # 1. people will use whatever kind of filter value they need, and ruby can compare it.\n # 2. the filter param is an array\n # #filter = self.make_symring(filter)\n # Weed out invalid filter requests\n allowed = (self.search_filter_keys & filter)\n return false if !filter.empty? && allowed.empty?\n valid_filter_mods = self.get_filter_modifiers(anytext, allowed)\n valid_search_filters = valid_filter_mods.map do |fmod|\n puts \"filter mod #{fmod.inspect} => #{self.search_filters[:filter_modifiers_to_search_filters][fmod]}\" if self.verbose_filters\n self.search_filters[:filter_modifiers_to_search_filters][fmod]\n end.compact\n puts \"valid_filter_modifiers: #{valid_search_filters.inspect}\" if self.verbose_filters\n return valid_search_filters\n end",
"def filter\n @filter ||= if Platform.linux?\n linux_filter\n elsif Platform.os_x?\n os_x_filter\n else\n raise \"Only works on Linux or OS X\"\n end\n end",
"def filters_for(path, options = {}, &block)\n builder = TableFiltersBuilder.new(self)\n table_filters(path, options) do\n capture(builder, &block)\n end\n end",
"def filter(key, &block)\n @output_filters[key] = block if block_given?\n end",
"def add_terms_filters\n add_work_type_filter\n add_user_filter\n add_pseud_filter\n add_collection_filter\n end",
"def add_filter(method_to_call, options = nil)\n if options == nil\n @filter_chain[method_to_call.to_sym] = true\n elsif options.has_key?(:only)\n @filter_chain[method_to_call.to_sym] = Hash.new\n @filter_chain[method_to_call.to_sym][:only] = options[:only]\n elsif options.has_key?(:except)\n @filter_chain[method_to_call.to_sym] = Hash.new\n @filter_chain[method_to_call.to_sym][:except] = options[:except]\n end\n end",
"def strict_filters=(_arg0); end",
"def validate_filter()\n filter_module = (RUBY_VERSION < '1.9') ? params[:filter] : params[:filter].to_sym\n if (params.key?(:filter) && @source::Filters::constants.include?(filter_module))\n @filter = \"#{@source.name}::Filters::#{params[:filter]}\".constantize\n else\n redirect_to root_path\n end\n end",
"def initialize(filter_type, &block)\n if FILTER_TYPES.include?(filter_type)\n @filter_type = filter_type\n else\n raise ArgumentError, \"invalid type #{filter_type}, allowed: #{FILTER_TYPES.join(', ')}\"\n end\n @block = block\n end",
"def add(type, filter=nil, &block)\n if((filter.nil? && !block_given?) || (filter && !filter.is_a?(Filter)))\n raise ArgumentError.new('Filter or proc must be provided for filter')\n end\n const = Splib.find_const(type)\n type = const unless const.nil?\n @lock.synchronize do\n @filters[type] ||= {}\n end\n if(block_given?)\n unless(block.arity == 1 || block.arity < 0)\n raise ArgumentError.new('Block must accept a parameter')\n end\n @lock.synchronize do\n @filters[type][:procs] ||= []\n unless(@filters[type][:procs].include?(block))\n @filters[type][:procs] << block\n end\n end\n end\n if(filter)\n @lock.synchronize do\n unless(@filters[type].include?(filter))\n @filters[type][:filters] ||= []\n unless(@filters[type][:filters].include?(filter))\n @filters[type][:filters] << filter\n end\n end\n end\n end\n filter ? block_given? ? [filter, block] : filter : block\n end",
"def filter(klass = nil, &block)\n @filterClass = klass\n @filterBlock = block\n end",
"def filter_proc(filters = {})\n lambda do |p|\n (filters[:name].nil? || p.name =~ filters[:name]) &&\n (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&\n (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&\n (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&\n (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&\n (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&\n (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&\n (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&\n (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&\n true\n end\n end",
"def filter(filter)\n current_widget.filter filter\n end",
"def uhook_filtered_search filters = {}\n create_scopes(filters) do |filter, value|\n case filter\n when :locale\n {:conditions => {:locale => value}}\n end\n end\n end",
"def filters=( args )\n @filters.clear\n add_filters(*args)\n end",
"def filter_callback=(value)\r\n @filter = value\r\n end"
] | [
"0.70155233",
"0.6996598",
"0.68954813",
"0.6658535",
"0.663216",
"0.658385",
"0.6567839",
"0.6495973",
"0.64650005",
"0.6464861",
"0.6454527",
"0.6416924",
"0.6345174",
"0.6312059",
"0.6290705",
"0.6290705",
"0.6271176",
"0.6257901",
"0.6233235",
"0.62192565",
"0.6142459",
"0.61258966",
"0.6110519",
"0.60721546",
"0.60699177",
"0.6051691",
"0.6044258",
"0.603331",
"0.6002925",
"0.598749",
"0.59817815",
"0.59663093",
"0.59257954",
"0.59257954",
"0.59215385",
"0.5887945",
"0.5887366",
"0.5881777",
"0.5878374",
"0.58732355",
"0.58585256",
"0.5858062",
"0.5853193",
"0.58242345",
"0.5821382",
"0.58197653",
"0.5817948",
"0.5810399",
"0.58021885",
"0.58021885",
"0.5751195",
"0.5750427",
"0.5746269",
"0.57433534",
"0.57213",
"0.5709147",
"0.5709147",
"0.5701693",
"0.56970835",
"0.5696223",
"0.56884086",
"0.56655854",
"0.5651244",
"0.5626655",
"0.5611067",
"0.56065506",
"0.5593874",
"0.559156",
"0.558921",
"0.5581431",
"0.55708474",
"0.5569264",
"0.5568404",
"0.555764",
"0.5548216",
"0.55461407",
"0.55448014",
"0.55369884",
"0.5527079",
"0.5514414",
"0.5509605",
"0.550554",
"0.5505247",
"0.54912543",
"0.54727876",
"0.54699147",
"0.5468061",
"0.5463568",
"0.54596525",
"0.54531574",
"0.5449497",
"0.5443637",
"0.544213",
"0.5433245",
"0.5423487",
"0.54163545",
"0.5409937",
"0.5401105",
"0.5397901",
"0.5397035"
] | 0.7337683 | 0 |
dir: target directory mode: file visit all files dir visit directory only handler: proc to call | def visit_with_mode(dir, mode, &handler)
assert_directory(dir)
entries = Dir.entries(dir)
.sort_by { |filename| filename }
if @direction == :desc
entries.reverse!
end
entries.each do |entry|
next if (dot_dir?(entry) && !@visit_dot_dir)
abs_path = File.join(dir, entry)
if File.directory?(abs_path)
mode == :dir && handler.call(abs_path)
visit_with_mode(abs_path, mode, &handler)
else
if mode == :file && target?(abs_path)
handler.call(abs_path)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_directory(dir, files, rec)\n dir.children(true).each do |f|\n # ignore sub-directories\n if f.directory?\n if rec == false\n next\n else\n process_directory(f.expand_path, files, rec)\n end\n end\n process_file(f.expand_path, files)\n end\n end",
"def process_dir( dir )\n #puts \"Scanning #{dir}\"\n Dir.foreach( dir ) do |entry|\n if entry.start_with?('.')\n next\n end\n path = \"#{dir}/#{entry}\"\n if Dir.exist?(path)\n process_dir(path)\n elsif entry.end_with?( '.rb' )\n process_file( path )\n end\n end\n end",
"def directory(dir); end",
"def files(rootDir)\n Dir.foreach(rootDir) do |dir|\n if dir != \".\" && dir != \"..\"\n puts \"Processing \" + dir\n Dir.foreach(rootDir + \"/\" + dir) do |file|\n if file != \".\" && file != \"..\"\n open(rootDir + \"/\" + dir + \"/\" + file) do |f|\n yield(f)\n end\n end\n end\n end\n end\nend",
"def traverse(dir, base=dir, &block)\n return unless File.directory?(dir)\n Dir.new(dir).each do |file|\n next if file == '.' or file == '..'\n path = File.join(dir, file)\n if File.directory?(path)\n traverse(path, base, &block)\n else\n block.call(path.sub(base+'/',''))\n end\n end\n end",
"def for(file_or_dir); end",
"def in_each_dir\n dirs.each do |dir|\n Dir.chdir(dir) do\n yield(dir)\n end\n end\n end",
"def indir(dir)\n olddir = Dir.pwd\n Dir.chdir(dir)\n yield\n ensure\n Dir.chdir(olddir)\n end",
"def indir(dir)\n olddir = Dir.pwd\n Dir.chdir(dir)\n yield\n ensure\n Dir.chdir(olddir)\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n #p path_cand\n if file_has_admitted_extension?(path_cand)\n @result_list.push(path_cand)\n end\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def each_file(&bl)\n unpack do |dir|\n Pathname(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n @result_list.push(path_cand)\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def each_file(&bl)\n unpack do |dir|\n Pathname.new(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end",
"def dir(*) end",
"def read_dir(dir, &blk)\n Dir.chdir(dir){\n Dir[\"*\"].each do |folder|\n unless ::File.directory?(folder)\n yield ::File.expand_path(folder)\n else\n read_dir(folder, &blk) unless ::File.symlink?(folder)\n end\n end\n }\n end",
"def dir_foreach( *args, &block )\n warn \"Path#dir_foreach is obsoleted. Use Path#each_entry.\"\n each_entry( *args, &block )\n end",
"def scanDir(dirname, matchfn, callfn, recurse)\n\tDir.foreach(dirname) do |filename|\n\t\tfullfilename = dirname + \"/\" + filename;\n\t\tif File.directory?(fullfilename)\n\t\t\tif recurse && filename != \".\" && filename != \"..\"\t\t# don't infinite loop kthx\n\t\t\t\tscanDir(fullfilename, matchfn, callfn, recurse)\n\t\t\tend\n\t\telsif matchfn.call(filename)\n\t\t\tcallfn.call(fullfilename)\n\t\tend\n\tend\nend",
"def parse_dir(dir, depth)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # Error check on input\n if Watson::FS.check_dir(dir)\n debug_print \"Opened #{ dir } for parsing\\n\"\n else\n print \"Unable to open #{ dir }, exiting\\n\"\n return false\n end\n\n debug_print \"Parsing through all files/directories in #{ dir }\\n\"\n\n # [review] - Shifted away from single Dir.glob loop to separate for dir/file\n # This duplicates code but is much better for readability\n # Not sure which is preferred?\n\n\n # Remove leading . or ./\n _glob_dir = dir.gsub(/^\\.(\\/?)/, '')\n debug_print \"_glob_dir: #{_glob_dir}\\n\"\n\n\n # Go through directory to find all files\n # Create new array to hold all parsed files\n _completed_files = Array.new()\n Dir.glob(\"#{ _glob_dir }{*,.*}\").select { |_fn| File.file?(_fn) }.sort.each do |_entry|\n debug_print \"Entry: #{_entry} is a file\\n\"\n\n\n # [review] - Warning to user when file is ignored? (outside of debug_print)\n # Check against ignore list, if match, set to \"\" which will be ignored\n @config.ignore_list.each do |_ignore|\n if _mtch = _entry.match(_ignore)\n _entry = ''\n break\n end\n end\n\n # If the resulting entry (after filtering) isn't empty, parse it and push into file array\n unless _entry.empty?\n debug_print \"Parsing #{ _entry }\\n\"\n _completed_files.push(parse_file(_entry))\n end\n\n end\n\n\n # Go through directory to find all subdirs\n # Create new array to hold all parsed subdirs\n _completed_dirs = Array.new()\n Dir.glob(\"#{ _glob_dir }{*, .*}\").select { |_fn| File.directory?(_fn) }.sort.each do |_entry|\n debug_print \"Entry: #{ _entry } is a dir\\n\"\n\n # Check if entry is in ignore list\n _skip = false\n\n @config.ignore_list.each do |_ignore|\n if mtch = _entry.match(_ignore)\n _skip = true\n end\n end\n\n debug_print \"#{ _entry } was not on ignorelist, adding\\n\"\n\n # If directory is on the ignore list then skip\n next if _skip == true\n\n ## Depth limit logic\n # Current depth is depth of previous parse_dir (passed in as second param) + 1\n _cur_depth = depth + 1\n debug_print \"Current Folder depth: #{ _cur_depth }\\n\"\n\n # If Config.parse_depth is 0, no limit on subdir parsing\n if @config.parse_depth == 0\n debug_print \"No max depth, parsing directory\\n\"\n _completed_dirs.push(parse_dir(\"#{ _entry }/\", _cur_depth))\n\n # If current depth is less than limit (set in config), parse directory and pass depth\n elsif _cur_depth < @config.parse_depth.to_i + 1\n debug_print \"Depth less than max dept (from config), parsing directory\\n\"\n _completed_dirs.push(parse_dir(\"#{ _entry }/\", _cur_depth))\n\n # Else, depth is greater than limit, ignore the directory\n else\n debug_print \"Depth greater than max depth, ignoring\\n\"\n end\n\n # Add directory to ignore list so it isn't repeated again accidentally\n @config.ignore_list.push(_entry)\n end\n\n\n # [review] - Not sure if Dir.glob requires a explicit directory/file close?\n\n # Create hash to hold all parsed files and directories\n _structure = Hash.new()\n _structure[:curdir] = dir\n _structure[:files] = _completed_files\n _structure[:subdirs] = _completed_dirs\n _structure\n end",
"def target_files_in_dir(base_dir = T.unsafe(nil)); end",
"def processDir( dirPath )\n return if not File.directory?( dirPath )\n\n puts File.basename( dirPath ) + \"/\"\n\n Dir.foreach( dirPath ) do | content |\n next if content == \".\" or content == \"..\"\n\n contentPath = dirPath + \"/\" + content\n next if File.symlink?( contentPath )\n\n if File.directory?( contentPath )\n processDir contentPath\n elsif File.file?( contentPath )\n fork do\n flacFile = FlacFile.new contentPath\n flacFile.normalize\n end\n end\n end\n\n Process.waitall\nend",
"def collect_in_dir directory, recursive = true\n if not File.readable? directory\n puts \"#{directory} not readable. Skipping.\" if @verbose\n else\n directory += \"/\" if not directory.end_with? \"/\"\n if File.directory? directory\n files = Dir.entries directory\n files.reject! {|d| d.match /^\\.{1,2}$/} # ignore parent and self links\n files.map! { |f| directory + f }\n files.each do |fname|\n if File.directory?(fname) and recursive\n collect_in_dir fname\n elsif not File.readable? fname\n puts \"#{fname} not readable.Skipping.\" if @verbose\n elsif File.file? fname and File.extname(fname) == @extension # if no directory\n pkg_info = parse_pkg fname\n @files[fname] = pkg_info if pkg_info\n end\n end\n end\n end\n end",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n path == \"/\" or @root.directory?(path) and @root.contents(path)\n end",
"def walk\n FileTreeProfiler.monitor_report(:profile, :dir, path)\n @children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.')\n full_path = ::File.join(path, entry)\n if ::File.directory?(full_path)\n children.push DirFile.new(self, entry)\n else\n children.push DataFile.new(self, entry)\n end\n end\n end",
"def process()\n scan_dir('.', '.')\n end",
"def explore(dir)\n\tterminate if $interrupted\n\tDir.new(dir).each do |node|\n\t\tnode_path = dir + '/' + node\n\t\tif File.directory?(node_path) && !File.symlink?(node_path) && node[0,1] != '.'\n\t\t\texplore node_path\n\t\telsif File.file?(node_path) && node[0] != '.'\n\t\t\tif greppable node_path\n\t\t\t\tif node =~ /#{ARGV[0]}/\n\t\t\t\t\tputs colorize(node_path, 'yellow')\n\t\t\t\t\tStats['name_matches'] += 1\n\t\t\t\tend\n\t\t\t\tgrep_file node_path unless Opts['names']\n\t\t\t\tStats['files_grepped'] += 1\n\t\t\telse\n\t\t\t\tStats['nodes_skipped'] += 1\n\t\t\tend\n\t\telse\n\t\t\tStats['nodes_skipped'] += 1\n\t\tend\n\tend\nend",
"def process_directory(path)\n Find.find(path) do |a_path| \n Find.prune if EXCLUDES_DIRECTORIES.include?(File.basename(a_path))\n if (ACCEPTED_FILES_PATTERN.each { | pattern| File.basename(pattern)} and\n !File.directory?(a_path))\n @files_processed += 1\n document = moddify_document(a_path)\n modify_file(a_path,document)\n end\n end\nend",
"def collect\n return if stat.ftype == \"directory\"\n self\n end",
"def files_in(dir)\n Dir.chdir(dir) do\n Dir.glob('**/*').select { |f| File.file?(f) }\n end\nend",
"def find_files(base_dir, flags); end",
"def walk(path); end",
"def process\n # here is a starting directory\n main_dir = '/home/john/code/ruby/files'\n # let's go to the directory we want\n Dir.chdir(main_dir)\n #print the present working directory (pwd)\n puts Dir.pwd\n # glob is stolen from Perl - list all the \n # matches for the wildcard pattern \"*\"\n listing = Dir.glob(\"*\")\n # put out the list\n puts listing.inspect\n\n\n #let's process the subdirectories and discard other files\n listing.each do |f|\n if File.directory? f\n processDirectory f\n else\n puts \"ignoring file: \" + f\n end\n end\n\n puts @power.inspect\nend",
"def process_rest(dir)\n Dir.glob(\"#{dir}/**/*/**\").sort.each do |path|\n next if EXCLUDE_FILE_LIST[File.basename(path).downcase]\n\n yield(path)\n end\n end",
"def visit_tree(files, &block)\n case files\n when Array\n files.each { | f| visit_tree(f,&block)}\n when String\n yield(:file, files) if block_given?\n when Hash\n files.each do |k,v|\n yield(:directory, k) if block_given?\n Dir.chdir(k) {visit_tree(v, &block) }\n end\n else\n throw \"Bad directory structure #{files}\"\n end\n end",
"def stat_directory(dir)\n return to_enum(__method__, dir) unless block_given?\n\n self.entries(dir).each do |entry|\n path = File.join(dir, entry)\n if stat = self.stat(path)\n yield path, stat\n end\n end\n\n nil\n end",
"def dir_foreach(*args, &block)\n warn \"Path::Name#dir_foreach is obsoleted. Use Path::Name#each_entry.\"\n each_entry(*args, &block)\n end",
"def stat_tree(dir, &block)\n return to_enum(__method__, dir) unless block_given?\n\n self.stat_directory(dir) do |path, stat|\n yield path, stat\n\n if stat.directory?\n stat_tree(path, &block)\n end\n end\n\n nil\n end",
"def dodir(dirname,output)\r\n Dir.foreach(dirname) do |content|\r\n if(content!=\".\" and content!=\"..\" and not content=~/^\\./) then\r\n begin\r\n if(File.directory?(dirname+'/'+content)) then\r\n output.puts \"--- START: [\"+content+\"] ---\\n\"\r\n dodir(dirname+'/'+content,output)\r\n output.puts \"--- END: [\"+content+\"] ---\\n\"\r\n else\r\n dofile(dirname+'/'+content,output) if content=~/.py$/\r\n end\r\n end \r\n end \r\n end\r\nend",
"def in_dir(dir, &block)\n original_dir = Dir.pwd\n begin\n Dir.chdir(dir)\n block.call\n ensure\n Dir.chdir(original_dir)\n end\n end",
"def process_dir(manifest, directory, options = {})\n manifest.directory(directory)\n \n files = relative_dir_files(directory)\n \n process_files(manifest, files, options)\n end",
"def foreach(&block)\n ::Dir.foreach(path, &block)\n end",
"def scan(dir,match=/\\.cha$/)\n files = []\n if not dir.split('/').pop =~ /^\\./ and File.directory?(dir)\n Dir.foreach(dir) do |file|\n path = File.join(dir,file)\n \n if File.directory?(path)\n# puts \"SCANNING #{path}\"\n scan(path,match).each { |pair| files.push pair }\n elsif file =~ match\n files.push path\n end\n end\n end\n\n return files\nend",
"def each(&block)\n SemanticLogger.named_tagged(dirmon_entry: id.to_s) do\n # Case insensitive filename matching\n Pathname.glob(pattern, File::FNM_CASEFOLD).each do |pathname|\n next if pathname.directory?\n pathname = begin\n pathname.realpath\n rescue Errno::ENOENT\n logger.warn(\"Unable to expand the realpath for #{pathname.inspect}. Skipping file.\")\n next\n end\n\n file_name = pathname.to_s\n\n # Skip archive directories\n next if file_name.include?(self.class.default_archive_directory)\n\n # Security check?\n if (whitelist_paths.size > 0) && whitelist_paths.none? { |whitepath| file_name.to_s.start_with?(whitepath) }\n logger.error \"Skipping file: #{file_name} since it is not in any of the whitelisted paths: #{whitelist_paths.join(', ')}\"\n next\n end\n\n # File must be writable so it can be removed after processing\n unless pathname.writable?\n logger.error \"Skipping file: #{file_name} since it is not writable by the current user. Must be able to delete/move the file after queueing the job\"\n next\n end\n block.call(pathname)\n end\n end\n end",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n [\"hello.txt\"]\n end",
"def find_in(dir); end",
"def process_directory(src, dest, ext = nil)\n src_path = '%s/*.%s' % [File.expand_path(src), ext || '*']\n dest_path = File.expand_path dest\n Dir.glob(src_path) do |file|\n dest_file = File.join(dest_path,File.basename(file))\n process_file(file, dest_file)\n end\n end",
"def get_files(dir)\r\n\t\r\n\t\t\tfiles = Dir.glob(dir)\r\n\t\t\tdir_path = dir.chomp(\"*\")\r\n\r\n\t\t\tfor file in files\r\n\t\t\t\tunless File.directory?(file)\r\n\t\t\t\t\tif @ext.include?(File.extname(file))\r\n\t\t\t\t\t\tread_lines file\r\n\t\t\t\t\t\t@num_files = @num_files+1\r\n\t\t\t\t\tend\r\n\t\t\t\t\t\r\n\t\t\t\telse\r\n\t\t\t\t\tget_files file+\"/*\"\r\n\t\t\t\tend\r\n\r\n\t\t\tend\r\n\t\tend",
"def each_file\n return to_enum(__method__) unless block_given?\n\n paths.each do |root|\n stat_tree(root).each do |filename, stat|\n if stat.file?\n yield filename\n end\n end\n end\n\n nil\n end",
"def collection_dir(*files); end",
"def do_dir(start, copyright) \n Dir.foreach(start) { |d| \n if d != \".\" && d != \"..\" then\n sub = start + \"/\" + d \n if not File.directory? sub and sub.include? \".java\" then\n do_java(sub, copyright)\n else \n if File.directory? sub and not sub.include? \".svn\" \n\t then do_dir(sub, copyright) end\n end \n end\n }\nend",
"def process_directory\n Dir.foreach(@source) do |f|\n next unless f.match(/[a-z]{2}[0-9]{3}[a-z]{2}[0-9]{4}\\.xml/)\n druid = get_druid_from_filename(f)\n mods_file = MODSFile.new(Nokogiri::XML(File.open(File.join(@source, f))), @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end",
"def each_file_in_tree\n self.directories_in_tree.find_each do |directory|\n next if directory.nil?\n directory.cfs_files.find_each do |cfs_file|\n next if cfs_file.nil?\n\n yield cfs_file if block_given?\n end\n end\n end",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def run_dir(root)\n\tDir.foreach(root) { |fn|\n\t\tnext if fn == \".\" || fn == \"..\"\n\t\tcombined = File.join(root, fn)\n\t\tif File.directory?(combined)\n\t\t\trun_dir(combined)\n\t\telsif File.file?(combined) && (fn[\".dll\"] || fn[\".pdb\"])\n\t\t\tfpath = combined\n\t\t\tfpath = fpath[2..-1] if fpath[0..1] == \"./\"\n\t\t\tfpath = fpath.gsub(\"/\", \"\\\\\")\n\t\t\tprint(\"#{fpath}\\n\")\n\t\t\t`compress -R #{fpath}`\n\t\t\texit(1) if $?.exitstatus != 0\n\t\t\t`del #{fpath}`\n\t\tend\n\t}\t\nend",
"def k_dir!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 56 )\n\n\n\n type = K_DIR\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 477:3: 'dir'\n match( \"dir\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 56 )\n\n\n end",
"def each_file(directory)\n directory_contents(directory).each do |path|\n yield path\n end\n end",
"def each_file\n @sftp.dir.foreach(@path.to_s) do |entry|\n filename = entry.name\n yield filename unless directory? filename\n end\n end",
"def dir; end",
"def dir; end",
"def dir; end",
"def process_directory(path)\n directories = []\n files = []\n sizes = {}\n mtimes = {}\n Dir.entries(path).sort.each do |filename|\n full_path = \"#{path}/#{filename}\"\n case filename\n when '.' || '..'\n\n when 'index.html'\n\n else\n\n case\n when filename =~ /^\\./\n # ignore hidden files\n when File.directory?(full_path)\n directories << filename\n when File.file?(full_path)\n files << filename\n sizes[full_path] = File.size(full_path)\n mtimes[full_path] = File.mtime(full_path)\n end\n\n end # case filename\n end\n\n directories.sort.each do |directory|\n process_directory(\"#{path}/#{directory}\")\n end\n\n # output this directory's info:\n write_index_file(\"#{path}/index.html\", directories, files, sizes, mtimes)\n puts \"#{path}/index.html\"\nend",
"def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end",
"def dir(path, &block)\n add Config::Patterns::Directory do |p|\n p.path = path\n yield p if block_given?\n end\n end",
"def in_directory( dir, &block )\n curdir = pwd\n begin\n cd dir\n return block.call\n ensure\n cd curdir\n end\nend",
"def process_directory(path)\n directories = []\n files = []\n sizes = {}\n Dir.entries(path).sort.each do |filename|\n full_path = \"#{path}/#{filename}\"\n case filename\n when '.' || '..'\n\n when 'index.html'\n\n else\n\n case\n when filename =~ /^\\./\n # ignore hidden files\n when File.directory?(full_path)\n directories << filename\n when File.file?(full_path)\n files << filename\n sizes[full_path] = File.size(full_path)\n end\n\n end # case filename\n end\n\n directories.sort.each do |directory|\n process_directory(\"#{path}/#{directory}\")\n end\n\n # output this directory's info:\n write_index_file(\"#{path}/index.html\", directories, files, sizes)\n puts \"#{path}/index.html\"\nend",
"def with_directory(dir)\n not_in_root = (dir != :root)\n\n dir_stack.push(dir) if not_in_root\n\n target_dir = not_in_root ? current_app_dir : app_root\n\n yield target_dir\n\n dir_stack.pop if not_in_root\n end",
"def within_dir dir, &blk\n cur_dir = Dir.getwd\n Dir.chdir(dir)\n yield\n Dir.chdir(cur_dir)\n end",
"def files(ident_only=false, &block)\n return super if @init_files\n return to_enum(:files, ident_only) if ! block_given?\n\n repo.chdir do\n Dir.glob(child_repo_path(File.join(DIR_FILE, '*'))).each do |f|\n ident = File.basename(f)\n yield ident_only ? ident : file(ident)\n end\n end\n @init_files = true\n end",
"def run_through_directory\n@file_array = []\n Dir.foreach('text_files') do |item|\n next if item == '.' or item == '..'\n @file_array << item\n end\nend",
"def traverse(pattern, arr, dir)\n Dir.glob(dir + '/**/*') do |file|\n next if file == '.' || file == '..' || file.include?('html~')\n harvest(pattern, file, arr) if file =~ /(.*).html/\n end\n end",
"def each_dir\n self.exit_list.each do |e|\n yield e if e\n end\n end",
"def getfiles path\n\nDir.foreach(path) do |f|\nname=File.basename f\npathn= @to_path + name\n\t\nfilepath =path +\"/\"+ f\n\nputs filepath\n if File.directory? filepath and name != '..' and name != '.' and name != 'new' \n\n Dir.chdir filepath\nstr = Dir.pwd\ngetfiles str\n\nDir.chdir('..')\nelsif File.file? f and name != 'app.rb' \n\tf1 = File.open(f, \"r:binary\")\nf2 = File.open(pathn, \"a:binary\")\n while (b = f1.getc)!= nil do\n \tf2.putc b\nend\n \nf2.close\n\n\nend\n\nend\nend",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n if File.directory?(get_path(path))\n Dir.entries(get_path(path))\n else\n false\n end\n\n rescue\n false\n end",
"def directory(file, remote_file, file_dest, flags)\n @actions << Action::DirectoryAction.new(file, remote_file, file_dest, flags)\n end",
"def each(&block)\n\t\t\t\treturn to_enum unless block_given?\n\t\t\t\t\n\t\t\t\t::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|\n\t\t\t\t\t# Ignore `.` and `..` entries.\n\t\t\t\t\tnext if path =~ /\\/..?$/\n\t\t\t\t\t\n\t\t\t\t\tyield Path.new(path, @root)\n\t\t\t\tend\n\t\t\tend",
"def walk(dir, denyFilters = nil, allowFilters = nil)\n verifyConfigFilename\n ignoreList = []\n Find.find(dir) do |file|\n if File.file?(file)\n fileNameWithoutPath = File.basename(file)\n\n # ignore filenames which start with the config filename \n if (fileNameWithoutPath.upcase.start_with?(S3U_CONFIG_FILENAME.upcase))\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to .s3u filter\"} if (@log)\n ignoreList.push file\n elsif (filter = match?(fileNameWithoutPath, denyFilters))\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to deny filter: #{filter.to_s}\"} if (@log)\n ignoreList.push file\n elsif (filter = match?(fileNameWithoutPath, allowFilters))\n @log.debug(@logPrefix) {\"Pass #{fileNameWithoutPath} due to allow filter: #{filter.to_s}\"} if (@log)\n yield file\n else\n @log.debug(@logPrefix) {\"Ignore #{fileNameWithoutPath} due to no rule\"} if (@log)\n ignoreList.push file\n end\n \n end\n end\n ignoreList\n end",
"def touch_files_in_dir(dir)\n `touch #{dir}/*`\n end",
"def all_files_in(dir_name)\n Nanoc::FilesystemTools.all_files_in(dir_name)\n end",
"def watch_recursive(dir)\n if watch dir\n # if watch current directory succeeded, then continue watching the sub-directories\n Dir.glob(File.join(dir, \"*/\"), File::FNM_DOTMATCH).each do|subdir|\n name = File.basename(subdir)\n next if name == \"..\" or name == \".\"\n watch_recursive subdir\n end\n end\n end",
"def files_in(dir)\r\n ensure_dir_data(dir)\r\n @dirs[dir][:files].keys\r\n end",
"def monitor(file_attr_to_checksum=nil)\n\n # Marking/Removing Algorithm:\n # assume that current dir is present\n # ls (glob) the dir path for child dirs and files\n # if child file is not already present, add it as new, mark it and handle its state\n # if file already present, mark it and handle its state.\n # if child dir is not already present, add it as new, mark it and propagates\n # the recursive call\n # if child dir already present, mark it and handle its state\n # marked files will not be remove in next remove phase\n\n # ls (glob) the dir path for child dirs and files\n globed_paths_enum = Dir.glob(@path + \"/*\").to_enum\n \n found_symlinks = {} # Store found symlinks under dir\n loop do\n globed_path = globed_paths_enum.next rescue break\n\n next unless is_globed_path_valid(globed_path)\n if File.symlink?(globed_path)\n add_found_symlinks(globed_path, found_symlinks)\n next\n end\n\n # Get File \\ Dir status\n globed_path_stat = File.lstat(globed_path) rescue next # File or dir removed from OS file system\n if globed_path_stat.file?\n # ----------------------------- FILE -----------------------\n child_stat = @files[globed_path]\n if child_stat\n # Mark that file exists (will not be deleted at end of monitoring)\n child_stat.marked = true\n # Handle existing file If we are not in manual mode.\n # In manual mode do nothing\n handle_existing_file(child_stat, globed_path, globed_path_stat) unless Params['manual_file_changes']\n else\n unless Params['manual_file_changes']\n # Handle regular case of new file.\n handle_new_file(child_stat, globed_path, globed_path_stat)\n else\n # Only create new content data instance based on copied/moved filed.\n handle_moved_file(globed_path, globed_path_stat, file_attr_to_checksum)\n end\n end\n else\n handle_dir(globed_path, file_attr_to_checksum)\n end\n end\n\n remove_not_found_symlinks(found_symlinks)\n\n GC.start\n end",
"def send_files dir\n halt ::Rack::Directory.new(dir).call(env)\n end",
"def scan_dir(source_dir, target_dir)\n @stats.enter_directory(source_dir)\n\n Dir.foreach(File.join(@source_dir, source_dir)) do |filename|\n source_path_relative = File.join(source_dir, filename)\n source_path = File.join(@source_dir, source_path_relative)\n target_path_relative = File.join(target_dir, filename)\n target_path = File.join(@target_dir, target_path_relative)\n\n # What kind of beast is this?\n if filename == '.' || filename == '..'\n is_skipped_directory = true\n else\n if File.directory?(source_path)\n if (path_matches_skipped?(source_path_relative))\n is_skipped_directory = true\n else\n is_directory = true\n end\n else\n if filename_matches_pattern?(filename)\n if path_matches_exception?(source_path_relative)\n is_exception = true\n else\n is_match = true\n end\n else\n is_ignored = true\n end\n end\n end\n\n if is_skipped_directory\n # do nothing\n elsif is_directory\n scan_dir(source_path_relative, target_path_relative)\n elsif is_match\n @stats.record_scan_matching(filename)\n scan_file(source_path, filename)\n elsif is_exception\n @stats.record_known_exception(filename)\n else # not a match\n @stats.record_scan_non_matching(filename)\n end\n end\n end",
"def scan_dir(path)\n old_files = dir_entries(@old_base, path)\n new_files = dir_entries(@new_base, path)\n old_files.each do |fname, type|\n unless new_files.has_key?(fname) && new_files[fname] == type\n delete_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n @entries << [path + fname, type, :deleted]\n end\n end\n new_files.each do |fname, type|\n if old_files.has_key?(fname) && old_files[fname] == type\n if type == :directory\n scan_dir(path + fname + '/')\n else\n compare_file(path + fname, type)\n end\n else\n @entries << [path + fname, type, :added]\n add_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n end\n end\n end",
"def each_data_dir(path)\n return enum_for(:each_data_dir,path) unless block_given?\n\n each_data_path(path) do |full_path|\n yield(full_path) if File.directory?(full_path)\n end\n end",
"def dir_contents(path, &b)\n path = Pathname.new(path).cleanpath\n if fs.directory?(path)\n entries = fs.entries(path).map do |entry|\n entry_path = path + entry\n if fs.directory?(entry_path)\n dir_item(entry)\n else\n file_item(entry, fs.get_size(entry_path))\n end\n end\n yield entries\n else\n yield Set.new\n end\n end",
"def file_list(dir, opts={})\r\n\topts={:recursive => false, :exclude => []}.merge(opts)\r\n\tf = []\r\n\tDir.glob(File.join(dir,\"*\")).each do | file |\r\n\t\tif File.file?(file) then\r\n\t\t\tnext if opts[:exclude].include? file\r\n\t\t\tf << file\r\n\t\telse\r\n\t\t\tf << file_list(file) if opts[:recursive] && File.directory?(file)\r\n\t\tend\r\n\tend\r\n\treturn f\r\nend",
"def traverse path\n entries = Dir.glob(\"#{View.expand_path(path)}/*\", File::FNM_DOTMATCH).\n select {|i| i !~ /\\/\\.(\\.*|svn|git)$/}. # Exclude some dirs (exclude entensions here too?)\n sort\n\n # Process dirs\n entries.each{ |f|\n next unless File.directory?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1- \")}/\\n\"\n traverse f\n }\n\n # Process files\n entries.each{ |f|\n next unless File.file?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1+ \")}\\n\"\n }\n\n end",
"def read_directories(dir = T.unsafe(nil)); end",
"def list_all_files_in_dir(target)\n all = Pathname.new(target).children\n dirs = all.select { |c| c.directory? }\n dirs.each do |d|\n Puppet.debug(\"Ignoring directory #{d.to_s}\")\n end\n all.select { |c| c.file? }\n end",
"def find(dirs); end",
"def in_dir(directory, &block)\n old_dir = File.expand_path '.'\n Dir.chdir directory if directory\n r = yield block\n Dir.chdir old_dir\n r\n end",
"def dir_files(dir)\n Find.find(dir).to_a.reject!{|f| File.directory?(f) }\nend",
"def each_filename\n next_descend = path\n while next_descend != PathExpression.EMPTY\n dir, next_descend = PathExpression.descend(path)\n yield dir\n end\n end",
"def walk(path, indent, mode, indentMax)\n list = Dir.entries(path);\n if (mode == \"t\")\n list.delete(\".\")\n list.delete(\"..\")\n list.sort! { |a,b| calcDirSize(path + \"\\\\\" + b) <=> calcDirSize(path + \"\\\\\" + a)}\n end\n for index in 0 ... list.size\n if list[index] != '.' && list[index] != '..'\n str = path + list[index]\n if File.directory?(path + \"\\\\\" + list[index]) && (mode == \"t\" || mode == \"n\")\n visit(path + \"\\\\\" + list[index], indent, mode)\n if mode != \"n\" || indentMax == -1 || indent < indentMax\n walk(path + \"\\\\\" + list[index], indent + 1, mode, indentMax)\n end\n elsif mode == \"d\"\n visit(path + \"\\\\\" + list[index], indent, mode)\n end\n end\n end\nend",
"def foreach(*args, &block)\n warn \"Path::Name#foreach is obsoleted. Use each_line or each_entry.\"\n if FileTest.directory? path\n # For polymorphism between Dir.foreach and IO.foreach,\n # Path::Name#foreach doesn't yield Path::Name object.\n Dir.foreach(path, *args, &block)\n else\n IO.foreach(path, *args, &block)\n end\n end",
"def process_libs_in_tree (dir)\n dir.children.each do |file|\n if file.directory?\n process_libs_in_tree file\n elsif (file.extname == \".dylib\" || file.extname == \".so\") && file.ftype == \"file\"\n process(file)\n end\n end\nend",
"def dir_ey\n ->(path) { File.directory?(path) }\n end",
"def files() = files_path.glob('**/*')",
"def traverse_files\n result = []\n paths = config[:paths].select { |p| File.exist?(p) }\n if paths.empty?\n log_warn \"search.paths #{config[:paths].inspect} do not exist\"\n return result\n end\n Find.find(*paths) do |path|\n is_dir = File.directory?(path)\n hidden = File.basename(path).start_with?('.')\n not_incl = config[:include] && !path_fnmatch_any?(path, config[:include])\n excl = path_fnmatch_any?(path, config[:exclude])\n if is_dir || hidden || not_incl || excl\n Find.prune if is_dir && (hidden || excl)\n else\n result << yield(path)\n end\n end\n result\n end",
"def each_directory(&block)\n @directories.each(&block)\n end"
] | [
"0.7269948",
"0.72344595",
"0.7196083",
"0.67955124",
"0.6779908",
"0.67796755",
"0.6704745",
"0.6700345",
"0.6700345",
"0.6691016",
"0.66885805",
"0.66692245",
"0.66111976",
"0.660302",
"0.6600337",
"0.65905225",
"0.6588868",
"0.658193",
"0.6553596",
"0.64825714",
"0.6463325",
"0.64290446",
"0.64143103",
"0.64142454",
"0.6408623",
"0.63832515",
"0.6334949",
"0.63204664",
"0.63150626",
"0.6306632",
"0.6297106",
"0.6296709",
"0.6295142",
"0.628859",
"0.6275776",
"0.62408334",
"0.6240522",
"0.62213165",
"0.6218647",
"0.6199228",
"0.61755514",
"0.61390364",
"0.61319697",
"0.609455",
"0.608991",
"0.60827786",
"0.60314083",
"0.60229015",
"0.600845",
"0.60080796",
"0.6005953",
"0.5994569",
"0.59881186",
"0.5986451",
"0.59863263",
"0.5985279",
"0.59692925",
"0.59692925",
"0.59692925",
"0.595679",
"0.59565157",
"0.59353036",
"0.593085",
"0.59298444",
"0.5924",
"0.59233636",
"0.58901036",
"0.5878148",
"0.5870079",
"0.5869141",
"0.58521676",
"0.5851871",
"0.5839125",
"0.5834574",
"0.58318996",
"0.5830415",
"0.5824418",
"0.58185667",
"0.5815036",
"0.57988197",
"0.5797413",
"0.5794792",
"0.5786527",
"0.578558",
"0.5781242",
"0.5773575",
"0.57734567",
"0.5762052",
"0.57596195",
"0.5754047",
"0.5750047",
"0.5749896",
"0.57441473",
"0.5741017",
"0.5738022",
"0.5728939",
"0.57286",
"0.5725962",
"0.5717587",
"0.571751"
] | 0.76961493 | 0 |
def random_quote random_quote = Quote.all.sample game = Game.find(...) game.random_question render json: random_quote, include: [:author] end def start_game instantiate new game get 10 random quotes for each quote, get a random author render json: [quote1, quote2..., quote10] end | def end_game
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n quotes = OriginalQuote.all\n @quote = quotes.sample\n render json: @quote, status: 200\n end",
"def index\n @jokes = Joke.offset(rand(Joke.count)).first\n @random_joke = Joke.all.shuffle\n @random_quote = Quote.all.shuffle\n @quotes = Quote.offset(rand(Quote.count)).first\n end",
"def random\n @song = Song.where(:user => current_user).sample\n if @song.present?\n respond_to do |format|\n format.html\n format.json { render json: @song }\n end\n else\n respond_to do |format|\n format.html { redirect_to songs_url, notice: 'No Songs created yet.' }\n format.json { head :no_content }\n end\n end\n end",
"def index\n if params['length'].to_i & params['length'].to_i != 0\n @quotes = Quote.all.shuffle.first(params['length'].to_i)\n else\n @quotes = Quote.all.shuffle\n end\n\n #@quotes = Quote.all\n \n respond_to do |format|\n format.html\n format.json { render json: {:data => { :quotes => @quotes}, :result => { :errorcode => \"\", :messages => \"ok\", :rstatus => 1 }} }\n end\n end",
"def index\n @quotecount = Quote.count('id')\n\t\n\tr = Random.new\n\t\n\tif @quotecount > 0\n\t\t@rid = r.rand(0...@quotecount) + 1\n\t\t@quote = Quote.find(@rid)\n\telse\n\t\t@rid = 0\n\tend\n\t\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def random \n if params[:random]\n @card = Card.where(:first => params[:random]).sample\n else\n # @card = Card.all.sample\n rand_id = rand(Card.count)\n @card = Card.first(:conditions => ['id >= ?', rand_id])\n end\n\n respond_to do |format|\n format.html #first.html.erb\n format.json { render json: @card }\n end\n end",
"def random_quote\r\n print Scraper.quotes(self.url).sample\r\n end",
"def random\n offset = rand(@ingredients.count)\n render json: @ingredients.offset(offset).first.as_json\n end",
"def get_random\n @question = Question.get_random\n\n unless @question\n render json: { error: \"random question can't be found\" }.to_json, status: 404\n end\n end",
"def random\n prompts = PromptDatum.all\n \n num = rand(1...prompts.length)\n\n render json: prompts[num]\n end",
"def mad_orig\n mad_quotes = MadQuote.all\n mad_quote = mad_quotes.sample\n orig_quote = OriginalQuote.where(id: mad_quote.original_quote_id)\n render json: [mad_quote, orig_quote], status: 200\n end",
"def ten_random\n @verbs = Verb.order(\"RANDOM()\").limit(10)\n render json: @verbs\n end",
"def sample_question\n get_all_from_database.sample\n end",
"def robot_details_generator\n @robot.robot_name = Faker::Name.first_name\n quote = HTTParty.get('http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=10')\n @quote = quote[0]['content']\n offset = rand(Suburb.count)\n Suburb.all.where(:id => offset).each do |suburb|\n @robot.suburb = suburb.suburb_name\n @robot.postcode = suburb.postcode\n @robot.state = suburb.state\n @robot.latitude = suburb.latitude\n @robot.longitude = suburb.longitude\n @robot.quote = @quote\n end\n end",
"def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end",
"def random_quote\n self.artist_products.select{|ap| ap unless ap.quote.blank?}.sort_by{rand}.first\n end",
"def random\n @shop = Shop.find(params[:shop_id])\n @random = @shop.items.all.sample\n end",
"def show\n @testimonials = select_random(Testimonial)\n end",
"def random\n random_card = self.class.get('/cards/random')\n end",
"def show\n @post = Post.find(params[:id])\n add_impression(current_user) # AppController method\n\n @random_post = Post.all.sample\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def seed_art\n ### generates seed art\n 100.times do \n categories = [\"Cool Things\", \"The color red\", \"Heavy stuff\", \"Ocean\"]\n category = Category.find_or_create_by(name: categories.sample)\n random = User.all.sample\n newart = Art.create(\n user_id: random[:id],\n artist_id: random[:id],\n category_id: category[:id],\n for_sale: false,\n slug: \"a-work-of-art\",\n description: \"a work of art\",\n caption: category[:name],\n value: rand(1..100),\n link: \"www.nftgram.io\"\n )\n user_length = User.all.length\n art_length = Art.all.length\n random_number_art = rand(1..art_length)\n random_number_user = rand(1..user_length)\n comments = [\"Beautiful.\", \"Very nice.\", \"Cooooool.\", \"Wow this is art.\", \"Perfection.\"]\n ### generates art likes\n Like.create(user_id: random_number_user, likeable_type: \"Art\", likeable_id: random_number_art)\n ### generates art comments\n Comment.create(comment: comments.sample, user_id: User.all.sample[:id], commentable_id: newart[:id], commentable_type: 'Art') end\nend",
"def show\n @cart = Cart.find_by(id: session[:cart_id])\n @random1 = Item.all.sample\n @random2 = Item.all.sample\n @random3 = Item.all.sample\n end",
"def random_play\n\t\tself.played = true\n\n\t\tlocal_participations = local_inscription.participations\n\t\taway_participations = away_inscription.participations\n\n\t\t# goals\n\t\t(1..3).to_a.sample.times do |n|\n\t\t\tGoal.create(game_id: self.id, participation_id: local_participations.sample.id)\n\t\tend\n\t\t# yellow_cards\n\t\tCard.create(game_id: self.id, participation_id: local_participations.sample.id, card_type: 1)\n\t\t# red_cards\n\t\tif (0..3).to_a.sample == 0\n\t\t\tCard.create(game_id: self.id, participation_id: local_participations.sample.id, card_type: 2)\t\n\t\tend\n\n\t\t# goals\n\t\t(1..3).to_a.sample.times do |n|\n\t\t\tGoal.create(game_id: self.id, participation_id: away_participations.sample.id)\n\t\tend\n\t\t# yellow_cards\n\t\tCard.create(game_id: self.id, participation_id: away_participations.sample.id, card_type: 1)\n\t\t# red_cards\n\t\tif (0..3).to_a.sample == 0\n\t\t\tCard.create(game_id: self.id, participation_id: away_participations.sample.id, card_type: 2)\t\n\t\tend\n\n\t\tself.save\n\tend",
"def random(q: nil, format: \"json\", face: nil, version: \"large\", pretty: false)\n params = {\n q: q,\n format: format,\n face: face,\n version: version,\n pretty: pretty\n }\n\n req = Request.new(params = params,\n headers = nil,\n body = nil)\n\n Scryfall::Card.new JSON.parse(connection.get(\"/cards/random\", req).body)\n end",
"def randomise\n @random_articles = Article.limit(5).order(\"RANDOM()\")\n @random_users = User.limit(5).order(\"RANDOM()\")\n @random_diarys = Diary.limit(5).order(\"RANDOM()\")\n @random_groups = Group.limit(5).order(\"RANDOM()\")\n end",
"def random_roberto_speech\n skip_authorization\n respond_to do |format|\n format.json do\n render json: { roberto_speech: \"#{RobertoBarros.in_ingrish} #{direction_for_active_cell(@play)}\" }\n end\n end\n end",
"def index\n @images = @current_user.images\n @images.each do |i|\n i.text=@current_user.quotes.random\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @images }\n end\n end",
"def show\n @quote = Quote.find_by_permalink(params[:short_link])\n @next_quote = Quote.first(:offset => rand(Quote.count))\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @result = Result.new\n questions = @quiz_run.questions\n # Retrieve 5 random questions, and paginate them\n @questions = questions.offset(rand(questions.count)).paginate(:page => params[:page], :per_page => 1, :total_entries => 5)\n end",
"def random\n RandomJam.jam(@api_key, @https)\n end",
"def random_quote\n quote = @db.get_first_value(\"SELECT quote FROM quotes ORDER BY RANDOM() LIMIT 1;\")\n return quote\n end",
"def show\n @q = Q.find_by_unique_id(params[:id])\n\n @q_next = Q.offset(rand(Q.count)).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @q }\n end\n end",
"def generate\n game = fetch_game(options[:game])\n game_data = game.get\n\n if game_data[:current_stage] != GameState::QUESTION_OPEN\n log.error \"question is not open.\"\n exit 0\n end\n question_count = game_data[:active_question_max_answer_id] + 1\n\n player_ids = []\n game.collection('players').where('is_active', '==', true).get.each do |player_snapshot|\n player_ids << player_snapshot.document_id\n end\n player_count = player_ids.size\n\n log.info \"#{player_count} active players.\"\n\n previous_second = nil\n sent_this_second = 0\n loop do\n db.transaction do |tx|\n 5.times do\n player_id = player_ids[rand(player_count)]\n game.collection('player_answers').doc(player_id).set({answer_id: rand(question_count)})\n sent_this_second += 1\n end\n end\n\n this_second = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i\n if this_second != previous_second\n log.info \"sent #{sent_this_second} this second.\"\n sent_this_second = 0\n previous_second = this_second\n end\n end\n end",
"def forecast_future(question, responses)\n random_key = responses.keys[rand(responses.size)]\n puts responses[random_key].sample\nend",
"def show\n @quizSelect = Quiz.find(1)\n @questions = @quizSelect.questions\n @cards = Card.all.limit(@quizSelect.questions.count*3).shuffle\n\n \tend",
"def random_skills(skills, count)\n Skill.where(name: skills.sample(count))\nend",
"def romeo_and_juliet_quote\n sample(romeo_and_juliet)\n end",
"def build_random_question(params = {})\n # default values\n params[:previous_question] ||= nil\n params[:duration] ||= 600\n\n # build and return the question\n question = Question.generate_random(params.slice(:number_of_goods))\n question.user = self\n question.duration = params[:duration]\n question\n end",
"def random\n @ip_address = request.remote_ip\n @random_joke = Joke.includes(:votes).where(:votes => {:joke_id => nil}).sample\n @joke_i_vote = Vote.where(ip_address: @ip_address).pluck(:joke_id)\n @joke_without_my_vote = Joke.where.not(id: @joke_i_vote)\n\n if @random_joke\n # 1. Find the joke without any votes\n @random_joke.id\n elsif @joke_without_my_vote.count > 0\n # 2. Find the joke I didn't vote\n @joke_without_my_vote.first.id\n else\n # 3. Ask the user to create joke, if I voted all already\n 0\n end\n end",
"def render_json_random(table)\n render json: serializer(table).new(model(table).random)\n end",
"def get_quote(author, index = nil)\n if index.nil?\n quote_length = (@quotes[author].length) - 1\n index = Random.rand(0..quote_length)\n end\n \n @quotes[author][index]\n end",
"def random\n @playlist = @db.shuffle\n end",
"def motivate(opts = {})\n author = (opts[:author].nil?) ? @quotes.keys.sample : opts[:author]\n\n readable(author) + @colourer.random(\" ~ \" + get_quote(author, opts[:id]))\n end",
"def index\n @assertions = Assertion.all.sample(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @assertions }\n end\n end",
"def generate_question(player_name)\n question = {}\n which_type = rand(0..(@question_types.size - 1))\n first_operand = rand(1..20)\n second_operand = rand(1..20)\n question_type = @question_types.keys[which_type]\n question_text = \"#{player_name}, what is #{first_operand} #{@question_types[question_type]} #{second_operand}? \"\n\n question[:text] = question_text\n question[:type] = question_type\n question[:first_num] = first_operand\n question[:second_num] = second_operand\n\n question\nend",
"def random_hugs\n huglist_sample = []\n 5.times { huglist_sample.push(Huglist.all.sample[:id]) }\n return huglist_sample.uniq\nend",
"def get_random()\n \n end",
"def get_random()\n \n end",
"def index\n t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n limit = rand(20..35)\n randoms = RandomPerson.all(limit: limit)\n t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n render locals: {\n randoms: randoms,\n winner_id: randoms[rand(0...limit)].id,\n elapsed_millis: (t2 - t1) * 1000\n }\n end",
"def generate_results\n Result.destroy_all\n\n puts 'Generating results'\n\n (MULTIPLIER * 3).times do\n user_id = User.all.sample.id\n question_id = Question.all.sample.id\n result = ['true', 'false'].sample\n Result.create(user_id: user_id, question_id: question_id, result: result)\n end\nend",
"def show\n @place_images = nil\n if @place\n if @place.galleries.random\n @place_images = @place.galleries.random.images.random(3)\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @place }\n end\n end",
"def generate_text_resources()\n\n # get total number of games in database\n upper_limit = JSON.parse(get_response(\"games\", \"\").body)['number_of_total_results']\n\n # generate a random id\n random_id = rand(upper_limit)\n \n # get 5 descriptions!\n description_response = JSON.parse(get_response(\n \"games\",\n \"offset=#{random_id}&limit=5&field_list=description,aliases\").body)\n\n # let's return the one's that aren't nil\n nonempty_descriptions = description_response[\"results\"].select{ |x| x[\"description\"] != nil }\n if nonempty_descriptions.empty?\n return generate_text_resources\n else\n return nonempty_descriptions\n end\nend",
"def random_meal\n # API EXAMPLE: https://www.themealdb.com/api/json/v1/1/random.php\n content = api_call('random.php')\n validate(content)\n content\n end",
"def king_richard_iii_quote\n sample(king_richard_iii)\n end",
"def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample)\n end\n ap cart \nend",
"def random_quote(msg)\n return if Variables::Constants::IGNORED_USERS.include?(msg.user.nick)\n quotes = Variables::NonConstants.get_quotes\n quote = quotes.sample\n @last_quotes = [] if @last_quotes.nil?\n quote = quotes.sample while @last_quotes.include?(quote)\n @last_quotes.prepend_capped(quote, 5)\n msg.reply(quote)\n end",
"def show \n @moods = Mood.all\n @foods = Food.all\n @diets = Diet.all\n @restaurants = Restaurant.near([@hood.latitude, @hood.longitude], 0.75)\n @rest_ids = @restaurants.map(&:id)\n @random = Dish.limit(30).where(restaurant_id: @rest_ids).order(\"RANDOM()\").first\n \n respond_to do |format|\n format.html\n format.js\n end\n end",
"def random_skill\n rand(70..90)\nend",
"def random()\n\n @config = params[:config].split(\"/\")\n getCount()\n validateCategories() or return\n\n @namerators = []\n (1..@count).each do\n @namerators.push(Result.new(@config))\n end\n render json: @namerators\n end",
"def random_experiment\n @running_experiments = if not current_user.nil?\n current_user.get_running_experiments\n elsif not sm_user.nil?\n sm_user.scalarm_user.get_running_experiments\n else\n []\n end\n\n if (experiment = @running_experiments.sample).nil?\n render inline: '', status: 404\n else\n render inline: experiment.id.to_s\n end\n end",
"def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend",
"def quote\n fetch('heroes_of_the_storm.quotes')\n end",
"def random_query\n # Use a fake query\n # TODO: better random queries\n 'query ' + (rand*5000).to_i.to_s\nend",
"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 create_rand_spot\n spot_list = []\n 100.times {\n spot_list << @spot = Spot.new\n }\n spot_list\nend",
"def quote\n fetch('games.street_fighter.quotes')\n end",
"def as_you_like_it_quote\n sample(as_you_like_it)\n end",
"def create_comments\n Author.all.each do |author|\n 2.times do\n Comment.create(body: Faker::Hipster.sentence(2), author_id: author.id, article_id: Article.pluck(:id).sample)\n end\n end\nend",
"def get_sample\n reviews = Review.where(destination_id: self.id)\n sample = reviews[rand(reviews.length)]\n return sample\n end",
"def random(*args); 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 execute\n questions = QuestionMapper.find_all\n answers = AnswerMapper.find_all\n answer_hash = Hash.new(0)\n\n answers.each do |ans| \n answer_hash[ans.id] = ans\n end \n \n questions.each do |question| \n answer_arr = [] \n answer_arr << question\n answer_arr << (answers.sample(3) - [answer_hash[question.id]] + [answer_hash[question.id]])\n print_segment(answer_arr)\n end \n\n :ok\n end",
"def pull_food_from_db\n PlaylistFood.order(\"random()\").first\n end",
"def json_index_random_items_by_limit_by_offset\n\n respond_to do |format|\n\n @items_designs = ItemsDesign.order(\"RANDOM()\").limit(params[:limit]).offset(params[:offset])\n format.json { render json: @items_designs }\n\n end\n end",
"def random\n @app = App.order(\"RANDOM()\").first\n if @app.nil?\n redirect_to home_url, notice: 'there is not app'\n else\n respond_to do |format|\n format.html { redirect_to @app}\n format.json { render :show, status: :show, location: @app }\n end\n end\n end",
"def index\n @restaurants = Restaurant.order('RANDOM()').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @restaurants }\n end\n end",
"def quote\n fetch('new_girl.quotes')\n end",
"def playtest_conf\n # @conf = Conf.where(game_id: params[:game_id]).sample #take a random Conf of that game\n @conf = find_playtest_conf\n\n respond_to do |format|\n if @conf\n format.html { redirect_to @conf }\n format.json { render :playtest_conf, status: :ok }\n else\n format.json { render :playtest_conf, status: :not_implemented }\n end\n end\n end",
"def show\n @game = Game.find params[:id]\n \n\n @alph = @game.questions.map do |q|\n q.question\n end\n\n @questions = @game.questions.map do |q|\n {image: q.question, word: q.answer}\n end\n\n end",
"def get_3_random_answers(company_id)\n get_answers(company_id).sample(3)\n end",
"def index\n @good_guys = GoodGuy.all.includes(:good_deeds).shuffle\n end",
"def new\n \tsession[:state]= 3\n \t\n \t@playground = Playground.find(session[:playground_id]) \t\n \t@player = Player.find(session[:player_id])\n\n\t#If the playground doesn't have a question, create new, otherwise find the question\n\t@question = Question.where(:playground_id => @playground.id)\n\tif @question.count == 0\n\t \t\n\t \t@question = Question.new\n\t\t@question.stimulus = \"What is ?\"\n\t #t.string \"image_url\"\n\t a = (0..100).to_a\n\t p1 = a.sample\n\t\t@question.param1 = p1\n\t\tb = (0..100).to_a\n\t p2 = b.sample\n\t\t@question.param2 = p2\n\t\t@question.number_response = p1 + p2\n\t \t@question.playground = (@playground)\n\t \t\n\t \t@question.save\n\t \t\n \telse \n \t\t @question = @question[0]\n \tend\n \t\n \tsession[:qid]=@question.id\n \n \t@player.update_attribute(:state, 3)\n @q_response = QResponse.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @q_response }\n end\n end",
"def teach\n KNOWLEDGE.sample #returns random element from array\nend",
"def quotes_by_author\n @quotes = Quote.where(:author_slug => params[:name]).paginate(:page => params[:page], :per_page => 15)\n @author = @quotes.first.author unless @quotes.empty?\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render json: @quote }\n end\n end",
"def index\n @card = @deck.cards.find(:first, :order => 'RAND()')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cards }\n end\n end",
"def get_sample\n if @options.blank?\n model.order('RAND()').first\n else\n if @options.has_key?(\"id\")\n find @options[\"id\"]\n elsif @options.has_key?(\"conditions\")\n model.order('RAND()').where(@options[\"conditions\"]).first\n end\n end\n end",
"def selected_surveys\n Survey.order('RANDOM()').first(COUNT / 2)\nend",
"def newCard\n\t@card = Cards.new\n \t@card.random\n end",
"def initialize(questions)\n @playing_questions = questions.sample(NUMBER_OF_QUESTIONS)\n @points = 0\n @correct_answers = 0\n end",
"def index\n randomShop\n\n end",
"def index\n @article = Article.last\n @articles = Article.where.not(id: @article).sample(12)\n end",
"def random_question\n QuestionWrapper.new(current_group.questions.random, view_context)\n end",
"def send_random(event)\n # Parse message parameters\n msg = event.content\n type = parse_type(msg) || Level\n tabs = parse_tabs(msg)\n amount = [msg[/\\d+/].to_i || 1, NUM_ENTRIES].min\n\n # Retrieve list of maps\n maps = tabs.empty? ? type.all : type.where(tab: tabs)\n\n # Format and send response\n if amount > 1\n tabs = format_tabs(tabs)\n type = format_type(type).downcase.pluralize\n event << \"Random selection of #{amount} #{tabs} #{type}:\".squish\n event << format_block(maps.sample(amount).map(&:name).join(\"\\n\"))\n else\n map = maps.sample\n send_screenshot(event, map)\n end\nrescue => e\n lex(e, \"Error getting random sample.\", event: event)\nend",
"def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample) \n end\n cart\nend",
"def get_random_quick_queries(types)\n allTypes = types.collect {|type| type.get_quick_queries}.flatten\n prng = Random.new\n random_qq = allTypes.sort {|item1, item2| prng.rand(-1 .. 1) }.slice(0, 5)\n random_qq.collect {|qq| render_quick_query(qq)}\n end",
"def show\n # Se o array de quotes for maior que zero, significa que as frases foram trazidas do banco de\n # dados\n if @quotes.size == 0\n # caso o array de quotes tenha tamanho zero, será feita a pesquisa das frase no \n # site http://quotes.toscrape.com/\n @quotes = WebCrawler.request(params[:tag].downcase)\n # Caso ocorra algum erro na pesquisa, é retornada uma lista vazia\n if @quotes == nil\n @quotes = []\n end\n end\n render json: {'quotes': @quotes.as_json.each{ |item| item.delete(\"_id\")}}, adapter: :json\n end",
"def pick_random\r\n @card_list.pick_random\r\n end",
"def draw_one\n # session[:cards]はランダム化したカードidの配列\n # すでに全カード使いきっていたら再設定\n session[:cards] = @tarot.cards.map(&:id).shuffle.shuffle if session[:cards].empty?\n @card = Card.find(session[:cards].pop)\n @panel = %w(panel-default panel-primary panel-success panel-info panel-warning panel-danger).shuffle.shuffle[0]\n respond_to do |format|\n format.json { render action: 'show', status: :created }\n format.js\n end\n end",
"def create_random_contract\n return nil if contracts.offered.count > 3\n create_third_party_mission available_contract_missions.sample\n end",
"def get_movies\n\t\t@movies = Movie.order(\"RANDOM()\").where(\"release_date > ?\", 3.years.ago).order('random()').joins(:critic_movies).group('movies.id').having(\"count(movie_id) >= #{CUTOFF}\")\n\t\t.limit(750).to_a\n\t\t@movies.each do | movie | \n\t\t\tmovie.title = movie.title.split.map(&:capitalize).join(' ')\n\t\tend\n\t\t@movies = @movies.to_a.map(&:serializable_hash).to_json\n\t\trender :json => @movies\n\tend",
"def retrieve_riddle()\n @question = @riddles.keys.sample(1).join(' ')\n end"
] | [
"0.71403",
"0.6931888",
"0.6931158",
"0.6839698",
"0.6745061",
"0.67166954",
"0.66780484",
"0.66424185",
"0.6592468",
"0.6538297",
"0.65339357",
"0.64561725",
"0.64355725",
"0.63954216",
"0.6292724",
"0.62890536",
"0.6255388",
"0.6254601",
"0.6192117",
"0.61052734",
"0.606051",
"0.605478",
"0.6012002",
"0.60093486",
"0.60044336",
"0.59790933",
"0.593738",
"0.58826226",
"0.58634216",
"0.5852875",
"0.585193",
"0.5823352",
"0.5823298",
"0.5804595",
"0.579663",
"0.5789962",
"0.57872695",
"0.57646966",
"0.57631606",
"0.57440424",
"0.5735426",
"0.5713544",
"0.57135004",
"0.5693715",
"0.56883425",
"0.5680114",
"0.56592745",
"0.56592745",
"0.56577384",
"0.5646717",
"0.56398994",
"0.5634202",
"0.5633899",
"0.56333417",
"0.56135005",
"0.561317",
"0.5610602",
"0.56072307",
"0.5603176",
"0.5598754",
"0.5589888",
"0.55872214",
"0.5583331",
"0.5572456",
"0.55723315",
"0.55432355",
"0.5538919",
"0.55355924",
"0.5534923",
"0.5530803",
"0.5529668",
"0.55219996",
"0.5509711",
"0.55072004",
"0.55047816",
"0.54979545",
"0.5487718",
"0.54853976",
"0.54850817",
"0.548407",
"0.54789984",
"0.54780394",
"0.54723954",
"0.54612356",
"0.54588354",
"0.54587495",
"0.5455153",
"0.54491574",
"0.54444957",
"0.5439487",
"0.54385716",
"0.54369557",
"0.54325783",
"0.54275584",
"0.54273677",
"0.5416394",
"0.54137117",
"0.54080826",
"0.5405059",
"0.5404691",
"0.5403786"
] | 0.0 | -1 |
Result updated_at should propagate to Event updated_at but does not yet | def results_updated_at
Result.where(race_id: races.map(&:id)).maximum(:updated_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_at\n dateChanged\n end",
"def update \n update = object.updated_at\n end",
"def updated_on\n updated_at\n end",
"def updated_at\n Time.at @updated rescue nil\n end",
"def updated_at\n created_at\n end",
"def unchanged?\n created_at == updated_at\n end",
"def bump_timestamps\n self.updated_at = Time.now.utc\n end",
"def update_received_modified\n self.received_at = Time.now if received_changed?\n end",
"def date() updated; end",
"def _update_timestamps\n if self.respond_to?('updated_at')\n self.updated_at = Time.now\n end\n end",
"def autolog_updated\n autolog_event(:updated)\n end",
"def update_status_timestamp\n self.overall_status_modified_at = Time.zone.now\n end",
"def last_updated\n self.dig_for_datetime(\"lastUpdateOn\")\n end",
"def set_timestamps\n return if skip_edited\n self.edited_at = self.updated_at\n return if skip_tagged\n return if replies.exists? && !status_changed?\n self.tagged_at = self.updated_at\n end",
"def updated(date_or_time = T.unsafe(nil)); end",
"def updated\n updated_at.utc.strftime(\"%F %T\") if updated_at\n end",
"def updated_at\n @udpated_at ||=\n Utilities.utc_to_localtime(@ldap_entry[:whenchanged].first)\n end",
"def updated_at\n @updated_at ||= parse_or_at(@attrs[:updated_at]) if @attrs[:updated_at]\n end",
"def timestamp_attributes_for_update\n ['last_activity']\n end",
"def updated_at\n @updated_at ||= Time.parse(@attributes['updated_at'])\n end",
"def _updated_at(target)\n result = rate(@original, target)\n \n result[:updated_at]\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 updated_at\n @gapi[\"updated\"]\n end",
"def updated_at_nil?\n object.updated_at.nil?\n end",
"def updated() read_attribute_w_fallbacks( :updated, :published ); end",
"def updated_at?\n !updated_at.nil?\n end",
"def stamp_changed\n return unless changed?\n\n self.dateChanged = Time.now\n self.changedBy = ApplicationController.application_name\n end",
"def updated?() updated.present?; end",
"def received_at\n updated_at_for_status \"received\"\n end",
"def set_updated!\n @updated_at = Time.now\n end",
"def set_target_updated_on_save\n self.target_updated_at = target.updated_at\n end",
"def last_updated\n\t\tupdated_at\n\tend",
"def updated(opts={})\n ordered(:updated_at)\n date_time_filter(:updated_at, time_range(opts[:on], opts[:during], opts[:since], opts[:until]))\n self\n end",
"def has_updated_at_timestamp?\n !!@updated_at\n end",
"def should_notify?\n self.created_at == self.updated_at\n end",
"def stamp_new_rows\n db.query(\"UPDATE #{audit} SET `_copied_at` = NOW() WHERE `_copied_at` IS NULL\")\n end",
"def updated_at\n @updated_at ||= begin\n updated_dates = [self[:updated_at] || self[:created_at] || Date.null_date.to_time]\n updated_dates += self.captions.collect{|c| c.updated_at }\n \n updated_dates.compact.max\n end\n end",
"def able_to_set_updated_at?\n !frozen? && !timeless? && (new_record? || changed?)\n end",
"def force_updated_on_change\n if @current_journal || changed?\n self.updated_on = current_time_from_proper_timezone\n if new_record?\n self.created_on = updated_on\n end\n end\n end",
"def updated_at\n commit.committer_date rescue Time.now\n end",
"def outdated; end",
"def updated_at\n formatted_time(object.updated_at)\n end",
"def mark_as_updated\n update_column( :updated_at, Time.now )\n Observation.delay(\n run_at: 10.minutes.from_now,\n priority: INTEGRITY_PRIORITY,\n unique_hash: { \"Observation::elastic_index\": id }\n ).elastic_index!( ids: [id] )\n end",
"def extendbyfourteendays\n updated_at = Time.now\n end",
"def updated\n ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing\n # db backed attribute\n read_attribute_w_fallbacks( :updated, :published )\n end",
"def updated_at\n DateTime.parse((solr_document[\"updated_at_dtsi\"] || solr_document[\"timestamp\"] || solr_document[\"created_at_dtsi\"]).to_s).utc\n end",
"def get_status_changed_at\n return @m_status_changed_at\n end",
"def after_update(updated)\n # not required\n end",
"def touch_date uid=nil\n if ref = ref_if_any(uid)\n ref.updated_at\n end\n end",
"def get_updated_times\n @last_updated_time = Event.last_updated_datetime.to_s(:timepart)\n @last_updated_date = Event.last_updated_datetime.to_s(:listing_date)\n @last_updated_datetime = Event.last_updated_datetime\n end",
"def update\n @event = Event.find(params[:id])\n params[:event][:date_at] = DateTime.parse(\"#{params[:event][:date_at]} #{params[:event][:start_at]} -0600\")\n params[:event][:start_at] = DateTime.parse(\"#{params[:event][:date_at]} #{params[:event][:start_at]} -0600\")\n @event.assign_attributes(params[:event])\n print \"\\ncambios en el objeto=>#{@event.changes}\\n\"\n changes = @event.changes_to_fb\n print \"\\nchanges_to_fb antes de guardar=>#{changes}\\n\"\n respond_to do |format|\n if @event.save\n change_to_fb = @current_user.delay.update_fb_event(@event,changes) if !changes.empty?\n print \"\\nSe cambio el de facebook=>#{change_to_fb}\\n\"\n format.html { redirect_to admin_events_path, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def has_changed?\n updated_at > 8.hours.ago\n end",
"def test_updated_by_necessary\n @event.updated_by = nil\n assert !@event.save\n end",
"def updated_at?\n valid_params[\"updated_at\"] != nil\n end",
"def refresh\n update_attributes({:updated_at => DateTime.parse(Time.now.to_s)})\n end",
"def viewed_at\n updated_at\n end",
"def date_triggered\n created_at\n end",
"def updated\n return @poco_data[:updated] unless @poco_data == nil\n upd = pick_first_node(@poco.xpath('./poco:updated'))\n if upd != nil\n DateTime.parse(upd)\n end\n end",
"def edited_at\n updated_at if @data['edited']\n end",
"def updated_data; end",
"def stale?\n unlocked? and item.has_attribute?(:updated_at) and updated_at < item.updated_at\n end",
"def updated\n watchers.find_all(&:updated?)\n end",
"def fresh?\n created_at == updated_at\n end",
"def touch_when_logging\n self.log_updated_at = Time.zone.now\n save\n end",
"def sent_at\n updated_at_for_status \"sent\"\n end",
"def update_record(item = nil, no_raise: false, **prm)\n keep_date = updated_at = old_values = nil\n # noinspection RubyMismatchedReturnType\n super { |record, attr|\n opt = attr.extract!(*ManifestItem::UPDATE_STATUS_OPTS)\n keep_date = !opt[:overwrite] unless opt[:overwrite].nil?\n new_fields = keep_date.nil? && attr.except(*NON_EDIT_KEYS).keys.presence\n old_values = new_fields && record.fields.slice(*new_fields)\n updated_at = record[:updated_at]\n }&.tap { |record|\n if keep_date.nil?\n keep_date = old_values&.all? { |k, v| record[k].to_s == v.to_s }\n end\n record.set_field_direct(:updated_at, updated_at) if keep_date\n }\n end",
"def rev\n updated_at\n end",
"def touch_date uid=nil\n if (ref = ref_for uid, false)\n ref.updated_at\n end\n #(ref = uid.nil? ? current_ref : ref_for(uid, false)) && ref.updated_at\n end",
"def did_update\n trigger_events(:update)\n end",
"def updated\n DateTime.parse(@json['user']['meta']['updated'])\n end",
"def last_update() (last_answer = answers.last) ? last_answer.time_stamp : created_at end",
"def reset_timestamp_attrs_for_update_if_needed!\n paper_trail.reset_timestamp_attrs_for_update_if_needed\n end",
"def outdated?; end",
"def stamp\n self.dateChanged = Time.now\n self.changedBy = ApplicationController.application_name\n end",
"def stamp\n self.dateChanged = Time.now\n self.changedBy = ApplicationController.application_name\n end",
"def stamp\n self.dateChanged = Time.now\n self.changedBy = ApplicationController.application_name\n end",
"def contact_info_updated_since(t)\n return false if sdb_update_at.nil?\n t < sdb_update_at\n end",
"def last_updated_at\n @last_updated_at\n end",
"def state_changed_at\n if occurred_at\n now = Time.zone.now\n occurred_at + now.hour.hours + now.min.minutes\n else\n Time.zone.now\n end\n end",
"def updated_at_datetime\n @updated_at_datetime ||= DateTime.parse(@updated_at)\n end",
"def test_updated_at\n person = FactoryBot.create(:person, updated_at: 1.week.ago)\n\n updated_at = person.updated_at\n person = Person.find(person.id)\n assert_equal updated_at.to_s, person.updated_at.to_s\n end",
"def _parse_stale_at\n if @response.current.observed_at\n utc_observed_at = @response.current.observed_at.utc\n utc_next_update = Time.utc(\n utc_observed_at.year, utc_observed_at.month, utc_observed_at.day,\n utc_observed_at.hour + 1, 0, 0\n )\n @response.current.stale_at = utc_next_update\n end\n end",
"def updated_by_last_action(arg) # rubocop:disable TrivialAccessors\n @updated = arg\n end",
"def updated\n DateTime.parse(@json['project']['meta']['updated'])\n end",
"def last_update\n \"none\"\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 updated?\n false\n end",
"def updated_at_string\n @updated_string\n end",
"def updated_at_string\n @updated_string\n end",
"def activity_on_update\n # Either use #changed? method for Rails < 5.1 or #saved_changes? for recent versions\n create_activity(:update) if respond_to?(:saved_changes?) ? saved_changes? : changed?\n end",
"def updated_at_column(record)\n if not record.updated_at.nil?\n time_ago_in_words(record.updated_at) + \" ago\"\n end\n end",
"def history_update\n return if !saved_changes?\n\n # return if it's no update\n return if new_record?\n\n # new record also triggers update, so ignore new records\n changes = saved_changes\n history_changes_last_done&.each do |key, value|\n if changes.key?(key) && changes[key] == value\n changes.delete(key)\n end\n end\n self.history_changes_last_done = changes\n #logger.info 'updated ' + self.changes.inspect\n\n return if changes['id'] && !changes['id'][0]\n\n ignored_attributes = self.class.instance_variable_get(:@history_attributes_ignored) || []\n ignored_attributes += %i[created_at updated_at]\n\n changes.each do |key, value|\n\n next if ignored_attributes.include?(key.to_sym)\n\n # get attribute name\n attribute_name = key.to_s\n if attribute_name[-3, 3] == '_id'\n attribute_name = attribute_name[ 0, attribute_name.length - 3 ]\n end\n\n value_id = []\n value_str = [ value[0], value[1] ]\n if key.to_s[-3, 3] == '_id'\n value_id[0] = value[0]\n value_id[1] = value[1]\n\n if respond_to?(attribute_name) && send(attribute_name)\n relation_class = send(attribute_name).class\n if relation_class && value_id[0]\n relation_model = relation_class.lookup(id: value_id[0])\n if relation_model\n if relation_model['name']\n value_str[0] = relation_model['name']\n elsif relation_model.respond_to?('fullname')\n value_str[0] = relation_model.send('fullname')\n end\n end\n end\n if relation_class && value_id[1]\n relation_model = relation_class.lookup(id: value_id[1])\n if relation_model\n if relation_model['name']\n value_str[1] = relation_model['name']\n elsif relation_model.respond_to?('fullname')\n value_str[1] = relation_model.send('fullname')\n end\n end\n end\n end\n end\n data = {\n history_attribute: attribute_name,\n value_from: value_str[0].to_s,\n value_to: value_str[1].to_s,\n id_from: value_id[0],\n id_to: value_id[1],\n }\n #logger.info \"HIST NEW #{self.class.to_s}.find(#{self.id}) #{data.inspect}\"\n history_log('updated', data)\n end\n end",
"def update\n set_deltatime\n set_last_update_at\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_at\n connection.get_metric_last_update_at(@id)\n end",
"def tweak_occurred_at\n self.occurred_at = created_at if occurred_at.to_date < Date.yesterday\n end",
"def feed_updated\n @articles_published.first.updated_at.xmlschema if @articles_published.length > 0\n end",
"def state_datetime\r\n if failed?\r\n failed_at\r\n elsif completed?\r\n completed_at\r\n else\r\n updated_at\r\n end\r\n end",
"def last_edited\n self.latest_update.to_date\n end",
"def item_updated(user, id, at)\n _coordinator.item_updated(user, id, at)\n end",
"def save_row_change\n row.updated_at = Time.now\n row.save\n end"
] | [
"0.6952121",
"0.69037646",
"0.6732456",
"0.6504944",
"0.6415278",
"0.6391613",
"0.6327927",
"0.6280748",
"0.628016",
"0.62776387",
"0.62690896",
"0.62477964",
"0.6210264",
"0.61881995",
"0.61763245",
"0.6165476",
"0.61480963",
"0.6117819",
"0.61164325",
"0.6059061",
"0.60547465",
"0.60537094",
"0.6049402",
"0.6046253",
"0.6037599",
"0.60119087",
"0.600622",
"0.5994049",
"0.5988594",
"0.5976138",
"0.596378",
"0.5961307",
"0.5944325",
"0.59366685",
"0.59353733",
"0.5929292",
"0.58784163",
"0.5870304",
"0.58557445",
"0.5845716",
"0.5844868",
"0.58403665",
"0.5836409",
"0.58217424",
"0.58086646",
"0.5806154",
"0.5789773",
"0.5775605",
"0.577311",
"0.57634455",
"0.5719836",
"0.57092166",
"0.5696349",
"0.5687671",
"0.5682837",
"0.56593794",
"0.56590563",
"0.56547266",
"0.5651634",
"0.5647156",
"0.5646049",
"0.56441647",
"0.564126",
"0.564123",
"0.5632989",
"0.56284636",
"0.5623831",
"0.56214345",
"0.56161815",
"0.5609036",
"0.5606788",
"0.5592852",
"0.5589419",
"0.558695",
"0.558695",
"0.558695",
"0.55822235",
"0.55786777",
"0.5575794",
"0.5575279",
"0.5570051",
"0.55667776",
"0.5564811",
"0.5559061",
"0.55588895",
"0.5542897",
"0.554179",
"0.5537871",
"0.5537871",
"0.5534765",
"0.5522505",
"0.5516279",
"0.5512919",
"0.5507059",
"0.55050945",
"0.55030704",
"0.5492731",
"0.548881",
"0.54865146",
"0.5483166",
"0.5482718"
] | 0.0 | -1 |
Will return falsepositive if there are only overall series results, but those should only exist if there _are_ "real" results. The results page should show the results in that case. | def any_results?
races.any?(&:any_results?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_results?\n true\n end",
"def more_results?()\n #This is a stub, used for indexing\n end",
"def hasResults?\n ! @results.empty?\n end",
"def no_results\n print \"0 results found. \\n\"\n end",
"def results?() ! find(locator(:no_results_message)) end",
"def has_results?\n !(name == 'aggregate' &&\n pipeline.find {|op| op.keys.include?('$out') })\n end",
"def show_zero_point_source_results?\n show_zero_point_source_results\n end",
"def get_results\n @results ||= @badge.meeting_individual_results.is_not_disqualified.sort_by_standard_points if @badge\n end",
"def has_abnormal_reports?\n\t\tself.reports.select{|c|\n\t\t\tc.has_abnormal_tests?\n\t\t}.size > 0\n\tend",
"def can_return_results\n if self.accession_list.blank? && self.search_terms.empty? && self.facet_filters.empty?\n errors.add(:base, \"You must supply either search terms, facet filters, or an accession list\")\n end\n end",
"def results\n query = parse\n\n results = []\n positive = query[:positive].to_a\n results << Language.where(name: positive)\n results << Language.where(type: positive)\n results << Language.where(designers: positive)\n\n weights = weight_results results\n\n positive = results.flatten.uniq(&:name).index_by &:name\n\n results = []\n negative = query[:negative].to_a\n\n results << Language.where_not(name: negative).map(&:name)\n results << Language.where_not(type: negative).map(&:name)\n results << Language.where_not(designers: negative).map(&:name)\n\n negative = results.inject(results[0]) {|result, array| result & array }.uniq\n\n final_results = positive.slice(*negative).values\n sort_results set_hits(final_results, weights), weights\n end",
"def no_more?\n more_results == :NO_MORE_RESULTS\n end",
"def unknown_yahoo_results(yahoo_results)\n resources = self.resources\n disease_resources = disease.resources\n\n @results = yahoo_results.inject([]) do |results,r|\n resource = disease_resources.detect do |t|\n (t.listing.address == r.address && t.listing.title == r.title && t.listing.city == r.city)\n end\n\n results ||= []\n if (resource.blank?) # Need this to include records found that are NOT in the database at all\n results << {:resource_id => 0, :data => r }\n elsif (!resource.blank? && !resources.detect { |t| resource.id == t.id })\n results << {:resource_id => resource.id, :data => r }\n end\n end\n end",
"def check_for_no_results(hash_of_results)\n if hash_of_results[JSON_NUMBER_OF_RESULTS] == 0\n puts 'No results, try again'\n go\n end\n end",
"def search_result_page_existed?\r\n displayed?\r\n end",
"def just_shown_results?\n return true if get[just_shown_key]\n end",
"def search_results(game_type)\n CombinedReplayData.search do\n all do\n any_of do\n with(:p1_rank).between(1..5)\n without(:p1_legend_rank, nil)\n end\n any_of do\n with(:p2_rank).between(1..5)\n without(:p2_legend_rank, nil)\n end\n end\n with(:played_at).greater_than(5.days.ago)\n with(:game_type, game_type)\n facet :p1_class_and_archetype\n facet :p2_class_and_archetype\n end\n end",
"def not_ok_check_results(categories:)\n\n # the region is on purpose - support intfc is global, but can't find endpoint outside of us-east-1\n support = Aws::Support::Client.new region: 'us-east-1'\n\n describe_trusted_advisor_checks_response = support.describe_trusted_advisor_checks language: 'en'\n\n if categories.nil?\n checks = describe_trusted_advisor_checks_response.checks\n else\n checks = describe_trusted_advisor_checks_response.checks.select { |check| categories.include? check.category }\n end\n\n checks.reduce([]) do |aggregate, check|\n describe_trusted_advisor_check_result_response = support.describe_trusted_advisor_check_result check_id: check.id,\n language: 'en'\n\n if describe_trusted_advisor_check_result_response.result.status != 'ok'\n aggregate << convert_check_result_into_hash(check.name,\n describe_trusted_advisor_check_result_response.result)\n end\n\n aggregate\n end\n end",
"def races_with_results\n races.select(&:any_results?)\n end",
"def get_results\n # 1. if the search is blank do NOT run the search (handled in subclasses)\n !self.search_text.blank? && !self.search_query.blank? && !self.search_type.blank? && !self.search_locale.blank?\n end",
"def any_results_including_children?\n races.any?(&:any_results?) || children.any?(&:any_results_including_children?)\n end",
"def results\n unless errors\n if total_results_returned == 1\n [Yahoo::SE::Result.new(self.to_json[\"ResultSet\"][\"Result\"])]\n elsif total_results_available == 0\n []\n else\n self.to_json[\"ResultSet\"][\"Result\"].map do |result_hash|\n Yahoo::SE::Result.new(result_hash)\n end\n end\n end\n end",
"def display_results\r\n raise \"Not implemented\"\r\n end",
"def total_results\n opensearch_totalResults\n end",
"def noSearchResults\n render :layout => false\n end",
"def test_results_filter(test_results)\n test_results.select do |tr|\n # Non TestResult items are never filtered.\n next true unless tr.kind_of?(Automation::TestDatabase::TestResult)\n entity_result(tr) != Automation::Result::Pass\n end\n end",
"def has_records? results\n not results.nil? and results.fetch('SearchResult', {}).fetch('Data', {}).fetch('Records', []).count > 0\n end",
"def results\n if @rubies_found > 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found > 1\n puts \"\\tFound #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found == 1\n puts \"\\tFound #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{@current_city}\"\n end\n end",
"def create_results(winning_side)\n self.category == \"singles\" ? create_singles_results(winning_side) : create_doubles_results(winning_side)\n end",
"def test_returns_no_matches\n records = Book.multi_solr_search \"not found\", :models => [Movie, Category]\n assert_equal [], records.docs\n assert_equal 0, records.total\n end",
"def search_results\n pages = Alchemy::PgSearch.config[:page_search_scope].pages\n # Since CanCan cannot (oh the irony) merge +accessible_by+ scope with pg_search scopes,\n # we need to fake a page object here\n if can? :show, Alchemy::Page.new(restricted: true, public_on: Date.current)\n pages.full_text_search(params[:query])\n else\n pages.not_restricted.full_text_search(params[:query])\n end\n end",
"def can_publish_results\n if !@contestproblem.in_correction?\n flash[:danger] = \"Une erreur est survenue.\"\n redirect_to @contestproblem and return\n end\n if @contestproblem.contestsolutions.where(:corrected => false).count > 0\n flash[:danger] = \"Les solutions ne sont pas toutes corrigées.\"\n redirect_to @contestproblem and return\n end\n if @contestproblem.contestsolutions.where(:star => true).count == 0\n flash[:danger] = \"Il faut au minimum une solution étoilée pour publier les résultats.\"\n redirect_to @contestproblem and return\n end\n end",
"def bad_results\n select {|r| !r.success }\n end",
"def vulnerable?\n !@results.empty?\n end",
"def more_results\n @server_status & SERVER_MORE_RESULTS_EXISTS != 0\n end",
"def query_yields_solutions?\n !(query_yields_boolean? || query_yields_statements?)\n end",
"def competitor_has_result?(competitor)\n competitor.scores.count > 0\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def index\n @results = {}\n\n if TeSS::Config.solr_enabled\n SEARCH_MODELS.each do |model_name|\n model = model_name.constantize\n @results[model_name.underscore.pluralize.to_sym] = Sunspot.search(model) do\n fulltext search_params\n\n with('end').greater_than(Time.zone.now) if model_name == 'Event'\n\n\n # Hide failing records\n if model.method_defined?(:link_monitor)\n unless current_user && current_user.is_admin?\n without(:failing, true)\n end\n end\n\n if model.attribute_method?(:user_requires_approval?)\n # TODO: Fix this duplication!\n # Hide shadowbanned users' events, except from other shadowbanned users and administrators\n unless current_user && (current_user.shadowbanned? || current_user.is_admin?)\n without(:shadowbanned, true)\n end\n\n # Hide unverified users' things, except from curators and admins\n unless current_user && (current_user.is_curator? || current_user.is_admin?)\n without(:unverified, true)\n end\n end\n end\n end\n \n end\n\n @results.reject! { |_, result| result.total < 1 }\n end",
"def has_results?\n meeting_individual_results.has_points(:goggle_cup_points).exists?\n end",
"def empty?\n self.results.empty?\n end",
"def trends_are_available?\n return false unless current_enrollment && current_enrollment.action_plans.count > 2\n\n one_week_ago_plan = current_action_plan.previous_action_plan\n two_weeks_ago_plan = one_week_ago_plan.try(:previous_action_plan)\n return false unless one_week_ago_plan && two_weeks_ago_plan\n\n # each of the previous two weeks must have assessments and results\n one_week_ago_plan.checkin_assessment.complete? && two_weeks_ago_plan.checkin_assessment.complete?\n end",
"def process_test_results(force: false, xunit_viewer: \"xunit-viewer\")\n process_test_results_xunit(force: force, xunit_viewer: xunit_viewer)\n end",
"def competition_results\n results.select(&:competition_result?)\n end",
"def series_facets(solr_doc)\n solr_doc[Solrizer.solr_name(\"parent_unittitles\", :displayable)] unless solr_doc[Solrizer.solr_name(\"parent_unittitles\", :displayable)].nil?\n end",
"def find_top\n @result_sets.each do |set|\n check set.results.first\n end\n end",
"def order_summary_failed?\n return false unless rejected?\n return true if self.EventLog =~ /Validering av summer feilet/\n false\n end",
"def results_complete?(max_results)\n complete = true\n @included_snps.each do |snp|\n if max_results != @snps[snp].results.length\n complete = false\n break\n end\n end\n return complete\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def guessing?\n ! page.has_content?(\"Your Results\")\n end",
"def discard_results; end",
"def results(do_all=false)\n [].tap do |res|\n if do_all || term_matches.present?\n res << IndexedSearch::Match::Result.new(self, term_map, rank_multiplier, term_multiplier, limit_reduction_factor, type_reduction_factor)\n end\n end\n end",
"def results_complete?(max_results)\n return @snp_list.results_complete?(max_results)\n end",
"def test_results_zero\r\n assert_output(\"Going home empty-handed.\\n\") { @g.results(0) }\r\n end",
"def query_yields_solutions?\n true\n end",
"def get_incresults(arr)\n # byebug\n if(arr.length == 0)\n 'no results available yet'\n else \n allIncorrect = arr.select do |ans|\n ans.is_right == false \n end\n end\nend",
"def search_results(all_pages)\n formatted_list = []\n all_pages.each do |show_hash|\n formatted_list << \"id. #{show_hash[\"id\"]} - #{show_hash[\"name\"]}\"\n end\n if formatted_list.count != 1\n self.print_search_results(formatted_list)\n else\n fetch_show_by_id(all_pages[0][\"id\"].to_s)\n end\nend",
"def any?\n !total_pages.zero?\n end",
"def result_summary\n options = { style: 'font-size: 25px;' }\n summary = if matches_exist?\n [bold_tag(pluralize(result_count, 'result'), options), filter_text]\n else\n [\n bold_tag(@query, options),\n 'not found -',\n pluralize(result_count, 'similar result'),\n filter_text\n ]\n end\n safe_join(summary, ' ')\n end",
"def test_results_negative\r\n assert_raises('Cannot have a negative number of rubies found!') { @g.results(-1) }\r\n end",
"def results; end",
"def results; end",
"def results; end",
"def show_results_tip?\n # Logged-in user who has the tip hidden?\n return false if current_user&.hide_results_tip\n\n setting = session[:hide_results_tip]\n\n return true unless setting\n return false if setting == :all\n\n setting != Current.setting.api_session_id\n end",
"def is_positive?\n return POSITIVE_RESPONSES.include?(self)\n end",
"def all_hits_count\n return @all_results.length || 0\n end",
"def index\n if params[:q]\n @search = UnitOfMeasure.search(params[:q])\n @unit_of_measures = @search.result.page(params[:page]).per(current_user.list_page_size)\n else\n @search = UnitOfMeasure.search(params[:q]) \n @unit_of_measures = @search.result.where(validity: true).page(params[:page]).per(current_user.list_page_size)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unit_of_measures }\n end\n end",
"def results_for_division(division)\n if division == :all\n @results\n else\n sections = @festival_info.sections(division)\n @results.select { |section, result| sections.include? section }\n end\n end",
"def complete_result?\n @result_count < 1000\n end",
"def generic_results?\n filter_param_keys = [\n 'filter', 'product_group_query', 'branded', 'color1', 'color2',\n 'size', 'sex', 'price_between', 'keywords'\n ]\n \n filter_param_keys.none? {|k| params.keys.member?(k)}\n end",
"def hasVisibleTreasures\n not visibleTreasures.empty?\n end",
"def clean_results(parse_results, existing_article_titles)\n parse_results.uniq!\n cleaned_results = clean_results_of_partial_phrases(parse_results)\n cleaned_results = clean_results_of_redirects_to_detected_articles(cleaned_results)\n cleaned_results = clean_results_of_redirects_to_wikified_titles(cleaned_results, existing_article_titles)\n cleaned_results\n end",
"def found_show_all\n showing_all_items?\n end",
"def results\n facet_results, _docs = search_service.search_results\n facet_results.facet_fields[IndexesWorkflow.suppressed_field].each_slice(2)\n end",
"def estimate_post_counts\n false\n end",
"def render?\n @data_set.data_series.any? { |ds|\n ds.data_type.is_a?(RailsDataExplorer::DataType::Quantitative)\n }\n end",
"def reports?\n !reports.empty?\n end",
"def false_positive\n observations.select(&:false_positive)\n end",
"def on_track?\n result = false\n\n # TODO: should limit the minimum date?\n # min_date = Time.zone.now.to_date - self.trial_days_total.days\n \n recent_grades = self.grades.order(\n \"due_date DESC\"\n ).limit(self.trial_days_actual)\n\n actual_value = 0\n ideal_value = 0\n total_grade = 0\n\n recent_grades.each do |grade|\n total_grade += 1\n actual_value += grade.accuracy\n ideal_value += grade.ideal_value\n end\n\n if total_grade > 0\n result = (actual_value/total_grade > ideal_value/total_grade)\n end\n return result\n end",
"def search_for_no_results\n visit('/locations?keyword=asdfdsggfdg')\n end",
"def has_alert?(results)\n results_format = @query_options['results_format']\n alert_condition = @query_options['alert_condition']\n\n alert = false\n if results_format.eql?(\"count\")\n count_value = results.first.map{|key,value| value}.first\n alert = eval(\"#{count_value} #{alert_condition}\")\n elsif results_format.eql?(\"size\")\n alert = eval(\"#{results.size} #{alert_condition}\")\n elsif results_format.eql?(\"xls\")\n alert = true\n end\n\n return alert\n end",
"def summarize!\n %i[critical warning unknown].each do |status|\n send(status, summary) unless results[status].empty?\n end\n ok(summary)\n end",
"def results_for_school(school, division)\n section_results(division).map { |sec|\n sec && sec.points_for_school(school) || 0\n }\n end",
"def results\n index.results\n end",
"def abandon_results!()\n #This is a stub, used for indexing\n end",
"def results\n fetch unless @results\n @results\n end",
"def pageWithResults?\n return @driver.find_elements(:xpath, \".//*[@id='resultados']/ul[*]/li[1]/a\").any?\nend",
"def result_neutral\n @page.find(input_elements[:result_neutral])\n end",
"def test_results_sad\r\n assert_output(\"Going home sad.\\n\") { @g.results(9) }\r\n end",
"def results_within_date_range\n eles = get_entries\n\n from = Date.strptime(summary_from.text, '%m/%d/%Y').strftime('%m/%d/%Y')\n to = Date.strptime(summary_to.text, '%m/%d/%Y').strftime('%m/%d/%Y')\n\n range = (from..to)\n if eles.nil? || eles.length == 0\n fail(ArgumentError.new('no results were found'))\n else\n eles.each do |result|\n the_date = Date.parse(result.find(input_elements[:result_date])['data-absolute-date']).strftime('%m/%d/%Y')\n unless range.include? the_date\n fail(ArgumentError.new(the_date.to_s + ' was not between ' + from.to_s + ' and ' + to.to_s))\n end\n end\n end\n end",
"def oa_conclusion_potential(result, ddf_header, sherpa_header)\n sherpa_post_index = sherpa_header.index(\"Post\")\n sherpa_pver_index = sherpa_header.index(\"Pver\") #TODO: post is covered in actual...\n sherpa_conclusion = ((result.has_key?(\"sherpa\") and (result[\"sherpa\"].size > sherpa_pver_index and\n result[\"sherpa\"][sherpa_pver_index].eql?(\"Yes\"))) ? true : false)\n sherpa_conclusion = ((result.has_key?(\"sherpa\") and (result[\"sherpa\"].size > sherpa_post_index and\n result[\"sherpa\"][sherpa_post_index].eql?(\"Yes\"))) ? true : sherpa_conclusion)\n return ( (sherpa_conclusion or oa_conclusion_actual(result, ddf_header, sherpa_header).eql?(\"Yes\")) ? \"Yes\" : \"No\") \n end",
"def more_pages?\n return false if start_index == 0\n (self.start_index + self.page_length) -1 < self.total_result_count\n end",
"def myquizze_results\n @current_user = get_logged_user\n if @quizze_instance = @current_user.get_latest_quizze_instance\n @quizze = @quizze_instance.get_quizze\n @sorted_affinities = @quizze_instance.sorted_affinities\n @explanations, @hash_dimension2answers, @hash_question_idurl2min_max_weight = @quizze_instance.get_explanations(@current_knowledge, @sorted_affinities)\n else\n redirect_to(\"/quizzes\") # select a quizz first !\n end\n end",
"def show_summary_page?\n return true if (self.no_complete_pdf == false or self.page_count == 1)\n return false\n end",
"def get_results\n \titems = self.possessions.find(:all, :limit => 20, :order => 'wants_count DESC')\n #reset data just for testing\n Possession.all.each do |item|\n item.new_owner = nil\n item.save\n end\n \t# items = prune(items)\n \tif items.count > 1\n \t\tfind_some_trades(items)\n \tend\n end",
"def search_terms_summary terms_and_scores \n return \"<span class='none_text'>No search queries during this period</span>\".html_safe if terms_and_scores.empty?\n words=terms_and_scores.collect{|ts| \"#{h(ts[0])}(#{ts[1]})\" }\n words.join(\", \").html_safe\n end"
] | [
"0.6628638",
"0.66195565",
"0.6285563",
"0.6235919",
"0.6127702",
"0.61047447",
"0.5931168",
"0.58871675",
"0.58763725",
"0.58066195",
"0.5726213",
"0.5715045",
"0.5712045",
"0.5678092",
"0.5662458",
"0.5601473",
"0.55778867",
"0.5548455",
"0.55397034",
"0.55061316",
"0.5479976",
"0.546649",
"0.54264295",
"0.5414694",
"0.54036903",
"0.53983086",
"0.5392302",
"0.53859335",
"0.53612447",
"0.5353375",
"0.5350952",
"0.5346919",
"0.5337646",
"0.53240085",
"0.53222007",
"0.53163147",
"0.5313678",
"0.52997303",
"0.52970314",
"0.52880436",
"0.52801967",
"0.52679116",
"0.52581537",
"0.52320933",
"0.5224216",
"0.5219008",
"0.5218421",
"0.5209195",
"0.5209116",
"0.5209116",
"0.5209116",
"0.5209116",
"0.5209116",
"0.52054",
"0.5202559",
"0.5197525",
"0.5183471",
"0.51777965",
"0.5175976",
"0.5158921",
"0.5156948",
"0.5151876",
"0.51464486",
"0.5142878",
"0.5130787",
"0.5130787",
"0.5130787",
"0.51267326",
"0.51246154",
"0.5124032",
"0.5113144",
"0.5110751",
"0.5109942",
"0.5108003",
"0.5105823",
"0.50993663",
"0.5095506",
"0.5094224",
"0.5088024",
"0.5086916",
"0.5086052",
"0.50849557",
"0.5083665",
"0.5067366",
"0.50664747",
"0.50639063",
"0.5057593",
"0.5053702",
"0.5053279",
"0.5047723",
"0.5045194",
"0.5040138",
"0.5032898",
"0.5027974",
"0.5024163",
"0.50235856",
"0.5022469",
"0.5019661",
"0.50190043",
"0.50188863"
] | 0.54496306 | 22 |
Will return falsepositive if there are only overall series results, but those should only exist if there _are_ "real" results. The results page should show the results in that case. | def any_results_including_children?
races.any?(&:any_results?) || children.any?(&:any_results_including_children?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_results?\n true\n end",
"def more_results?()\n #This is a stub, used for indexing\n end",
"def hasResults?\n ! @results.empty?\n end",
"def no_results\n print \"0 results found. \\n\"\n end",
"def results?() ! find(locator(:no_results_message)) end",
"def has_results?\n !(name == 'aggregate' &&\n pipeline.find {|op| op.keys.include?('$out') })\n end",
"def show_zero_point_source_results?\n show_zero_point_source_results\n end",
"def get_results\n @results ||= @badge.meeting_individual_results.is_not_disqualified.sort_by_standard_points if @badge\n end",
"def has_abnormal_reports?\n\t\tself.reports.select{|c|\n\t\t\tc.has_abnormal_tests?\n\t\t}.size > 0\n\tend",
"def can_return_results\n if self.accession_list.blank? && self.search_terms.empty? && self.facet_filters.empty?\n errors.add(:base, \"You must supply either search terms, facet filters, or an accession list\")\n end\n end",
"def results\n query = parse\n\n results = []\n positive = query[:positive].to_a\n results << Language.where(name: positive)\n results << Language.where(type: positive)\n results << Language.where(designers: positive)\n\n weights = weight_results results\n\n positive = results.flatten.uniq(&:name).index_by &:name\n\n results = []\n negative = query[:negative].to_a\n\n results << Language.where_not(name: negative).map(&:name)\n results << Language.where_not(type: negative).map(&:name)\n results << Language.where_not(designers: negative).map(&:name)\n\n negative = results.inject(results[0]) {|result, array| result & array }.uniq\n\n final_results = positive.slice(*negative).values\n sort_results set_hits(final_results, weights), weights\n end",
"def no_more?\n more_results == :NO_MORE_RESULTS\n end",
"def unknown_yahoo_results(yahoo_results)\n resources = self.resources\n disease_resources = disease.resources\n\n @results = yahoo_results.inject([]) do |results,r|\n resource = disease_resources.detect do |t|\n (t.listing.address == r.address && t.listing.title == r.title && t.listing.city == r.city)\n end\n\n results ||= []\n if (resource.blank?) # Need this to include records found that are NOT in the database at all\n results << {:resource_id => 0, :data => r }\n elsif (!resource.blank? && !resources.detect { |t| resource.id == t.id })\n results << {:resource_id => resource.id, :data => r }\n end\n end\n end",
"def check_for_no_results(hash_of_results)\n if hash_of_results[JSON_NUMBER_OF_RESULTS] == 0\n puts 'No results, try again'\n go\n end\n end",
"def search_result_page_existed?\r\n displayed?\r\n end",
"def just_shown_results?\n return true if get[just_shown_key]\n end",
"def search_results(game_type)\n CombinedReplayData.search do\n all do\n any_of do\n with(:p1_rank).between(1..5)\n without(:p1_legend_rank, nil)\n end\n any_of do\n with(:p2_rank).between(1..5)\n without(:p2_legend_rank, nil)\n end\n end\n with(:played_at).greater_than(5.days.ago)\n with(:game_type, game_type)\n facet :p1_class_and_archetype\n facet :p2_class_and_archetype\n end\n end",
"def not_ok_check_results(categories:)\n\n # the region is on purpose - support intfc is global, but can't find endpoint outside of us-east-1\n support = Aws::Support::Client.new region: 'us-east-1'\n\n describe_trusted_advisor_checks_response = support.describe_trusted_advisor_checks language: 'en'\n\n if categories.nil?\n checks = describe_trusted_advisor_checks_response.checks\n else\n checks = describe_trusted_advisor_checks_response.checks.select { |check| categories.include? check.category }\n end\n\n checks.reduce([]) do |aggregate, check|\n describe_trusted_advisor_check_result_response = support.describe_trusted_advisor_check_result check_id: check.id,\n language: 'en'\n\n if describe_trusted_advisor_check_result_response.result.status != 'ok'\n aggregate << convert_check_result_into_hash(check.name,\n describe_trusted_advisor_check_result_response.result)\n end\n\n aggregate\n end\n end",
"def races_with_results\n races.select(&:any_results?)\n end",
"def get_results\n # 1. if the search is blank do NOT run the search (handled in subclasses)\n !self.search_text.blank? && !self.search_query.blank? && !self.search_type.blank? && !self.search_locale.blank?\n end",
"def results\n unless errors\n if total_results_returned == 1\n [Yahoo::SE::Result.new(self.to_json[\"ResultSet\"][\"Result\"])]\n elsif total_results_available == 0\n []\n else\n self.to_json[\"ResultSet\"][\"Result\"].map do |result_hash|\n Yahoo::SE::Result.new(result_hash)\n end\n end\n end\n end",
"def any_results?\n races.any?(&:any_results?)\n end",
"def display_results\r\n raise \"Not implemented\"\r\n end",
"def total_results\n opensearch_totalResults\n end",
"def noSearchResults\n render :layout => false\n end",
"def test_results_filter(test_results)\n test_results.select do |tr|\n # Non TestResult items are never filtered.\n next true unless tr.kind_of?(Automation::TestDatabase::TestResult)\n entity_result(tr) != Automation::Result::Pass\n end\n end",
"def has_records? results\n not results.nil? and results.fetch('SearchResult', {}).fetch('Data', {}).fetch('Records', []).count > 0\n end",
"def results\n if @rubies_found > 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found == 1\n puts \"\\tFound #{@rubies_found} rubies and #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found > 1\n puts \"\\tFound #{@rubies_found} ruby and #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found > 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} rubies in #{@current_city}\"\n elsif @rubies_found == 1 && @fake_rubies_found.zero?\n puts \"\\tFound #{@rubies_found} ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found > 1\n puts \"\\tFound #{@fake_rubies_found} fake rubies in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found == 1\n puts \"\\tFound #{@fake_rubies_found} fake ruby in #{@current_city}\"\n elsif @rubies_found.zero? && @fake_rubies_found.zero?\n puts \"\\tFound no rubies or fake rubies in #{@current_city}\"\n end\n end",
"def create_results(winning_side)\n self.category == \"singles\" ? create_singles_results(winning_side) : create_doubles_results(winning_side)\n end",
"def test_returns_no_matches\n records = Book.multi_solr_search \"not found\", :models => [Movie, Category]\n assert_equal [], records.docs\n assert_equal 0, records.total\n end",
"def search_results\n pages = Alchemy::PgSearch.config[:page_search_scope].pages\n # Since CanCan cannot (oh the irony) merge +accessible_by+ scope with pg_search scopes,\n # we need to fake a page object here\n if can? :show, Alchemy::Page.new(restricted: true, public_on: Date.current)\n pages.full_text_search(params[:query])\n else\n pages.not_restricted.full_text_search(params[:query])\n end\n end",
"def can_publish_results\n if !@contestproblem.in_correction?\n flash[:danger] = \"Une erreur est survenue.\"\n redirect_to @contestproblem and return\n end\n if @contestproblem.contestsolutions.where(:corrected => false).count > 0\n flash[:danger] = \"Les solutions ne sont pas toutes corrigées.\"\n redirect_to @contestproblem and return\n end\n if @contestproblem.contestsolutions.where(:star => true).count == 0\n flash[:danger] = \"Il faut au minimum une solution étoilée pour publier les résultats.\"\n redirect_to @contestproblem and return\n end\n end",
"def bad_results\n select {|r| !r.success }\n end",
"def vulnerable?\n !@results.empty?\n end",
"def more_results\n @server_status & SERVER_MORE_RESULTS_EXISTS != 0\n end",
"def query_yields_solutions?\n !(query_yields_boolean? || query_yields_statements?)\n end",
"def competitor_has_result?(competitor)\n competitor.scores.count > 0\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def index\n @results = {}\n\n if TeSS::Config.solr_enabled\n SEARCH_MODELS.each do |model_name|\n model = model_name.constantize\n @results[model_name.underscore.pluralize.to_sym] = Sunspot.search(model) do\n fulltext search_params\n\n with('end').greater_than(Time.zone.now) if model_name == 'Event'\n\n\n # Hide failing records\n if model.method_defined?(:link_monitor)\n unless current_user && current_user.is_admin?\n without(:failing, true)\n end\n end\n\n if model.attribute_method?(:user_requires_approval?)\n # TODO: Fix this duplication!\n # Hide shadowbanned users' events, except from other shadowbanned users and administrators\n unless current_user && (current_user.shadowbanned? || current_user.is_admin?)\n without(:shadowbanned, true)\n end\n\n # Hide unverified users' things, except from curators and admins\n unless current_user && (current_user.is_curator? || current_user.is_admin?)\n without(:unverified, true)\n end\n end\n end\n end\n \n end\n\n @results.reject! { |_, result| result.total < 1 }\n end",
"def has_results?\n meeting_individual_results.has_points(:goggle_cup_points).exists?\n end",
"def empty?\n self.results.empty?\n end",
"def trends_are_available?\n return false unless current_enrollment && current_enrollment.action_plans.count > 2\n\n one_week_ago_plan = current_action_plan.previous_action_plan\n two_weeks_ago_plan = one_week_ago_plan.try(:previous_action_plan)\n return false unless one_week_ago_plan && two_weeks_ago_plan\n\n # each of the previous two weeks must have assessments and results\n one_week_ago_plan.checkin_assessment.complete? && two_weeks_ago_plan.checkin_assessment.complete?\n end",
"def process_test_results(force: false, xunit_viewer: \"xunit-viewer\")\n process_test_results_xunit(force: force, xunit_viewer: xunit_viewer)\n end",
"def competition_results\n results.select(&:competition_result?)\n end",
"def series_facets(solr_doc)\n solr_doc[Solrizer.solr_name(\"parent_unittitles\", :displayable)] unless solr_doc[Solrizer.solr_name(\"parent_unittitles\", :displayable)].nil?\n end",
"def find_top\n @result_sets.each do |set|\n check set.results.first\n end\n end",
"def order_summary_failed?\n return false unless rejected?\n return true if self.EventLog =~ /Validering av summer feilet/\n false\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def results_complete?(max_results)\n complete = true\n @included_snps.each do |snp|\n if max_results != @snps[snp].results.length\n complete = false\n break\n end\n end\n return complete\n end",
"def guessing?\n ! page.has_content?(\"Your Results\")\n end",
"def discard_results; end",
"def results(do_all=false)\n [].tap do |res|\n if do_all || term_matches.present?\n res << IndexedSearch::Match::Result.new(self, term_map, rank_multiplier, term_multiplier, limit_reduction_factor, type_reduction_factor)\n end\n end\n end",
"def results_complete?(max_results)\n return @snp_list.results_complete?(max_results)\n end",
"def test_results_zero\r\n assert_output(\"Going home empty-handed.\\n\") { @g.results(0) }\r\n end",
"def query_yields_solutions?\n true\n end",
"def get_incresults(arr)\n # byebug\n if(arr.length == 0)\n 'no results available yet'\n else \n allIncorrect = arr.select do |ans|\n ans.is_right == false \n end\n end\nend",
"def search_results(all_pages)\n formatted_list = []\n all_pages.each do |show_hash|\n formatted_list << \"id. #{show_hash[\"id\"]} - #{show_hash[\"name\"]}\"\n end\n if formatted_list.count != 1\n self.print_search_results(formatted_list)\n else\n fetch_show_by_id(all_pages[0][\"id\"].to_s)\n end\nend",
"def any?\n !total_pages.zero?\n end",
"def result_summary\n options = { style: 'font-size: 25px;' }\n summary = if matches_exist?\n [bold_tag(pluralize(result_count, 'result'), options), filter_text]\n else\n [\n bold_tag(@query, options),\n 'not found -',\n pluralize(result_count, 'similar result'),\n filter_text\n ]\n end\n safe_join(summary, ' ')\n end",
"def test_results_negative\r\n assert_raises('Cannot have a negative number of rubies found!') { @g.results(-1) }\r\n end",
"def results; end",
"def results; end",
"def results; end",
"def show_results_tip?\n # Logged-in user who has the tip hidden?\n return false if current_user&.hide_results_tip\n\n setting = session[:hide_results_tip]\n\n return true unless setting\n return false if setting == :all\n\n setting != Current.setting.api_session_id\n end",
"def all_hits_count\n return @all_results.length || 0\n end",
"def is_positive?\n return POSITIVE_RESPONSES.include?(self)\n end",
"def index\n if params[:q]\n @search = UnitOfMeasure.search(params[:q])\n @unit_of_measures = @search.result.page(params[:page]).per(current_user.list_page_size)\n else\n @search = UnitOfMeasure.search(params[:q]) \n @unit_of_measures = @search.result.where(validity: true).page(params[:page]).per(current_user.list_page_size)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unit_of_measures }\n end\n end",
"def results_for_division(division)\n if division == :all\n @results\n else\n sections = @festival_info.sections(division)\n @results.select { |section, result| sections.include? section }\n end\n end",
"def complete_result?\n @result_count < 1000\n end",
"def generic_results?\n filter_param_keys = [\n 'filter', 'product_group_query', 'branded', 'color1', 'color2',\n 'size', 'sex', 'price_between', 'keywords'\n ]\n \n filter_param_keys.none? {|k| params.keys.member?(k)}\n end",
"def hasVisibleTreasures\n not visibleTreasures.empty?\n end",
"def clean_results(parse_results, existing_article_titles)\n parse_results.uniq!\n cleaned_results = clean_results_of_partial_phrases(parse_results)\n cleaned_results = clean_results_of_redirects_to_detected_articles(cleaned_results)\n cleaned_results = clean_results_of_redirects_to_wikified_titles(cleaned_results, existing_article_titles)\n cleaned_results\n end",
"def results\n facet_results, _docs = search_service.search_results\n facet_results.facet_fields[IndexesWorkflow.suppressed_field].each_slice(2)\n end",
"def found_show_all\n showing_all_items?\n end",
"def estimate_post_counts\n false\n end",
"def render?\n @data_set.data_series.any? { |ds|\n ds.data_type.is_a?(RailsDataExplorer::DataType::Quantitative)\n }\n end",
"def reports?\n !reports.empty?\n end",
"def false_positive\n observations.select(&:false_positive)\n end",
"def on_track?\n result = false\n\n # TODO: should limit the minimum date?\n # min_date = Time.zone.now.to_date - self.trial_days_total.days\n \n recent_grades = self.grades.order(\n \"due_date DESC\"\n ).limit(self.trial_days_actual)\n\n actual_value = 0\n ideal_value = 0\n total_grade = 0\n\n recent_grades.each do |grade|\n total_grade += 1\n actual_value += grade.accuracy\n ideal_value += grade.ideal_value\n end\n\n if total_grade > 0\n result = (actual_value/total_grade > ideal_value/total_grade)\n end\n return result\n end",
"def search_for_no_results\n visit('/locations?keyword=asdfdsggfdg')\n end",
"def has_alert?(results)\n results_format = @query_options['results_format']\n alert_condition = @query_options['alert_condition']\n\n alert = false\n if results_format.eql?(\"count\")\n count_value = results.first.map{|key,value| value}.first\n alert = eval(\"#{count_value} #{alert_condition}\")\n elsif results_format.eql?(\"size\")\n alert = eval(\"#{results.size} #{alert_condition}\")\n elsif results_format.eql?(\"xls\")\n alert = true\n end\n\n return alert\n end",
"def summarize!\n %i[critical warning unknown].each do |status|\n send(status, summary) unless results[status].empty?\n end\n ok(summary)\n end",
"def results_for_school(school, division)\n section_results(division).map { |sec|\n sec && sec.points_for_school(school) || 0\n }\n end",
"def results\n index.results\n end",
"def abandon_results!()\n #This is a stub, used for indexing\n end",
"def results\n fetch unless @results\n @results\n end",
"def pageWithResults?\n return @driver.find_elements(:xpath, \".//*[@id='resultados']/ul[*]/li[1]/a\").any?\nend",
"def result_neutral\n @page.find(input_elements[:result_neutral])\n end",
"def test_results_sad\r\n assert_output(\"Going home sad.\\n\") { @g.results(9) }\r\n end",
"def results_within_date_range\n eles = get_entries\n\n from = Date.strptime(summary_from.text, '%m/%d/%Y').strftime('%m/%d/%Y')\n to = Date.strptime(summary_to.text, '%m/%d/%Y').strftime('%m/%d/%Y')\n\n range = (from..to)\n if eles.nil? || eles.length == 0\n fail(ArgumentError.new('no results were found'))\n else\n eles.each do |result|\n the_date = Date.parse(result.find(input_elements[:result_date])['data-absolute-date']).strftime('%m/%d/%Y')\n unless range.include? the_date\n fail(ArgumentError.new(the_date.to_s + ' was not between ' + from.to_s + ' and ' + to.to_s))\n end\n end\n end\n end",
"def oa_conclusion_potential(result, ddf_header, sherpa_header)\n sherpa_post_index = sherpa_header.index(\"Post\")\n sherpa_pver_index = sherpa_header.index(\"Pver\") #TODO: post is covered in actual...\n sherpa_conclusion = ((result.has_key?(\"sherpa\") and (result[\"sherpa\"].size > sherpa_pver_index and\n result[\"sherpa\"][sherpa_pver_index].eql?(\"Yes\"))) ? true : false)\n sherpa_conclusion = ((result.has_key?(\"sherpa\") and (result[\"sherpa\"].size > sherpa_post_index and\n result[\"sherpa\"][sherpa_post_index].eql?(\"Yes\"))) ? true : sherpa_conclusion)\n return ( (sherpa_conclusion or oa_conclusion_actual(result, ddf_header, sherpa_header).eql?(\"Yes\")) ? \"Yes\" : \"No\") \n end",
"def more_pages?\n return false if start_index == 0\n (self.start_index + self.page_length) -1 < self.total_result_count\n end",
"def myquizze_results\n @current_user = get_logged_user\n if @quizze_instance = @current_user.get_latest_quizze_instance\n @quizze = @quizze_instance.get_quizze\n @sorted_affinities = @quizze_instance.sorted_affinities\n @explanations, @hash_dimension2answers, @hash_question_idurl2min_max_weight = @quizze_instance.get_explanations(@current_knowledge, @sorted_affinities)\n else\n redirect_to(\"/quizzes\") # select a quizz first !\n end\n end",
"def get_results\n \titems = self.possessions.find(:all, :limit => 20, :order => 'wants_count DESC')\n #reset data just for testing\n Possession.all.each do |item|\n item.new_owner = nil\n item.save\n end\n \t# items = prune(items)\n \tif items.count > 1\n \t\tfind_some_trades(items)\n \tend\n end",
"def search_terms_summary terms_and_scores \n return \"<span class='none_text'>No search queries during this period</span>\".html_safe if terms_and_scores.empty?\n words=terms_and_scores.collect{|ts| \"#{h(ts[0])}(#{ts[1]})\" }\n words.join(\", \").html_safe\n end",
"def show_summary_page?\n return true if (self.no_complete_pdf == false or self.page_count == 1)\n return false\n end"
] | [
"0.6627425",
"0.661909",
"0.6284414",
"0.6235429",
"0.6126472",
"0.610397",
"0.5930444",
"0.58869624",
"0.58753353",
"0.5806088",
"0.57264924",
"0.5713771",
"0.5711489",
"0.56771517",
"0.56608605",
"0.5600434",
"0.5578196",
"0.5548319",
"0.5539034",
"0.55057716",
"0.546758",
"0.5448615",
"0.5426341",
"0.5416291",
"0.54033357",
"0.5398367",
"0.5391187",
"0.5385488",
"0.53602636",
"0.5353291",
"0.5351152",
"0.53458834",
"0.5336713",
"0.53231335",
"0.5321327",
"0.5315815",
"0.53128576",
"0.53007627",
"0.52980405",
"0.52861965",
"0.52791035",
"0.5267522",
"0.5258237",
"0.523182",
"0.52247655",
"0.52212226",
"0.52178985",
"0.52091885",
"0.52091885",
"0.52091885",
"0.52091885",
"0.52091885",
"0.52086884",
"0.5203867",
"0.52031446",
"0.51970595",
"0.5182466",
"0.5177388",
"0.5175506",
"0.5158322",
"0.5157234",
"0.5150825",
"0.51471853",
"0.514251",
"0.5131304",
"0.5131304",
"0.5131304",
"0.5126036",
"0.51244926",
"0.5123188",
"0.5113003",
"0.51115066",
"0.5109268",
"0.51072896",
"0.51046014",
"0.5099235",
"0.50959826",
"0.5094576",
"0.5087159",
"0.508635",
"0.50850075",
"0.50827",
"0.50826454",
"0.5067063",
"0.50665206",
"0.506413",
"0.5058445",
"0.5054497",
"0.5053999",
"0.5048129",
"0.5044513",
"0.50401443",
"0.50328124",
"0.5027896",
"0.50235003",
"0.50230145",
"0.5022754",
"0.50188917",
"0.5018837",
"0.50183755"
] | 0.54794616 | 20 |
Returns only the children with +results+ | def children_with_results
children.select(&:any_results_including_children?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend",
"def any_results_including_children?\n races.any?(&:any_results?) || children.any?(&:any_results_including_children?)\n end",
"def pull_out(parent_hash)\n return parent_hash[\"results\"]\n rescue\n return []\n end",
"def search_children(node, attribute, search_term)\n matches = []\n end",
"def getTestNames(results)\n path = getCollectionPath(results)\n while !(String(path).end_with? Jekyll::RESULTS_URL_PATTERN || path.root?) do\n path = path.parent\n end\n return path.children\n end",
"def results_with_query(results)\n results.find_all do |result|\n query.all? do |attribute, value|\n result.send(attribute) == value\n end\n end\n end",
"def get_childs\n childs = Category.any_in(parent_ids: [parent.id])\n\n results = Array.new\n childs.each do |child|\n results << child\n end\n\n results\n end",
"def results\n fetch unless @results\n @results\n end",
"def filter(results)\n if params[:q].present?\n results = Project.search(results, params[:q])\n end\n \n if params[:tag].present?\n results = Project.match_tag(results, params[:tag])\n end\n \n return results\n end",
"def index\n if !signed_in?\n redirect_to root_path\n end\n @children = Child.all\n if !params[:search].nil?\n @result = Child.search(params[:search])\n end\n if @result.nil? && params[:search].nil?\n @result = Child.all\n end\t \n end",
"def get_results(with_root = false)\n ret = []\n\n # Iterate over all occupied descendants and create chain data\n @occupied_descendants.each do |node|\n ret << [node.data, node.get_chain(with_root)]\n end\n\n # Return\n ret\n end",
"def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end",
"def search_results\r\n @browser.divs(class: 'rc').collect do |div|\r\n div.h3.a.text\r\n end\r\n end",
"def all_children\n children(all: true)\n end",
"def fetch_search_results(context)\n\n params = @params\n site_id = context['__site_id']\n\n matching_ids = Node.search_ids do\n\n # Site ID\n with :site_id, site_id\n\n # Node classification\n if params['classification']\n with :classification, params['classification']\n end\n\n # Parent\n if params['scope_to']\n parent_scope = context[params['scope_to']]\n with :parent_uri, parent_scope['uri']\n elsif params['parent_uri']\n with :parent_uri, params['parent_uri']\n end\n\n # Ordering\n order_by_fields = params['order_by'].blank? ? [] : params['order_by'].split(',')\n order_by_fields.each do |order_by_field|\n\n field_name, direction = order_by_field.gsub(/[\"']/, '').strip.split(' ', 2)\n direction = 'asc' if direction.blank?\n order_by field_name.to_sym, direction.to_sym\n\n end\n\n # Limit\n if params['limit']\n paginate :page => 1, :per_page => params['limit']\n end\n\n end\n\n results = []\n matching_ids.each do |id|\n\n node = Rails.cache.fetch \"node_id:#{site_id}:#{id}\" do\n Node.where(:site_id => site_id).find(id).to_liquid\n end\n results << node\n\n end\n\n results\n\n end",
"def results_from_search(query_results)\n ids = query_results.map do |result|\n result['id']\n end\n find_from_search(*ids)\n end",
"def search_results\n builder = search_builder.with(search_state)\n builder.page = search_state.page\n builder.rows = search_state.per_page\n\n builder = yield(builder) if block_given?\n response = repository.search(builder)\n\n if response.grouped? && grouped_key_for_results\n response.group(grouped_key_for_results)\n elsif response.grouped? && response.grouped.length == 1\n response.grouped.first\n else\n response\n end\n end",
"def results_list\n list = []\n begin\n self.spans(:class=>\"s3d-search-result-name\").each do |element|\n list << element.text\n end\n rescue\n list = []\n end\n list\n end",
"def onlychildren_list\n if matches.length == 1\n [self] + matches[0].onlychildren_list\n else\n [self]\n end\n end",
"def process_results (results)\n\t\t\tresults.each do |result|\n\t\t\t\tresult = process_result(result)\n\t\t\tend\n\t\t\treturn results\n\t\tend",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end",
"def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end",
"def results_list\n list = []\n begin\n self.spans(:class=>\"s3d-search-result-name\").each do |element|\n list << element.text\n end\n rescue\n list = []\n end\n return list\n end",
"def children(options={})\n @global_page.children.all options\n end",
"def find_with(results, with = nil)\n ret = QueryResult.new\n ret << results if results\n ret << with if with\n ret.flatten!\n\n ret.size == 1 ? ret[0] : ret\n end",
"def results\n populate\n @results\n end",
"def all_children\n find_all_children_with_dotted_ids\n end",
"def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end",
"def results\n @results\n end",
"def races_with_results\n races.select(&:any_results?)\n end",
"def all_children\n return @all_children if !@all_children.nil?\n @all_children = PhotoCollection.all_urls.find_all{|url| url[self.url] && url != self.url}.collect{|url| PhotoCollection.find_by_url(url)}\n end",
"def find_entities(results)\n document = ::Nokogiri::XML(results.body)\n document.remove_namespaces!\n document.xpath('//entry')\n end",
"def get_search_results\n\t\twait_until_page_loads\n\t\t@se.find_elements(@locs[:results_item])\n\tend",
"def children\n return @children if !@children.nil?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end",
"def results\n content = Nokogiri::XML::Builder.new do |xml|\n xml.get_results(filter: \"first=1 rows=#{MAX_RESULTS} task_id=#{id}\", details: 1)\n end\n Hash.from_xml(@agent.sendrecv(content.to_xml)).deep_symbolize_keys\n end",
"def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end",
"def children(all: false)\n scoped_children =\n if at_or_below_genus?\n Name.with_correct_spelling.subtaxa_of_genus_or_below(text_name)\n else\n Name.with_correct_spelling.\n with_rank_and_name_in_classification(rank, text_name)\n end\n\n return scoped_children.to_a if all\n\n Name.all_ranks.reverse_each do |rank2|\n next if rank_index(rank2) >= rank_index(rank)\n\n matches = scoped_children.with_rank(rank2)\n return matches.to_a if matches.any?\n end\n []\n end",
"def descendants(result = nil, depth = 0)\n \n if (result.nil?)\n result = Hash.new\n end\n \n children.each do |kid|\n node = Array.new\n node[0] = kid\n kid_spice = kid.spice\n if (!kid_spice.nil? && kid_spice.length > 0)\n # TBD: I know there is a Ruby way to copy an array but can't look it up on the plane - just copy myself for now\n spouse_list = Array.new\n kid_spice.each do |s|\n spouse_list << s\n end\n node[1] = spouse_list\n end\n result[node] = depth\n kid.descendants(result, depth + 1)\n end \n \n return result\n \n end",
"def find_selected_childentries(userid)\n @entries = Entry.find(:all, :conditions => [\"user_id=? and parent_id = ? \", userid, self.id])\n \n \n return @entries\n end",
"def children\n entries\n end",
"def search_results\n pages = Alchemy::PgSearch.config[:page_search_scope].pages\n # Since CanCan cannot (oh the irony) merge +accessible_by+ scope with pg_search scopes,\n # we need to fake a page object here\n if can? :show, Alchemy::Page.new(restricted: true, public_on: Date.current)\n pages.full_text_search(params[:query])\n else\n pages.not_restricted.full_text_search(params[:query])\n end\n end",
"def targeted_app_results\n selected_app_results.where(account_path: selected_app_results.first.account_path)\n .page(0).per(10)\n end",
"def get_results()\n restriction_nodes = []\n result_nodes = []\n if !(@inputs.nil? || @inputs.empty? || @inputs.first.empty?)\n input_set = @inputs.first\n restriction_nodes= input_set.nodes\n result_nodes = input_set.breadth_first_search(true){|node| node.item.text.downcase.include?(@keyword_phrase.to_s.downcase)} \n end\n \n if !@inplace\n results = @server.match_all(parse_keyword_phrase(), restriction_nodes) \n result_nodes = results.map{|item| Xplain::Node.new(item: item)}\n end\n \n result_nodes\n \n end",
"def get_childs(recursive, ret_obj)\n\n return self.class.get_childs(self.id, recursive, ret_obj)\n end",
"def search_results(load: true)\n Pseud.search(body: search_body, load: load)\n end",
"def items\n parsed_contents['results'] if parsed_contents\n end",
"def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end",
"def test_results_filter(test_results)\n test_results.select do |tr|\n # Non TestResult items are never filtered.\n next true unless tr.kind_of?(Automation::TestDatabase::TestResult)\n entity_result(tr) != Automation::Result::Pass\n end\n end",
"def results\n @@RESULT_DIRS.keys.map{ |k| result(k) }.reject{ |r| r.nil? }\n end",
"def children\n rows\n end",
"def children(res)\n # delete() returns nil when nothing was removed. so use delete_if instead.\n @graph.children(Resource.id(res).hash).delete_if{|i| i == 0}.collect { |hashid| id2obj(hashid) }\n end",
"def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end",
"def search_all_results(query)\n results = []\n\n page = 1\n\n loop do\n hits = search(query, page)\n\n results.concat(hits['results'])\n\n if hits['last_page'] == page || hits['last_page'] == 0\n break\n else\n page += 1\n end\n end\n\n results\n end",
"def find_all(conditions)\n @root.find_all(conditions)\n end",
"def all_children(special=nil)\n if special && special[:exclude]\n transaction do\n # exclude some items and all their children\n special[:exclude] = [special[:exclude]] if !special[:exclude].is_a?(Array)\n # get objects for ids\n special[:exclude].collect! {|s| s.is_a?(self.class) ? s : self.class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = special[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq.join(',')\n if exclude_list.blank?\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND id NOT IN (#{exclude_list}) AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end",
"def children#WORKING\n if self.adult == true\n self.related_users.select{|user| user.adult == false}\n else\n return []\n end\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def competition_results\n results.select(&:competition_result?)\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def get_children\n return children\n end",
"def search_results(*args)\n ranks_and_ids = search_result_ranks_and_ids(*args)\n search_results_from_ids(ranks_and_ids.map(&:last))\n end",
"def results\n @results ||= Results.new(self)\n end",
"def results\n index.results\n end",
"def get_all_child_lists\n child_check\n \n if @all_child_terms.nil? and @all_child_names.nil?\n @all_child_terms = []\n @all_child_names = []\n \n self.children.each do |child|\n @all_child_terms.push( child.term )\n @all_child_terms.push( child.all_child_terms )\n @all_child_names.push( child.term_name )\n @all_child_names.push( child.all_child_names )\n end\n \n @all_child_terms = @all_child_terms.flatten.uniq\n @all_child_names = @all_child_names.flatten.uniq\n end\n end",
"def ascendants(result = nil, depth = 0)\n \n if (result.nil?)\n result = Hash.new\n end\n \n parents.each do |par|\n node = Array.new\n node[0] = par\n par_spice = par.spice\n if (!par_spice.nil? && par_spice.length > 0)\n # TBD: I know there is a Ruby way to copy an array but can't look it up on the plane - just copy myself for now\n spouse_list = Array.new\n par_spice.each do |s|\n spouse_list << s\n end\n node[1] = spouse_list\n end\n result[node] = depth\n par.ascendants(result, depth + 1)\n end \n \n return result\n \n end",
"def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end",
"def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end",
"def while_results(&block)\n loop do\n results = get![:results]\n break if results.nil? || results.empty?\n results.each(&block)\n end\n end",
"def children(options={:type => nil, :get_dataset => false, :recursive => false, :keep_cache => true, :reload => false, :preconditions => {:hidden => false}})\n return @children_cache if @children_cache and !options[:get_dataset] and !options[:reload]\n klass = Ecore::db[:documents]\n if options[:type]\n raise(TypeError, \":type must be an Ecore::DocumentResource\") unless options[:type].respond_to?(:table_name)\n klass = Ecore::db[:\"#{options[:type].table_name}\"]\n end\n query = klass.store_preconditions((@user_obj || @group_ids || @user_id),nil,self,nil,(options[:preconditions] || {:hidden => false}))\n query = ( options[:recursive] ? query.where(:path.like(\"#{absolute_path}%\")) : query.where(:path => absolute_path) )\n return query if options[:get_dataset]\n children_cache = query.order(:position,:name).receive(:all)\n return children_cache if options[:keep_cache]\n @children_cache = children_cache\n end",
"def js_listing(res)\n # One day I'll get to deprecate Ruby 2.2 and jump into the world of Hash#dig.\n return nil unless res[:json] && res[:json][:data] && res[:json][:data][:things]\n Models::Listing.new(@client, children: res[:json][:data][:things])\n end",
"def all\n load[:results]\n end",
"def results_as_objects(results)\n results_as_objects = []\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects \n end",
"def each\n current_result = self\n begin \n last_result = current_result\n current_result.elements[:results].each do |result|\n\t# The collection of refs we are holding onto could grow without bounds, so dup\n\t# the ref\n\tyield result.dup\n end\n current_result = current_result.next_page if current_result.more_pages?\n end while !last_result.equal? current_result\n end",
"def reify_results(ids)\n results = []\n \n ids_hash = {}\n ids.each do |class_name, id|\n (ids_hash[class_name] ||= []) << id\n end\n \n ids.map {|ary| ary.first}.uniq.each do |class_name|\n klass = class_name.constantize\n \n finder = (\n Ultrasphinx::Search.client_options['finder_methods'].detect do |method_name| \n klass.respond_to? method_name\n end or\n # XXX This default is kind of buried, but I'm not sure why you would need it to be \n # configurable, since you can use ['finder_methods'].\n \"find_all_by_#{klass.primary_key}\"\n )\n\n records = klass.send(finder, ids_hash[class_name])\n \n unless Ultrasphinx::Search.client_options['ignore_missing_records']\n if records.size != ids_hash[class_name].size\n missed_ids = ids_hash[class_name] - records.map(&:id)\n msg = if missed_ids.size == 1\n \"Couldn't find #{class_name} with ID=#{missed_ids.first}\"\n else\n \"Couldn't find #{class_name.pluralize} with IDs: #{missed_ids.join(',')} (found #{records.size} results, but was looking for #{ids_hash[class_name].size})\"\n end\n raise ActiveRecord::RecordNotFound, msg\n end\n end\n \n records.each do |record|\n results[ids.index([class_name, record.id])] = record\n end\n end\n \n # Add an accessor for global search rank for each record, if requested\n if self.class.client_options['with_global_rank']\n # XXX Nobody uses this\n results.each_with_index do |result, index|\n if result\n global_index = per_page * (current_page - 1) + index\n result.instance_variable_get('@attributes')['result_index'] = global_index\n end\n end\n end\n\n # Add an accessor for distance, if requested\n if self.options['location']['lat'] and self.options['location']['long']\n results.each_with_index do |result, index|\n if result\n distance = (response[:matches][index][:attributes]['@geodist'] or INFINITY)\n result.instance_variable_get('@attributes')['distance'] = distance\n end\n end\n end\n \n results.compact!\n \n if ids.size - results.size > Ultrasphinx::Search.client_options['max_missing_records']\n # Never reached if Ultrasphinx::Search.client_options['ignore_missing_records'] is false due to raise\n raise ConfigurationError, \"Too many results for this query returned ActiveRecord::RecordNotFound. The index is probably out of date\" \n end\n \n results \n end",
"def items\n @document.xpath('//results/page/items/*')\n end",
"def results\n @results ||= Results.new(klass, self)\n end",
"def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end",
"def results\n if cookies[:fit_my_4x4].present?\n @vehicle_filter = JSON.parse(cookies[:fit_my_4x4]).with_indifferent_access\n\n if params[:id].present?\n @this_category = Category.friendly.find(params[:id])\n\n @products = @this_category.leaves.map { |c| c.products.active.includes(:vehicles).references(:vehicles).where('refinery_ironman_vehicles.id in (?)', @vehicle_filter.values) }.flatten.paginate(:page => params[:page], :per_page => 12)\n\n if @this_category.depth == 0\n @category = @this_category\n elsif @this_category.depth == 1\n @category = @this_category.parent\n @subcategory = @this_category\n elsif @this_category.depth == 2\n @category = @this_category.parent.parent\n @subcategory = @this_category.parent\n @sub_subcategory = @this_category\n end\n\n else\n @products = Refinery::Ironman::Product.active.includes(:vehicles).references(:vehicles).where('refinery_ironman_vehicles.id in (?)', @vehicle_filter.values).order('refinery_ironman_products.name').paginate(:page => params[:page], :per_page => 12)\n end\n end\n\n present(@page)\n end",
"def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end",
"def list_results(**opt)\n # May be overridden by the subclass.\n end",
"def get_children(pi)\n response = Net::HTTP.get_response URI.parse(URI.escape(SERVICE_DCMDB + \"work/\" + pi + \"/children\"))\n children = Array.new\n case response\n when Net::HTTPSuccess\n doc = Document.new(response.body)\n XPath.each(doc, \"//workpid\") { |el|\n children.push(el.text)\n } \n end\n\n return children\n\n end",
"def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end",
"def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end",
"def completed?\n children.present? && (children_with_results.size == children.count)\n end",
"def children\n models = tests + tags\n models << background if background\n\n models\n end",
"def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end",
"def results_for_division(division)\n if division == :all\n @results\n else\n sections = @festival_info.sections(division)\n @results.select { |section, result| sections.include? section }\n end\n end",
"def fetch_results_for(search_term)\n if params['tag'] #limited to args, sorted differently\n @show_search_title = true\n return(SearchResult.find_args_with_tag(params['tag'])) \n end\n \n return [] if search_term.blank?\n \n SearchResult.find(search_term, current_user)\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def collect_child_elements(memo = [])\n memo\n end",
"def find!\n @total_found = 0\n @results = nil\n return results\n end",
"def children\n rows + tags\n end",
"def find_nested\n [self] + @properties.values.select {|v| v.is_a?(Mida::Item) ? v.find_nested : nil }.compact.flatten\n end",
"def pageWithResults?\n return @driver.find_elements(:xpath, \".//*[@id='resultados']/ul[*]/li[1]/a\").any?\nend",
"def all_child_terms\n get_all_child_lists\n return @all_child_terms\n end",
"def children\n _children\n end",
"def pull_out(parent_hash)\n return parent_hash[\"data\"][\"children\"]\n rescue\n return []\n end"
] | [
"0.6459362",
"0.6355265",
"0.63484645",
"0.6250594",
"0.6238641",
"0.5964827",
"0.59176993",
"0.5885458",
"0.5861433",
"0.5841403",
"0.5840733",
"0.5839581",
"0.57967174",
"0.57507205",
"0.5739048",
"0.5718785",
"0.5714855",
"0.56983995",
"0.5697021",
"0.5694411",
"0.5668937",
"0.5668937",
"0.5663969",
"0.5654792",
"0.5636998",
"0.5633571",
"0.56225795",
"0.56149083",
"0.5608169",
"0.5604465",
"0.56037074",
"0.5596805",
"0.55955565",
"0.5580833",
"0.55798084",
"0.55758077",
"0.55724025",
"0.55617714",
"0.5545835",
"0.5543194",
"0.554214",
"0.5505996",
"0.55057126",
"0.5504653",
"0.5498198",
"0.5496802",
"0.5492112",
"0.5472839",
"0.54725987",
"0.5451623",
"0.5449418",
"0.54476523",
"0.54160875",
"0.5415866",
"0.5412725",
"0.5404615",
"0.54026186",
"0.5399836",
"0.5396683",
"0.53873485",
"0.5375885",
"0.5353439",
"0.53454584",
"0.53407544",
"0.5338578",
"0.53340656",
"0.53201115",
"0.5314848",
"0.5309465",
"0.5305418",
"0.5305057",
"0.53045493",
"0.530108",
"0.52987915",
"0.52791107",
"0.5278987",
"0.5277615",
"0.5266681",
"0.5266501",
"0.5257604",
"0.5256107",
"0.52551657",
"0.5254611",
"0.52508616",
"0.52506214",
"0.5244021",
"0.5236872",
"0.5236291",
"0.5231823",
"0.5224764",
"0.52190435",
"0.52190435",
"0.52190435",
"0.52178335",
"0.52049613",
"0.52041173",
"0.5201969",
"0.51972485",
"0.5193328",
"0.5190072"
] | 0.8369089 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.